:: commit 50076656f452532ec6b95c5445896851e331ec90

mintsuki <mintsuki@protonmail.com> — 2022-03-17 18:59

parents: 4f90e0c723

limine: Add SMBIOS request

diff --git a/common/limine.h b/common/limine.h
index 98f8aeb3..3be01c45 100644
--- a/common/limine.h
+++ b/common/limine.h
@@ -184,4 +184,21 @@ struct limine_rsdp_request {
     LIMINE_PTR(struct limine_rsdp_response *) response;
 };
 
+// SMBIOS
+
+#define LIMINE_SMBIOS_REQUEST { LIMINE_COMMON_MAGIC, 0x9e9046f11e095391, 0xaa4a520fefbde5ee }
+
+struct limine_smbios_response {
+    uint64_t flags;
+
+    LIMINE_PTR(void *) entry_32;
+    LIMINE_PTR(void *) entry_64;
+};
+
+struct limine_smbios_request {
+    uint64_t id[4];
+    uint64_t flags;
+    LIMINE_PTR(struct limine_smbios_response *) response;
+};
+
 #endif
diff --git a/common/protos/limine.c b/common/protos/limine.c
index a6a28b3d..560ea1cd 100644
--- a/common/protos/limine.c
+++ b/common/protos/limine.c
@@ -256,6 +256,29 @@ FEAT_START
     rsdp_request->response = reported_addr(rsdp_response);
 FEAT_END
 
+    // SMBIOS feature
+FEAT_START
+    struct limine_smbios_request *smbios_request = get_request(LIMINE_SMBIOS_REQUEST);
+    if (smbios_request == NULL) {
+        break; // next feature
+    }
+
+    struct limine_smbios_response *smbios_response =
+        ext_mem_alloc(sizeof(struct limine_smbios_response));
+
+    void *smbios_entry_32 = NULL, *smbios_entry_64 = NULL;
+    acpi_get_smbios(&smbios_entry_32, &smbios_entry_64);
+
+    if (smbios_entry_32) {
+        smbios_response->entry_32 = reported_addr(smbios_entry_32);
+    }
+    if (smbios_entry_64) {
+        smbios_response->entry_64 = reported_addr(smbios_entry_64);
+    }
+
+    smbios_request->response = reported_addr(smbios_response);
+FEAT_END
+
     // Modules
 FEAT_START
     struct limine_module_request *module_request = get_request(LIMINE_MODULE_REQUEST);
diff --git a/test/limine.c b/test/limine.c
index b397b7dc..fe23842b 100644
--- a/test/limine.c
+++ b/test/limine.c
@@ -43,6 +43,12 @@ static struct limine_rsdp_request rsdp_request = {
     .flags = 0, .response = NULL
 };
 
+__attribute__((used))
+static struct limine_smbios_request smbios_request = {
+    .id = LIMINE_SMBIOS_REQUEST,
+    .flags = 0, .response = NULL
+};
+
 static char *get_memmap_type(uint64_t type) {
     switch (type) {
         case LIMINE_MEMMAP_USABLE:
@@ -167,5 +173,15 @@ FEAT_START
     e9_printf("RSDP at: %x", rsdp_response->address);
 FEAT_END
 
+FEAT_START
+    if (smbios_request.response == NULL) {
+        e9_printf("SMBIOS not passed");
+        break;
+    }
+    struct limine_smbios_response *smbios_response = smbios_request.response;
+    e9_printf("SMBIOS 32-bit entry at: %x", smbios_response->entry_32);
+    e9_printf("SMBIOS 64-bit entry at: %x", smbios_response->entry_64);
+FEAT_END
+
     for (;;);
 }
tab: 248 wrap: offon