From e2a90fce95fde6eaef50e6d99e32b902ec14cc0d Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Sat, 31 Aug 2024 15:08:15 +0200 Subject: Source bump. Signed-off-by: Amlal El Mahrouss --- dev/ZKA/HALKit/AMD64/HalMPContextSwitch.asm | 37 ++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 9 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 6b3ed33a..98dbfa02 100644 --- a/dev/ZKA/HALKit/AMD64/HalMPContextSwitch.asm +++ b/dev/ZKA/HALKit/AMD64/HalMPContextSwitch.asm @@ -11,24 +11,43 @@ [global mp_get_current_context] [global mp_do_context_switch] -[global _hal_spin_core] [extern _hal_switch_context] [extern _hal_leak_current_context] section .text -;; writes to rdx the stackframe inside rcx. -;; rcx: Stack Pointer -;; rdx: SMP core address. +;; Does a user mode switch, and then loads the task to be run. +;; rcx: code ptr. +;; rdx: stack ptr. mp_do_context_switch: - jmp $ + mov r11, rdx + mov r12, rcx + + ; Enable SCE that enables sysret and syscall + mov rcx, 0xc0000082 + wrmsr + mov rcx, 0xc0000080 + rdmsr + or eax, 1 + wrmsr + mov rcx, 0xc0000081 + rdmsr + mov edx, 0x00180008 + wrmsr + + mov rcx, r11 + mov rdx, r12 + mov r11, 0x202 + + ;; rcx and rdx already set. + o64 sysret ret +mp_do_context_switch_fail: + jmp $ + + ;; @brief Gets the current stack frame. mp_get_current_context: call _hal_leak_current_context ret - -_hal_spin_core: - jmp $ - ret -- cgit v1.2.3