In my opinion, and this is just me, I don't like UEFI, and think it is way over-kill for what it actually should do.
A BIOS, whether it be the Legacy BIOS or the UEFI, should have little to do with the OS, just enough to access what needs to be accessed, before the OS takes control. For example, you must be able to read from the disk. If not, how are you going to read from the disk to read your driver that reads from the disk? The same goes for the screen (terminal) output. There are other things too, network booting, etc.
However, for the hobbyist like you and I, console in, console out, and disk access is really all we need. The rest should be done via the OS.
My UEFI boot code does the following using UEFI:
- 1. loads the loader which in turn, loads the kernel, and other system files.
2. retrieves the "default" video screen modes and stores them for the kernel.
3. switches to one of these "default" modes allowing the user to interrupt the process and choose a mode.
4. gets the memory map.
5. stops the UEFI services and jumps to the kernel.
That's it.
Now for a few notes.
- 1. UEFI has no text mode as you know it. For example, you can't write to memory at 0xB8000 and see text. You must use the Console out services and then your kernel *must* have a graphical text-out system already in place when it takes over. You cannot print debug messages using the Legacy style text-out via writes to screen memory at 0xB8000. (Imagine debugging your kernel's terminal/console out driver with no console out services...)
2. To be able to get to the kernel, you must stop the UEFI services. However, once you stop the UEFI services, you no longer have any access to these services including printing to the screen and disk access.
3. Your UEFI code is not in realmode. It is already in 32- or 64-bit protected/long mode.
4. You already have access to all physical memory via default selectors.
5. You can, however, load and execute (UEFI) PE files.
6. You have to find a UEFI service before you can use that service. Therefore, you have to use services to find services to use services. uuuggg.
Requirements:
- 1. You need a compiler that will output the correct binary, linking with the correct library. I use a modified version of Alex's who is a frequent visitor here. http://www.fysnet.net/nbc.htm
2. You need a GDT formatted drive that *must* use a FAT partition as your boot partition.
3. (Most of) your loader/kernel files must be on this FAT partition.
Most UEFI systems will partition the drive to have a small FAT partition, hidden from other partitions, used to boot the OS. Once it boots the OS, this partition is usually not touched anymore. As for if your OS will need to know how to read from a FAT partition, most likely yes. The UEFI will take you only so far. You will need to read from the booted partition or another non-fat partition to continue loading drivers and OS items.
I am not trying to say that UEFI is bad, nor am I trying to convince you to stay with the Legacy BIOS. I just want to make sure that you understand that it is a lot of work to get to know how to use the UEFI. Something I don't recommend a newbie uses, though there have been quite a few comments on this forum about using the Legacy BIOS is a sin.
Hope that helps,
Ben
http://www.fysnet.net/osdesign_book_series.htm