summaryrefslogtreecommitdiff
path: root/asm/int_syscall_handler.asm
diff options
context:
space:
mode:
authorMichal Idziorek <m.i@gmx.at>2014-12-01 21:49:22 +0100
committerMichal Idziorek <m.i@gmx.at>2014-12-01 21:49:22 +0100
commitd8331335ff1720ce28eba45afe1a02814b38b033 (patch)
treef671279d258477321699d158765f576512851e3a /asm/int_syscall_handler.asm
parent100be313c22bd6116b1adc5eb30f5db56f4b0772 (diff)
finally implemented fork() syscall
Diffstat (limited to 'asm/int_syscall_handler.asm')
-rw-r--r--asm/int_syscall_handler.asm38
1 files changed, 38 insertions, 0 deletions
diff --git a/asm/int_syscall_handler.asm b/asm/int_syscall_handler.asm
index 50202d3..89f152b 100644
--- a/asm/int_syscall_handler.asm
+++ b/asm/int_syscall_handler.asm
@@ -1,4 +1,5 @@
global int_syscall_handler
+[extern task_fork]
[extern syscall_exit]
[extern syscall_write]
@@ -13,11 +14,18 @@ global int_syscall_handler
[extern syscall_sbrk]
[extern syscall_stat]
[extern syscall_lstat]
+[extern syscall_fork]
[extern syscall_unhandled]
[bits 32]
+
+pid: dd 0x0
+
int_syscall_handler:
+cmp eax, 72
+je call_fork
+
cli
push ebx
@@ -63,6 +71,7 @@ int_syscall_handler:
cmp eax, 79
je call_lstat
+
push eax
jmp call_unhandled
@@ -89,6 +98,34 @@ done_blocking:
iret ;Interrupt-Return
+call_fork:
+
+ 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_fork ;Call C code
+ mov [pid],eax
+
+ 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
+
+ mov ebx,[pid]
+
+ sti
+
+ iretd ;Interrupt-Return
+ ;;;;
+
call_stat:
call syscall_stat
jmp done
@@ -139,6 +176,7 @@ call_unhandled:
;;; THIS CALLS NEED REENABLE INTERRUPTS BEFORE calling workers
+ ;; TODO: redesign this shit!
call_read:
mov al, 0x20 ;Port number AND command number to Acknowledge IRQ