OSDev.org
https://forum.osdev.org/

Drive number detection for CD
https://forum.osdev.org/viewtopic.php?f=1&t=22180
Page 1 of 1

Author:  CWood [ Sun Jun 20, 2010 1:26 pm ]
Post subject:  Drive number detection for CD

I am currently making my operating system, MaLux, El Torito compatible. However, I cannot seem to figure out how to implement drive number detection. Here is what I have so far for this:
Code:
.finddrivenum:
      inc   byte [bsDriveNumber]

      mov   ah, 0x41
      mov   bx, 0x55AA
      mov   dl, bsDriveNumber
      int   0x13

      cmp   ah, 01
      je   FAILURE

      cmp   bx, 0xAA55
      jne   .finddrivenum

      cmp   byte [bsDriveNumber], 0x80
      je   .finddrivenum

      cmp   byte [bsDriveNumber], 0x00
      je   .finddrivenum

      mov   ah, 0x48
      mov   dl, bsDriveNumber
      mov   si, Buffer
      int   0x13

      mov   ax, [ds:si+2]
      and   ax, 100b
      jz   .finddrivenum


Am I going about this the right way, or am I clutching at straws? Also, does VirtualBox from Sun Microsystems support the MS/IBM int 13 extensions?
Thanks, and hopefully if/when I get this working I will be able to get some screen shots up :P

Author:  Benjamin1996 [ Sun Jun 20, 2010 1:41 pm ]
Post subject:  Re: Drive number detection for CD

death2all wrote:
I am currently making my operating system, MaLux, El Torito compatible. However, I cannot seem to figure out how to implement drive number detection. Here is what I have so far for this:
Code:
.finddrivenum:
      inc   byte [bsDriveNumber]

      mov   ah, 0x41
      mov   bx, 0x55AA
      mov   dl, bsDriveNumber
      int   0x13

      cmp   ah, 01
      je   FAILURE

      cmp   bx, 0xAA55
      jne   .finddrivenum

      cmp   byte [bsDriveNumber], 0x80
      je   .finddrivenum

      cmp   byte [bsDriveNumber], 0x00
      je   .finddrivenum

      mov   ah, 0x48
      mov   dl, bsDriveNumber
      mov   si, Buffer
      int   0x13

      mov   ax, [ds:si+2]
      and   ax, 100b
      jz   .finddrivenum


Am I going about this the right way, or am I clutching at straws? Also, does VirtualBox from Sun Microsystems support the MS/IBM int 13 extensions?
Thanks, and hopefully if/when I get this working I will be able to get some screen shots up :P

Doesn't the BIOS leave the drive number in the DL register for you, when it jumps to 7C00?

Author:  CWood [ Sun Jun 20, 2010 1:52 pm ]
Post subject:  Re: Drive number detection for CD

...
(feeling a bit sheepish :S)

Author:  Benjamin1996 [ Sun Jun 20, 2010 1:58 pm ]
Post subject:  Re: Drive number detection for CD

death2all wrote:
...
(feeling a bit sheepish :S)

Hehe... I'm just glad to help you :).

Author:  Tosi [ Sun Jun 20, 2010 8:34 pm ]
Post subject:  Re: Drive number detection for CD

Benjamin1996 wrote:
death2all wrote:
I am currently making my operating system, MaLux, El Torito compatible. However, I cannot seem to figure out how to implement drive number detection. Here is what I have so far for this:
Code:
...


Am I going about this the right way, or am I clutching at straws? Also, does VirtualBox from Sun Microsystems support the MS/IBM int 13 extensions?
Thanks, and hopefully if/when I get this working I will be able to get some screen shots up :P

Doesn't the BIOS leave the drive number in the DL register for you, when it jumps to 7C00?

I think most BIOSes do, but there are always the weird ones. Some jump to 7C00:0000 instead of 0000:7C00 for instance

Author:  qw [ Mon Jun 21, 2010 5:48 am ]
Post subject:  Re: Drive number detection for CD

Tosi wrote:
I think most BIOSes do, but there are always the weird ones. Some jump to 7C00:0000 instead of 0000:7C00 for instance
That should be 07C0:0000. Segmentation keeps confusing people.

Author:  CWood [ Mon Jun 21, 2010 11:42 am ]
Post subject:  Re: Drive number detection for CD

Ok, but back to my question, does Sun VirtualBox support the MS/IBM Int 13 extensions (Int 41h - 49h) for LBA disk reading? I need to know, because that is what my boot sector is using to load in the kernel, and if it doesn't support it, then I need something else, rather than trying to waste my efforts.

Author:  StephanvanSchaik [ Mon Jun 21, 2010 1:35 pm ]
Post subject:  Re: Drive number detection for CD

You can test if INT 0x13 extensions are available using INT 13h; AH=41h. If they are you can simply use INT 13h; AH=42h. If they aren't, then you'll have to rely on INT 13h; AH=02h.

The above doesn't really apply to CD-ROMs though, since the El Torito specification was made when those extensions were already common. So basically you can always use INT 13h; AH=42h when booting from a CD-ROM on a x86 machine with the BIOS as its firmware, without having to check if they're actually present.


Regards,
Stephan J.R. van Schaik.

Author:  quok [ Mon Jun 21, 2010 4:11 pm ]
Post subject:  Re: Drive number detection for CD

StephanVanSchaik wrote:
The above doesn't really apply to CD-ROMs though, since the El Torito specification was made when those extensions were already common. So basically you can always use INT 13h; AH=42h when booting from a CD-ROM on a x86 machine with the BIOS as its firmware, without having to check if they're actually present.


Indeed, actually checking for the availability of the extensions when performing an El-Torito boot may cause various BIOS bugs to show up. Here is an article where I outline several real world BIOS bugs that you may run in to when doing El-Torito booting. I gathered them from various bootloader sources, including Grub and Syslinux. That post is linked to from the El-Torito wiki article.

Author:  Tosi [ Mon Jun 21, 2010 8:49 pm ]
Post subject:  Re: Drive number detection for CD

Hobbes wrote:
Tosi wrote:
I think most BIOSes do, but there are always the weird ones. Some jump to 7C00:0000 instead of 0000:7C00 for instance
That should be 07C0:0000. Segmentation keeps confusing people.

Oops. I was half-asleep after an all-nighter.

Author:  qw [ Tue Jun 22, 2010 6:16 am ]
Post subject:  Re: Drive number detection for CD

Being half-asleep keeps confusing people.

Page 1 of 1 All times are UTC - 6 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/