kern/host now maintains the EFI system table address and implements a
new flavour for host_info() that allows user servers to access it.
---
i386/i386/multiboot2_hdr_asm.h | 2 +-
i386/i386at/acpi_parse_apic.c | 9 +++++++++
include/mach/host_info.h | 15 +++++++++++++++
kern/host.c | 14 ++++++++++++++
kern/host.h | 5 +++++
5 files changed, 44 insertions(+), 1 deletion(-)
diff --git a/i386/i386/multiboot2_hdr_asm.h b/i386/i386/multiboot2_hdr_asm.h
index 9c2b5619..ccb2a448 100644
--- a/i386/i386/multiboot2_hdr_asm.h
+++ b/i386/i386/multiboot2_hdr_asm.h
@@ -37,7 +37,7 @@ multiboot2_hdr:
.long MULTIBOOT2_TAG_TYPE_ELF_SECTIONS
.long MULTIBOOT2_TAG_TYPE_ACPI_OLD
.long MULTIBOOT2_TAG_TYPE_ACPI_NEW
- .long 0 /* alignment */
+ .long MULTIBOOT2_TAG_TYPE_EFI64
/* Align modules on page boundaries */
.short MULTIBOOT2_HEADER_TAG_MODULE_ALIGN
.short 0
diff --git a/i386/i386at/acpi_parse_apic.c b/i386/i386at/acpi_parse_apic.c
index b33b5324..3d992d12 100644
--- a/i386/i386at/acpi_parse_apic.c
+++ b/i386/i386at/acpi_parse_apic.c
@@ -26,6 +26,10 @@
#include <mach/machine.h> /* machine_slot */
#include <mach/machine/multiboot2.h>
+#ifdef __x86_64__
+#include <kern/host.h>
+#endif
+
#include <kern/printf.h> /* printf */
#include <kern/debug.h>
#include <i386/vm_param.h> /* phystokv */
@@ -719,6 +723,11 @@ acpi_mb2_initialise (const struct multiboot2_raw_info *bi)
}
break;
+#ifdef __x86_64__
+ case MULTIBOOT2_TAG_TYPE_EFI64:
+ host_efi_systab = ((const struct multiboot2_tag_efi64 *)tag)->pointer;
+ break;
+#endif
default:
break;
}
diff --git a/include/mach/host_info.h b/include/mach/host_info.h
index b84376b8..e6ea515a 100644
--- a/include/mach/host_info.h
+++ b/include/mach/host_info.h
@@ -53,6 +53,9 @@ typedef char kernel_version_t[KERNEL_VERSION_MAX];
#define HOST_PROCESSOR_SLOTS 2 /* processor slot numbers */
#define HOST_SCHED_INFO 3 /* scheduling info */
#define HOST_LOAD_INFO 4 /* avenrun/mach_factor info */
+#ifdef __x86_64__
+#define HOST_EFI_SYSTAB 5 /* EFI System table. */
+#endif /* __x86_64__ */
struct host_basic_info {
integer_t max_cpus; /* max number of cpus possible */
@@ -87,4 +90,16 @@ typedef struct host_load_info *host_load_info_t;
#define HOST_LOAD_INFO_COUNT \
(sizeof(host_load_info_data_t)/sizeof(integer_t))
+#ifdef __x86_64__
+typedef uint64_t host_efi_systab_data_t;
+typedef uint64_t *host_efi_systab_t;
+#define HOST_EFI_SYSTAB_COUNT \
+ (sizeof(host_efi_systab_data_t)/sizeof(integer_t))
+
+/* This is the address returned for the EFI system table in the case
+ where UEFI is not available. */
+#define HOST_NO_UEFI (~0ULL)
+
+#endif /* __x86_64__ */
+
#endif /* _MACH_HOST_INFO_H_ */
diff --git a/kern/host.c b/kern/host.c
index 035ef05f..166d6f40 100644
--- a/kern/host.c
+++ b/kern/host.c
@@ -45,6 +45,9 @@
#include <kern/mach_host.server.h>
#include <mach/vm_param.h>
+#ifdef __x86_64__
+uint64_t host_efi_systab = HOST_NO_UEFI;
+#endif /* __x86_64__ */
host_data_t realhost;
kern_return_t host_processors(
@@ -195,6 +198,17 @@ kern_return_t host_info(
return KERN_SUCCESS;
}
+#ifdef __x86_64__
+ case HOST_EFI_SYSTAB:
+ {
+ if (*count < HOST_EFI_SYSTAB_COUNT)
+ return KERN_FAILURE;
+
+ *(host_efi_systab_t) info = host_efi_systab;
+ *count = HOST_EFI_SYSTAB_COUNT;
+ return KERN_SUCCESS;
+ }
+#endif /* __x86_64__ */
default:
return KERN_INVALID_ARGUMENT;
}
diff --git a/kern/host.h b/kern/host.h
index 5771da16..ff381f47 100644
--- a/kern/host.h
+++ b/kern/host.h
@@ -45,4 +45,9 @@ typedef struct host host_data_t;
extern host_data_t realhost;
+#ifdef __x86_64__
+/* The physical adddress of the UEFI System table. */
+extern uint64_t host_efi_systab;
+#endif /* __x86_64__ */
+
#endif /* _KERN_HOST_H_ */
--
2.47.3