GRUB - UEFI emulation?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
bellezzasolo
Member
Member
Posts: 110
Joined: Sun Feb 20, 2011 2:01 pm

GRUB - UEFI emulation?

Post by bellezzasolo »

So, I've been writing a UEFI OS. Of course, we all want our OSes to run on all systems, not just UEFI.
However, I've been thinking. GRUB2 has a nice set of drivers and module support. It even provides the same flat memory model as UEFI.
So, what's to prevent GRUB2 emulating UEFI firmware? OK, not the full runtime service thing, but I don't see a significant subset being too difficult.
Thoughts?
Whoever said you can't do OS development on Windows?
https://github.com/ChaiSoft/ChaiOS
LtG
Member
Member
Posts: 384
Joined: Thu Aug 13, 2015 4:57 pm

Re: GRUB - UEFI emulation?

Post by LtG »

bellezzasolo wrote:So, I've been writing a UEFI OS. Of course, we all want our OSes to run on all systems, not just UEFI.
However, I've been thinking. GRUB2 has a nice set of drivers and module support. It even provides the same flat memory model as UEFI.
So, what's to prevent GRUB2 emulating UEFI firmware? OK, not the full runtime service thing, but I don't see a significant subset being too difficult.
Thoughts?
Not sure what your after..

Is your idea that your OS would only support UEFI boot and it would work directly with UEFI machines and on BIOS machines you would use GRUB2 and it should provide UEFI environment so your bootstrap still works?

Wouldn't it be better and simpler to separate the two distinct concerns:
- OS/kernel doesn't care how it gets instantiated, it just wants to be a good OS/kernel
- Bootstrap is firmware specific (BIOS or UEFI, or something else for other than PC platforms) and it's job is to instantiate your OS

So write your UEFI bootstrap in such a manner that it "instantiates" your OS and then you can write another one for BIOS, and the latter stages of both can and likely would be nearly identical.

I don't really see much benefit in trying to make BIOS look like UEFI, given that the other solution is more reliable since trying to "translate" all UEFI stuff into BIOS stuff in such a manner that it always works is pretty much impossible, unless GRUB2 becomes even more of an OS in and of itself.
User avatar
zaval
Member
Member
Posts: 659
Joined: Fri Feb 17, 2017 4:01 pm
Location: Ukraine, Bachmut
Contact:

Re: GRUB - UEFI emulation?

Post by zaval »

bellezzasolo wrote:So, I've been writing a UEFI OS. Of course, we all want our OSes to run on all systems, not just UEFI.
However, I've been thinking. GRUB2 has a nice set of drivers and module support. It even provides the same flat memory model as UEFI.
So, what's to prevent GRUB2 emulating UEFI firmware? OK, not the full runtime service thing, but I don't see a significant subset being too difficult.
Thoughts?
Runtime services are a tiny portion of UEFI, probably you meant Boot Services (and bunch of protocols for doing things like various I/O for storage and overall peripheralls (SATA, USB and PCIe are alone a monstrous thing each, but there are a lot yet - SD/MMC, NAND for example), graphics, consoles, driver binding, device paths, various networking things like TCP/IP, TFTP, iSCSI, PXE, etc etc)?

And why "emulating"? Is it religiously forbidden for it to even think it could "implement" it? :D Who knows better than the GRUB developers? I think they know better. Since I am working with mips and arm SBCs I have no idea about GRUB, but I heard it is able to play role a UEFI OsLoader, so maybe this is their way - they don't think it's needed for them to compete with Tianocore, which already supplies a base ground, massive framework, in fact, for traditional BIOS makers, now making UEFI? They just don't want. How does that idea look to you?

Personally, I don't see any reason for hobby OSes aiming at x86 to support legacy protocols like BIOS. It's just work for the past, not future. UEFI is getting widespread, so if you ever will have users for your OS, they most probably will be more comfortable with UEFI than BIOS. :) It's like learning assembly by books talking about 16-bit real mode and DOS. Somehow it's often seen even now.
ANT - NT-like OS for x64 and arm64.
efify - UEFI for a couple of boards (mips and arm). suspended due to lost of all the target park boards (russians destroyed our town).
Notturno
Posts: 6
Joined: Tue Jul 25, 2017 11:25 am

