:: commit 3ced8e10241f10dbbfcb752c79bd62107a236fd6

Marvin Friedrich <contact@marvinf.com> — 2024-12-03 23:37

parents: af981e39a5

protos/limine: Add RISC-V BSP Hart ID request

diff --git a/PROTOCOL.md b/PROTOCOL.md
index df7e2b7d..e7aa61db 100644
--- a/PROTOCOL.md
+++ b/PROTOCOL.md
@@ -880,6 +880,34 @@ processor. This field is unused for the structure describing the bootstrap
 processor.
 * `extra_argument` - A free for use field.
 
+### RISC-V BSP Hart ID Feature
+
+ID:
+```c
+#define LIMINE_RISCV_BSP_HARTID_REQUEST { LIMINE_COMMON_MAGIC, 0x1369359f025525f9, 0x2ff2a56178391bb6 }
+```
+
+Request:
+```c
+struct limine_riscv_bsp_hartid_request {
+    uint64_t id[4];
+    uint64_t revision;
+    LIMINE_PTR(struct limine_riscv_bsp_hartid_response *) response;
+};
+```
+
+Response:
+```c
+struct limine_riscv_bsp_hartid_response {
+    uint64_t revision;
+    uint64_t bsp_hartid;
+};
+```
+
+* `bsp_hartid` - The Hart ID of the boot processor.
+Note: This request contains the same information as `limine_mp_response.bsp_hartid`,
+but doesn't boot up other APs.
+
 ### Memory Map Feature
 
 ID:
diff --git a/common/protos/limine.c b/common/protos/limine.c
index 8d81f522..242e31a6 100644
--- a/common/protos/limine.c
+++ b/common/protos/limine.c
@@ -1475,6 +1475,19 @@ FEAT_START
     mp_request->response = reported_addr(mp_response);
 FEAT_END
 
+#if defined(__riscv)
+    // RISC-V BSP Hart ID
+FEAT_START
+    struct limine_riscv_bsp_hartid_request *bsp_request = get_request(LIMINE_RISCV_BSP_HARTID_REQUEST);
+    if (bsp_request == NULL) {
+        break;
+    }
+    struct limine_riscv_bsp_hartid_response *bsp_response = ext_mem_alloc(sizeof(struct limine_riscv_bsp_hartid_response));
+    bsp_response->bsp_hartid = bsp_hartid;
+    bsp_request->response = reported_addr(bsp_response);
+FEAT_END
+#endif
+
     // Memmap
 FEAT_START
     struct limine_memmap_request *memmap_request = get_request(LIMINE_MEMMAP_REQUEST);
diff --git a/limine.h b/limine.h
index 8436a838..03707d0d 100644
--- a/limine.h
+++ b/limine.h
@@ -648,6 +648,21 @@ struct limine_dtb_request {
     LIMINE_PTR(struct limine_dtb_response *) response;
 };
 
+/* RISC-V Boot Hart ID */
+
+#define LIMINE_RISCV_BSP_HARTID_REQUEST { LIMINE_COMMON_MAGIC, 0x1369359f025525f9, 0x2ff2a56178391bb6 }
+
+struct limine_riscv_bsp_hartid_response {
+    uint64_t revision;
+    uint64_t bsp_hartid;
+};
+
+struct limine_riscv_bsp_hartid_request {
+    uint64_t id[4];
+    uint64_t revision;
+    LIMINE_PTR(struct limine_riscv_bsp_hartid_response *) response;
+};
+
 #ifdef __cplusplus
 }
 #endif
tab: 248 wrap: offon