x86_64: Basic exit() syscall!

User processes need to do something, amirite?
This commit is contained in:
apio 2023-01-05 21:53:48 +01:00
parent a33a72915e
commit 0aac6c888d
Signed by: apio
GPG Key ID: B8A7D06E42258954
3 changed files with 12 additions and 2 deletions

View File

@ -188,3 +188,4 @@ ISR_ERROR 21 ; control-protection exception (#CP)
; ISR 22-31 reserved
IRQ 32, 0 ; timer interrupt
IRQ 33, 0 ; keyboard interrupt
ISR 66 ; user exit

View File

@ -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.");

View File

@ -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;