:: commit 4f90e0c7234e090da7cf1cdbd377eddfceb6fa7c

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

parents: a3d3e2bb13

limine: Add RSDP request

diff --git a/common/limine.h b/common/limine.h
index 3f295249..98f8aeb3 100644
--- a/common/limine.h
+++ b/common/limine.h
@@ -168,4 +168,20 @@ struct limine_module_request {
     LIMINE_PTR(struct limine_module_response *) response;
 };
 
+// RSDP
+
+#define LIMINE_RSDP_REQUEST { LIMINE_COMMON_MAGIC, 0xc5e77b6b397e7b43, 0x27637845accdcf3c }
+
+struct limine_rsdp_response {
+    uint64_t flags;
+
+    LIMINE_PTR(void *) address;
+};
+
+struct limine_rsdp_request {
+    uint64_t id[4];
+    uint64_t flags;
+    LIMINE_PTR(struct limine_rsdp_response *) response;
+};
+
 #endif
diff --git a/common/protos/limine.c b/common/protos/limine.c
index eda6b06e..a6a28b3d 100644
--- a/common/protos/limine.c
+++ b/common/protos/limine.c
@@ -238,6 +238,24 @@ FEAT_START
     boot_info_request->response = reported_addr(boot_info_response);
 FEAT_END
 
+    // RSDP feature
+FEAT_START
+    struct limine_rsdp_request *rsdp_request = get_request(LIMINE_RSDP_REQUEST);
+    if (rsdp_request == NULL) {
+        break; // next feature
+    }
+
+    struct limine_rsdp_response *rsdp_response =
+        ext_mem_alloc(sizeof(struct limine_rsdp_response));
+
+    void *rsdp = acpi_get_rsdp();
+    if (rsdp) {
+        rsdp_response->address = reported_addr(rsdp);
+    }
+
+    rsdp_request->response = reported_addr(rsdp_response);
+FEAT_END
+
     // Modules
 FEAT_START
     struct limine_module_request *module_request = get_request(LIMINE_MODULE_REQUEST);
diff --git a/test/Makefile b/test/GNUmakefile
similarity index 96%
rename from test/Makefile
rename to test/GNUmakefile
index 39e273c6..878f7bd2 100644
--- a/test/Makefile
+++ b/test/GNUmakefile
@@ -66,6 +66,6 @@ multiboot.elf: multiboot_trampoline.o
 	nasm -felf32 $< -o $@
 
 clean:
-	rm -rf test.elf stivale.o stivale2.o e9print.o memory.o
+	rm -rf test.elf limine.o stivale.o stivale2.o e9print.o memory.o
 	rm -rf multiboot2.o multiboot2.elf multiboot2_trampoline.o
 	rm -rf multiboot.o multiboot_trampoline.o multiboot.elf
diff --git a/test/limine.c b/test/limine.c
index 3c333f48..b397b7dc 100644
--- a/test/limine.c
+++ b/test/limine.c
@@ -37,6 +37,12 @@ static struct limine_module_request module_request = {
     .flags = 0, .response = NULL
 };
 
+__attribute__((used))
+static struct limine_rsdp_request rsdp_request = {
+    .id = LIMINE_RSDP_REQUEST,
+    .flags = 0, .response = NULL
+};
+
 static char *get_memmap_type(uint64_t type) {
     switch (type) {
         case LIMINE_MEMMAP_USABLE:
@@ -152,5 +158,14 @@ FEAT_START
     }
 FEAT_END
 
+FEAT_START
+    if (rsdp_request.response == NULL) {
+        e9_printf("RSDP not passed");
+        break;
+    }
+    struct limine_rsdp_response *rsdp_response = rsdp_request.response;
+    e9_printf("RSDP at: %x", rsdp_response->address);
+FEAT_END
+
     for (;;);
 }
tab: 248 wrap: offon