2024-11-02 11:31:51 +00:00
|
|
|
#include <mango/machine/cpu.h>
|
2023-03-18 19:35:00 +00:00
|
|
|
#include <arch/msr.h>
|
2022-12-24 10:28:41 +00:00
|
|
|
|
|
|
|
|
int ml_cpu_block_init(ml_cpu_block *p)
|
|
|
|
|
{
|
2023-03-18 19:35:00 +00:00
|
|
|
p->c_this = p;
|
2022-12-24 10:28:41 +00:00
|
|
|
gdt_init(&p->c_gdt, &p->c_gdt_ptr);
|
2023-02-08 20:24:40 +00:00
|
|
|
idt_init(&p->c_idt_ptr);
|
2022-12-24 10:28:41 +00:00
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int ml_cpu_block_use(ml_cpu_block *p)
|
|
|
|
|
{
|
|
|
|
|
gdt_load(&p->c_gdt_ptr);
|
2023-02-08 20:24:40 +00:00
|
|
|
idt_load(&p->c_idt_ptr);
|
2023-03-18 19:35:00 +00:00
|
|
|
wrmsr(MSR_GS_BASE, (uint64_t)p);
|
2022-12-24 10:28:41 +00:00
|
|
|
return 0;
|
|
|
|
|
}
|