Fri, 19 Jan 2018 20:16:47 +0100
3 files changed,
28 insertions(+),
3 deletions(-)
M
kernel/main.c
→
kernel/main.c
@@ -122,6 +122,8 @@
int sysinit(void) { uint8_t scancode = 0; + syscall(1, 0xCAFEBABE, 0xDEADBEEF, 0x42069420); + printk("PRESS ENTER\n"); while (scancode != 0x1C) {
M
kernel/syscall.c
→
kernel/syscall.c
@@ -1,13 +1,18 @@
#include "cedos/interrupts.h" +#include "cedos/core.h" -INTERRUPT(syscall_interrupt, frame) { - printk("SYSCALL\n"); +void test(uint32_t ebx, uint32_t ecx, uint32_t edx) { + printk("SYSCALL 0x01: EBX=%X ECX=%X EDX=%X\n", ebx, ecx, edx); } +void* SYSCALL_TABLE[] = { hard_reset, test }; + +extern void syscall_interrupt(void); + /*! * Installs the syscall interrupt to INT 0x30 */ int syscall_init(void) { - install_interrupt(0x30, syscall_interrupt, 0x08, INT_GATE); + install_interrupt(0x30, &syscall_interrupt, 0x08, INT_GATE); return 1; }
A
kernel/syscall.s
@@ -0,0 +1,18 @@
+.global syscall_interrupt +/*! + * Prehandles scheduler interrupts by switching from process- to scheduler-stack + */ +syscall_interrupt: + // push arguments on stack + push %edx + push %ecx + push %ebx + + mov $SYSCALL_TABLE, %ecx + mov (%ecx, %eax, 4), %eax + + call %eax + + // restore stack + add $12, %esp + iret