diff options
author | Ian Moffett <ian@osmora.org> | 2025-09-17 01:06:27 -0400 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2025-09-17 01:06:27 -0400 |
commit | b6983be0368bb39e3a8cbd919235b14504f1d995 (patch) | |
tree | 6c8c4b6776cfed7b688cde150e6f9af94598a7c2 /src/sys/arch/amd64/cpu/cpu_mp.c | |
parent | 2a9275af4c4e95fc49b4b6c8bbc417dd691bfe87 (diff) |
kern/amd64: mp: Add cpu_get() routine
This commit introduces a new cpu_get() function to acquire a specific
CPU by using a logical ID as an index.
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'src/sys/arch/amd64/cpu/cpu_mp.c')
-rw-r--r-- | src/sys/arch/amd64/cpu/cpu_mp.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/sys/arch/amd64/cpu/cpu_mp.c b/src/sys/arch/amd64/cpu/cpu_mp.c index 8d84b1f..3483e4a 100644 --- a/src/sys/arch/amd64/cpu/cpu_mp.c +++ b/src/sys/arch/amd64/cpu/cpu_mp.c @@ -79,6 +79,23 @@ ap_entry(struct limine_smp_info *) for (;;); } +/* + * Get a specific core descriptor + */ +struct pcore * +cpu_get(uint16_t index) +{ + if (index == 0) { + return &g_bsp; + } + + if ((index - 1) >= ncores_up) { + index %= (ncores_up - 1); + } + + return corelist[index - 1]; +} + void bsp_ap_startup(void) { |