Partition Table Woes :'(
Posted: Wed Sep 01, 2004 3:08 am
Hmm.. When I read from the partition tables the data is weird
Normal Layout: 80C.H.S.06C.H.S.LBASect.LBASize.
What I get: 0180??????06????LBASect.LBASize.
I get this on all my computers, I'm temted to push on amd use the lba values to make chs values and use the values that i know.
heres my code:
typedef struct{
byte Bsect[446];
byte Active1;
byte Sect1;
word HeadCyl1;
byte Part1;
byte ESect1;
word EHeadCyl1;
dword SLBA1;
dword Size1;
byte Active2;
byte Sect2;
word HeadCyl2;
byte Part2;
byte ESect2;
word EHeadCyl2;
dword SLBA2;
dword Size2;
byte Active3;
byte Sect3;
word HeadCyl3;
byte Part3;
byte ESect3;
word EHeadCyl3;
dword SLBA3;
dword Size3;
byte Active4;
byte Sect4;
word HeadCyl4;
byte Part4;
byte ESect4;
word EHeadCyl4;
dword SLBA4;
dword Size4;
word Sig;
}NOALIGN PART_T;
static PPART_T Partition;
THX in advance
Normal Layout: 80C.H.S.06C.H.S.LBASect.LBASize.
What I get: 0180??????06????LBASect.LBASize.
I get this on all my computers, I'm temted to push on amd use the lba values to make chs values and use the values that i know.
heres my code:
typedef struct{
byte Bsect[446];
byte Active1;
byte Sect1;
word HeadCyl1;
byte Part1;
byte ESect1;
word EHeadCyl1;
dword SLBA1;
dword Size1;
byte Active2;
byte Sect2;
word HeadCyl2;
byte Part2;
byte ESect2;
word EHeadCyl2;
dword SLBA2;
dword Size2;
byte Active3;
byte Sect3;
word HeadCyl3;
byte Part3;
byte ESect3;
word EHeadCyl3;
dword SLBA3;
dword Size3;
byte Active4;
byte Sect4;
word HeadCyl4;
byte Part4;
byte ESect4;
word EHeadCyl4;
dword SLBA4;
dword Size4;
word Sig;
}NOALIGN PART_T;
static PPART_T Partition;
Code: Select all
byte Check_PartTable(int ide,int drive,int part)
{
PART_T PartTable;
int i;
if(Read_ones_CHS(0,0,drive,ide,1,0x20,(word*) &PartTable)!=0)
{return 1;}
kprintf("Sig: 0x%x\n Active1: 0x%x\n Sect1: 0x% x\n HeadCyl1: 0x%x\n"
" Part1: 0x%x\n ESect1: 0x% x\n EHeadCyl1: 0x%x\n "
"SLBA1: 0x%x\n Size1:0x% x\n",
PartTable.Sig,PartTable.Active1,PartTable.Sect1,
Part Table.HeadCyl1,PartTable.Part1,PartTable.ESect1,
Par tTable.EHeadCyl1,PartTable.SLBA1,PartTable.Size1
);
}
Code: Select all
word Read_ones_CHS(int cyln,int head,int drive,int ide,word sect,int com,word *buffer)
{
int r0,r1,r2,i;
if(head>15)
r1=15;
else if(head<0)
r1=0;
else
r1=head;
if(drive>1)
r2=16;
if(drive<0)
r2=0;
if(drive==1)
r2=16;
while(!inportb(ide+7)&0xD0);
outportb(ide+6,(r1|r2|0xA0));
outportb(ide+2,0x01);
outportb(ide+3,sect);
outportb(ide+4,cyln&0xFF);
outportb(ide+5,cyln>>8);
outportb(ide+7,com);
while((inportb(ide+7)&0x50)!=0x50);
while((inportb(ide+7)&0x08)!=0x08);
while((inportb(ide+7)&0x80)==0x80);
for(i=0;i<256;i++)
{
r0=inportw(ide);
buffer[i]=(r0>>8)|(r0&0xFF)<<8;
}
while(inportb(ide+7)&0x80);
outportb(ide+0x206,0x12);
return inportb(ide+1);
}