summaryrefslogtreecommitdiffhomepage
path: root/Kernel/HALKit
diff options
context:
space:
mode:
Diffstat (limited to 'Kernel/HALKit')
-rw-r--r--Kernel/HALKit/AMD64/HalCoreMultiProcessingAMD64.cpp7
-rw-r--r--Kernel/HALKit/AMD64/HalHart.cpp12
-rw-r--r--Kernel/HALKit/AMD64/HalKernelMouse.cxx2
-rw-r--r--Kernel/HALKit/AMD64/HalSMPCoreManager.asm48
4 files changed, 24 insertions, 45 deletions
diff --git a/Kernel/HALKit/AMD64/HalCoreMultiProcessingAMD64.cpp b/Kernel/HALKit/AMD64/HalCoreMultiProcessingAMD64.cpp
index 37a681ab..26773640 100644
--- a/Kernel/HALKit/AMD64/HalCoreMultiProcessingAMD64.cpp
+++ b/Kernel/HALKit/AMD64/HalCoreMultiProcessingAMD64.cpp
@@ -10,6 +10,7 @@
#include <ArchKit/ArchKit.hpp>
#include <KernelKit/Semaphore.hpp>
#include <KernelKit/ProcessScheduler.hxx>
+#include <KernelKit/Timer.hpp>
#define kAPIC_ICR_Low 0x300
#define kAPIC_ICR_High 0x310
@@ -184,11 +185,7 @@ namespace NewOS::HAL
{
Semaphore sem;
- while (sem.IsLocked())
- {
- }
-
- sem.Lock(&ProcessScheduler::The().Leak().GetCurrent().Leak());
+ sem.LockOrWait(&ProcessScheduler::The().Leak().GetCurrent().Leak(), Seconds(5));
cFramePtr = stackFrame;
diff --git a/Kernel/HALKit/AMD64/HalHart.cpp b/Kernel/HALKit/AMD64/HalHart.cpp
index 92e075aa..069f3767 100644
--- a/Kernel/HALKit/AMD64/HalHart.cpp
+++ b/Kernel/HALKit/AMD64/HalHart.cpp
@@ -16,15 +16,19 @@ namespace NewOS
{
HAL::rt_cli();
+ rt_do_context_switch(stack);
+
HAL::rt_sti();
}
- /// @brief makes thread sleep.
+ /// @brief makes the thread sleep on a loop.
/// hooks and hangs thread to prevent code from executing.
void rt_hang_thread(HAL::StackFrame* stack)
{
- HAL::rt_cli();
-
- HAL::rt_sti();
+ while (true)
+ {
+ /* nohing, code is spinning */
+ }
+
}
} // namespace NewOS
diff --git a/Kernel/HALKit/AMD64/HalKernelMouse.cxx b/Kernel/HALKit/AMD64/HalKernelMouse.cxx
index 8dbd328a..5d50e4f2 100644
--- a/Kernel/HALKit/AMD64/HalKernelMouse.cxx
+++ b/Kernel/HALKit/AMD64/HalKernelMouse.cxx
@@ -10,7 +10,7 @@
#include <KernelKit/Framebuffer.hpp>
#include <NewKit/Defines.hpp>
-// forward decl.
+/// @note forward decl.
EXTERN_C NewOS::Boolean _hal_draw_mouse();
EXTERN_C NewOS::Void _hal_init_mouse();
diff --git a/Kernel/HALKit/AMD64/HalSMPCoreManager.asm b/Kernel/HALKit/AMD64/HalSMPCoreManager.asm
index c4042b50..320120a4 100644
--- a/Kernel/HALKit/AMD64/HalSMPCoreManager.asm
+++ b/Kernel/HALKit/AMD64/HalSMPCoreManager.asm
@@ -22,59 +22,37 @@ section .text
;; rcx: Stack Pointer
;; rdx: SMP core address.
rt_do_context_switch:
- push rax
push rcx
- push rdx
- push rbx
- push rbp
- push rsi
- push rdi
- push r8
- push r9
- push r10
- push r11
- push r12
- push r13
- push r14
- push r15
+ push rax
- jmp _hal_switch_context
+ call _hal_switch_context
- pop r15
- pop r14
- pop r13
- pop r12
- pop r11
- pop r10
- pop r9
- pop r8
- pop rdi
- pop rsi
- pop rbp
- pop rbx
- pop rdx
pop rcx
pop rax
-
- mov eax, 0
-
retfq
;; gets the current stack frame.
rt_get_current_context:
- push rdx
+ push rax
+
jmp _hal_leak_current_context
- mov rdx, rax
- pop rdx
+
+ mov rax, r9
+ pop rax
+
+ mov r9, rax
+
retfq
;; @brief enables a smp core to run.
_hal_enable_smp:
-; Read the APIC base MSR
+ ; Read the APIC base MSR
mov ecx, 0x1B ; IA32_APIC_BASE MSR
rdmsr
+
; Enable the APIC by setting bit 11 (APIC Global Enable)
or rdx, 0x800
+
; Set the base address (0xFEE00000)
mov eax, 0xFEE
shl rax, 12