Schedule on PIC timer raise.

This causes a page fault because we don't properly handle the sleep
case.
This commit is contained in:
Drew Galbraith 2023-05-29 22:32:50 -07:00
parent 496dfeaef9
commit 656687b183
2 changed files with 12 additions and 1 deletions

View File

@ -4,6 +4,7 @@
#include "common/port.h"
#include "debug/debug.h"
#include "scheduler/scheduler.h"
#define IDT_INTERRUPT_GATE 0x8E
@ -122,6 +123,7 @@ extern "C" void interrupt_timer(InterruptFrame*) {
dbgln("timer: %us", cnt * 50 / 1000);
}
outb(PIC1_COMMAND, PIC_EOI);
sched::Yield();
}
void EnablePic() {

View File

@ -12,22 +12,31 @@
#include "syscall/syscall.h"
extern "C" void zion() {
dbgln("[boot] Init GDT & IDT.");
InitGdt();
InitIdt();
dbgln("[boot] Init Paging.");
InitPaging();
dbgln("[boot] Init Physical Memory Manager.");
phys_mem::InitBootstrapPageAllocation();
KernelHeap heap(0xFFFFFFFF'40000000, 0xFFFFFFFF'80000000);
phys_mem::InitPhysicalMemoryManager();
dbgln("[boot] Init syscalls.");
InitSyscall();
dbgln("[boot] Init scheduler.");
// Schedule every 50ms.
SetFrequency(/* hertz= */ 20);
sched::InitScheduler();
sched::EnableScheduler();
dbgln("[boot] Loading sys init program.");
LoadInitProgram();
dbgln("[boot] Init finished, yielding.");
sched::EnableScheduler();
sched::Yield();
dbgln("Sleeping!");