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