OSDev.org

The Place to Start for Operating System Developers
It is currently Fri Mar 29, 2024 3:43 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 28 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Don't know what to make of UEFI
PostPosted: Sun Dec 08, 2013 9:50 pm 
Offline
Member
Member
User avatar

Joined: Mon Nov 05, 2012 8:31 pm
Posts: 286
Location: New Zealand
I got a new laptop the other day, and it uses UEFI. You can use "legacy mode" to use BIOS, but I am scared that UEFI will replace BIOS in the future and from what I've read about UEFI (not much actually), it doesn't sound good.

Has anyone made their OS work with UEFI? If so, is it alright?

_________________
Currently developing Lithium OS (LiOS).

Recursive paging saves lives.
"I want to change the world, but they won't give me the source code."


Top
 Profile  
 
 Post subject: Re: Don't know what to make of UEFI
PostPosted: Sun Dec 08, 2013 10:59 pm 
Offline
Member
Member
User avatar

Joined: Tue Dec 25, 2007 6:03 am
Posts: 734
Location: Perth, Western Australia
Conceptually, UEFI is a very good idea (Replacing the old RMode bios with something more extensible). However, I have not (yet) attempted to OSDev with it, but from what I've seen, you can still use grub to boot you using multiboot and just not care that there's UEFI at the low level (except that VBE is now unavaliable).

_________________
Kernel Development, It's the brain surgery of programming.
Acess2 OS (c) | Tifflin OS (rust) | mrustc - Rust compiler
Currently Working on: mrustc


Top
 Profile  
 
 Post subject: Re: Don't know what to make of UEFI
PostPosted: Sun Dec 08, 2013 11:54 pm 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 3:45 am
Posts: 9301
Location: On the balcony, where I can actually keep 1½m distance
I already run an UEFI system (no legacy involved) on my desktop and in practice there's little difference, other than GRUB having gone the way of the trash.

What you should not forget is that UEFI actually allows you to make calls to the firmware without having to switch to realmode and whatnot, doesn't stick you with an 1MB limit to load stuff, and more of those legacy nuisances.

_________________
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]


Top
 Profile  
 
 Post subject: Re: Don't know what to make of UEFI
PostPosted: Mon Dec 09, 2013 5:14 am 
Offline
Member
Member
User avatar

Joined: Fri Mar 07, 2008 5:36 pm
Posts: 2111
Location: Bucharest, Romania
What you've probably read about is the SecureBoot eature. There was some concern that most firmware vendors wouldn't let users manage their keys, meaning the choice of OS would have been that of the vendor's instead of that of the user's. Or that the user would have been forced not to use the feature (if disabling it was an option). This didn't happen, though.

_________________
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]


Top
 Profile  
 
 Post subject: Re: Don't know what to make of UEFI
PostPosted: Mon Dec 09, 2013 8:04 pm 
Offline
Member
Member
User avatar

Joined: Wed Oct 30, 2013 8:11 am
Posts: 70
UEFI is not bad as it seems.
1. It is removing Real Mode addiction. This is a REALLY good thing.
2. No boot sectors, 0x7C00's,512 byte-addiction,16 bit puke etc.
3. Your bootloader is not loaded in puke Real Mode, and UEFI is
capable of loading a whole file from the FAT disk. Plenty of disk space + RAM.
4. Much easier, C compilers like GCC are able to produce EFI Based code, without
any ridiculous tweaking or forcing the poor compiler to write 16-bit code.
5. EFI does provide services like the BIOS, except that you don't have to stick to 1MB or
some 10000000 limitations.
The wikipedia page about EFI says the following.
Quote:
EFI defines two types of services: boot services and runtime services. Boot services are only available while the firmware owns the platform (before the ExitBootServices call). Boot services include text and graphical consoles on various devices, and bus, block and file services. Runtime services are still accessible while the operating system is running; they include services such as date, time and NVRAM access. In addition, the Graphics Output Protocol (GOP) provides limited runtime services support. The operating system is permitted to directly write to the framebuffer provided by GOP during runtime mode. However, the ability to change video modes is lost after transitioning to runtime services mode until the OS graphics driver is loaded.

_________________
When you say, "I wrote a program that crashed Windows," people just stare at you blankly and say, "Hey, I got those with the system, for free." - Linus Torvalds
64 bit Kernel in early development
http://github.com/nerdguy12/core64


Top
 Profile  
 
 Post subject: Re: Don't know what to make of UEFI
PostPosted: Mon Dec 09, 2013 9:11 pm 
Offline
Member
Member
User avatar

Joined: Fri Mar 07, 2008 5:36 pm
Posts: 2111
Location: Bucharest, Romania
nerdguy wrote:
1. It is removing Real Mode addiction. This is a REALLY good thing.


I think you're probably overstating the benefits of not needing real mode. Sure, a step in the right direction, but I don't see too much practical importance.

