x86_64: Basic exit() syscall!
User processes need to do something, amirite?
This commit is contained in:
parent
a33a72915e
commit
0aac6c888d
@ -187,4 +187,5 @@ ISR 20 ; virtualization exception (#VE)
|
||||
ISR_ERROR 21 ; control-protection exception (#CP)
|
||||
; ISR 22-31 reserved
|
||||
IRQ 32, 0 ; timer interrupt
|
||||
IRQ 33, 0 ; keyboard interrupt
|
||||
IRQ 33, 0 ; keyboard interrupt
|
||||
ISR 66 ; user exit
|
||||
|
@ -107,6 +107,12 @@ extern "C" void arch_interrupt_entry(Registers* regs)
|
||||
scancode_queue.try_push(scancode);
|
||||
pic_eoi(regs);
|
||||
}
|
||||
else if (regs->isr == 66) // Exit!!
|
||||
{
|
||||
kdbgln("exiting from user task!!");
|
||||
Scheduler::current()->state = ThreadState::Dying;
|
||||
kernel_yield();
|
||||
}
|
||||
else
|
||||
{
|
||||
kwarnln("IRQ catched! Halting.");
|
||||
|
@ -36,7 +36,7 @@ u64 IDTEntry::get_offset() const
|
||||
static IDTEntry idt[256];
|
||||
|
||||
#define IDT_TA_InterruptGate 0b10001110
|
||||
#define IDT_TA_UserInterruptGate 0b11101110
|
||||
#define IDT_TA_UserCallableInterruptGate 0b11101110
|
||||
#define IDT_TA_TrapGate 0b10001111
|
||||
|
||||
struct [[gnu::packed]] IDTR
|
||||
@ -60,6 +60,7 @@ static void idt_add_handler(short num, void* handler, u8 type_attr)
|
||||
#define INT(x) extern "C" void _isr##x()
|
||||
#define TRAP(x) idt_add_handler(x, (void*)_isr##x, IDT_TA_TrapGate)
|
||||
#define IRQ(x) idt_add_handler(x, (void*)_isr##x, IDT_TA_InterruptGate)
|
||||
#define SYS(x) idt_add_handler(x, (void*)_isr##x, IDT_TA_UserCallableInterruptGate)
|
||||
|
||||
INT(0);
|
||||
INT(1);
|
||||
@ -83,6 +84,7 @@ INT(20);
|
||||
INT(21);
|
||||
INT(32);
|
||||
INT(33);
|
||||
INT(66);
|
||||
|
||||
void setup_idt()
|
||||
{
|
||||
@ -110,6 +112,7 @@ void setup_idt()
|
||||
TRAP(21);
|
||||
IRQ(32);
|
||||
IRQ(33);
|
||||
SYS(66);
|
||||
|
||||
static IDTR idtr;
|
||||
idtr.limit = 0x0FFF;
|
||||
|
Loading…
Reference in New Issue
Block a user