OSDev.org

The Place to Start for Operating System Developers
It is currently Sat Sep 21, 2019 7:41 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 11 posts ] 
Author Message
 Post subject: Drive number detection for CD
PostPosted: Sun Jun 20, 2010 1:26 pm 
Offline
Member
Member

Joined: Sun Jun 20, 2010 1:21 pm
Posts: 127
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


Top
 Profile  
 
 Post subject: Re: Drive number detection for CD
PostPosted: Sun Jun 20, 2010 1:41 pm 
Offline
Member
Member

Joined: Sat Apr 10, 2010 7:00 am
Posts: 78
Location: Denmark
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?


Top
 Profile  
 
 Post subject: Re: Drive number detection for CD
PostPosted: Sun Jun 20, 2010 1:52 pm 
Offline
Member
Member

Joined: Sun Jun 20, 2010 1:21 pm
Posts: 127
...
(feeling a bit sheepish :S)


Top
 Profile  
 
 Post subject: Re: Drive number detection for CD
PostPosted: Sun Jun 20, 2010 1:58 pm 
Offline
Member
Member

Joined: Sat Apr 10, 2010 7:00 am
Posts: 78
Location: Denmark
death2all wrote:
...
(feeling a bit sheepish :S)

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


Top
 Profile  
 
 Post subject: Re: Drive number detection for CD
PostPosted: Sun Jun 20, 2010 8:34 pm 
Offline
Member
Member

Joined: Tue Jun 15, 2010 9:27 am
Posts: 255
Location: Flyover State, United States
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

_________________
Getting_Started on the wiki
x86 technical information
Interrupt Jump Table
Real Programmers Don't Use Pascal
My open-source projects


Top
 Profile  
 
 Post subject: Re: Drive number detection for CD
PostPosted: Mon Jun 21, 2010 5:48 am 
Offline
Member
Member
User avatar

Joined: Mon Jan 26, 2009 2:48 am
Posts: 792
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.


Top
 Profile  
 
 Post subject: Re: Drive number detection for CD
PostPosted: Mon Jun 21, 2010 11:42 am 
Offline
Member
Member

Joined: Sun Jun 20, 2010 1:21 pm
Posts: 127
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.


Top
 Profile  
 
 Post subject: Re: Drive number detection for CD
PostPosted: Mon Jun 21, 2010 1:35 pm 
Offline
Member
Member

Joined: Sat Sep 29, 2007 5:43 pm
Posts: 127
Location: Amsterdam, The Netherlands
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.


Top
 Profile  
 
 Post subject: Re: Drive number detection for CD
PostPosted: Mon Jun 21, 2010 4:11 pm 
Offline
Member
Member

Joined: Wed Oct 18, 2006 10:43 pm
Posts: 490
Location: Kansas City, KS, USA
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.


Top
 Profile  
 
 Post subject: Re: Drive number detection for CD
PostPosted: Mon Jun 21, 2010 8:49 pm 
Offline
Member
Member

Joined: Tue Jun 15, 2010 9:27 am
Posts: 255
Location: Flyover State, United States
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.

_________________
Getting_Started on the wiki
x86 technical information
Interrupt Jump Table
Real Programmers Don't Use Pascal
My open-source projects


Top
 Profile  
 
 Post subject: Re: Drive number detection for CD
PostPosted: Tue Jun 22, 2010 6:16 am 
Offline
Member
Member
User avatar

Joined: Mon Jan 26, 2009 2:48 am
Posts: 792
Being half-asleep keeps confusing people.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Google [Bot] and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group