User:Madanra/Tasks before leaving Real Mode: Difference between revisions

From OSDev.wiki
Jump to navigation Jump to search
Content added Content deleted
(Add a couple of forum links)
 
(4 intermediate revisions by the same user not shown)
Line 18: Line 18:


*; Get a list of disk drives present and their "virtual cylinders, heads, and sectors" information
*; Get a list of disk drives present and their "virtual cylinders, heads, and sectors" information
: The CHS information is useful for correctly setting the CHS values in partition tables without guesswork, and it's useful to know the mapping from "BIOS device number" to disk.
: The CHS information is useful for correctly setting the CHS values in partition tables without guesswork, and you'll to know the mapping from "BIOS device number" to physical device so that after booting you know which devices the CHS geometry you found applies to.


*; If you booted from disk, find out what disk you booted from
*; If you booted from disk, find out what disk you booted from
: If you've loaded your kernel etc. using BIOS functions and a "BIOS device number" you'll need to know what physical device this corresponds to so you can identify your boot partition once booted.
: This is somewhat covered by the previous item, but is one its most important advantages: if you've loaded your kernel etc. using BIOS functions and a "BIOS device number" you'll need to know what physical device this corresponds to so you can identify what physical partition you booted from once your OS is running.


*; If you booted from network, get network information
*; If you booted from network, get network information
Line 29: Line 29:


:*; Determinte PCI access mechanism
:*; Determinte PCI access mechanism
:: It's best to ask the BIOS to avoid manual probing.
:: It's best to ask the BIOS to avoid manual probing. See [[PCI]].


:*; Enable A20 line
:*; Enable A20 line
:: It's best to ask BIOS to do it and fall back to less reliable methods if the BIOS won't.
:: It's best to ask BIOS to do it and fall back to less reliable methods if the BIOS won't. See [[A20 Line]]


:*; Tell the BIOS what mode you're going to use
:*; Tell the BIOS what mode you're going to use
Line 45: Line 45:
: Self-explanatory :)
: Self-explanatory :)


== Links ==
== See also ==


=== Articles ===
[http://forum.osdev.org/viewtopic.php?p=161572]

[http://forum.osdev.org/viewtopic.php?p=236336]
* [[Journey To The Protected Land]]

=== Forum threads ===

* [http://forum.osdev.org/viewtopic.php?p=236336#p236336 Forum post that this is based on]
* [http://forum.osdev.org/viewtopic.php?p=161572#p161572 Forum post about INT 0x15, EAX=0xEC00]

=== External links ===

Latest revision as of 16:49, 31 May 2014

Before switching to Protected Mode or Long Mode, there's a number of tasks you'll want your bootloader to perform that are hard or impossible afterwards.

Tasks

  • Get a map of the physical address space
The only safe and reliable way of getting a memory map is BIOS function INT 0x15, EAX=0xE820 or UEFI function GetMemoryMap. See Detecting Memory (x86) and Memory Map (x86).
  • Video tasks
If you don't have a video driver for every graphics card in existence, you're going to need to use BIOS or UEFI functions. You may want to:
  • Get a list of video modes
  • Get the monitor's EDID
  • Set the video mode
See Getting VBE Mode Info.
  • Get a list of disk drives present and their "virtual cylinders, heads, and sectors" information
The CHS information is useful for correctly setting the CHS values in partition tables without guesswork, and you'll to know the mapping from "BIOS device number" to physical device so that after booting you know which devices the CHS geometry you found applies to.
  • If you booted from disk, find out what disk you booted from
This is somewhat covered by the previous item, but is one its most important advantages: if you've loaded your kernel etc. using BIOS functions and a "BIOS device number" you'll need to know what physical device this corresponds to so you can identify what physical partition you booted from once your OS is running.
  • If you booted from network, get network information
Find the network card's MAC address and IP address, plus the DNS server's IP address, TFTP server's IP address etc. so that you can avoid doing (relatively slow) DHCP negotiations a second time if/when possible.
  • BIOS only
  • Determinte PCI access mechanism
It's best to ask the BIOS to avoid manual probing. See PCI.
  • Enable A20 line
It's best to ask BIOS to do it and fall back to less reliable methods if the BIOS won't. See A20 Line
  • Tell the BIOS what mode you're going to use
For x86-64 processors, the AMD manuals specify a BIOS function INT 0x15, EAX=0xEC00, BL=mode which tells the BIOS whether we are planning to use protected mode only, long mode only, or a mixture.
  • UEFI only
  • Get addresses of ACPI, SMBIOS etc. tables
UEFI tells you the location of various significat tables so you don't have to search for them.
  • Load your kernel/initrd/whatever
Self-explanatory :)

See also

Articles

Forum threads

External links