Fixing scheduler
This commit is contained in:
parent
184f1a60de
commit
3b08a6ce99
12 changed files with 101 additions and 72 deletions
26
src/smp.c
26
src/smp.c
|
|
@ -24,15 +24,24 @@ static cpu_state *cpus;
|
|||
static cpu_state bsp_cpu;
|
||||
|
||||
/* Returns the CPU structure for this particular CPU */
|
||||
cpu_state *get_current_cpu_struct(){
|
||||
cpu_state *get_current_cpu_state(){
|
||||
return (cpu_state*)rdmsr(GSBASE);
|
||||
}
|
||||
|
||||
cpu_state *get_cpu_struct(int id){
|
||||
cpu_state *get_bsp_cpu_state(){
|
||||
return &bsp_cpu;
|
||||
}
|
||||
|
||||
cpu_state *get_cpu_state(int id){
|
||||
|
||||
if(id == 0){
|
||||
return &bsp_cpu;
|
||||
}
|
||||
|
||||
return &cpus[id];
|
||||
}
|
||||
|
||||
bool get_cpu_struct_initialized(){
|
||||
bool get_cpu_state_initialized(){
|
||||
if(rdmsr(GSBASE) < get_kinfo()->hhdmoffset){
|
||||
return false;
|
||||
}
|
||||
|
|
@ -96,14 +105,12 @@ void smp_init(){
|
|||
}
|
||||
|
||||
bsp_cpu.scheduler_context = (struct context*)kzalloc(sizeof(struct context));
|
||||
|
||||
cpus[bsp_cpu.id] = bsp_cpu;
|
||||
cpus[bsp_cpu.id] = bsp_cpu;
|
||||
|
||||
/* If one of the APs has halted, then halt the BSP */
|
||||
extern bool kernel_killed;
|
||||
if(kernel_killed == true){
|
||||
kkill();
|
||||
}
|
||||
|
||||
assert(!kernel_killed && "Some APs failed to init!");
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -113,7 +120,8 @@ void bsp_early_init(){
|
|||
|
||||
struct limine_mp_response *smp_response = smp_request.response;
|
||||
|
||||
bsp_cpu.id = smp_response->cpus[0]->lapic_id;
|
||||
bsp_cpu.id = smp_response->cpus[0]->lapic_id;
|
||||
|
||||
wrmsr(KERNELGSBASE, (uint64_t)&bsp_cpu);
|
||||
wrmsr(GSBASE, (uint64_t)&bsp_cpu);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue