diff options
| author | Amlal EL Mahrouss <amlalelmahrouss@icloud.com> | 2024-08-30 18:46:00 +0200 |
|---|---|---|
| committer | Amlal EL Mahrouss <amlalelmahrouss@icloud.com> | 2024-08-30 19:56:02 +0200 |
| commit | a9d87cbd143b05cc3de711d84401f8ef514f3aa3 (patch) | |
| tree | cfc703f1dc02f6894b4d6d173d18d84be5757c5f /dev/ZKA/HALKit/AMD64/HalMPContextSwitch.asm | |
| parent | 5229ca8ae190c0cb3db8d381a44be4113e81d5dc (diff) | |
[IMP] Updated the ARM64 release of ZKA.
[IMP] Shall use the timer on AMD64 by default, a SMP driver will be written if needed.
Signed-off-by: Amlal EL Mahrouss <amlalelmahrouss@icloud.com>
Diffstat (limited to 'dev/ZKA/HALKit/AMD64/HalMPContextSwitch.asm')
| -rw-r--r-- | dev/ZKA/HALKit/AMD64/HalMPContextSwitch.asm | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/dev/ZKA/HALKit/AMD64/HalMPContextSwitch.asm b/dev/ZKA/HALKit/AMD64/HalMPContextSwitch.asm index c5af31a0..965d7d07 100644 --- a/dev/ZKA/HALKit/AMD64/HalMPContextSwitch.asm +++ b/dev/ZKA/HALKit/AMD64/HalMPContextSwitch.asm @@ -10,7 +10,7 @@ [bits 64] [global rt_get_current_context] -[global rt_do_context_switch] +[global mp_do_context_switch] [global _hal_spin_core] [extern _hal_switch_context] [extern _hal_leak_current_context] @@ -20,20 +20,10 @@ section .text ;; writes to rdx the stackframe inside rcx. ;; rcx: Stack Pointer ;; rdx: SMP core address. -rt_do_context_switch: - push rcx - call _hal_switch_context - pop rcx - - ;; Now grab newly allocated process's stack frame. - push rax - call _hal_leak_current_context - mov r9, rax - pop rax - +mp_do_context_switch: ;; Take care of context switching within AP. - mov r9, rax + mov r9, rcx mov rbp, [r9 + (8 * 5)] mov rsp, [r9 + (8 * 6)] @@ -60,7 +50,26 @@ rt_do_context_switch: mov r9, [r9 + (8 * 12)] - retfq + ; User code selector is 0x20 btw (Amlal). + + mov ax, 0x23 + mov ds, ax + mov es, ax + mov fs, ax + mov gs, ax + + push 0x23 + push rsp + + pushfq + pop rax + or rax, 0x200 + push rax + + push 0x20 + push rbp + + iretq ;; gets the current stack frame. rt_get_current_context: |
