First of all, I'm new the this forum. You seem like helpful people, though.
My OS is at http://code.google.com/p/awos/ -- so you can see all the source code there.
Now, my problem is, my IDE detection code isn't working. Obviously it is detecting a hard disk, because the while(!(status & 0x40)) loop works (to make sure that DRDY is set). The problem is, the KiAtapiIdent struct is empty, set to all 0xFFFFFFFF. Doing a dump of memory in Qemu, that's what came up at the location (I had it print the location on the screen).
Here is the relevant code:
buffer is a char *. malloc()d to contain 512 bytes,
Code: Select all
while(status & 0x80) status = inportb(PORT_ATAPI_STATUS);
while(!(status & 0x40)) status = inportb(PORT_ATAPI_STATUS);
outportb(PORT_ATAPI_COMMAND, 0xEC); //EIDE ident
for(i = 0; i < 512; i++)
buffer[i] = inportb(PORT_ATAPI_DATA);
atapi = (struct KiAtapiIdent *)buffer;
if(!(atapi->config & 0x40))
{
retv = 0x02;
goto ret;
}
hd:
dprintf("hd: detected a disk at ide0:0\nconfiguration byte: %08l\n", atapi->config);
ptable = (char *)kmalloc(512);
if(!HdReadSector(0, 1, 1, 0, 0, 0, ptable))
dprintf("hd: critical error: could not read partition table!\n");
else
dprintf("last two bytes of partition table: %02X %02X\n", ptable[510], ptable[511]);
retv = TRUE;
last two bytes of partition table: 0xFFFFFFFF 0xFFFFFFFF
Like I said if you want to see the rest of my code go here:
http://awos.googlecode.com/svn/trunk/src/kernel/
Places you might want to look are hdd.c and driver/hdd.h.
Thank you!
Andrew