Drive number detection for CD

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
CWood
Member
Member
Posts: 127
Joined: Sun Jun 20, 2010 1:21 pm

Drive number detection for CD

Post by CWood »

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: Select all

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

Re: Drive number detection for CD

Post by Benjamin1996 »

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: Select all

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

Re: Drive number detection for CD

Post by CWood »

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

Re: Drive number detection for CD

Post by Benjamin1996 »

death2all wrote:...
(feeling a bit sheepish :S)
Hehe... I'm just glad to help you :).
Tosi
Member
Member
Posts: 255
Joined: Tue Jun 15, 2010 9:27 am
Location: Flyover State, United States
Contact:

Re: Drive number detection for CD

Post by Tosi »

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: Select all

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

Re: Drive number detection for CD

Post by qw »

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

Re: Drive number detection for CD

Post by CWood »

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

Re: Drive number detection for CD

Post by StephanvanSchaik »

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

Re: Drive number detection for CD

Post by quok »

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

Re: Drive number detection for CD

Post by Tosi »

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

Re: Drive number detection for CD

Post by qw »

Being half-asleep keeps confusing people.
Post Reply