mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-27 12:48:22 +00:00
x86_64 cpu: change how the current cpu pointer is found
This commit is contained in:
@@ -208,7 +208,7 @@ arch_syscall_entry:
|
||||
; because it's still using the user stack
|
||||
mov cr2, rax
|
||||
; rax can be used just fine now
|
||||
mov rax, [gs:0x0] ; cpu pointer
|
||||
mov rax, [gs:0x8] ; cpu pointer
|
||||
mov rax, [rax] ; thread pointer
|
||||
mov rax, [rax] ; kernel stack top
|
||||
xchg rsp, rax ; switch stack pointers
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
typedef struct cpu_t {
|
||||
thread_t *thread;
|
||||
struct cpu_t *self;
|
||||
uint64_t gdt[7];
|
||||
ist_t ist;
|
||||
long id;
|
||||
@@ -31,7 +32,6 @@ typedef struct cpu_t {
|
||||
void *schedulerstack;
|
||||
isr_t *isrqueue;
|
||||
dpc_t *dpcqueue;
|
||||
struct cpu_t *self;
|
||||
isr_t *dpcisr;
|
||||
} cpu_t;
|
||||
|
||||
@@ -58,13 +58,13 @@ cpu_t *_bsp(void);
|
||||
|
||||
static inline cpu_t *_cpu() {
|
||||
cpu_t *cpu;
|
||||
asm volatile ("mov %%gs:0, %%rax" : "=a"(cpu) : : "memory");
|
||||
asm volatile ("mov %%gs:8, %%rax" : "=a"(cpu) : : "memory");
|
||||
return cpu;
|
||||
}
|
||||
|
||||
static inline void cpu_set(cpu_t *ptr) {
|
||||
ptr->self = ptr;
|
||||
wrmsr(MSR_GSBASE, (uint64_t)&ptr->self);
|
||||
wrmsr(MSR_GSBASE, (uint64_t)ptr);
|
||||
}
|
||||
|
||||
void cpu_initstate();
|
||||
|
||||
Reference in New Issue
Block a user