summaryrefslogtreecommitdiffhomepage
path: root/dev/ZKA
diff options
context:
space:
mode:
authorAmlal EL Mahrouss <amlalelmahrouss@icloud.com>2024-08-26 18:08:06 +0200
committerAmlal EL Mahrouss <amlalelmahrouss@icloud.com>2024-08-26 18:21:47 +0200
commit60cc51ae3bc8de2276a7c7a5f3e7117dc0473c98 (patch)
treecdfd89dd332845a65129422e1160cb2e199b1615 /dev/ZKA
parent9a86282760e642734bf5b6e233bc3728991fb4e4 (diff)
[IMP] Detect MP support, redirect interrupt to startup routine.
[FIX] Use RCX instead of RAX, move RAX to R9, instead of opposite Signed-off-by: Amlal EL Mahrouss <amlalelmahrouss@icloud.com>
Diffstat (limited to 'dev/ZKA')
-rw-r--r--dev/ZKA/FirmwareKit/Handover.hxx8
-rw-r--r--dev/ZKA/HALKit/AMD64/HalCoreMultiProcessingAMD64.cxx1
-rw-r--r--dev/ZKA/HALKit/AMD64/HalInterruptAPI.asm11
-rw-r--r--dev/ZKA/HALKit/AMD64/HalKernelMain.cxx3
-rw-r--r--dev/ZKA/HALKit/AMD64/HalMPContextSwitch.asm7
5 files changed, 18 insertions, 12 deletions
diff --git a/dev/ZKA/FirmwareKit/Handover.hxx b/dev/ZKA/FirmwareKit/Handover.hxx
index ba7b23b2..2873b954 100644
--- a/dev/ZKA/FirmwareKit/Handover.hxx
+++ b/dev/ZKA/FirmwareKit/Handover.hxx
@@ -75,14 +75,10 @@ namespace Kernel::HEL
{
VoidPtr f_SmBios;
VoidPtr f_VendorPtr;
- struct
- {
- VoidPtr f_ImagePtr;
- SizeT f_ImageSz;
- };
- VoidPtr f_MPPtr;
} f_HardwareTables;
+ Bool f_MultiProcessingEnabled;
+
struct
{
UIntPtr f_The;
diff --git a/dev/ZKA/HALKit/AMD64/HalCoreMultiProcessingAMD64.cxx b/dev/ZKA/HALKit/AMD64/HalCoreMultiProcessingAMD64.cxx
index b1b8d698..d11d1c8c 100644
--- a/dev/ZKA/HALKit/AMD64/HalCoreMultiProcessingAMD64.cxx
+++ b/dev/ZKA/HALKit/AMD64/HalCoreMultiProcessingAMD64.cxx
@@ -114,6 +114,7 @@ namespace Kernel::HAL
/// @param targetAddress
/// @return
/***********************************************************************************/
+
Void hal_send_start_ipi(UInt32 apicId, UInt8 vector, UInt32 targetAddress)
{
Kernel::ke_dma_write(targetAddress, kAPIC_ICR_High, (apicId << 24));
diff --git a/dev/ZKA/HALKit/AMD64/HalInterruptAPI.asm b/dev/ZKA/HALKit/AMD64/HalInterruptAPI.asm
index 12c71663..0c79be81 100644
--- a/dev/ZKA/HALKit/AMD64/HalInterruptAPI.asm
+++ b/dev/ZKA/HALKit/AMD64/HalInterruptAPI.asm
@@ -186,7 +186,16 @@ __NEW_INT_51:
sti
iretq
-IntNormal 52
+[extern hal_ap_startup]
+
+__NEW_INT_52:
+ cli
+
+ jmp hal_ap_startup
+
+ sti
+ ret
+
IntNormal 53
IntNormal 54
IntNormal 55
diff --git a/dev/ZKA/HALKit/AMD64/HalKernelMain.cxx b/dev/ZKA/HALKit/AMD64/HalKernelMain.cxx
index 126473a0..6be8eeaf 100644
--- a/dev/ZKA/HALKit/AMD64/HalKernelMain.cxx
+++ b/dev/ZKA/HALKit/AMD64/HalKernelMain.cxx
@@ -218,7 +218,8 @@ Kernel::Void hal_real_init(Kernel::Void) noexcept
kSyscalls[cShutdownInterrupt].Leak().Leak()->fHooked = true;
kSyscalls[cRebootInterrupt].Leak().Leak()->fHooked = true;
- Kernel::HAL::hal_system_get_cores(kHandoverHeader->f_HardwareTables.f_VendorPtr);
+ if (kHandoverHeader->f_MultiProcessingEnabled)
+ Kernel::HAL::hal_system_get_cores(kHandoverHeader->f_HardwareTables.f_VendorPtr);
Kernel::kcout << "newoskrnl: Creating filesystem and such.\r";
diff --git a/dev/ZKA/HALKit/AMD64/HalMPContextSwitch.asm b/dev/ZKA/HALKit/AMD64/HalMPContextSwitch.asm
index 70ee1205..c5af31a0 100644
--- a/dev/ZKA/HALKit/AMD64/HalMPContextSwitch.asm
+++ b/dev/ZKA/HALKit/AMD64/HalMPContextSwitch.asm
@@ -21,15 +21,14 @@ section .text
;; rcx: Stack Pointer
;; rdx: SMP core address.
rt_do_context_switch:
- push rax
+ push rcx
call _hal_switch_context
- pop rax
+ pop rcx
;; Now grab newly allocated process's stack frame.
-
push rax
call _hal_leak_current_context
- mov rax, r9
+ mov r9, rax
pop rax
;; Take care of context switching within AP.