summaryrefslogtreecommitdiffhomepage
path: root/dev/ZKA/HALKit/AMD64/HalMPContextSwitch.asm
diff options
context:
space:
mode:
Diffstat (limited to 'dev/ZKA/HALKit/AMD64/HalMPContextSwitch.asm')
-rw-r--r--dev/ZKA/HALKit/AMD64/HalMPContextSwitch.asm37
1 files changed, 28 insertions, 9 deletions
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