mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-27 20:58: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);
|
||||
|
||||
@@ -72,7 +72,7 @@ static void mcfg_write32(int bus, int device, int function, uint32_t offset, uin
|
||||
|
||||
static uint64_t msiformatmessage(uint32_t *data, int vector, int edgetrigger, int deassert) {
|
||||
*data = (edgetrigger ? 0 : (1 << 15)) | (deassert ? 0 : (1 << 14)) | vector;
|
||||
return 0xfee00000 | (_cpu()->id << 12);
|
||||
return 0xfee00000 | (current_cpu_id() << 12);
|
||||
}
|
||||
|
||||
// in PCIe, every function has 4096 bytes of config space for it.
|
||||
|
||||
Reference in New Issue
Block a user