News for hackers. Stuff that matters.
Re:UEFI boot: how does that actually work, then? (2014) by userbinator on Friday November 11, 2016 @09:23PM (#12936222)
IMHO UEFI is an overly complex solution that seems to be optimised for multibooting in various complex ways, a use-case that is probably extremely rare; how many "average users" do you know which have more than one OS natively installed on their machine? And of those, how many have more than two? Especially in this era of VMs, multibooting is becoming increasingly rare.

On the other hand, BIOS boot is optimised for the overwhelmingly common case of one OS; select a boot device, load its first sector into memory, and jump to it. The BIOS does not need to know at all about filesystems, partitioning, or other things which are more at the OS level, which I think is a good application of the principle of "separation of concerns"; UEFI however seems to have become much of an OS itself, with all the associated complexity and increased failure modes of such. Two memorable incidents:

https://news.ycombinator.com/item?id=11008449

https://news.ycombinator.com/item?id=5139055

There is no BIOS specification. BIOS is a de facto standard – it works the way it worked on actual IBM PCs, in the 1980s. That’s kind of one of the reasons UEFI exists.

It's more like a collection of specifications, but you can find much of the important ones here and much of the API is in the IBM PC/AT Technical Reference:

http://cs.dartmouth.edu/~bx/blog/resources/bios.html

The particularly relevant one for this article is here:

http://www.phoenix.com/resources/specs-bbs101.pdf

(Note the URL and the date of the document.)

The design doesn’t provide a standard way of booting from anything except disks. We’re not going to really talk about that in this article, but just be aware it’s another advantage of UEFI booting: it provides a standard way for booting from, for instance, a remote server.

Network booting in the BIOS world is almost always done through PXE.

Re:UEFI boot: how does that actually work, then? (2014) by drvdevd on Friday November 11, 2016 @09:35PM (#12936272)
Thats interesting. I've booted UEFI machines using PXE and judging from the PXE ROM versions displayed, the PXE code hasn't changed much, on my boxes at least.

I would agree that UEFI is an OS of its' own. But thats the whole point isn't it? That way writing drivers for peripherals can be done in C, etc.

I have a BIOS machine I cant boot using my SD card for example, which I need to do. I imagine writing (or porting) a driver for UEFI to interface with that SD card reader would be an order of magnitude simpler than doing the same by modifying my BIOS (which I've seriously considered doing).

Re:UEFI boot: how does that actually work, then? (2014) by kijiki on Saturday November 12, 2016 @08:42AM (#12937758)
The BIOS way to do this is with an Option ROM. During boot, the BIOS scans for a special signature, and jumps to a fixed offset in that block. The OPROM init routine then hooks the various software interrupts that the BIOS, boot-loader and other OPROMs use to read from disk.

You can inject a custom one into your BIOS image, but if you have PCI/PCIe available, you can get cards that have an OPROM onboard. The easiest/hacky way is an old NIC that someone has reverse engineered enough to flash its OPROM; you're just using it for the OPROM, the NIC functionality is unused.

Re:UEFI boot: how does that actually work, then? (2014) by drvdevd on Saturday November 12, 2016 @09:27PM (#12941508)
Very interesting thank you. You may already be aware, but when I first saw the replies here mentioning Option ROMs I immediately thought of the thunderstrike EFI vulnerabilities for Macbooks. I've yet to actually mess with them, but apparently that was how they worked at least in the first generation, I haven't followed the research much further yet [https://trmm.net/Thunderstrike]. So since option ROMs, for obvious reasons, survived the "transition" to EFI, does this mean the same mechanism could be used in BIOS machines? At least this might also have implications for backporting peripheral drivers too (for whatever reason)...
Re:UEFI boot: how does that actually work, then? (2014) by userbinator on Saturday November 12, 2016 @01:04AM (#12936829)
If you really want to boot from an SD card, try putting it in a standard USB card reader. Booting from USB mass storage has been supported for over a decade in BIOS, well before UEFI.

Otherwise, if you want to actually integrate a driver for an internal SD card reader (which isn't a USB one) into the BIOS, then an Option ROM (INT 13H hook) would be the way to go.

Re:UEFI boot: how does that actually work, then? (2014) by rasz_pl on Saturday November 12, 2016 @06:55AM (#12937505)
Go ahead. Try writing a custom uefi module, I dare you. Its such a complicated mess it takes a team, and still you end up with blinders on every corner(intel reference code full of bugs etc).
Re:UEFI boot: how does that actually work, then? (2014) by drvdevd on Saturday November 12, 2016 @09:31PM (#12941521)
I have no doubt that its a mess. I suppose I've just bought into the hype about what (U)EFI was supposed to be when it came along. Maybe one day it or something like it will make this all easier.