kernel: add a helper to retrieve the bsp CPU

This is useful to be able to e.g. set affinity for the BSP CPU.
This commit is contained in:
8infy
2024-09-01 19:36:17 +03:00
parent 0ecbbff4d1
commit 6154318ab3
2 changed files with 6 additions and 0 deletions
+4
View File
@@ -124,3 +124,7 @@ void kernel_entry() {
sched_runinit();
sched_threadexit();
}
cpu_t *_bsp(void) {
return &bsp_cpu;
}
+2
View File
@@ -54,6 +54,8 @@ static inline uint16_t be_to_cpu_w(uint16_t w) {
return __builtin_bswap16(w);
}
cpu_t *_bsp(void);
static inline cpu_t *_cpu() {
cpu_t *cpu;
asm volatile ("mov %%gs:0, %%rax" : "=a"(cpu) : : "memory");