kernel: implement cpu IDs and per-cpu variables

This commit is contained in:
2023-03-18 19:35:00 +00:00
parent 56bc47f570
commit 57eaf4e01c
14 changed files with 232 additions and 18 deletions

View File

@@ -1,7 +1,9 @@
#include <socks/machine/cpu.h>
#include <arch/msr.h>
int ml_cpu_block_init(ml_cpu_block *p)
{
p->c_this = p;
gdt_init(&p->c_gdt, &p->c_gdt_ptr);
idt_init(&p->c_idt_ptr);
return 0;
@@ -11,5 +13,6 @@ int ml_cpu_block_use(ml_cpu_block *p)
{
gdt_load(&p->c_gdt_ptr);
idt_load(&p->c_idt_ptr);
wrmsr(MSR_GS_BASE, (uint64_t)p);
return 0;
}