summaryrefslogtreecommitdiffhomepage
path: root/dev/ZKA/HALKit/AMD64/HalMPContextSwitch.asm
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-09-01 11:21:55 +0200
committerAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-09-01 11:21:55 +0200
commit1af5efb5c96af6f3246c8eae42912b2fbcd7f006 (patch)
tree9cf4cf8d7ed93eef0ff3daac211879cb9a961c81 /dev/ZKA/HALKit/AMD64/HalMPContextSwitch.asm
parente757bb6a90c98f53995e4828d68eba26a2327540 (diff)
Many bug fixes, and wip fixes.
RoadMap: - Ring-3 switch [ Still gives GPF ] - Make timer interrupt on non SMP profile. - Work on SMP support, to offload tasks to other cores. - Validate kernel and components (compiler, dlls, programs...) 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.asm41
1 files changed, 13 insertions, 28 deletions
diff --git a/dev/ZKA/HALKit/AMD64/HalMPContextSwitch.asm b/dev/ZKA/HALKit/AMD64/HalMPContextSwitch.asm
index f5f36b27..9ef3122c 100644
--- a/dev/ZKA/HALKit/AMD64/HalMPContextSwitch.asm
+++ b/dev/ZKA/HALKit/AMD64/HalMPContextSwitch.asm
@@ -13,6 +13,7 @@
[global mp_do_context_switch]
[extern _hal_switch_context]
[extern _hal_leak_current_context]
+[global mp_do_context_switch_pre]
section .text
@@ -20,9 +21,16 @@ section .text
;; rcx: code ptr.
;; rdx: stack ptr.
mp_do_context_switch:
- mov r11, rdx
- mov r12, rcx
-
+ mov r11, 0x0202
+ mov rsp, rdx
+ o64 sysret
+
+;; @brief Gets the current stack frame.
+mp_get_current_context:
+ call _hal_leak_current_context
+ ret
+
+mp_do_context_switch_pre:
; Enable SCE that enables sysret and syscall
mov rcx, 0xc0000082
wrmsr
@@ -33,30 +41,7 @@ mp_do_context_switch:
mov rcx, 0xc0000081
rdmsr
mov edx, 0x00180008
- wrmsr
- mov rbx, 0x28
- mov ds, rbx
+ wrmsr
- mov rbx, 0x28
- mov fs, rbx
-
- mov rbx, 0x28
- mov gs, rbx
-
- mov rbx, 0x28
- mov es, rbx
-
- ;; Swap registers, since it's the other way around.
-
- mov rcx, r12 ;; code ptr
- mov rsp, r11 ;; stack ptr
- mov r11, 0x0202
-
- ;; rcx and rdx already set.
- o64 sysret
-
-;; @brief Gets the current stack frame.
-mp_get_current_context:
- call _hal_leak_current_context
- ret
+ ret \ No newline at end of file