nerdguy wrote:
2. No boot sectors, 0x7C00's,512 byte-addiction,16 bit puke etc.


  • At least for PXE, it already meant no boot sectors.
  • 7C00h is irrelevant---things still need to be loaded somewhere. Who cares where that is? (There's something to be said about faulty RAM here.)

Quote:
4. Much easier, C compilers like GCC are able to produce EFI Based code, without
any ridiculous tweaking or forcing the poor compiler to write 16-bit code.


Strictly speaking, it's a C dialect. The (U)EFI C requires sizeof to be a function rather than an operator, as it normally is.

_________________
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]


Top
 Profile  
 
 Post subject: Re: Don't know what to make of UEFI
PostPosted: Wed Jan 01, 2014 1:26 am 
Offline
Member
Member
User avatar

Joined: Wed Oct 30, 2013 8:11 am
Posts: 70
I find this page useful for an Introduction to UEFI. (Just wanted to share with you people in case anyone finds it interesting)
http://www.rodsbooks.com/efi-programming/index.html

_________________
When you say, "I wrote a program that crashed Windows," people just stare at you blankly and say, "Hey, I got those with the system, for free." - Linus Torvalds
64 bit Kernel in early development
http://github.com/nerdguy12/core64


Top
 Profile  
 
 Post subject: Re: Don't know what to make of UEFI
PostPosted: Wed Jan 01, 2014 1:22 pm 
Offline
Member
Member
User avatar

Joined: Wed Oct 27, 2010 4:53 pm
Posts: 1150
Location: Scotland
What's bothered me the most about UEFI until today is the difficulty in saving data back to flash drives without having to conquer USB first, but it looks as if this EFI service can actually handle that http://wiki.phoenix.com/wiki/index.php/EFI_USB2_HC_PROTOCOL#UsbAsyncInterruptTransfer.28.29, just so long as you don't exit EFI boot services. It may even be able to handle multiple flash drives and allow them to be plugged in and out and continue to be used, unlike with the BIOS (which will reject them after they've been removed and plugged back in, and which doesn't even like an SD card being changed for an identical one). If these capabilities really work that way, or even if they only work as well as the BIOS (has anyone tried them out for anything other than loading their OS?), it means EFI could still be a good environment for the early development of an OS even if the OS designer wants to be able to do useful work with that new OS from early on without having to write his/her own USB drivers first (as in my case where my OS has from the beginning been a self-sufficient development platform capable of modifying and saving itself, and where I've also been using my text editor to write a book, where again it's vital to be able to save data).

There will doubtless be a point at which things break as you change the setup of the machine, at which time you would need to bite the bullet and get your own USB code written, but it looks as if you may be able to reap the rewards of writing a simple OS to run in an EFI environment without having vast amounts of complex code to write before you reach that stage. I don't think I'll explore that route now myself as I've already gone down the BIOS-dependent route already and am at the point where writing my own USB drivers is the next logical step anyway (after which I will be able to write code to boot on EFI machines without any need to depend on EFI services beyond setting a screen mode and picking up a few pieces of information about things such as memory), but if I was starting out from scratch today I'd be looking at EFI instead as it may actually be better than the BIOS even for for someone who wants to be able to do useful work with their OS from the outset.

_________________
Help the people of Laos by liking - https://www.facebook.com/TheSBInitiative/?ref=py_c

MSB-OS: http://www.magicschoolbook.com/computing/os-project - direct machine code programming


Top
 Profile  
 
 Post subject: Re: Don't know what to make of UEFI
PostPosted: Sun Jan 05, 2014 10:28 am 
Offline
Member
Member
User avatar

Joined: Tue Feb 08, 2011 1:58 pm
Posts: 496
BMW wrote:
Has anyone made their OS work with UEFI? If so, is it alright?

Yes, I did. And it's a real nightmare. You'll find BIOS easy and nice.

Basically, you have to link a special PE executable, and place it under "\EFI\BOOT\BOOTX32.EFI" on a FAT partition labelled "EFI System" of a GPT disk. Since there's a minimum limit for FAT32 (FAT12 and FAT16 not surely supported), your loader partition will need at least 64Mb. Next (if your code get's called on boot by some voodoo magic), you'll have to walk through pointer tables, and pray to find UUIDs you want and play being CPU looking up IDT entries (but with different tables)), and try to avoid calling malicious code (no checks on service entry points at all). Technically every EFI loader application eager to call EFI ExitBootServices and get the hell out of there. Oh, and it has a really big overbloated SDK.

Does anybody really think this is easier or better than 512 bytes of code at 7C00h with well defined environment and services? Remember, computer use this code only for a small fraction of time. And it uses that to boot something else that has it's own way to communicate with the hardware anyway.

But, EFI is the way to go to boot your OS on modern machines.

Luckily the big mess can be smaller, you can use an assembler to produce that special PE (similar to writing a BIOS boot record).
Calling EFI services should be straightforward using the library on our wiki: uefi.inc

Good luck!


