I'm at the point where I'd much rather not drop back to real mode to do stuff, so I kind of need to know where my OS booted from. I know with the BIOS it's stored in DL, and I've used that quite a bit, but in protected mode that cute little number doesn't mean much. I've already searched this site through the search feature and with Google, and I've tried Googling the entire net for it, but I couldn't really find anything. It was all either real mode or completely irrelevant.
I hope to eventually support booting from USB, and so I can't just assume I booted from the first hard drive. Basically, what I'm asking is this: Is there a way to find out where I booted from without scanning each and every possible boot source?
Detecting boot drive in protected mode
- Firestryke31
- Member
- Posts: 550
- Joined: Sat Nov 29, 2008 1:07 pm
- Location: Throw a dart at central Texas
- Contact:
Detecting boot drive in protected mode
Owner of Fawkes Software.
Wierd Al wrote: You think your Commodore 64 is really neato,
What kind of chip you got in there, a Dorito?
Re: Detecting boot drive in protected mode
Unfortunately, this is indeed a big problem.
In some sense, you need to scan each drive attached to the system anyway -- because during your boot sequence you need to generate a hardware list. I am not trying to do my boot process in any ideal way yet, so I'm just preserving some BIOS-based boot loader info for the boot disk (such as the MBR/partition table) in memory -- and searching for a match, as I do my hardware search.
As I understand it, there is a list of drive info that the BIOS can supply (with some INT call during Real Mode) that can give you a more intelligent method for determining the boot drive. But I haven't looked into that yet. I'm pretty sure it's built into DexOS -- you may want to look at that source.
In some sense, you need to scan each drive attached to the system anyway -- because during your boot sequence you need to generate a hardware list. I am not trying to do my boot process in any ideal way yet, so I'm just preserving some BIOS-based boot loader info for the boot disk (such as the MBR/partition table) in memory -- and searching for a match, as I do my hardware search.
As I understand it, there is a list of drive info that the BIOS can supply (with some INT call during Real Mode) that can give you a more intelligent method for determining the boot drive. But I haven't looked into that yet. I'm pretty sure it's built into DexOS -- you may want to look at that source.
Last edited by bewing on Mon Jan 19, 2009 5:57 pm, edited 1 time in total.
Re: Detecting boot drive in protected mode
There is no reliable way to do this from pmode, best to store it in realmode, for later use.
- Firestryke31
- Member
- Posts: 550
- Joined: Sat Nov 29, 2008 1:07 pm
- Location: Throw a dart at central Texas
- Contact:
Re: Detecting boot drive in protected mode
Is there some reliable way of getting the boot drive from the value stored in DL?
Edit: stupid question, if there were, everyone would use that...
Edit: stupid question, if there were, everyone would use that...
Owner of Fawkes Software.
Wierd Al wrote: You think your Commodore 64 is really neato,
What kind of chip you got in there, a Dorito?
Re: Detecting boot drive in protected mode
As I say, there IS such a way, in Real mode, but it's complicated.
Re: Detecting boot drive in protected mode
The general way to get physical place of boot drive is int 13h/48h. For floppies (when DL = 0 or 1) I displace this value with DOR.0 value. For old IDE hard drives BIOS associates logical numbers with drives in detection order. Floppy/hard drive emulation on CD must be disabled.Firestryke31 wrote:Is there some reliable way of getting the boot drive from the value stored in DL?
If you have seen bad English in my words, tell me what's wrong, please.
- Love4Boobies
- Member
- Posts: 2111
- Joined: Fri Mar 07, 2008 5:36 pm
- Location: Bucharest, Romania
Re: Detecting boot drive in protected mode
There's also another way. The BBS defines a few extra PnP functions, one of which is "Get IPL Device from Last Boot". But keep in mind that although it can be used in protected mode, you need 16-bit descriptors.
EDIT: Nevermind my last edit
Enjoy!
Code: Select all
short FAR (* entryPoint) (Function, IPLEntry, BiosSelector);
short Function; // PnP BIOS function 64h.
unsigned short FAR *IPLEntry; // Index of entry in IPL Table.
unsigned short BiosSelector; // PnP BIOS readable/writable selector.
Enjoy!
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
[ Project UDI ]