aboutsummaryrefslogtreecommitdiff
path: root/sys/amd64
diff options
context:
space:
mode:
authorAhmad Khalifa <ahmadkhalifa570@gmail.com>2024-06-03 01:40:43 +0000
committerGordon Tetlow <gordon@FreeBSD.org>2025-08-07 23:10:00 +0000
commitce4fe4c4bfcd5908b5f4121623f6640e15261bc8 (patch)
tree814c9b5757179bf9d7362513d2cd9081a5fd44ac /sys/amd64
parent2ea99b8ed14208286ec3c8d6ccc997537c13d195 (diff)
Add a new sysctl in order to diffrentiate UEFI architectures
With the new 32-bit UEFI loader, it's convenient to have a sysctl to figure out how we booted. Can be accessed at machdep.efi_arch Reviewed by: imp Pull Request: https://github.com/freebsd/freebsd-src/pull/1098 (cherry picked from commit b538d4911004ca541507166b8ec9689d2e87d1aa) (cherry picked from commit 0e8890a425bc778d323566c881e26bad7c54baf2) Approved by: so Security: FreeBSD-EN-25:12.efi
Diffstat (limited to 'sys/amd64')
-rw-r--r--sys/amd64/amd64/machdep.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/sys/amd64/amd64/machdep.c b/sys/amd64/amd64/machdep.c
index ea0f164b2e56..9644e167d54d 100644
--- a/sys/amd64/amd64/machdep.c
+++ b/sys/amd64/amd64/machdep.c
@@ -1691,6 +1691,27 @@ SYSCTL_PROC(_machdep, OID_AUTO, efi_map,
efi_map_sysctl_handler, "S,efi_map_header",
"Raw EFI Memory Map");
+static int
+efi_arch_sysctl_handler(SYSCTL_HANDLER_ARGS)
+{
+ char *arch;
+ caddr_t kmdp;
+
+ kmdp = preload_search_by_type("elf kernel");
+ if (kmdp == NULL)
+ kmdp = preload_search_by_type("elf64 kernel");
+
+ arch = (char *)preload_search_info(kmdp,
+ MODINFO_METADATA | MODINFOMD_EFI_ARCH);
+ if (arch == NULL)
+ return (0);
+
+ return (SYSCTL_OUT_STR(req, arch));
+}
+SYSCTL_PROC(_machdep, OID_AUTO, efi_arch,
+ CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, 0,
+ efi_arch_sysctl_handler, "A", "EFI Firmware Architecture");
+
void
spinlock_enter(void)
{