[SOLVED] Bootsector: How to tell if USB uses FDD/HDD emu?
Posted: Sun Feb 26, 2012 11:19 am
Hi all,
I've wrote a bootsector that checks for int 13h extensions (thanks for the site, excellent resources in the wiki), using the extensions if they're present, otherwise falling back to LBA to CHS translation and using int 13, 2h. This works fine, on bochs, most of my computers, etc. (both FDD/HDD).
Except one machine: my primary one! When I try to boot off USB, it makes it appear as though it uses HDD emulation and says it supports the int 13h extensions (with no error code returned afterwards), but doesn't actually read any data. The drive index is 0x80, and the snippet below results in control flow going to read_sectors_lba. If I insert an unconditional jmp to use the CHS routine, the machine in question boots fine. Other machines boot using the LBA code fine, so there shouldn't be any bugs.
I'm stumped. Any ideas?
Thanks in advance.
I've wrote a bootsector that checks for int 13h extensions (thanks for the site, excellent resources in the wiki), using the extensions if they're present, otherwise falling back to LBA to CHS translation and using int 13, 2h. This works fine, on bochs, most of my computers, etc. (both FDD/HDD).
Except one machine: my primary one! When I try to boot off USB, it makes it appear as though it uses HDD emulation and says it supports the int 13h extensions (with no error code returned afterwards), but doesn't actually read any data. The drive index is 0x80, and the snippet below results in control flow going to read_sectors_lba. If I insert an unconditional jmp to use the CHS routine, the machine in question boots fine. Other machines boot using the LBA code fine, so there shouldn't be any bugs.
Code: Select all
# Check to see what routines are supported
movw %cx, %dx
movb $0x41, %ah
movw $0x55AA, %bx
stc
int $0x13
jc read_sectors_chs
cmp $0xAA55, %bx
jne read_sectors_chs
testb $0x01, %cl
jz read_sectors_chs
read_sectors_lba:
...
Thanks in advance.