tasking: add simple base for running things in ring 3

This commit is contained in:
2025-04-07 16:13:31 +03:00
parent 03e718c2c8
commit 372b308ec8
9 changed files with 163 additions and 10 deletions
+41
View File
@@ -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