summaryrefslogtreecommitdiff
path: root/asm
diff options
context:
space:
mode:
authorMiguel <m.i@gmx.at>2018-08-17 21:41:21 +0200
committerMiguel <m.i@gmx.at>2018-08-17 21:41:21 +0200
commitc15925a24efe14f437d8a2699500241a58fdc8f9 (patch)
treec0db3a7d2a4f857324735df35e9cc1f0539c5f24 /asm
parent6fd78c2ff950310d8372ec0353553cc4a5a43e72 (diff)
cleanup and working on fifo pipes
Diffstat (limited to 'asm')
-rw-r--r--asm/syscall.h11
-rw-r--r--asm/syscall.s5
-rw-r--r--asm/usermode.h7
-rw-r--r--asm/usermode.s15
4 files changed, 27 insertions, 11 deletions
diff --git a/asm/syscall.h b/asm/syscall.h
new file mode 100644
index 0000000..2cadce4
--- /dev/null
+++ b/asm/syscall.h
@@ -0,0 +1,11 @@
+/*
+ * Issue a System Call from Ring 3 / User Space
+ *
+ * Accepts up to 3 parameters.
+ * Check syscalls.h for details.
+ */
+
+uint32_t syscall(uint32_t code,
+ uint32_t param_1,
+ uint32_t param_2,
+ uint32_t param_3);
diff --git a/asm/syscall.s b/asm/syscall.s
index 8860d89..388b6fa 100644
--- a/asm/syscall.s
+++ b/asm/syscall.s
@@ -1,10 +1,5 @@
.global syscall
-// call from c with 4 x 32bit params
-// syscall number, p1,p2,p3,p4
-
-// TODO: push stack frame?
-
syscall:
push %ebx // preserve (sysV abi convnetion)
diff --git a/asm/usermode.h b/asm/usermode.h
new file mode 100644
index 0000000..9b76db3
--- /dev/null
+++ b/asm/usermode.h
@@ -0,0 +1,7 @@
+/*
+ * Switch to User Mode and returin to function given by pointer
+ * provide the address of a void func() that will be called without
+ * any params.
+ */
+
+void usermode(uint32_t func);
diff --git a/asm/usermode.s b/asm/usermode.s
index acf4b04..67eca04 100644
--- a/asm/usermode.s
+++ b/asm/usermode.s
@@ -1,8 +1,9 @@
-.global asm_usermode
-.extern userfunc
+.global usermode
-# pass address to func to exec (TODO)
-asm_usermode:
+usermode:
+
+ mov 0x4(%esp),%edx //get adress of passed : void func()
+ //to be called in ring 3
// 0x23 is user data segment (|2 low bits)
// 0x1b is user code segment (|2 low bits)
@@ -13,6 +14,7 @@ asm_usermode:
mov %ax, %es
mov %ax, %fs
mov %ax, %gs
+
// ss is handled by iret
mov %esp, %eax
@@ -25,10 +27,11 @@ asm_usermode:
//mov $0x200, %eax
//push %eax // eflags image
pushl $0x1B // return code segment selector
- push $userfunc // return instruction pointer
+ push %edx // return instruction pointer
+
iret
- jmp . // will never be reached?
+ jmp . // never to be reached