Page 1 of 1

Drive number detection for CD

Posted: Sun Jun 20, 2010 1:26 pm
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

Re: Drive number detection for CD

Posted: Sun Jun 20, 2010 1:41 pm
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?

Re: Drive number detection for CD

Posted: Sun Jun 20, 2010 1:52 pm
by CWood
...
(feeling a bit sheepish :S)

Re: Drive number detection for CD

Posted: Sun Jun 20, 2010 1:58 pm
by Benjamin1996
death2all wrote:...
(feeling a bit sheepish :S)
Hehe... I'm just glad to help you :).

Re: Drive number detection for CD

Posted: Sun Jun 20, 2010 8:34 pm
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

Re: Drive number detection for CD

Posted: Mon Jun 21, 2010 5:48 am
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.

Re: Drive number detection for CD

Posted: Mon Jun 21, 2010 11:42 am
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.

Re: Drive number detection for CD

Posted: Mon Jun 21, 2010 1:35 pm
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.

Re: Drive number detection for CD

Posted: Mon Jun 21, 2010 4:11 pm
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.

Re: Drive number detection for CD

Posted: Mon Jun 21, 2010 8:49 pm
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.

Re: Drive number detection for CD

Posted: Tue Jun 22, 2010 6:16 am
by qw
Being half-asleep keeps confusing people.