diff options
Diffstat (limited to 'kernel/cpu')
-rw-r--r-- | kernel/cpu/idt.c | 1 | ||||
-rw-r--r-- | kernel/cpu/int_syscall.s | 35 | ||||
-rw-r--r-- | kernel/cpu/isr.s | 16 | ||||
-rw-r--r-- | kernel/cpu/syscall.c | 7 |
4 files changed, 44 insertions, 15 deletions
diff --git a/kernel/cpu/idt.c b/kernel/cpu/idt.c index ec7ca63..805eb20 100644 --- a/kernel/cpu/idt.c +++ b/kernel/cpu/idt.c @@ -249,7 +249,6 @@ void install_handler(void (*handler_function)(), u16 type_attribute, u8 entry) { } void idt_init(void) { - // list_of_handlers = kcalloc(sizeof(void *), 128); memset(list_of_handlers, 0, sizeof(void *) * 256); install_handler(page_fault, INT_32_INTERRUPT_GATE(0x0), 0xE); diff --git a/kernel/cpu/int_syscall.s b/kernel/cpu/int_syscall.s new file mode 100644 index 0000000..b2c0de9 --- /dev/null +++ b/kernel/cpu/int_syscall.s @@ -0,0 +1,35 @@ +.intel_syntax noprefix +.global int_syscall +.extern syscall_functions +int_syscall: +push ebp +mov ebp,esp +push edi +push esi +push ebx + +mov edx,DWORD PTR [ebp+0x8] # reg_t* +mov eax,DWORD PTR [edx+0x20] # syscall number +mov eax,DWORD PTR [eax*4+syscall_functions] # function pointer + +mov edi,DWORD PTR [edx+0x4] +push edi +mov edi,DWORD PTR [edx+0x8] +push edi +mov edi,DWORD PTR [edx+0x18] +push edi +mov edi,DWORD PTR [edx+0x1c] +push edi +mov edi,DWORD PTR [edx+0x14] +push edi +call eax +add esp,0x20 +mov edx,DWORD PTR [ebp+0x8] # reg_t* +mov DWORD PTR [edx+0x20],eax +lea esp,[ebp-0xc] + +pop ebx +pop esi +pop edi +pop ebp +ret diff --git a/kernel/cpu/isr.s b/kernel/cpu/isr.s index 1bb2fff..8032485 100644 --- a/kernel/cpu/isr.s +++ b/kernel/cpu/isr.s @@ -270,12 +270,12 @@ ISR_NOERRCODE 254 ISR_NOERRCODE 255 isr_common_stub: - pusha # Pushes edi,esi,ebp,esp,ebx,edx,ecx,eax + pusha # Pushes edi,esi,ebp,esp,ebx,edx,ecx,eax - mov ax, ds # Lower 16-bits of eax = ds. - push eax # save the data segment descriptor + mov ax, ds # Lower 16-bits of eax = ds. + push eax # save the data segment descriptor - mov ax, 0x10 # load the kernel data segment descriptor + mov ax, 0x10 # load the kernel data segment descriptor mov ds, ax mov es, ax mov fs, ax @@ -285,13 +285,13 @@ isr_common_stub: call int_handler add esp, 4 - pop ebx # reload the original data segment descriptor + pop ebx # reload the original data segment descriptor mov ds, bx mov es, bx mov fs, bx mov gs, bx - popa # Pops edi,esi,ebp... - add esp, 8 # Cleans up the pushed error code and pushed ISR number + popa # Pops edi,esi,ebp... + add esp, 8 # Cleans up the pushed error code and pushed ISR number sti - iret # pops 5 things at once: CS, EIP, EFLAGS, SS, and ESP + iret # pops 5 things at once: CS, EIP, EFLAGS, SS, and ESP diff --git a/kernel/cpu/syscall.c b/kernel/cpu/syscall.c index e2ea7e3..193367e 100644 --- a/kernel/cpu/syscall.c +++ b/kernel/cpu/syscall.c @@ -182,18 +182,13 @@ int (*syscall_functions[])() = { (void(*))syscall_tmp_handle_packet, }; +void int_syscall(reg_t *r); void syscall_function_handler(u32 eax, u32 arg1, u32 arg2, u32 arg3, u32 arg4, u32 arg5, u32 ebp, u32 esp) { assert(eax < sizeof(syscall_functions) / sizeof(syscall_functions[0])); syscall_functions[eax](arg1, arg2, arg3, arg4, arg5); } -void int_syscall(reg_t *r) { - u32 syscall = r->eax; - assert(syscall < sizeof(syscall_functions) / sizeof(syscall_functions[0])); - r->eax = syscall_functions[syscall](r->ebx, r->ecx, r->edx, r->esi, r->edi); -} - void syscalls_init(void) { install_handler(int_syscall, INT_32_INTERRUPT_GATE(0x3), 0x80); } |