mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-31 06:28:22 +00:00
kernel: fix remaining _cpu() races
This commit is contained in:
@@ -19,9 +19,9 @@ typedef struct cpu_t {
|
||||
thread_t *thread;
|
||||
struct cpu_t *self;
|
||||
vmmcontext_t *vmmctx;
|
||||
long id;
|
||||
uint64_t gdt[7];
|
||||
ist_t ist;
|
||||
long id;
|
||||
isr_t isr[MAX_ISR_COUNT];
|
||||
int acpiid;
|
||||
timer_t *timer;
|
||||
@@ -78,6 +78,12 @@ static inline void set_current_vmm_context(vmmcontext_t *context) {
|
||||
asm volatile ("mov %%rax, %%gs:16" : : "a"(context) : "memory");
|
||||
}
|
||||
|
||||
static inline long current_cpu_id(void) {
|
||||
long id;
|
||||
asm volatile ("mov %%gs:24, %%rax" : "=a"(id) : : "memory");
|
||||
return id;
|
||||
}
|
||||
|
||||
static inline void cpu_set(cpu_t *ptr) {
|
||||
ptr->self = ptr;
|
||||
wrmsr(MSR_GSBASE, (uint64_t)ptr);
|
||||
|
||||
Reference in New Issue
Block a user