Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 3 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 (;;);
}
Loading