Re: GRUB - UEFI emulation?

Post by Notturno »

zaval wrote:Personally, I don't see any reason for hobby OSes aiming at x86 to support legacy protocols like BIOS. It's just work for the past, not future. UEFI is getting widespread, so if you ever will have users for your OS, they most probably will be more comfortable with UEFI than BIOS.
I disagree. While most modern PCs support both UEFI and BIOS not all emulators support UEFI. Most users will probably run a hobby OS on an emulator and they might use an emulator which does not support UEFI like Bochs.
mallard
Member
Member
Posts: 280
Joined: Tue May 13, 2014 3:02 am
Location: Private, UK

Re: GRUB - UEFI emulation?

Post by mallard »

Notturno wrote: I disagree. While most modern PCs support both UEFI and BIOS not all emulators support UEFI. Most users will probably run a hobby OS on an emulator and they might use an emulator which does not support UEFI like Bochs.
Not only that, but few people are willing to "hand over" expensive, up-to-date hardware for testing a hobby OS on (whether it's their own or someone elses). Much more likely that they'll have a few-generations-old PC sitting in a cupboard somewhere with nothing on it that they don't mind losing...
Image
Muf
Posts: 6
Joined: Sun Apr 16, 2017 4:45 pm
Libera.chat IRC: mf

Re: GRUB - UEFI emulation?

Post by Muf »

For what it's worth I think there are a few legacy BIOS boot loaders like Chameleon that emulate (U)EFI for the purpose of booting macOS on non-EFI systems.
User avatar
Roman
Member
Member
Posts: 568
Joined: Thu Mar 27, 2014 3:57 am
Location: Moscow, Russia
Contact:

Re: GRUB - UEFI emulation?

Post by Roman »

This is somewhat off-topic but you might find this interesting: https://www.cnx-software.com/2016/08/11 ... platforms/
"If you don't fail at least 90 percent of the time, you're not aiming high enough."
- Alan Kay
User avatar
zaval
Member
Member
Posts: 659
Joined: Fri Feb 17, 2017 4:01 pm
Location: Ukraine, Bachmut
Contact:

Re: GRUB - UEFI emulation?

Post by zaval »

mallard wrote: Not only that, but few people are willing to "hand over" expensive, up-to-date hardware for testing a hobby OS on (whether it's their own or someone elses). Much more likely that they'll have a few-generations-old PC sitting in a cupboard somewhere with nothing on it that they don't mind losing...
that is what I called "working for the past".

you won't test your own creature on the "up-to-date" hardware even having it? you hate your OS! :lol:

well, it's a little stereotyped. like "new hardware" necessarily means a several times overpriced new iSomething(R) device from you know. :D Nowadays one could buy a little and cute and inexpensive x86 SBC with all the new features, still quite affordable by price. Exactly for testing his/her own OS. Or have something not bloody new, but still quite modern. different flea markets suggest all the spectrum for all prices. shortly speaking it's a very bad excuse to still mess around BIOS/DOS/16 bits in 2017. And finally, "testing the OS" is not going to burn out your shiny rig. :) The biggest damage would either nihilizing data on the storage - easily overcome, just use an empty drive, or bricking the board. only if you play with the FW, which is improbable, but that still is kind of revertible.
Roman wrote: This is somewhat off-topic but you might find this interesting: https://www.cnx-software.com/2016/08/11 ... platforms/
uboot...
Image

last time I checked their "support", most Services were just stubs. It's not implementing UEFI, it's mimicking and pretending you do so. they just managed to run some primitive UEFI applications. Noone with a sane psychic would use uboot for UEFI on arm. There is Tianocore which is a true UEFI implementation. uboot is a messy linux only kind of loader.
ANT - NT-like OS for x64 and arm64.
efify - UEFI for a couple of boards (mips and arm). suspended due to lost of all the target park boards (russians destroyed our town).
Post Reply