Skip to content

Commit

Permalink
Merge pull request #435 from marv7000/add-bsp-request
Browse files Browse the repository at this point in the history
protos/limine: Add RISC-V BSP Hart ID request
  • Loading branch information
mintsuki authored Dec 3, 2024
2 parents af981e3 + 657eb7c commit 10cae4a
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 2 deletions.
28 changes: 28 additions & 0 deletions PROTOCOL.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
13 changes: 13 additions & 0 deletions common/protos/limine.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
15 changes: 15 additions & 0 deletions limine.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions test.mk
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ ovmf-loongarch64:
test.hdd:
rm -f test.hdd
dd if=/dev/zero bs=1M count=0 seek=64 of=test.hdd
parted -s test.hdd mklabel gpt
parted -s test.hdd mkpart primary 2048s 100%
PATH=$PATH:/sbin:/usr/sbin parted -s test.hdd mklabel gpt
PATH=$PATH:/sbin:/usr/sbin parted -s test.hdd mkpart primary 2048s 100%

.PHONY: mbrtest.hdd
mbrtest.hdd:
Expand Down
18 changes: 18 additions & 0 deletions test/limine.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,14 @@ static volatile struct limine_paging_mode_request _pm_request = {
.min_mode = LIMINE_PAGING_MODE_MIN
};

#ifdef __riscv
__attribute__((section(".limine_requests")))
static volatile struct limine_riscv_bsp_hartid_request _bsp_request = {
.id = LIMINE_RISCV_BSP_HARTID_REQUEST,
.revision = 0, .response = NULL,
};
#endif

__attribute__((used, section(".limine_requests_end_marker")))
static volatile LIMINE_REQUESTS_END_MARKER;

Expand Down Expand Up @@ -539,5 +547,15 @@ FEAT_START
e9_printf(" mode: %d", pm_response->mode);
FEAT_END

FEAT_START
e9_printf("");
struct limine_riscv_bsp_hartid_response *bsp_response = _bsp_request.response;
if (bsp_response == NULL) {
e9_printf("RISC-V BSP Hart ID was not passed");
break;
}
e9_printf("RISC-V BSP Hart ID: %x", bsp_response->bsp_hartid);
FEAT_END

for (;;);
}

0 comments on commit 10cae4a

Please sign in to comment.