Page 1 of 1

[SOLVED] Bootsector: How to tell if USB uses FDD/HDD emu?

Posted: Sun Feb 26, 2012 11:19 am
by b00tsect
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.

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:
   ...
I'm stumped. Any ideas?
Thanks in advance.

Re: Bootsector: How to tell whether USB uses FDD/HDD emulati

Posted: Sun Feb 26, 2012 11:55 am
by M2004
1) A buggy bios failing to boot properly from usb device by using lba method?

2) Do you check edd support bit (bit4, cx register) returned by
INT 13h AH=41h: Check Extensions Present

http://en.wikipedia.org/wiki/INT_13H#IN ... ns_Present

Regards
Mac2004

Re: Bootsector: How to tell whether USB uses FDD/HDD emulati

Posted: Sun Feb 26, 2012 12:20 pm
by b00tsect
No need to check bit 4; look at grub source:

Code: Select all

   /* use CHS if fails */
   jc LOCAL(chs_mode)
   cmpw  $0xaa55, %bx
   jne   LOCAL(chs_mode)

   andw  $1, %cx
   jz LOCAL(chs_mode)
You were right on the buggy BIOS, though; %dl was getting wiped after the call to int 13h, 41h. Thanks! :D

Re: [SOLVED] Bootsector: How to tell if USB uses FDD/HDD emu

Posted: Sun Feb 26, 2012 12:38 pm
by M2004
Good, you got this problem solved =D>

Regards
Mac2004