summaryrefslogtreecommitdiff
path: root/asm/asm_usermode.s
diff options
context:
space:
mode:
authorMiguel <m.i@gmx.at>2018-09-03 15:18:16 +0200
committerMiguel <m.i@gmx.at>2018-09-03 15:18:16 +0200
commit7eb87bf3f3fa6226657a7106eb255cbfa97758d2 (patch)
tree2d7d2280d32180d18796999bf7687ebe5bf208df /asm/asm_usermode.s
parent76b3da6022310dd8edbbbfdf4f73f1696a559853 (diff)
big renaming
Diffstat (limited to 'asm/asm_usermode.s')
-rw-r--r--asm/asm_usermode.s38
1 files changed, 38 insertions, 0 deletions
diff --git a/asm/asm_usermode.s b/asm/asm_usermode.s
new file mode 100644
index 0000000..71ecc1d
--- /dev/null
+++ b/asm/asm_usermode.s
@@ -0,0 +1,38 @@
+.global asm_usermode
+
+asm_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)
+
+ // set segment registers
+ mov $0x23, %ax
+ mov %ax, %ds
+ mov %ax, %es
+ mov %ax, %fs
+ mov %ax, %gs
+
+ // ss is handled by iret
+
+ mov %esp, %eax
+
+ pushl $0x23 // user data segment
+ pushl $0x8fff000-3*32 //%eax // current stack
+ pushf //
+
+ // http://x86.renejeschke.de/html/file_module_x86_id_145.html
+ //mov $0x200, %eax
+ //push %eax // eflags image
+ pushl $0x1B // return code segment selector
+ push %edx // return instruction pointer
+
+ iret
+
+ jmp . // never to be reached
+
+
+
+