From 1c719fa743d91b9d2c23c476791a7a46b583e3d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sun, 23 Mar 2025 12:08:15 +0800 Subject: [PATCH] Bootmgr (BSD): add support for OpenBSD and NetBSD --- CMakeLists.txt | 4 ++-- src/detection/bootmgr/bootmgr_bsd.c | 16 ++++++++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4abd9b8b2..36ce53e39 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -739,7 +739,7 @@ elseif(NetBSD) src/detection/bluetooth/bluetooth_nosupport.c src/detection/bluetoothradio/bluetoothradio_nosupport.c src/detection/board/board_nbsd.c - src/detection/bootmgr/bootmgr_nosupport.c + src/detection/bootmgr/bootmgr_bsd.c src/detection/brightness/brightness_nbsd.c src/detection/btrfs/btrfs_nosupport.c src/detection/chassis/chassis_nbsd.c @@ -821,7 +821,7 @@ elseif(OpenBSD) src/detection/bluetooth/bluetooth_nosupport.c src/detection/bluetoothradio/bluetoothradio_nosupport.c src/detection/board/board_windows.c - src/detection/bootmgr/bootmgr_nosupport.c + src/detection/bootmgr/bootmgr_bsd.c src/detection/brightness/brightness_obsd.c src/detection/btrfs/btrfs_nosupport.c src/detection/chassis/chassis_windows.c diff --git a/src/detection/bootmgr/bootmgr_bsd.c b/src/detection/bootmgr/bootmgr_bsd.c index 86fe86fac..74a8114af 100644 --- a/src/detection/bootmgr/bootmgr_bsd.c +++ b/src/detection/bootmgr/bootmgr_bsd.c @@ -2,10 +2,22 @@ #include "efi_helper.h" #include "common/io/io.h" -#include +#ifdef __OpenBSD__ + #include +#else + #include +#endif #include #include +#ifdef __NetBSD__ + typedef uint16_t efi_char; +#endif + +#ifndef EFI_GLOBAL_VARIABLE + #define EFI_GLOBAL_VARIABLE { 0x8be4df61, 0x93ca, 0x11d2, 0xaa, 0x0d, { 0x00, 0xe0, 0x98, 0x03, 0x2b, 0x8c } } +#endif + const char* ffDetectBootmgr(FFBootmgrResult* result) { FF_AUTO_CLOSE_FD int efifd = open("/dev/efi", O_RDWR); @@ -13,7 +25,7 @@ const char* ffDetectBootmgr(FFBootmgrResult* result) uint8_t buffer[2048]; struct efi_var_ioc ioc = { - .vendor = { 0x8be4df61, 0x93ca, 0x11d2, 0xaa, 0x0d, { 0x00, 0xe0, 0x98, 0x03, 0x2b, 0x8c } }, + .vendor = EFI_GLOBAL_VARIABLE, .data = buffer, };