summaryrefslogtreecommitdiffhomepage
path: root/Kernel/HALKit
diff options
context:
space:
mode:
authorAmlal <amlalelmahrouss@icloud.com>2024-06-13 06:32:06 +0000
committerAmlal <amlalelmahrouss@icloud.com>2024-06-13 06:32:06 +0000
commit36ff25861676cd1f5fb94b901fa59b015c614bc5 (patch)
tree92d68c0e4ba1eeb0d608a917bfdc587909260e13 /Kernel/HALKit
parent4e75e05a20ddd0dbca982e8f3bc2ea8043ed3a3f (diff)
parenta0b3442fe9978093326dc29d0938f1116eadd147 (diff)
Merged in MHR-23 (pull request #15)
MHR-23
Diffstat (limited to 'Kernel/HALKit')
-rw-r--r--Kernel/HALKit/64x0/HalVirtualMemory.cxx2
-rw-r--r--Kernel/HALKit/64x0/ReadMe.md2
-rw-r--r--Kernel/HALKit/AMD64/CPUID.hxx2
-rw-r--r--Kernel/HALKit/AMD64/HalACPIFactoryInterface.cxx2
-rw-r--r--Kernel/HALKit/AMD64/HalControlRegister.s2
-rw-r--r--Kernel/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cpp2
-rw-r--r--Kernel/HALKit/AMD64/HalCoreMultiProcessingAMD64.cpp136
-rw-r--r--Kernel/HALKit/AMD64/HalDebugOutput.cxx2
-rw-r--r--Kernel/HALKit/AMD64/HalDebugPort.cxx2
-rw-r--r--Kernel/HALKit/AMD64/HalDescriptorLoader.cpp2
-rw-r--r--Kernel/HALKit/AMD64/HalHardwareMP.cpp2
-rw-r--r--Kernel/HALKit/AMD64/HalInstallTIB.asm2
-rw-r--r--Kernel/HALKit/AMD64/HalInterruptAPI.asm52
-rw-r--r--Kernel/HALKit/AMD64/HalKernelMain.cxx13
-rw-r--r--Kernel/HALKit/AMD64/HalKernelMouse.cxx8
-rw-r--r--Kernel/HALKit/AMD64/HalNewBoot.asm2
-rw-r--r--Kernel/HALKit/AMD64/HalPageAlloc.cpp2
-rw-r--r--Kernel/HALKit/AMD64/HalPageAlloc.hpp2
-rw-r--r--Kernel/HALKit/AMD64/HalProcessor.cpp2
-rw-r--r--Kernel/HALKit/AMD64/HalSMPCore.cxx2
-rw-r--r--Kernel/HALKit/AMD64/HalSMPCoreManager.asm65
-rw-r--r--Kernel/HALKit/AMD64/Hypervisor.hpp2
-rw-r--r--Kernel/HALKit/AMD64/PCI/Database.cxx2
-rw-r--r--Kernel/HALKit/AMD64/PCI/Device.cxx2
-rw-r--r--Kernel/HALKit/AMD64/PCI/Dma.cxx2
-rw-r--r--Kernel/HALKit/AMD64/PCI/Express.cxx2
-rw-r--r--Kernel/HALKit/AMD64/PCI/IO.cxx2
-rw-r--r--Kernel/HALKit/AMD64/PCI/Iterator.cxx2
-rw-r--r--Kernel/HALKit/AMD64/PCI/PCI.cxx2
-rw-r--r--Kernel/HALKit/AMD64/Processor.hpp2
-rw-r--r--Kernel/HALKit/AMD64/Storage/AHCI.cxx4
-rw-r--r--Kernel/HALKit/AMD64/Storage/ATA-DMA.cxx4
-rw-r--r--Kernel/HALKit/AMD64/Storage/ATA-PIO.cxx4
-rw-r--r--Kernel/HALKit/ARM64/APM/.gitkeep (renamed from Kernel/HALKit/ARM64/ACPI/.gitkeep)0
-rw-r--r--Kernel/HALKit/ARM64/ReadMe.md5
-rw-r--r--Kernel/HALKit/AXP/CoreSyscallHandlerDEC.cpp2
-rw-r--r--Kernel/HALKit/AXP/Processor.hpp2
-rw-r--r--Kernel/HALKit/POWER/HalContextSwitchPowerPC.s2
-rw-r--r--Kernel/HALKit/POWER/HalHardware.cxx2
-rw-r--r--Kernel/HALKit/POWER/HalHart.cxx2
-rw-r--r--Kernel/HALKit/POWER/HalSerialPort.cxx2
-rw-r--r--Kernel/HALKit/POWER/HalStartSequence.s2
-rw-r--r--Kernel/HALKit/POWER/HalThread.cxx2
-rw-r--r--Kernel/HALKit/POWER/HalVirtualMemory.cxx2
-rw-r--r--Kernel/HALKit/POWER/Hart.hxx2
-rw-r--r--Kernel/HALKit/POWER/MBCI/HalMBCIHost.cxx2
-rw-r--r--Kernel/HALKit/POWER/Processor.hpp2
-rw-r--r--Kernel/HALKit/POWER/ppc-cpu.h2
-rw-r--r--Kernel/HALKit/RISCV/Hart.hxx2
49 files changed, 291 insertions, 78 deletions
diff --git a/Kernel/HALKit/64x0/HalVirtualMemory.cxx b/Kernel/HALKit/64x0/HalVirtualMemory.cxx
index eec86fc2..bb4357f4 100644
--- a/Kernel/HALKit/64x0/HalVirtualMemory.cxx
+++ b/Kernel/HALKit/64x0/HalVirtualMemory.cxx
@@ -1,6 +1,6 @@
/* -------------------------------------------
- Copyright SoftwareLabs
+ Copyright Zeta Electronics Corporation
------------------------------------------- */
diff --git a/Kernel/HALKit/64x0/ReadMe.md b/Kernel/HALKit/64x0/ReadMe.md
index 6744f602..a22d0385 100644
--- a/Kernel/HALKit/64x0/ReadMe.md
+++ b/Kernel/HALKit/64x0/ReadMe.md
@@ -1,4 +1,4 @@
64x0 Hardware Abstraction Layer
-- Supported CPU: SoftwareLabs 64x0
+- Supported CPU: Zeta Electronics Corporation 64x0
- Supported Firmware: CoreBoot \ No newline at end of file
diff --git a/Kernel/HALKit/AMD64/CPUID.hxx b/Kernel/HALKit/AMD64/CPUID.hxx
index 976a521e..602b2466 100644
--- a/Kernel/HALKit/AMD64/CPUID.hxx
+++ b/Kernel/HALKit/AMD64/CPUID.hxx
@@ -1,6 +1,6 @@
/* -------------------------------------------
- Copyright SoftwareLabs
+ Copyright Zeta Electronics Corporation
File: CPUID.hxx
Purpose: CPUID flags.
diff --git a/Kernel/HALKit/AMD64/HalACPIFactoryInterface.cxx b/Kernel/HALKit/AMD64/HalACPIFactoryInterface.cxx
index 14241f60..057ba61b 100644
--- a/Kernel/HALKit/AMD64/HalACPIFactoryInterface.cxx
+++ b/Kernel/HALKit/AMD64/HalACPIFactoryInterface.cxx
@@ -1,6 +1,6 @@
/* -------------------------------------------
- Copyright SoftwareLabs
+ Copyright Zeta Electronics Corporation
------------------------------------------- */
diff --git a/Kernel/HALKit/AMD64/HalControlRegister.s b/Kernel/HALKit/AMD64/HalControlRegister.s
index 7798ea09..20eda96f 100644
--- a/Kernel/HALKit/AMD64/HalControlRegister.s
+++ b/Kernel/HALKit/AMD64/HalControlRegister.s
@@ -1,6 +1,6 @@
/* -------------------------------------------
- Copyright SoftwareLabs
+ Copyright Zeta Electronics Corporation
------------------------------------------- */
diff --git a/Kernel/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cpp b/Kernel/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cpp
index 6d831d3b..5f64cc20 100644
--- a/Kernel/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cpp
+++ b/Kernel/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cpp
@@ -1,6 +1,6 @@
/* -------------------------------------------
- Copyright SoftwareLabs
+ Copyright Zeta Electronics Corporation
------------------------------------------- */
diff --git a/Kernel/HALKit/AMD64/HalCoreMultiProcessingAMD64.cpp b/Kernel/HALKit/AMD64/HalCoreMultiProcessingAMD64.cpp
index a184efc2..f15faf3c 100644
--- a/Kernel/HALKit/AMD64/HalCoreMultiProcessingAMD64.cpp
+++ b/Kernel/HALKit/AMD64/HalCoreMultiProcessingAMD64.cpp
@@ -1,6 +1,6 @@
/* -------------------------------------------
- Copyright SoftwareLabs
+ Copyright Zeta Electronics Corporation
------------------------------------------- */
@@ -8,12 +8,22 @@
#include <HALKit/AMD64/Processor.hpp>
#include <NewKit/KernelCheck.hpp>
#include <ArchKit/ArchKit.hpp>
+#include <KernelKit/Semaphore.hpp>
+#include <KernelKit/ProcessScheduler.hxx>
#define kAPIC_ICR_Low 0x300
#define kAPIC_ICR_High 0x310
#define kAPIC_SIPI_Vector 0x00500
#define kAPIC_EIPI_Vector 0x00400
+/// @brief This symbol is the kernel main symbol.
+EXTERN_C void KeMain();
+
+/// @brief assembly routine. internal use only.
+EXTERN_C void _hal_enable_smp(void);
+
+/// @note: _hal_switch_context
+
///////////////////////////////////////////////////////////////////////////////////////
//! NOTE: fGSI stands 'Field Global System Interrupt'
@@ -102,9 +112,22 @@ namespace NewOS::HAL
UIntPtr Address;
};
+ STATIC Void hal_switch_context(HAL::StackFramePtr stackFrame);
+
///////////////////////////////////////////////////////////////////////////////////////
- STATIC MadtType* kApicInfoBlock = nullptr;
+ STATIC MadtType* kApicInfoBlock = nullptr;
+ STATIC UIntPtr kApicMadtAddresses[255] = {0};
+ STATIC SizeT kApicMadtAddressesCount = 0UL;
+ STATIC UIntPtr cBaseAddressAPIC = 0xFEE00000;
+
+ /// @brief this will help us schedule our cores.
+ STATIC Boolean* cProgramInitialized = nullptr;
+
+ enum
+ {
+ cAPICEOI = 0xb0,
+ };
///////////////////////////////////////////////////////////////////////////////////////
@@ -119,6 +142,8 @@ namespace NewOS::HAL
NewOS::ke_dma_write(targetAddress, kAPIC_ICR_Low, kAPIC_SIPI_Vector | vector);
}
+ EXTERN_C Void _hal_spin_core(Void);
+
/// @brief Send end IPI for CPU.
/// @param apicId
/// @param vector
@@ -130,6 +155,63 @@ namespace NewOS::HAL
NewOS::ke_dma_write(targetAddress, kAPIC_ICR_Low, kAPIC_EIPI_Vector | vector);
}
+ STATIC HAL::StackFramePtr cFramePtr = nullptr;
+
+ EXTERN_C Void hal_apic_acknowledge_cont(Void)
+ {
+ kcout << "newoskrnl: finish kernel init... \r";
+
+ if (cProgramInitialized &&
+ *cProgramInitialized)
+ {
+ *cProgramInitialized = false;
+
+ kcout << "newoskrnl: putting thread to sleep...\r";
+
+ _hal_spin_core();
+ }
+ else
+ {
+ KeMain();
+
+ _hal_spin_core();
+ }
+ }
+
+ EXTERN_C StackFramePtr _hal_leak_current_context(Void)
+ {
+ return cFramePtr;
+ }
+
+ EXTERN_C Void hal_apic_acknowledge(Void)
+ {
+ hal_apic_acknowledge_cont();
+ }
+
+ EXTERN_C Void _hal_switch_context(HAL::StackFramePtr stackFrame)
+ {
+ hal_switch_context(stackFrame);
+ }
+
+ STATIC Void hal_switch_context(HAL::StackFramePtr stackFrame)
+ {
+ Semaphore sem;
+ while (sem.IsLocked())
+ {
+ }
+
+ sem.Lock(&ProcessScheduler::The().Leak().GetCurrent().Leak());
+
+ cFramePtr = stackFrame;
+
+ /// yes the exception field contains the core id.
+ hal_send_start_ipi(stackFrame->Exception, 0x40, cBaseAddressAPIC);
+
+ sem.Unlock();
+ }
+
+ /// @brief Fetch and enable cores inside main CPU.
+ /// @param rsdPtr RSD PTR structure.
Void hal_system_get_cores(voidPtr rsdPtr)
{
auto acpi = ACPIFactoryInterface(rsdPtr);
@@ -139,20 +221,50 @@ namespace NewOS::HAL
{
MadtType* madt = (MadtType*)kApicMadt;
- constexpr auto cMaxProbableCores = 4;
+ constexpr auto cMaxProbableCores = 4; // the amount of cores we want.
+ constexpr auto cStartAt = 0; // start here to avoid boot core.
+
+ for (SizeT coreAt = cStartAt; coreAt < cMaxProbableCores; ++coreAt)
+ {
+ if (madt->MadtRecords[coreAt].Flags == kThreadLAPIC) // if local apic.
+ {
+ MadtType::MadtAddress& madtRecord = madt->MadtRecords[coreAt];
+
+ // then register as a core for scheduler.
+ kcout << "newoskrnl: register core as scheduler thread.\r";
+
+ kApicMadtAddresses[kApicMadtAddressesCount] = madtRecord.Address;
+ ++kApicMadtAddressesCount;
+ }
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ /// Start local APIC now.
+ ///////////////////////////////////////////////////////////////////////////
+
+ auto flagsSet = NewOS::ke_dma_read(cBaseAddressAPIC, 0xF0); // SVR register.
+
+ // enable APIC.
+ flagsSet |= 0x100;
+
+ NewOS::ke_dma_write(cBaseAddressAPIC, 0xF0, flagsSet);
+
+ /// Set sprurious interrupt vector.
+ NewOS::ke_dma_write(cBaseAddressAPIC, 0xF0, 0x100 | 0xFF);
+
+ // highest task priority. for our realtime kernel.
+ NewOS::ke_dma_write(cBaseAddressAPIC, 0x21, 0);
+
+ cProgramInitialized = new Boolean(true);
+
+ constexpr auto cWhereToInterrupt = 0x40;
+ constexpr auto cWhatCore = 1;
- for (SizeT i = 0; i < cMaxProbableCores; ++i)
- {
- if (madt->MadtRecords[i].Flags == 0x01) // if local apic.
- {
- // then register as a core for scheduler.
- kcout << "newoskrnl: register core as scheduler thread.\r";
- }
- }
+ hal_send_start_ipi(cWhatCore, cWhereToInterrupt, cBaseAddressAPIC);
}
else
{
- kcout << "newoskrnl: APIC is not present! it is a vital component.\r";
+ kcout << "newoskrnl: APIC is not present! it is a vital component to enable SMP.\r";
ke_stop(RUNTIME_CHECK_FAILED);
}
}
diff --git a/Kernel/HALKit/AMD64/HalDebugOutput.cxx b/Kernel/HALKit/AMD64/HalDebugOutput.cxx
index 22d5c072..25c1546e 100644
--- a/Kernel/HALKit/AMD64/HalDebugOutput.cxx
+++ b/Kernel/HALKit/AMD64/HalDebugOutput.cxx
@@ -1,6 +1,6 @@
/* -------------------------------------------
- Copyright SoftwareLabs
+ Copyright Zeta Electronics Corporation
------------------------------------------- */
diff --git a/Kernel/HALKit/AMD64/HalDebugPort.cxx b/Kernel/HALKit/AMD64/HalDebugPort.cxx
index bc85746d..2644e247 100644
--- a/Kernel/HALKit/AMD64/HalDebugPort.cxx
+++ b/Kernel/HALKit/AMD64/HalDebugPort.cxx
@@ -1,6 +1,6 @@
/* -------------------------------------------
- Copyright SoftwareLabs
+ Copyright Zeta Electronics Corporation
------------------------------------------- */
diff --git a/Kernel/HALKit/AMD64/HalDescriptorLoader.cpp b/Kernel/HALKit/AMD64/HalDescriptorLoader.cpp
index 253c2f41..48f57cc0 100644
--- a/Kernel/HALKit/AMD64/HalDescriptorLoader.cpp
+++ b/Kernel/HALKit/AMD64/HalDescriptorLoader.cpp
@@ -1,6 +1,6 @@
/* -------------------------------------------
- Copyright SoftwareLabs
+ Copyright Zeta Electronics Corporation
------------------------------------------- */
diff --git a/Kernel/HALKit/AMD64/HalHardwareMP.cpp b/Kernel/HALKit/AMD64/HalHardwareMP.cpp
index 9c034362..92e075aa 100644
--- a/Kernel/HALKit/AMD64/HalHardwareMP.cpp
+++ b/Kernel/HALKit/AMD64/HalHardwareMP.cpp
@@ -1,6 +1,6 @@
/* -------------------------------------------
- Copyright SoftwareLabs
+ Copyright Zeta Electronics Corporation
------------------------------------------- */
diff --git a/Kernel/HALKit/AMD64/HalInstallTIB.asm b/Kernel/HALKit/AMD64/HalInstallTIB.asm
index a5f3ef73..f53fb14e 100644
--- a/Kernel/HALKit/AMD64/HalInstallTIB.asm
+++ b/Kernel/HALKit/AMD64/HalInstallTIB.asm
@@ -2,7 +2,7 @@
;; * ========================================================
;; *
;; * NewOS
-;; * Copyright SoftwareLabs, all rights reserved.
+;; * Copyright Zeta Electronics Corporation, all rights reserved.
;; *
;; * ========================================================
;; */
diff --git a/Kernel/HALKit/AMD64/HalInterruptAPI.asm b/Kernel/HALKit/AMD64/HalInterruptAPI.asm
index 875a1abc..ef5a8319 100644
--- a/Kernel/HALKit/AMD64/HalInterruptAPI.asm
+++ b/Kernel/HALKit/AMD64/HalInterruptAPI.asm
@@ -1,7 +1,7 @@
;; /*
;; * ---------------------------------------------------
;; *
-;; * Copyright SoftwareLabs, all rights reserved.
+;; * Copyright Zeta Electronics Corporation, all rights reserved.
;; *
;; * File: HalInterruptAPI.asm
;; * Purpose: Interrupt routing, redirect raw interrupts into their handlers.
@@ -14,7 +14,7 @@
%define kInterruptId 0x21
%macro IntExp 1
-global __NEW_INT_%1
+global __NEW_INT_%1
__NEW_INT_%1:
cld
@@ -22,7 +22,7 @@ __NEW_INT_%1:
%endmacro
%macro IntNormal 1
-global __NEW_INT_%1
+global __NEW_INT_%1
__NEW_INT_%1:
cld
@@ -100,7 +100,7 @@ __NEW_INT_14:
sti
iretq
-
+
IntNormal 15
IntNormal 16
IntExp 17
@@ -120,7 +120,49 @@ IntExp 30
IntNormal 31
-IntNormal 32
+[extern hal_apic_acknowledge]
+
+__NEW_INT_32:
+ 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
+
+ jmp hal_apic_acknowledge
+
+ 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
+
+ ;; tell there local apic that we're done.
+ mov dword [0xFEE00000 + 0xB0], eax ; LAPIC_EOI
+
+ iretq
IntNormal 33
diff --git a/Kernel/HALKit/AMD64/HalKernelMain.cxx b/Kernel/HALKit/AMD64/HalKernelMain.cxx
index 3136bf76..708004b3 100644
--- a/Kernel/HALKit/AMD64/HalKernelMain.cxx
+++ b/Kernel/HALKit/AMD64/HalKernelMain.cxx
@@ -1,11 +1,11 @@
/* -------------------------------------------
- Copyright SoftwareLabs
+ Copyright Zeta Electronics Corporation
------------------------------------------- */
#include <ArchKit/ArchKit.hpp>
-#include <Builtins/Toolbox/Toolbox.hxx>
+#include <Builtins/GX/GX>
#include <FirmwareKit/Handover.hxx>
#include <KernelKit/FileManager.hpp>
#include <KernelKit/Framebuffer.hpp>
@@ -16,7 +16,6 @@
#include <NewKit/Json.hpp>
EXTERN_C NewOS::VoidPtr kInterruptVectorTable[];
-EXTERN_C void AppMain();
namespace NewOS::HAL
{
@@ -77,9 +76,9 @@ EXTERN_C void hal_init_platform(
NewOS::HAL::hal_system_get_cores(kHandoverHeader->f_HardwareTables.f_RsdPtr);
- /// END POST
+ NewOS::kcout << "newoskrnl: We're done here...\r";
- AppMain();
-
- NewOS::ke_stop(RUNTIME_CHECK_BOOTSTRAP);
+ while (true)
+ {
+ }
}
diff --git a/Kernel/HALKit/AMD64/HalKernelMouse.cxx b/Kernel/HALKit/AMD64/HalKernelMouse.cxx
index 1e1ddd5b..8dbd328a 100644
--- a/Kernel/HALKit/AMD64/HalKernelMouse.cxx
+++ b/Kernel/HALKit/AMD64/HalKernelMouse.cxx
@@ -1,12 +1,12 @@
/* -------------------------------------------
- Copyright SoftwareLabs
+ Copyright Zeta Electronics Corporation
------------------------------------------- */
#include <Builtins/PS2/PS2MouseInterface.hxx>
-#include <Builtins/Toolbox/Toolbox.hxx>
-#include <Builtins/Toolbox/Rsrc/Cursor.rsrc>
+#include <Builtins/GX/GX>
+#include <Builtins/GX/Rsrc/Cursor.rsrc>
#include <KernelKit/Framebuffer.hpp>
#include <NewKit/Defines.hpp>
@@ -23,7 +23,7 @@ STATIC NewOS::PS2MouseInterface kMousePS2;
STATIC NewOS::Char kMousePacket[4] = {};
STATIC NewOS::Boolean kMousePacketReady = false;
-STATIC ToolboxInitRsrc();
+STATIC GXInit();
#define kPS2Leftbutton 0b00000001
#define kPS2Middlebutton 0b00000010
diff --git a/Kernel/HALKit/AMD64/HalNewBoot.asm b/Kernel/HALKit/AMD64/HalNewBoot.asm
index 7c60d363..3de6f38c 100644
--- a/Kernel/HALKit/AMD64/HalNewBoot.asm
+++ b/Kernel/HALKit/AMD64/HalNewBoot.asm
@@ -2,7 +2,7 @@
;; * ========================================================
;; *
;; * NewOS
-;; * Copyright SoftwareLabs, all rights reserved.
+;; * Copyright Zeta Electronics Corporation, all rights reserved.
;; *
;; * ========================================================
;; */
diff --git a/Kernel/HALKit/AMD64/HalPageAlloc.cpp b/Kernel/HALKit/AMD64/HalPageAlloc.cpp
index 4658a8aa..ac043cff 100644
--- a/Kernel/HALKit/AMD64/HalPageAlloc.cpp
+++ b/Kernel/HALKit/AMD64/HalPageAlloc.cpp
@@ -1,6 +1,6 @@
/* -------------------------------------------
- Copyright SoftwareLabs
+ Copyright Zeta Electronics Corporation
------------------------------------------- */
diff --git a/Kernel/HALKit/AMD64/HalPageAlloc.hpp b/Kernel/HALKit/AMD64/HalPageAlloc.hpp
index cede1b41..29947f2f 100644
--- a/Kernel/HALKit/AMD64/HalPageAlloc.hpp
+++ b/Kernel/HALKit/AMD64/HalPageAlloc.hpp
@@ -1,6 +1,6 @@
/* -------------------------------------------
- Copyright SoftwareLabs
+ Copyright Zeta Electronics Corporation
------------------------------------------- */
diff --git a/Kernel/HALKit/AMD64/HalProcessor.cpp b/Kernel/HALKit/AMD64/HalProcessor.cpp
index 8cbfba6a..0aa69dae 100644
--- a/Kernel/HALKit/AMD64/HalProcessor.cpp
+++ b/Kernel/HALKit/AMD64/HalProcessor.cpp
@@ -1,6 +1,6 @@
/* -------------------------------------------
- Copyright SoftwareLabs
+ Copyright Zeta Electronics Corporation
------------------------------------------- */
diff --git a/Kernel/HALKit/AMD64/HalSMPCore.cxx b/Kernel/HALKit/AMD64/HalSMPCore.cxx
index 7aa13068..34061b09 100644
--- a/Kernel/HALKit/AMD64/HalSMPCore.cxx
+++ b/Kernel/HALKit/AMD64/HalSMPCore.cxx
@@ -1,6 +1,6 @@
/* -------------------------------------------
- Copyright SoftwareLabs
+ Copyright Zeta Electronics Corporation
------------------------------------------- */
diff --git a/Kernel/HALKit/AMD64/HalSMPCoreManager.asm b/Kernel/HALKit/AMD64/HalSMPCoreManager.asm
index 18f80398..c4042b50 100644
--- a/Kernel/HALKit/AMD64/HalSMPCoreManager.asm
+++ b/Kernel/HALKit/AMD64/HalSMPCoreManager.asm
@@ -2,7 +2,7 @@
;; * ========================================================
;; *
;; * NewOS
-;; * Copyright SoftwareLabs, all rights reserved.
+;; * Copyright Zeta Electronics Corporation, all rights reserved.
;; *
;; * ========================================================
;; */
@@ -11,6 +11,10 @@
[global rt_get_current_context]
[global rt_do_context_switch]
+[global _hal_enable_smp]
+[global _hal_spin_core]
+[extern _hal_switch_context]
+[extern _hal_leak_current_context]
section .text
@@ -18,9 +22,66 @@ 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
+
+ jmp _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
+ jmp _hal_leak_current_context
+ mov rdx, rax
+ pop rdx
retfq
+
+;; @brief enables a smp core to run.
+_hal_enable_smp:
+; 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
+ or rax, rdx
+ wrmsr
+ ret
+
+_hal_spin_core:
+ jmp $
+ ret
diff --git a/Kernel/HALKit/AMD64/Hypervisor.hpp b/Kernel/HALKit/AMD64/Hypervisor.hpp
index ad2b69fd..05e127c2 100644
--- a/Kernel/HALKit/AMD64/Hypervisor.hpp
+++ b/Kernel/HALKit/AMD64/Hypervisor.hpp
@@ -1,6 +1,6 @@
/* -------------------------------------------
- Copyright SoftwareLabs
+ Copyright Zeta Electronics Corporation
------------------------------------------- */
diff --git a/Kernel/HALKit/AMD64/PCI/Database.cxx b/Kernel/HALKit/AMD64/PCI/Database.cxx
index 77c735fb..631ed79f 100644
--- a/Kernel/HALKit/AMD64/PCI/Database.cxx
+++ b/Kernel/HALKit/AMD64/PCI/Database.cxx
@@ -1,6 +1,6 @@
/* -------------------------------------------
- Copyright SoftwareLabs
+ Copyright Zeta Electronics Corporation
------------------------------------------- */
diff --git a/Kernel/HALKit/AMD64/PCI/Device.cxx b/Kernel/HALKit/AMD64/PCI/Device.cxx
index 0574b06a..9e18581d 100644
--- a/Kernel/HALKit/AMD64/PCI/Device.cxx
+++ b/Kernel/HALKit/AMD64/PCI/Device.cxx
@@ -1,6 +1,6 @@
/* -------------------------------------------
- Copyright SoftwareLabs
+ Copyright Zeta Electronics Corporation
------------------------------------------- */
diff --git a/Kernel/HALKit/AMD64/PCI/Dma.cxx b/Kernel/HALKit/AMD64/PCI/Dma.cxx
index 4ac294df..e58ea175 100644
--- a/Kernel/HALKit/AMD64/PCI/Dma.cxx
+++ b/Kernel/HALKit/AMD64/PCI/Dma.cxx
@@ -1,6 +1,6 @@
/* -------------------------------------------
- Copyright SoftwareLabs
+ Copyright Zeta Electronics Corporation
------------------------------------------- */
diff --git a/Kernel/HALKit/AMD64/PCI/Express.cxx b/Kernel/HALKit/AMD64/PCI/Express.cxx
index 53b9c579..daa3f0ba 100644
--- a/Kernel/HALKit/AMD64/PCI/Express.cxx
+++ b/Kernel/HALKit/AMD64/PCI/Express.cxx
@@ -1,6 +1,6 @@
/* -------------------------------------------
- Copyright SoftwareLabs
+ Copyright Zeta Electronics Corporation
------------------------------------------- */
diff --git a/Kernel/HALKit/AMD64/PCI/IO.cxx b/Kernel/HALKit/AMD64/PCI/IO.cxx
index d506ad5f..24ee05b3 100644
--- a/Kernel/HALKit/AMD64/PCI/IO.cxx
+++ b/Kernel/HALKit/AMD64/PCI/IO.cxx
@@ -1,6 +1,6 @@
/* -------------------------------------------
- Copyright SoftwareLabs
+ Copyright Zeta Electronics Corporation
------------------------------------------- */
diff --git a/Kernel/HALKit/AMD64/PCI/Iterator.cxx b/Kernel/HALKit/AMD64/PCI/Iterator.cxx
index d1ac4aef..8675f171 100644
--- a/Kernel/HALKit/AMD64/PCI/Iterator.cxx
+++ b/Kernel/HALKit/AMD64/PCI/Iterator.cxx
@@ -1,6 +1,6 @@
/* -------------------------------------------
- Copyright SoftwareLabs
+ Copyright Zeta Electronics Corporation
------------------------------------------- */
diff --git a/Kernel/HALKit/AMD64/PCI/PCI.cxx b/Kernel/HALKit/AMD64/PCI/PCI.cxx
index b22ba951..eaf7f20a 100644
--- a/Kernel/HALKit/AMD64/PCI/PCI.cxx
+++ b/Kernel/HALKit/AMD64/PCI/PCI.cxx
@@ -1,6 +1,6 @@
/* -------------------------------------------
- Copyright SoftwareLabs
+ Copyright Zeta Electronics Corporation
------------------------------------------- */
diff --git a/Kernel/HALKit/AMD64/Processor.hpp b/Kernel/HALKit/AMD64/Processor.hpp
index 4916d845..c52fecdf 100644
--- a/Kernel/HALKit/AMD64/Processor.hpp
+++ b/Kernel/HALKit/AMD64/Processor.hpp
@@ -1,6 +1,6 @@
/* -------------------------------------------
- Copyright SoftwareLabs
+ Copyright Zeta Electronics Corporation
File: Prcoessor.hxx
Purpose: AMD64 processor abstraction.
diff --git a/Kernel/HALKit/AMD64/Storage/AHCI.cxx b/Kernel/HALKit/AMD64/Storage/AHCI.cxx
index a8045617..587c64cb 100644
--- a/Kernel/HALKit/AMD64/Storage/AHCI.cxx
+++ b/Kernel/HALKit/AMD64/Storage/AHCI.cxx
@@ -1,6 +1,6 @@
/* -------------------------------------------
- Copyright SoftwareLabs
+ Copyright Zeta Electronics Corporation
------------------------------------------- */
@@ -11,7 +11,7 @@
* @version 0.1
* @date 2024-02-02
*
- * @copyright Copyright (c) SoftwareLabs
+ * @copyright Copyright (c) Zeta Electronics Corporation
*
*/
diff --git a/Kernel/HALKit/AMD64/Storage/ATA-DMA.cxx b/Kernel/HALKit/AMD64/Storage/ATA-DMA.cxx
index 1b83874f..fea103dd 100644
--- a/Kernel/HALKit/AMD64/Storage/ATA-DMA.cxx
+++ b/Kernel/HALKit/AMD64/Storage/ATA-DMA.cxx
@@ -1,6 +1,6 @@
/* -------------------------------------------
- Copyright SoftwareLabs
+ Copyright Zeta Electronics Corporation
------------------------------------------- */
@@ -11,7 +11,7 @@
* @version 0.1
* @date 2024-02-02
*
- * @copyright Copyright (c) SoftwareLabs
+ * @copyright Copyright (c) Zeta Electronics Corporation
*
*/
diff --git a/Kernel/HALKit/AMD64/Storage/ATA-PIO.cxx b/Kernel/HALKit/AMD64/Storage/ATA-PIO.cxx
index bc40e4f2..e4ab1367 100644
--- a/Kernel/HALKit/AMD64/Storage/ATA-PIO.cxx
+++ b/Kernel/HALKit/AMD64/Storage/ATA-PIO.cxx
@@ -1,6 +1,6 @@
/* -------------------------------------------
- Copyright SoftwareLabs
+ Copyright Zeta Electronics Corporation
------------------------------------------- */
@@ -11,7 +11,7 @@
* @version 0.1
* @date 2024-02-02
*
- * @copyright Copyright (c) SoftwareLabs
+ * @copyright Copyright (c) Zeta Electronics Corporation
*
*/
diff --git a/Kernel/HALKit/ARM64/ACPI/.gitkeep b/Kernel/HALKit/ARM64/APM/.gitkeep
index e69de29b..e69de29b 100644
--- a/Kernel/HALKit/ARM64/ACPI/.gitkeep
+++ b/Kernel/HALKit/ARM64/APM/.gitkeep
diff --git a/Kernel/HALKit/ARM64/ReadMe.md b/Kernel/HALKit/ARM64/ReadMe.md
index 89679e18..d4d35a0b 100644
--- a/Kernel/HALKit/ARM64/ReadMe.md
+++ b/Kernel/HALKit/ARM64/ReadMe.md
@@ -1,4 +1,3 @@
-ARM64 Hardware Abstraction Layer
+# ARM64 Hardware Abstraction Layer
-- Supported CPU: Qualcomm CPU
-- Supported Firmware: EDK 2 \ No newline at end of file
+- Supported Firmware: CoreBoot \ No newline at end of file
diff --git a/Kernel/HALKit/AXP/CoreSyscallHandlerDEC.cpp b/Kernel/HALKit/AXP/CoreSyscallHandlerDEC.cpp
index c16722ba..ea0997ed 100644
--- a/Kernel/HALKit/AXP/CoreSyscallHandlerDEC.cpp
+++ b/Kernel/HALKit/AXP/CoreSyscallHandlerDEC.cpp
@@ -1,6 +1,6 @@
/* -------------------------------------------
- Copyright SoftwareLabs
+ Copyright Zeta Electronics Corporation
------------------------------------------- */
diff --git a/Kernel/HALKit/AXP/Processor.hpp b/Kernel/HALKit/AXP/Processor.hpp
index 768093b9..a3799ae7 100644
--- a/Kernel/HALKit/AXP/Processor.hpp
+++ b/Kernel/HALKit/AXP/Processor.hpp
@@ -1,6 +1,6 @@
/* -------------------------------------------
- Copyright SoftwareLabs
+ Copyright Zeta Electronics Corporation
------------------------------------------- */
diff --git a/Kernel/HALKit/POWER/HalContextSwitchPowerPC.s b/Kernel/HALKit/POWER/HalContextSwitchPowerPC.s
index 64558ae1..14d805db 100644
--- a/Kernel/HALKit/POWER/HalContextSwitchPowerPC.s
+++ b/Kernel/HALKit/POWER/HalContextSwitchPowerPC.s
@@ -1,6 +1,6 @@
/* -------------------------------------------
- Copyright SoftwareLabs
+ Copyright Zeta Electronics Corporation
------------------------------------------- */
diff --git a/Kernel/HALKit/POWER/HalHardware.cxx b/Kernel/HALKit/POWER/HalHardware.cxx
index fcded4d3..8dd0205c 100644
--- a/Kernel/HALKit/POWER/HalHardware.cxx
+++ b/Kernel/HALKit/POWER/HalHardware.cxx
@@ -1,6 +1,6 @@
/* -------------------------------------------
- Copyright SoftwareLabs
+ Copyright Zeta Electronics Corporation
------------------------------------------- */
diff --git a/Kernel/HALKit/POWER/HalHart.cxx b/Kernel/HALKit/POWER/HalHart.cxx
index 7af92cb1..16a26a3a 100644
--- a/Kernel/HALKit/POWER/HalHart.cxx
+++ b/Kernel/HALKit/POWER/HalHart.cxx
@@ -1,6 +1,6 @@
/* -------------------------------------------
- Copyright SoftwareLabs
+ Copyright Zeta Electronics Corporation
------------------------------------------- */
diff --git a/Kernel/HALKit/POWER/HalSerialPort.cxx b/Kernel/HALKit/POWER/HalSerialPort.cxx
index 0e34f7d0..86388b4c 100644
--- a/Kernel/HALKit/POWER/HalSerialPort.cxx
+++ b/Kernel/HALKit/POWER/HalSerialPort.cxx
@@ -1,6 +1,6 @@
/* -------------------------------------------
- Copyright SoftwareLabs
+ Copyright Zeta Electronics Corporation
------------------------------------------- */
diff --git a/Kernel/HALKit/POWER/HalStartSequence.s b/Kernel/HALKit/POWER/HalStartSequence.s
index fc969e9f..07cec350 100644
--- a/Kernel/HALKit/POWER/HalStartSequence.s
+++ b/Kernel/HALKit/POWER/HalStartSequence.s
@@ -1,6 +1,6 @@
/* -------------------------------------------
- Copyright SoftwareLabs
+ Copyright Zeta Electronics Corporation
------------------------------------------- */
diff --git a/Kernel/HALKit/POWER/HalThread.cxx b/Kernel/HALKit/POWER/HalThread.cxx
index 22503ad8..83f03373 100644
--- a/Kernel/HALKit/POWER/HalThread.cxx
+++ b/Kernel/HALKit/POWER/HalThread.cxx
@@ -1,6 +1,6 @@
/* -------------------------------------------
- Copyright SoftwareLabs
+ Copyright Zeta Electronics Corporation
------------------------------------------- */
diff --git a/Kernel/HALKit/POWER/HalVirtualMemory.cxx b/Kernel/HALKit/POWER/HalVirtualMemory.cxx
index 326d635a..a49ba63f 100644
--- a/Kernel/HALKit/POWER/HalVirtualMemory.cxx
+++ b/Kernel/HALKit/POWER/HalVirtualMemory.cxx
@@ -1,6 +1,6 @@
/* -------------------------------------------
- Copyright SoftwareLabs
+ Copyright Zeta Electronics Corporation
------------------------------------------- */
diff --git a/Kernel/HALKit/POWER/Hart.hxx b/Kernel/HALKit/POWER/Hart.hxx
index 04897d01..4e4a281b 100644
--- a/Kernel/HALKit/POWER/Hart.hxx
+++ b/Kernel/HALKit/POWER/Hart.hxx
@@ -1,6 +1,6 @@
/* -------------------------------------------
- Copyright SoftwareLabs
+ Copyright Zeta Electronics Corporation
File: Hart.hxx
Purpose: POWER hardware threads.
diff --git a/Kernel/HALKit/POWER/MBCI/HalMBCIHost.cxx b/Kernel/HALKit/POWER/MBCI/HalMBCIHost.cxx
index 79a29fac..8a24506a 100644
--- a/Kernel/HALKit/POWER/MBCI/HalMBCIHost.cxx
+++ b/Kernel/HALKit/POWER/MBCI/HalMBCIHost.cxx
@@ -1,6 +1,6 @@
/* -------------------------------------------
- Copyright SoftwareLabs
+ Copyright Zeta Electronics Corporation
------------------------------------------- */
diff --git a/Kernel/HALKit/POWER/Processor.hpp b/Kernel/HALKit/POWER/Processor.hpp
index ece50c44..af00b7af 100644
--- a/Kernel/HALKit/POWER/Processor.hpp
+++ b/Kernel/HALKit/POWER/Processor.hpp
@@ -1,6 +1,6 @@
/* -------------------------------------------
- Copyright SoftwareLabs
+ Copyright Zeta Electronics Corporation
Purpose: POWER processor header.
diff --git a/Kernel/HALKit/POWER/ppc-cpu.h b/Kernel/HALKit/POWER/ppc-cpu.h
index b7a96767..3855b85c 100644
--- a/Kernel/HALKit/POWER/ppc-cpu.h
+++ b/Kernel/HALKit/POWER/ppc-cpu.h
@@ -1,7 +1,7 @@
#ifndef __ASM_PPC_PROCESSOR_H
#define __ASM_PPC_PROCESSOR_H
-/// ! @note The NeWS cpu is based on the e500 with 64-bit extensions, much like the 970.
+/// ! @note The Zeta cpu is based on the e500 with 64-bit extensions, much like the 970.
/*
* Default implementation of macro that returns current
diff --git a/Kernel/HALKit/RISCV/Hart.hxx b/Kernel/HALKit/RISCV/Hart.hxx
index eb0fa258..17ec84a1 100644
--- a/Kernel/HALKit/RISCV/Hart.hxx
+++ b/Kernel/HALKit/RISCV/Hart.hxx
@@ -1,6 +1,6 @@
/* -------------------------------------------
- Copyright SoftwareLabs
+ Copyright Zeta Electronics Corporation
File: Hart.hxx
Purpose: RISC-V hardware threads.