Top
 Profile  
 
 Post subject: Re: Don't know what to make of UEFI
PostPosted: Sun Jan 05, 2014 6:10 pm 
Offline
Member
Member
User avatar

Joined: Sat Jul 30, 2011 10:07 am
Posts: 374
Location: Wrocław/Racibórz, Poland
Quote:
512 bytes of code at 7C00h with well defined environment and services
lol

_________________
Reaver Project :: Repository :: Ohloh project page
<klange> This is a horror story about what happens when you need a hammer and all you have is the skulls of the damned.
<drake1> as long as the lock is read and modified by atomic operations


Top
 Profile  
 
 Post subject: Re: Don't know what to make of UEFI
PostPosted: Tue Jan 07, 2014 5:19 pm 
Offline
Member
Member
User avatar

Joined: Tue Feb 08, 2011 1:58 pm
Posts: 496
Griwes wrote:
Quote:
512 bytes of code at 7C00h with well defined environment and services
lol

Well,
Int 16/AH=00h and AH=01h for getting user input
Int 13/AH=0Ah and AH=42h for reading sectors into memory
did not change much in the last few decades. Nor did the VGA. What else do you need for a fancy OS loader?

OS kernels have their own way to do things, they do not rely on boot firmware once they are up and running.


Top
 Profile  
 
 Post subject: Re: Don't know what to make of UEFI
PostPosted: Tue Jan 07, 2014 5:53 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5103
turdus wrote:
Int 13/AH=0Ah and AH=42h for reading sectors into memory
Under some circumstances, you may need to use AH=02h instead. For example, a USB device that the BIOS has decided to emulate in "superfloppy" mode.


Top
 Profile  
 
 Post subject: Re: Don't know what to make of UEFI
PostPosted: Tue Jan 14, 2014 8:50 am 
Offline
Member
Member
User avatar

Joined: Tue Feb 08, 2011 1:58 pm
Posts: 496
Octocontrabass wrote:
Under some circumstances, you may need to use AH=02h instead. For example, a USB device that the BIOS has decided to emulate in "superfloppy" mode.

Who cares? Never saw BIOS and USB stick behave like that, those circumstances are marginal errors.
As a matter of fact AH=42h alone enough to boot from any fixed disk (ide, ata, sata, etc.) or removable USB storage (ahci,uhci,ehci) manufactured in the last decade or so. I did not implement anything else in my bootloader, yet never had any problem with booting my OS on real hardware from a pendrive or sd card.
On the other hand I experienced problems finding the UEFI block protocol when booting on real hardware. Currently I do not have proper fallback solution if it's not found :-(


Top
 Profile  
 
 Post subject: Re: Don't know what to make of UEFI
PostPosted: Tue Jan 14, 2014 11:14 am 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5103
turdus wrote:
Who cares? Never saw BIOS and USB stick behave like that, those circumstances are marginal errors.
You have not looked hard enough: most BIOSes only allow AH=42h if the first sector is a "valid" MBR, and each BIOS uses different criteria. Most only check for a partition table, but some also check that the partitions don't overlap, or that one of them is marked bootable. One BIOS checks for a FAT BPB!

If you like to boot Linux ISOs from a flash drive (using isohybrid), you've probably seen a computer boot without using AH=42h, since the isohybrid boot sector is not "valid" enough for many BIOSes.


Top
 Profile  
 
 Post subject: Re: Don't know what to make of UEFI
PostPosted: Thu Jan 16, 2014 1:32 pm 
Offline
Member
Member
User avatar

Joined: Tue Feb 08, 2011 1:58 pm
Posts: 496
Octocontrabass wrote:
most BIOSes only allow AH=42h if the first sector is a "valid" MBR

Where did you get such a nonsense? Let's make this clear: AH=42h reads a sector from disk to memory, nothing more, nothing less.

Octocontrabass wrote:
Most only check for a partition table, but some also check that the partitions don't overlap, or that one of them is marked bootable.

Wrong again. No BIOS checks for partition table of any kind, it's the job of MBR code. As the last step of POST, BIOS checks whether the first sector has a magic, and if yes, transfers control to it. That's all, and it has nothing to do with sector loading nor with partition tables. Writing a VBR in place of MBR would boot just fine, give it a try.

Octocontrabass wrote:
One BIOS checks for a FAT BPB!

Wrong again. No BIOS checks for BPB, it's the job of VBR code. Besides, it would mean BIOS can only boot from FAT, which is simply not true.

Octocontrabass wrote:
If you like to boot Linux ISOs from a flash drive (using isohybrid), you've probably seen a computer boot without using AH=42h, since the isohybrid boot sector is not "valid" enough for many BIOSes.

I don't care linux boot hacks. I was talking about BIOS Boot Specification.

Let's make this to an end. You are not aware of basic terms, and how an IBM compatible PC boots up, and this thread is about using UEFI anyway.

Have a nice day and don't learn too hard.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 28 posts ]  Go to page 1, 2  Next

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 36 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group