Files
Limine/common/lib/bli.c
sanana 196e07ab05 bli: Implement initial Boot Loader Interface support
This patch makes Limine advertise its branding and the ESP partition GUID to
systemd over the Boot Loader Interface specification. There's more to the Boot
Loader Interface than these variables, but this acts as an initial
implementation. See #473.

BLI variables are initialised for all protocols, not just Linux. While currently
only systemd makes use of it, this allows future Limine protocol kernels (or
their userspace) to discover the ESP.
2025-03-15 16:23:43 +03:00

37 lines
994 B
C

#if defined (UEFI)
#include <config.h>
#include <efi.h>
#include <lib/bli.h>
#include <lib/guid.h>
#include <lib/misc.h>
#define LIMINE_BRAND L"Limine " LIMINE_VERSION
static EFI_GUID bli_vendor_guid = { 0x4a67b082, 0x0a4c, 0x41cf, { 0xb6, 0xc7, 0x44, 0x0b, 0x29, 0xbb, 0x8c, 0x4f } };
void init_bli(void) {
gRT->SetVariable(L"LoaderInfo",
&bli_vendor_guid,
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
sizeof(LIMINE_BRAND),
LIMINE_BRAND);
char part_uuid_str[37];
guid_to_string(&boot_volume->part_guid, part_uuid_str);
// Convert part_uuid_str to a wide-char string
wchar_t part_uuid[37];
for (size_t i = 0; i < 37; i++) {
part_uuid[i] = (wchar_t) part_uuid_str[i];
}
gRT->SetVariable(L"LoaderDevicePartUUID",
&bli_vendor_guid,
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
sizeof(part_uuid),
part_uuid);
}
#endif