summaryrefslogtreecommitdiffhomepage
path: root/dev/ZKA/HALKit/AMD64/HalMPContextSwitch.asm
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-08-31 15:08:15 +0200
committerAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-08-31 15:08:15 +0200
commite2a90fce95fde6eaef50e6d99e32b902ec14cc0d (patch)
treea7cc8f17478f9e77019beab9e524d39fe311f775 /dev/ZKA/HALKit/AMD64/HalMPContextSwitch.asm
parent2c4b02249ec4355a73b826909ab1889e45871faf (diff)
Source bump.
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
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