(ah=0x01: invalid function in AH or invalid parameter). I think it's more the second part of the error message, because I don't
think function 0x02 is wrong for reading disk sectors.
Here the code:
Code: Select all
int __NOINLINE __REGPARM readDiskSector(const int sector, const int device_id, const int heads, const int tracks, const int sector_count) {
char str[7];
str[6] = 0;
int h = sector/(sector_count/heads);
int c = (sector-h*(sector_count/heads))/tracks;
int s = sector-c*tracks-h*(sector_count/heads)+1;
printChar(0x20);
printChar('H');
toHexString(h,str);
print(str);
printChar(',');
printChar('T');
toHexString(c,str);
print(str);
printChar(',');
printChar('S');
toHexString(s,str);
print(str);
printChar(0x20);
int ret = 0;
__asm__ __volatile__("push %%es\n"
"mov %%al,%%ch\n"
"mov %%cl,%%dh\n"
"mov %%dl,%%cl\n"
"mov %%bl,%%dl\n"
"mov $0x1000,%%ax\n"
"mov %%ax,%%es\n"
"mov $0x0000,%%bx\n"
"mov $0x0201,%%ax\n"
"int $0x13\n"
"pop %%es\n"
"jnc disk_read_successful\n"
"mov %%ah,%%al\n"
"xor %%ah,%%ah\n": "=a"(ret) : "a"(0x0000|h),"b"(0x0000|device_id),"c"(0x0000|(c & 0xFF)),"d"(0x0000|(s|((c>>2)&0xC0))) : "memory");
printChar(0x20);
toHexString(ret,str);
print(str);
printChar(0x20);
__asm__ __volatile__("disk_read_successful:");
return ret;
}
QEMU - 0.13.0
Oracle VM VirtualBox - 4.3.0
--> No difference in behaviour
Compiling system: Windows 7 64Bit + gcc
Bootloader: modified MikeOS loader with Unreal mode and A20 gate support
BtW: I now that the values for ch and dh are swapped here, but If they're not I can't actually read past the first track, so I guessed it's better to be able to read two tracks at least.
(Already asked that here, but I did not get any good replies apart from complains about my coding style http://stackoverflow.com/questions/2458 ... irst-track)
[Edited]