diff options
| author | Amlal <amlal@el-mahrouss-logic.com> | 2024-09-08 22:19:00 +0200 |
|---|---|---|
| committer | Amlal <amlal@el-mahrouss-logic.com> | 2024-09-08 22:19:00 +0200 |
| commit | ef71b80d3df1969a2be85eadf2d83cd85745469d (patch) | |
| tree | 218415d633ba1010f57f218a139c791e7a737e4f /dev/ZKA/HALKit | |
| parent | 11219de11b35cb4f1e1a27408244243b11b41e05 (diff) | |
A lot:
- Changed task banks are being switched in the kernel.
- Changed user mode switch mode, improved it to push rflags.
- User proc will start the scheduler when it's being jumped on.
Signed-off-by: Amlal <amlal@el-mahrouss-logic.com>
Diffstat (limited to 'dev/ZKA/HALKit')
| -rw-r--r-- | dev/ZKA/HALKit/AMD64/HalCoreMPScheduler.cxx | 2 | ||||
| -rw-r--r-- | dev/ZKA/HALKit/AMD64/HalMPContextSwitch.asm | 35 | ||||
| -rw-r--r-- | dev/ZKA/HALKit/ARM64/HalSchedulerCore.cxx | 2 | ||||
| -rw-r--r-- | dev/ZKA/HALKit/POWER/HalContextSwitchPowerPC.s | 6 |
4 files changed, 29 insertions, 16 deletions
diff --git a/dev/ZKA/HALKit/AMD64/HalCoreMPScheduler.cxx b/dev/ZKA/HALKit/AMD64/HalCoreMPScheduler.cxx index a5bf07ec..1a518c5d 100644 --- a/dev/ZKA/HALKit/AMD64/HalCoreMPScheduler.cxx +++ b/dev/ZKA/HALKit/AMD64/HalCoreMPScheduler.cxx @@ -152,7 +152,7 @@ namespace Kernel::HAL VoidPtr f_Image; } fBlocks[kSchedProcessLimitPerTeam] = {0}; - EXTERN_C HAL::StackFramePtr _hal_leak_current_context(Void) + EXTERN_C HAL::StackFramePtr mp_get_current_context(Void) { return fBlocks[UserProcessScheduler::The().CurrentProcess().Leak().ProcessId % kSchedProcessLimitPerTeam].f_Frame; } diff --git a/dev/ZKA/HALKit/AMD64/HalMPContextSwitch.asm b/dev/ZKA/HALKit/AMD64/HalMPContextSwitch.asm index 4403263a..c61db220 100644 --- a/dev/ZKA/HALKit/AMD64/HalMPContextSwitch.asm +++ b/dev/ZKA/HALKit/AMD64/HalMPContextSwitch.asm @@ -9,10 +9,7 @@ [bits 64] -[global mp_get_current_context] -[global mp_do_context_switch] -[extern _hal_switch_context] -[extern _hal_leak_current_context] +[global mp_do_user_switch] [global mp_do_context_switch_pre] section .text @@ -20,7 +17,7 @@ section .text ;; Does a user mode switch, and then loads the task to be run. ;; rcx: code ptr. ;; rdx: stack ptr. -mp_do_context_switch: +mp_do_user_switch: mov ax, 0x18 | 3 mov ds, ax mov es, ax @@ -28,14 +25,28 @@ mp_do_context_switch: mov fs, ax push 0x18 | 3 - push rdx - push 0x200 + + mov rax, mp_user_switch_proc_end + push rax + + o64 pushf + push 0x20 | 3 - push rcx + + mov rdx, mp_user_switch_proc + push rdx + + mov rsp, mp_user_switch_proc_end o64 iret -;; @brief Gets the current stack frame. -mp_get_current_context: - call _hal_leak_current_context - ret +section .bss + +mp_user_switch_proc_begin: + resb 4*4096 +mp_user_switch_proc_end: + +section .text + +mp_user_switch_proc: + jmp $ diff --git a/dev/ZKA/HALKit/ARM64/HalSchedulerCore.cxx b/dev/ZKA/HALKit/ARM64/HalSchedulerCore.cxx index 781c639a..2c801372 100644 --- a/dev/ZKA/HALKit/ARM64/HalSchedulerCore.cxx +++ b/dev/ZKA/HALKit/ARM64/HalSchedulerCore.cxx @@ -33,7 +33,7 @@ namespace Kernel /// Wakes up thread from the hang state. Void mp_wakeup_thread(HAL::StackFrame* stack) { - mp_do_context_switch(stack); + ZKA_UNUSED(stack); } /// @brief makes the thread sleep on a loop. diff --git a/dev/ZKA/HALKit/POWER/HalContextSwitchPowerPC.s b/dev/ZKA/HALKit/POWER/HalContextSwitchPowerPC.s index 9a9c3aa6..588de23a 100644 --- a/dev/ZKA/HALKit/POWER/HalContextSwitchPowerPC.s +++ b/dev/ZKA/HALKit/POWER/HalContextSwitchPowerPC.s @@ -7,10 +7,10 @@ .align 4 .type name, @function .text -.globl mp_do_context_switch +.globl mp_do_user_switch /* r3 (3) = assigner stack, r4 (4) = assignee stack */ -mp_do_context_switch: +mp_do_user_switch: lwz 0(%4), 0(%3) lwz 4(%4), 4(%3) lwz 8(%4), 8(%3) @@ -24,5 +24,7 @@ mp_do_context_switch: lwz 34(%4), 34(%3) lwz 38(%4), 38(%3) + /* also change exception level */ + /* we are done here, the assignee should start executing code now. */ blr |
