blob: 72f80dc856ebeb3685cddaf610227a6c248a6f34 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
#include "../kernel/kernel.h"
.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 $VMEM_USER_STACK_TOP-4*32 //(3 values will be poped on _start) 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
|