From c2c03f41e078481921bad82487eded0fc51ebb59 Mon Sep 17 00:00:00 2001 From: Michal Idziorek Date: Tue, 2 Dec 2014 01:02:49 +0100 Subject: further work on fork and friends --- asm/int_syscall_handler.asm | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) (limited to 'asm/int_syscall_handler.asm') diff --git a/asm/int_syscall_handler.asm b/asm/int_syscall_handler.asm index 504d3e8..70090f0 100644 --- a/asm/int_syscall_handler.asm +++ b/asm/int_syscall_handler.asm @@ -1,6 +1,7 @@ global int_syscall_handler [extern task_fork] [extern task_exit] +[extern task_wait] [extern syscall_exit] @@ -25,13 +26,15 @@ pid: dd 0x0 int_syscall_handler: - cmp eax, 72 je call_fork cmp eax, 60 je call_exit +cmp eax, 77 +je call_wait + cli push ebx @@ -96,12 +99,35 @@ done_blocking: iret ;Interrupt-Return +call_wait: + + cli + + pusha ;Push all standard registers + + mov ebx, esp ;save current stack pointer in esp + mov esp, 0x7000 ;now put the stack outside of virtual memory in kernel space! + + push ebx ;Push pointer to all the stuff we just pushed + + call task_wait ;Call C code + + mov esp, eax ;Replace the stack with what the C code gave us + + popa ;Put the standard registers back + + sti + + iretd ;Interrupt-Return + ;;;; + call_exit: cli pusha ;Push all standard registers + mov ebx, esp ;save current stack pointer in esp mov esp, 0x7000 ;now put the stack outside of virtual memory in kernel space! push ebx ;Push pointer to all the stuff we just pushed @@ -126,7 +152,7 @@ call_fork: mov ebx, esp ;save current stack pointer in esp mov esp, 0x7000 ;now put the stack outside of virtual memory in kernel space! - push ebx ;Push pointer to all the stuff we just pushed + push ebx call task_fork ;Call C code mov [pid],eax -- cgit v1.2.3