os/user_space.c

44 lines
1.3 KiB
C
Raw Normal View History

2024-05-21 18:41:16 +03:00
void enter_user_space(void)
{
2024-05-22 00:15:05 +03:00
asm volatile("cli; \
2024-05-21 18:41:16 +03:00
mov $0x23, %ax; \
mov %ax, %ds; \
mov %ax, %es; \
mov %ax, %fs; \
mov %ax, %gs; \
mov %esp, %eax; \
pushl $0x23; \
pushl %eax; \
pushf; \
popl %eax; \
orl $0x200, %eax; \
pushl %eax; \
pushl $0x1B; \
push $1f; \
iret; \
1: \
");
2024-05-23 20:59:18 +03:00
}
void enter_user_space_v2()
{
asm volatile("cli; \
mov $0x23, %ax; \
mov %ax, %ds; \
mov %ax, %es; \
mov %ax, %fs; \
mov %ax, %gs; \
mov %esp, %eax; \
push $0x23; \
push %eax; \
pushf; \
pop %eax; \
or $0x200, %eax; \
push %eax; \
push $0x1B; \
push $user_code_entry; \
iret; \
user_code_entry: \
call user_main; \
");
2024-05-21 18:41:16 +03:00
}