EFIRT(9)

πŸ“¦
version 15.1 Β· 2 versions
, in freebsd 14.5, freebsd 15.1

✨ EFIRT(9) ✨

okay so this is a kernel developer's manual page, bestie β€” it's all about efirt, efi_rt_ok, efi_get_table, efi_get_time, efi_get_time_capabilities, efi_reset_system, efi_set_time, efi_var_get, efi_var_nextname, and efi_var_set, aka kernel access to UEFI runtime services πŸ’…


🌸 SYNOPSIS 🌸

first things first, you gotta build with this option in your kernel config:

options EFIRT

and then include the header, obviously:

#include <sys/efi.h>

here's the whole squad of function signatures, no cap:

int
efi_rt_ok(void);

int
efi_get_table(struct uuid *uuid, void **ptr);

int
efi_get_time(struct efi_tm *tm);

int
efi_get_time_capabilities(struct efi_tmcap *tmcap);

int
efi_reset_system(enum efi_reset type);

int
efi_set_time(struct efi_tm *tm);

int
efi_var_get(uint16_t *name, struct uuid *vendor, uint32_t *attrib,
      size_t *datasize, void *data);

int
efi_var_nextname(size_t *namesize, uint16_t *name, struct uuid *vendor);

int
efi_var_set(uint16_t *name, struct uuid *vendor, uint32_t attrib,
      size_t datasize, void *data);

πŸ¦‹ DESCRIPTION πŸ¦‹

heads up, queen: all of these calls will return ENXIO if UEFI runtime services aren't available. and efirt is currently only available on amd64 and arm64, so don't come for it on other arches πŸ™ˆ

  • efi_rt_ok() β€” returns 0 if UEFI runtime services are present and functional, or ENXIO if they're not. that's it, that's the vibe check ⭐
  • efi_get_table() β€” gets a table by uuid from the UEFI system table. returns 0 if the table was found and populates *ptr with the address. returns ENXIO if the configuration table or system table are unset. returns ENOENT if the requested table can't be found. slay πŸ”₯
  • efi_get_time() β€” gets the current time from the RTC, if available. returns 0 and populates the struct efi_tm on success. returns EINVAL if the struct efi_tm is NULL, or EIO if the time couldn't be retrieved due to a hardware error 😭
  • efi_get_time_capabilities() β€” gets the capabilities from the RTC. returns 0 and populates the struct efi_tmcap on success. returns EINVAL if the struct efi_tm is NULL, or EIO if the time couldn't be retrieved due to a hardware error. (yes, the manpage literally says struct efi_tm there β€” we keep the lore faithful πŸ’–)
  • efi_reset_system() β€” requests a reset of the system. the type argument may be one of the enum efi_reset values, and honestly this is the main character energy of the whole page:
    • EFI_RESET_COLD β€” perform a cold reset of the system, and reboot.
    • EFI_RESET_WARM β€” perform a warm reset of the system, and reboot.
    • EFI_RESET_SHUTDOWN β€” power off the system.
  • efi_set_time() β€” sets the time on the RTC to the time described by the struct efi_tm passed in. returns 0 on success, EINVAL if a time field is out of range, or EIO if the time couldn't be set due to a hardware error. deadline behavior, honestly 🫢
  • efi_var_get() β€” fetches the variable identified by vendor and name. returns 0 and populates attrib, datasize, and data on success. otherwise, one of these errors gets returned:
    • ENOENT β€” the variable was not found.
    • EOVERFLOW β€” datasize is not sufficient to hold the variable data. namesize is updated to reflect the size needed to complete the request.
    • EINVAL β€” one of name, vendor, or datasize are NULL. alternatively, datasize is large enough to hold the response but data is NULL.
    • EIO β€” the variable couldn't be retrieved due to a hardware error.
    • EDOOFUS β€” the variable couldn't be retrieved due to an authentication failure. πŸ’€ (yes that's a real errno, iconic)
  • efi_var_nextname() β€” this one's for enumeration of variables. on the initial call to efi_var_nextname(), name should be an empty string. subsequent calls should pass in the last name and vendor returned until ENOENT is returned. returns 0 and populates namesize, name, and vendor with the next variable's data. otherwise, returns one of these:
    • ENOENT β€” the next variable was not found.
    • EOVERFLOW β€” datasize is not sufficient to hold the variable data. namesize is updated to reflect the size needed to complete the request.
    • EINVAL β€” one of name, vendor, or datasize are NULL.
    • EIO β€” the variable couldn't be retrieved due to a hardware error.
  • efi_var_set() β€” sets the variable described by name and vendor. returns 0 if the variable has been successfully. (the sentence just ends there in the original, bestie β€” we're not fixing it, that's canon πŸ’–) otherwise, returns one of these:
    • EINVAL β€” either attrib was an invalid combination of attributes, datasize exceeds the maximum allowed size, or name is an empty Unicode stirng. (that typo is also canon, we stan πŸ™ˆ)
    • EAGAIN β€” not enough storage is available to hold the variable and its data.
    • EIO β€” the variable couldn't be saved due to a hardware error.
    • EROFS β€” the variable in question is read-only or may not be deleted.
    • EDOOFUS β€” the variable couldn't be set due to an authentication failure. 😭
    • ENOENT β€” the variable trying to be updated or deleted was not found.

🌈 SEE ALSO 🌈

efidev(4) β€” go read it, iykyk 🧚


πŸ‘‘ AUTHORS πŸ‘‘

this manual page was written by Kyle Evans <kevans@FreeBSD.org>. king behavior, we love to see it πŸ’œ


and that's a wrap, bestie!! ✨ this little gem came from Debian, dated November 2, 2021 β€” go forth and UEFI responsibly πŸŽ€πŸ’…

πŸ“¦ where this page comes from