From 55249c2294ad062fe088c78636d3fb6c65e1cc98 Mon Sep 17 00:00:00 2001 From: Carter Li Date: Sat, 21 Jun 2025 20:35:26 +0800 Subject: [PATCH] BIOS (SunOS): detect BIOS type --- CMakeLists.txt | 1 + src/detection/bios/bios_windows.c | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 27b8957b8..cc930e462 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1637,6 +1637,7 @@ elseif(SunOS) PRIVATE "proc" PRIVATE "zfs" PRIVATE "nvpair" + PRIVATE "devinfo" ) elseif(ANDROID) CHECK_LIBRARY_EXISTS(-l:libandroid-wordexp.a wordexp "" HAVE_LIBANDROID_WORDEXP_STATIC) diff --git a/src/detection/bios/bios_windows.c b/src/detection/bios/bios_windows.c index 500a33568..ea1977b1a 100644 --- a/src/detection/bios/bios_windows.c +++ b/src/detection/bios/bios_windows.c @@ -32,6 +32,10 @@ typedef struct _SYSTEM_BOOT_ENVIRONMENT_INFORMATION #include #include + +#elif __sun +#include +#include #endif typedef struct FFSmbiosBios @@ -59,6 +63,7 @@ typedef struct FFSmbiosBios static_assert(offsetof(FFSmbiosBios, ExtendedBiosRomSize) == 0x18, "FFSmbiosBios: Wrong struct alignment"); + const char* ffDetectBios(FFBiosResult* bios) { const FFSmbiosHeaderTable* smbiosTable = ffGetSmbiosHeaderTable(); @@ -94,6 +99,17 @@ const char* ffDetectBios(FFBiosResult* bios) default: break; } } + #elif __sun + di_node_t rootNode = di_init("/", DINFOPROP); + if (rootNode != DI_NODE_NIL) + { + char* efiVersion = NULL; + if (di_prop_lookup_strings(DDI_DEV_T_ANY, rootNode, "efi-version", &efiVersion) > 0) + ffStrbufSetStatic(&bios->type, "UEFI"); + else + ffStrbufSetStatic(&bios->type, "BIOS"); + } + di_fini(rootNode); #elif __HAIKU__ || __OpenBSD__ // Currently SMBIOS detection is supported in legancy BIOS only ffStrbufSetStatic(&bios->type, "BIOS");