diff options
Diffstat (limited to 'Source/Kernel/SyscallManager')
-rw-r--r-- | Source/Kernel/SyscallManager/IDT.ns.cpp | 15 | ||||
-rw-r--r-- | Source/Kernel/SyscallManager/IDT.wtf.asm | 5 |
2 files changed, 15 insertions, 5 deletions
diff --git a/Source/Kernel/SyscallManager/IDT.ns.cpp b/Source/Kernel/SyscallManager/IDT.ns.cpp index caa3b36..0684255 100644 --- a/Source/Kernel/SyscallManager/IDT.ns.cpp +++ b/Source/Kernel/SyscallManager/IDT.ns.cpp @@ -55,12 +55,14 @@ extern "C" void irq13(); extern "C" void irq14(); extern "C" void irq15(); -extern "C" void int64(); +extern "C" void int65(); //IRQ to request a task switch +extern "C" void int66(); //IRQ to signal that thread ended extern "C" void idt_flush(u32int); extern "C" void interrupt_handler(registers_t regs) { - bool doSwitch = (regs.int_no == 32 or regs.int_no == 64); + Task::currentThread->enterInterrupt(); //Do that so that whatever is called here can use waitIRQ + bool doSwitch = (regs.int_no == 32 or regs.int_no >= 65); //SYSCALLS >= 65 are task-managing-related if (regs.int_no < 32) { IDT::handleException(regs, regs.int_no); } else if (regs.int_no < 48) { @@ -70,7 +72,11 @@ extern "C" void interrupt_handler(registers_t regs) { Dev::handleIRQ(regs, (regs.int_no - 32)); doSwitch = doSwitch or Task::IRQwakeup(regs.int_no - 32); } + if (regs.int_no == 66) { //This syscall signals to kernel that thread ended. + Task::currentThread->finish(regs.eax); + } if (doSwitch) Task::doSwitch(); + Task::currentThread->exitInterrupt(); } namespace IDT { @@ -155,12 +161,13 @@ void init() { setGate(46, (u32int)irq14, 0x08, 0x8E); setGate(47, (u32int)irq15, 0x08, 0x8E); - setGate(64, (u32int)int64, 0x08, 0x8E); + setGate(65, (u32int)int65, 0x08, 0x8E); + setGate(66, (u32int)int66, 0x08, 0x8E); idt_flush((u32int)&idt_ptr); } -void handleException(registers_t regs, int no) { +void handleException(registers_t regs, int no) { //TODO :: make exception handling work with task managment asm volatile("cli;"); char* exceptions[] = { "Division by zero", "Debug exception", "Non maskable interrupt", diff --git a/Source/Kernel/SyscallManager/IDT.wtf.asm b/Source/Kernel/SyscallManager/IDT.wtf.asm index 7980d13..b94612e 100644 --- a/Source/Kernel/SyscallManager/IDT.wtf.asm +++ b/Source/Kernel/SyscallManager/IDT.wtf.asm @@ -97,7 +97,10 @@ IRQ 13, 45 IRQ 14, 46 IRQ 15, 47 -SYSCALL 64 ; this syscall requests a task switch +SYSCALL 64 ; this syscall is the one and only useful syscall. It does everything. +; The next syscalls are task-managing-specific +SYSCALL 65 ; this syscall requests a task switch +SYSCALL 66 ; signals to kernel that thread has finished (retval in eax) ; ****************************************************************** |