diff options
Diffstat (limited to 'src/stem/task')
-rw-r--r-- | src/stem/task/idt.c | 9 | ||||
-rw-r--r-- | src/stem/task/idt_.asm | 12 | ||||
-rw-r--r-- | src/stem/task/syscall.c | 16 | ||||
-rw-r--r-- | src/stem/task/syscall.h | 9 |
4 files changed, 46 insertions, 0 deletions
diff --git a/src/stem/task/idt.c b/src/stem/task/idt.c index b9bd1ef..7c05e2e 100644 --- a/src/stem/task/idt.c +++ b/src/stem/task/idt.c @@ -3,6 +3,7 @@ #include <core/sys.h> #include <mem/paging.h> #include "task.h" +#include "syscall.h" #include <stdlib.h> @@ -56,6 +57,8 @@ extern void irq13(); extern void irq14(); extern void irq15(); +extern void syscall64(); + extern void idt_flush(int32_t ptr); struct idt_entry idt_entries[256]; @@ -91,6 +94,10 @@ void idt_irqHandler(struct registers regs) { if (doSwitch) tasking_switch(); } +void idt_syscallHandler(struct registers regs) { + syscalls[regs.eax](®s); +} + static void idt_setGate(uint8_t num, uint32_t base, uint16_t sel, uint8_t flags) { idt_entries[num].base_lo = base & 0xFFFF; idt_entries[num].base_hi = (base >> 16) & 0xFFFF; @@ -168,6 +175,8 @@ void idt_init() { idt_setGate(46, (int32_t)irq14, 0x08, 0x8E); idt_setGate(47, (int32_t)irq15, 0x08, 0x8E); + idt_setGate(64, (int32_t)syscall64, 0x08, 0x8E); + idt_flush((int32_t)&idt_ptr); monitor_write("IDT ok\n"); diff --git a/src/stem/task/idt_.asm b/src/stem/task/idt_.asm index b73f7a5..63d1570 100644 --- a/src/stem/task/idt_.asm +++ b/src/stem/task/idt_.asm @@ -63,6 +63,7 @@ idt_flush: COMMONSTUB isr COMMONSTUB irq +COMMONSTUB syscall ;************************************************************************************ @@ -92,6 +93,15 @@ COMMONSTUB irq jmp irq_common_stub %endmacro +%macro SYSCALL 1 + [GLOBAL syscall%1] + syscall%1: + cli + push byte 0 + push byte %1 + jmp syscall_common_stub +%endmacro + ISR_NOERRCODE 0 ISR_NOERRCODE 1 ISR_NOERRCODE 2 @@ -141,3 +151,5 @@ IRQ 12, 44 IRQ 13, 45 IRQ 14, 46 IRQ 15, 47 + +SYSCALL 64 diff --git a/src/stem/task/syscall.c b/src/stem/task/syscall.c new file mode 100644 index 0000000..281d680 --- /dev/null +++ b/src/stem/task/syscall.c @@ -0,0 +1,16 @@ +#include "syscall.h" + +#define CALL0(name, scname) static void scname(struct registers* r) { r->eax = name(); } +#define CALL1(name, scname) static void scname(struct registers* r) { \ + r->eax = name(r->ebx); } +#define CALL2(name, scname) static void scname(struct registers* r) { \ + r->eax = name(r->ebx, r->ecx); } + +CALL0(tasking_switch, schedule_sc); + +int_callback syscalls[] = { + 0, //Syscall 0 will be thread_exit + schedule_sc, + 0, //Syscall 2 will be thread_sleep + 0, //Syscall 3 will be process_exit + 0 }; diff --git a/src/stem/task/syscall.h b/src/stem/task/syscall.h new file mode 100644 index 0000000..54af108 --- /dev/null +++ b/src/stem/task/syscall.h @@ -0,0 +1,9 @@ +#ifndef DEF_SYSCALL_H +#define DEF_SYSCALL_H + +#include "idt.h" + +extern int_callback syscalls[]; + +#endif + |