tasking: add simple base for running things in ring 3
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
; TODO: maybe put it near idt.c?
|
||||
global sys_exit_handler
|
||||
extern printf
|
||||
sys_exit_handler:
|
||||
; Сохраняем регистры Ring 3
|
||||
pusha
|
||||
push ds
|
||||
push es
|
||||
push fs
|
||||
push gs
|
||||
|
||||
; Переключаемся на сегменты Ring 0
|
||||
mov ax, 0x10 ; Селектор данных Ring 0 (gdt_data)
|
||||
mov ds, ax
|
||||
mov es, ax
|
||||
mov fs, ax
|
||||
mov gs, ax
|
||||
|
||||
; Выполняем действие
|
||||
push sys_exit_msg
|
||||
call printf
|
||||
add esp, 4
|
||||
|
||||
; Восстанавливаем сегменты Ring 3
|
||||
pop gs
|
||||
pop fs
|
||||
pop es
|
||||
pop ds
|
||||
popa
|
||||
|
||||
; Возвращаемся в Ring 3
|
||||
iret
|
||||
|
||||
global test_user_function
|
||||
test_user_function:
|
||||
mov eax, 0xDEADBEEF
|
||||
int 0x80
|
||||
jmp $
|
||||
|
||||
section .data
|
||||
sys_exit_msg: db "Returned from Ring 3", 0
|
||||
Reference in New Issue
Block a user