What sort of things are UEFI "applications" actually used for?
Asked Answered
M

6

16

I'm interested in PC firmware programming, and am just studying the UEFI spec. To my surprise, it seems like a spec for an entire OS which is embedded in firmware. You can even write UEFI "applications", which run directly using the UEFI boot services, without any other OS present.

I've found blog posts which show how to create a "Hello, world!" application which can run in the UEFI preboot environment. This is... interesting, and bizarre at the same time. I'll run my "Hello, world" programs on a regular OS, thank you.

What kind of use cases are UEFI applications actually good for? Fancy boot configuration screens? Does any "real", commercially available PC firmware use UEFI applications to implement anything more than just boot loaders and boot configuration utilities?

Mateusz answered 9/11, 2014 at 7:11 Comment(6)
If you are studying it so seriously that an "Hello world" example is beneath you, you must have read at least the Wikipedia page about the subject, which answers most, if not al of your questions, and sums up quite a number of real-life examples, as well as existing hardware that uses EFI already.Shaduf
@GolezTrol, I've read the Wikipedia page, and unless I missed something, the only examples of UEFI applications it gives are boot loaders, the UEFI shell (which does things like... launching a boot loader), and "Hello, world". Please note the question is not asking whether "real" hardware uses UEFI, but is focused specifically on the utility of UEFI applications (which run during the pre-boot phase). I have edited the question to make my intention slightly clearer.Mateusz
Intel suggests that diagnostics tools can be run as UEFI applications, which the added benefit of not needing a (full) OS for that. Another random example is Microsoft Battery Charger which verifies that a phone has enough power before continue booting.Shaduf
@GolezTrol, those are good examples -- thank you. But it would be better if you make them an answer, so I can upvote.Mateusz
Thanks, I hope the examples helped you, but I just googled them, and I'm not sure I'm expert enough on the subject to provide a good, solid, future-proof answer.Shaduf
Voting to close as too broad.Serica
M
18

Anything that isn't PEI/DXE/SMM core or driver is an application, so any "real" PC have them, because BIOS Setup is actually an UEFI application. Some vendors include various other apps like firmware updaters, diagnostic and troubleshooting utilities, etc. UEFI 2.4 makes possible to add your own application with a properly filled BootXXXX/KeyXXXX variable pair and then run it by pressing a key combination during POST.

Most console applications written in C can be compiled as UEFI application by using StdLib package of current EFI Development Kit and then run in UEFI shell.

Major examples of useful UEFI apps (besides bootloaders, shell and Linux kernel, of course) are Intel ME System Tools, Read Universal, Python 2.7 and many more.

Eventually, when legacy boot will not be available anymore, all currently useful DOS utilities must either be made UEFI applications or go extinct.

Morpho answered 9/11, 2014 at 14:9 Comment(0)
C
12

Despite many valuable answers here, because I wrote couple UEFI applications myself I will try to add my 2 cents. First, what is UEFI application to just give ground what we talking about:

UEFI Specificatin v2.5:

Section 2.1.1

The major differences between image types are the memory type that the firmware will load the image into, and the action taken when the image’s entry point exits or returns. An application image is always unloaded when control is returned from the image’s entry point.

Section 2.1.2

When the application returns from its entry point, or when it calls the Boot Service EFI_BOOT_SERVICES.Exit(), the application is unloaded from memory and control is returned to the UEFI component that loaded the application.

Groups of applications that make sense in UEFI:

  • Configuration tools - Configuration interface for Option ROMs (ie. for storage controllers), out of band management (ie. AMT configuration tools), manufacturer performance tweaking tools
  • Provisioning tools - used by administrators to preload specific BIOS setting, manually setting all options in BIOS setup would be inefficient
  • Diagnostics tools - mostly for tests that cannot be performed in OS (DRAM tests, full storage scan, storage R/W tests, etc.). In some districts specific diagnostics tools are required in UEFI BIOS, so those can be sold to government.
  • Security applications - HDD encryption/decryption, antivirus scanner and anti thief applications
  • BIOS capability enhancement - Power Over Ethernet extensions, DRAM discovery, patching and modification of system tables (SMBIOS, ACPI)
  • Display tools - for displaying complex animations while running, splash screen displaying
  • Bootloaders - this is special type of application, which can call EFI_BOOT_SERVICES.ExitBootServices() causing termination of all memory management and passing control to Operating System.

Note that very important feature of UEFI application is that it can be added to boot order and be executed each boot time. Also UEFI application do not have to be delivered with BIOS image it can be stored in connected device memory, which is common for Option ROM configuration tools.

Chen answered 7/1, 2016 at 12:38 Comment(0)
M
9

Here it is an example of a full blown UEFI Pre-boot Application;

There are SED SSD/HDD drives. As soon as SSD/HDD loses its power it goes into locked state (hardware-based encryption) There is no way you can get access to drive's data and all partitions on the drive are no longer even visible. Only small read-only partition (ShadowMBR) is available. UEFI firmware boots an UEFI application from that only available partition (UEFI app is written on that partition during the initialization process and when the ownership of an SED is taken). It securely authenticate user and if credentials are valid it unlocks the drive. When the drive is unlocked Shadow MBR disappears and all partitions on the drive becomes available. Then the App chain-boots the installed OS.

So if you don't have credentials you cannot even boot the OS and you cannot access the data on the drive by any means.

Mateusz answered 7/5, 2015 at 19:19 Comment(0)
H
5

Here's a couple of examples:

  1. https://github.com/NikolajSchlej/CrScreenshotDxe UEFI DXE driver to take screenshots from GOP-compatible graphic console (yes, you can make PNG screenshots of your BIOS and save them)

  2. http://ruexe.blogspot.com/ RU.EFI is quite an advanced tool for debugging the BIOS

Humane answered 4/1, 2016 at 7:50 Comment(0)
V
4

Well, there are the OS loaders - both the more heavyweight ones (Windows, GRUB, BSD Loader) and the "present a menu" ones (rEFInd, Gummiboot). Shim, which enables UEFI Secure Boot for Linux platforms, consists of an application as well as installing a protocol for use by other applications.

Then you have things like the Linux kernel, which when compiled with CONFIG_EFI_STUB becomes a valid UEFI application, with the awareness of booting itself.

And firmware updates can also be shipped as UEFI applications.

The UEFI shell itself is an application.

Then there are things like factory production testing utilities, development diagnosis tools, ...

Vernettaverneuil answered 9/11, 2014 at 9:7 Comment(0)
M
2

Windows 7 - 8 have UEFI installer. I'm not fully aware of the details, but I'm pretty sure this new environment gives a lot more flexibility to the developers than traditional boot environment on DVD.

Some motherboards have "instant on" features that allows you to get to a desktop screen within a few seconds. This is usually a stripped down flavor of some linux that allows you to access a web browser and play music/video. ASUS have such boards.

Megilp answered 9/11, 2014 at 7:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.