summaryrefslogtreecommitdiff
path: root/asm/asm_usermode.S
diff options
context:
space:
mode:
authorMiguel <m.i@gmx.at>2018-09-12 15:23:38 +0200
committerMiguel <m.i@gmx.at>2018-09-12 15:23:38 +0200
commitc72944b5646863ffaaaff94dc03b939a08566203 (patch)
tree3ce3d74fc27b297cd6958d0d8ba588ccbbe16bfb /asm/asm_usermode.S
parent800b1a878ec34a8ff30ed093e20561182fa6ae36 (diff)
struggling with vmem
Diffstat (limited to 'asm/asm_usermode.S')
-rw-r--r--asm/asm_usermode.S39
1 files changed, 39 insertions, 0 deletions
diff --git a/asm/asm_usermode.S b/asm/asm_usermode.S
new file mode 100644
index 0000000..a07f480
--- /dev/null
+++ b/asm/asm_usermode.S
@@ -0,0 +1,39 @@
+.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
+ pushl $0xe0000000-3*32 //%eax // current stack (3 values will be poped) we subst 4 to align
+ 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
+
+
+
+