diff options
| author | Michal Idziorek <m.i@gmx.at> | 2014-12-01 23:33:31 +0100 |
|---|---|---|
| committer | Michal Idziorek <m.i@gmx.at> | 2014-12-01 23:33:31 +0100 |
| commit | f20db37ca17245d5d20302a1ac1da347de5c3607 (patch) | |
| tree | ce0712176387f4555cf290615b71cdd1c935557d /asm | |
| parent | d8331335ff1720ce28eba45afe1a02814b38b033 (diff) | |
very buggy fork, execve and exit
Diffstat (limited to 'asm')
| -rw-r--r-- | asm/int_syscall_handler.asm | 63 |
1 files changed, 45 insertions, 18 deletions
diff --git a/asm/int_syscall_handler.asm b/asm/int_syscall_handler.asm index 89f152b..504d3e8 100644 --- a/asm/int_syscall_handler.asm +++ b/asm/int_syscall_handler.asm @@ -1,5 +1,7 @@ global int_syscall_handler [extern task_fork] +[extern task_exit] + [extern syscall_exit] [extern syscall_write] @@ -23,17 +25,19 @@ pid: dd 0x0 int_syscall_handler: + cmp eax, 72 je call_fork +cmp eax, 60 +je call_exit + cli push ebx push ecx push edx - cmp eax, 60 - je call_exit cmp eax, 61 je call_write @@ -78,12 +82,6 @@ je call_fork done: - mov ebx,eax - - mov al, 0x20 ;Port number AND command number to Acknowledge IRQ - out 0x20, al ;Acknowledge IRQ, so we keep getting interrupts - - mov eax,ebx done_blocking: @@ -98,6 +96,27 @@ done_blocking: iret ;Interrupt-Return +call_exit: + + cli + + pusha ;Push all standard registers + + 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_exit ;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_fork: cli @@ -113,9 +132,6 @@ call_fork: mov esp, ebx ;Replace the stack with what the C code gave us - mov al, 0x20 ;Port number AND command number to Acknowledge IRQ - out 0x20, al ;Acknowledge IRQ, so we keep getting interrupts - popa ;Put the standard registers back @@ -166,9 +182,6 @@ call_sbrk: call syscall_sbrk jmp done -call_exit: - call syscall_exit - jmp done call_unhandled: call syscall_unhandled @@ -189,10 +202,24 @@ call_read: call_execve: - mov al, 0x20 ;Port number AND command number to Acknowledge IRQ - out 0x20, al ;Acknowledge IRQ, so we keep getting interrupts - sti + pusha + + mov eax,esp + mov esp,0x7000 + + push ebx + push ecx + push edx + mov ebx,eax call syscall_execve - jmp done_blocking + pop eax + pop eax + pop eax + + mov esp,ebx + + popa + + jmp done |
