:: commit f487061f40faa876b79ba57249f172ef0ec0054e

mintsuki <mintsuki@protonmail.com> — 2022-03-20 07:19

parents: 38233a2405

limine: Add boot time request

diff --git a/common/limine.h b/common/limine.h
index d24e929b..3934af47 100644
--- a/common/limine.h
+++ b/common/limine.h
@@ -253,4 +253,20 @@ struct limine_efi_system_table_request {
     LIMINE_PTR(struct limine_efi_system_table_response *) response;
 };
 
+// Boot time
+
+#define LIMINE_BOOT_TIME_REQUEST { LIMINE_COMMON_MAGIC, 0x502746e184c088aa, 0xfbc5ec83e6327893 }
+
+struct limine_boot_time_response {
+    uint64_t revision;
+
+    int64_t boot_time;
+};
+
+struct limine_boot_time_request {
+    uint64_t id[4];
+    uint64_t revision;
+    LIMINE_PTR(struct limine_boot_time_response *) response;
+};
+
 #endif
diff --git a/common/protos/limine.c b/common/protos/limine.c
index fc8c2311..cbb05717 100644
--- a/common/protos/limine.c
+++ b/common/protos/limine.c
@@ -477,6 +477,21 @@ FEAT_START
     framebuffer_request->response = reported_addr(framebuffer_response);
 FEAT_END
 
+    // Boot time feature
+FEAT_START
+    struct limine_boot_time_request *boot_time_request = get_request(LIMINE_BOOT_TIME_REQUEST);
+    if (boot_time_request == NULL) {
+        break; // next feature
+    }
+
+    struct limine_boot_time_response *boot_time_response =
+        ext_mem_alloc(sizeof(struct limine_boot_time_response));
+
+    boot_time_response->boot_time = time();
+
+    boot_time_request->response = reported_addr(boot_time_response);
+FEAT_END
+
     // Wrap-up stuff before memmap close
     struct gdtr *local_gdt = ext_mem_alloc(sizeof(struct gdtr));
     local_gdt->limit = gdt.limit;
diff --git a/test/limine.c b/test/limine.c
index ed9def87..6d795f5f 100644
--- a/test/limine.c
+++ b/test/limine.c
@@ -52,6 +52,11 @@ struct limine_efi_system_table_request est_request = {
     .revision = 0, .response = NULL
 };
 
+struct limine_boot_time_request boot_time_request = {
+    .id = LIMINE_BOOT_TIME_REQUEST,
+    .revision = 0, .response = NULL
+};
+
 struct limine_smp_request _smp_request = {
     .id = LIMINE_SMP_REQUEST,
     .revision = 0, .response = NULL
@@ -229,6 +234,16 @@ FEAT_START
     e9_printf("EFI system table at: %x", est_response->address);
 FEAT_END
 
+FEAT_START
+    e9_printf("");
+    if (boot_time_request.response == NULL) {
+        e9_printf("Boot time not passed");
+        break;
+    }
+    struct limine_boot_time_response *boot_time_response = boot_time_request.response;
+    e9_printf("Kernel boot time: %d", boot_time_response->boot_time);
+FEAT_END
+
 FEAT_START
     e9_printf("");
     if (_smp_request.response == NULL) {
tab: 248 wrap: offon