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

View File

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