From ef71b80d3df1969a2be85eadf2d83cd85745469d Mon Sep 17 00:00:00 2001 From: Amlal Date: Sun, 8 Sep 2024 22:19:00 +0200 Subject: A lot: - Changed task banks are being switched in the kernel. - Changed user mode switch mode, improved it to push rflags. - User proc will start the scheduler when it's being jumped on. Signed-off-by: Amlal --- dev/ZKA/HALKit/AMD64/HalMPContextSwitch.asm | 35 +++++++++++++++++++---------- 1 file changed, 23 insertions(+), 12 deletions(-) (limited to 'dev/ZKA/HALKit/AMD64/HalMPContextSwitch.asm') diff --git a/dev/ZKA/HALKit/AMD64/HalMPContextSwitch.asm b/dev/ZKA/HALKit/AMD64/HalMPContextSwitch.asm index 4403263a..c61db220 100644 --- a/dev/ZKA/HALKit/AMD64/HalMPContextSwitch.asm +++ b/dev/ZKA/HALKit/AMD64/HalMPContextSwitch.asm @@ -9,10 +9,7 @@ [bits 64] -[global mp_get_current_context] -[global mp_do_context_switch] -[extern _hal_switch_context] -[extern _hal_leak_current_context] +[global mp_do_user_switch] [global mp_do_context_switch_pre] section .text @@ -20,7 +17,7 @@ section .text ;; Does a user mode switch, and then loads the task to be run. ;; rcx: code ptr. ;; rdx: stack ptr. -mp_do_context_switch: +mp_do_user_switch: mov ax, 0x18 | 3 mov ds, ax mov es, ax @@ -28,14 +25,28 @@ mp_do_context_switch: mov fs, ax push 0x18 | 3 - push rdx - push 0x200 + + mov rax, mp_user_switch_proc_end + push rax + + o64 pushf + push 0x20 | 3 - push rcx + + mov rdx, mp_user_switch_proc + push rdx + + mov rsp, mp_user_switch_proc_end o64 iret -;; @brief Gets the current stack frame. -mp_get_current_context: - call _hal_leak_current_context - ret +section .bss + +mp_user_switch_proc_begin: + resb 4*4096 +mp_user_switch_proc_end: + +section .text + +mp_user_switch_proc: + jmp $ -- cgit v1.2.3