I am starting by trying to run IDENTIFY on a drive to see what information I get back, but there seem to be some funny results.
This is what I have so far:
Code: Select all
/* Check if drive is busy */
for ( ; (inb (0x1F7) & 0x80) != 0; ) {
printf ("Busy\n");
}
printf ("Not Busy\n");
/* Disable interrupts */
__asm cli;
/* Check if drive ready */
for ( ; (inb (0x1F7) & 0x40) == 0; ) {
printf ("Not Ready\n");
}
printf ("Ready\n");
/* Identify command - Transferrs data into the hard drive's cache */
outb (0x1F6, 0x0);
outb (0x1F7, 0xEC);
for ( ; (inb (0x1F7) & 0x8) == 0; ) {
printf ("Waiting\n");
}
printf ("Identify complete...\n");
/* Read data */
printf ("Word 0 - %u\n", inw(0x1F0));
printf ("Word 1 - %u (cylinders)\n", inw(0x1F0));
printf ("Word 2 - %u (unused)\n", inw(0x1F0));
printf ("Word 3 - %u (heads)\n", inw(0x1F0));
printf ("Word 4 - %u (unused)\n", inw(0x1F0));
printf ("Word 5 - %u (unused)\n", inw(0x1F0));
printf ("Word 6 - %u (sectors per track)\n", inw(0x1F0));
My inw function looks like this (extern char inw (uword port);):
Code: Select all
_inw:
PUSH EDX
PUSH EBP
MOV EBP, ESP
XOR EAX, EAX
MOV DX, [EBP + 12] ; Port number
IN AX, DX
POP EBP
POP EDX
RET
Any ideas where I have gone wrong on this?