summaryrefslogtreecommitdiffhomepage
path: root/Private/HALKit
diff options
context:
space:
mode:
authorAmlal <amlalelmahrouss@icloud.com>2024-04-22 08:37:14 +0000
committerAmlal <amlalelmahrouss@icloud.com>2024-04-22 08:37:14 +0000
commit09e1c9738bc5dce28a6e181ebc585f0dea01f109 (patch)
tree2df231f8601402147514572120f762c69bf5c84a /Private/HALKit
parent41cc598c501ee190385c041b2149eae228b24741 (diff)
parent76c0c6b21532aee82df5bd62cd886bc63d933899 (diff)
Merged in MHR-5 (pull request #1)
MHR-5
Diffstat (limited to 'Private/HALKit')
-rw-r--r--Private/HALKit/64x0/HalVirtualMemory.cxx6
-rw-r--r--Private/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cpp32
-rw-r--r--Private/HALKit/AMD64/HalCoreMultiProcessingAMD64.cpp4
-rw-r--r--Private/HALKit/AMD64/HalHardwareMP.cpp10
-rw-r--r--Private/HALKit/AMD64/HalKernelMain.cxx14
-rw-r--r--Private/HALKit/AMD64/Processor.hpp10
-rw-r--r--Private/HALKit/AMD64/Storage/ATA-PIO.cxx16
-rw-r--r--Private/HALKit/POWER/.gitkeep (renamed from Private/HALKit/PowerPC/.gitkeep)0
-rw-r--r--Private/HALKit/POWER/APM/.gitkeep (renamed from Private/HALKit/PowerPC/APM/.gitkeep)0
-rw-r--r--Private/HALKit/POWER/HalContextSwitchPowerPC.s28
-rw-r--r--Private/HALKit/POWER/HalHardware.cxx (renamed from Private/HALKit/PowerPC/HalHardware.cxx)2
-rw-r--r--Private/HALKit/POWER/HalHart.cxx (renamed from Private/HALKit/PowerPC/HalSMPManager.cxx)5
-rw-r--r--Private/HALKit/POWER/HalSerialPort.cxx (renamed from Private/HALKit/PowerPC/HalSerialPort.cxx)6
-rw-r--r--Private/HALKit/POWER/HalStartSequence.s14
-rw-r--r--Private/HALKit/POWER/HalThread.cxx (renamed from Private/HALKit/PowerPC/HalThread.cxx)2
-rw-r--r--Private/HALKit/POWER/HalVirtualMemory.cxx (renamed from Private/HALKit/PowerPC/HalVirtualMemory.cxx)9
-rw-r--r--Private/HALKit/POWER/Hart.hxx27
-rw-r--r--Private/HALKit/POWER/MBCI/.gitkeep (renamed from Private/HALKit/PowerPC/PCI/.gitkeep)0
-rw-r--r--Private/HALKit/POWER/MBCI/HalMBCIHost.cxx8
-rw-r--r--Private/HALKit/POWER/Processor.hpp (renamed from Private/HALKit/PowerPC/Processor.hpp)20
-rw-r--r--Private/HALKit/POWER/ppc-cpu.h (renamed from Private/HALKit/PowerPC/ppc-cpu.h)8
-rw-r--r--Private/HALKit/POWER/ppc-mmu.h (renamed from Private/HALKit/PowerPC/ppc-mmu.h)11
-rw-r--r--Private/HALKit/PowerPC/HalCoreContextSwitchPowerPC.s30
-rw-r--r--Private/HALKit/PowerPC/HalStartSequence.s6
-rw-r--r--Private/HALKit/PowerPC/Hart.hxx20
-rw-r--r--Private/HALKit/PowerPC/PCI/HalDevice.cxx1
26 files changed, 146 insertions, 143 deletions
diff --git a/Private/HALKit/64x0/HalVirtualMemory.cxx b/Private/HALKit/64x0/HalVirtualMemory.cxx
index 8fc08df0..2ae0f7ac 100644
--- a/Private/HALKit/64x0/HalVirtualMemory.cxx
+++ b/Private/HALKit/64x0/HalVirtualMemory.cxx
@@ -4,11 +4,11 @@
------------------------------------------- */
-#include <HALKit/PowerPC/Processor.hpp>
+#include <HALKit/POWER/Processor.hpp>
#include <KernelKit/DebugOutput.hpp>
using namespace NewOS;
-/// @brief Flush system TLB, looks like the PowerPC version, as it acts the same, no specific instruction for that.
+/// @brief Flush system TLB, looks like the POWER version, as it acts the same, no specific instruction for that.
/// @note The 88K MMU should be present in the die.
-EXTERN_C void hal_flush_tlb() { asm volatile("isync;invltlb;msync;isync"); }
+EXTERN_C void hal_flush_tlb() { asm volatile("invltlb"); }
diff --git a/Private/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cpp b/Private/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cpp
index aa9c0e47..99a66532 100644
--- a/Private/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cpp
+++ b/Private/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cpp
@@ -9,86 +9,86 @@
#include <NewKit/String.hpp>
/// @brief Handle GPF fault.
-/// @param rsp
+/// @param rsp
EXTERN_C void idt_handle_gpf(NewOS::UIntPtr rsp) {
MUST_PASS(NewOS::ProcessScheduler::Shared().Leak().GetCurrent());
- NewOS::kcout << "NewOS: Stack Pointer: "
+ NewOS::kcout << "New OS: Stack Pointer: "
<< NewOS::StringBuilder::FromInt("rsp{%}", rsp);
NewOS::kcout
- << "NewOS: General Protection Fault, caused by "
+ << "New OS: General Protection Fault, caused by "
<< NewOS::ProcessScheduler::Shared().Leak().GetCurrent().Leak().GetName();
NewOS::ProcessScheduler::Shared().Leak().GetCurrent().Leak().Crash();
}
/// @brief Handle the scheduler interrupt, raised from the HPET timer.
-/// @param rsp
+/// @param rsp
EXTERN_C void idt_handle_scheduler(NewOS::UIntPtr rsp) {
NewOS::kcout << NewOS::StringBuilder::FromInt("rsp{%}", rsp);
NewOS::kcout
- << "NewOS: Will be scheduled back later "
+ << "New OS: Will be scheduled back later "
<< NewOS::ProcessScheduler::Shared().Leak().GetCurrent().Leak().GetName()
<< NewOS::end_line();
/// schedule another process.
if (!NewOS::ProcessHelper::StartScheduling()) {
- NewOS::kcout << "NewOS: Continue schedule this process...\r\n";
+ NewOS::kcout << "New OS: Continue schedule this process...\r\n";
}
}
/// @brief Handle page fault.
-/// @param rsp
+/// @param rsp
EXTERN_C void idt_handle_pf(NewOS::UIntPtr rsp) {
MUST_PASS(NewOS::ProcessScheduler::Shared().Leak().GetCurrent());
NewOS::kcout << NewOS::StringBuilder::FromInt("rsp{%}", rsp);
NewOS::kcout
- << "NewOS: Segmentation Fault, caused by "
+ << "New OS: Segmentation Fault, caused by "
<< NewOS::ProcessScheduler::Shared().Leak().GetCurrent().Leak().GetName();
NewOS::ProcessScheduler::Shared().Leak().GetCurrent().Leak().Crash();
}
/// @brief Handle math fault.
-/// @param rsp
+/// @param rsp
EXTERN_C void idt_handle_math(NewOS::UIntPtr rsp) {
MUST_PASS(NewOS::ProcessScheduler::Shared().Leak().GetCurrent());
NewOS::kcout << NewOS::StringBuilder::FromInt("rsp{%}", rsp);
NewOS::kcout
- << "NewOS: Math error, caused by "
+ << "New OS: Math error, caused by "
<< NewOS::ProcessScheduler::Shared().Leak().GetCurrent().Leak().GetName();
NewOS::ProcessScheduler::Shared().Leak().GetCurrent().Leak().Crash();
}
/// @brief Handle any generic fault.
-/// @param rsp
+/// @param rsp
EXTERN_C void idt_handle_generic(NewOS::UIntPtr rsp) {
MUST_PASS(NewOS::ProcessScheduler::Shared().Leak().GetCurrent());
NewOS::kcout << NewOS::StringBuilder::FromInt("sp{%}", rsp);
NewOS::kcout
- << "NewOS: Execution error, caused by "
+ << "New OS: Execution error, caused by "
<< NewOS::ProcessScheduler::Shared().Leak().GetCurrent().Leak().GetName();
NewOS::ProcessScheduler::Shared().Leak().GetCurrent().Leak().Crash();
}
/// @brief Handle #UD fault.
-/// @param rsp
+/// @param rsp
EXTERN_C void idt_handle_ud(NewOS::UIntPtr rsp) {
MUST_PASS(NewOS::ProcessScheduler::Shared().Leak().GetCurrent());
- NewOS::kcout << "NewOS: Stack Pointer: "
+ NewOS::kcout << "New OS: Stack Pointer: "
<< NewOS::StringBuilder::FromInt("rsp{%}", rsp);
NewOS::kcout
- << "NewOS: Invalid interrupt, caused by "
+ << "New OS: Invalid interrupt, caused by "
<< NewOS::ProcessScheduler::Shared().Leak().GetCurrent().Leak().GetName();
NewOS::ProcessScheduler::Shared().Leak().GetCurrent().Leak().Crash();
-} \ No newline at end of file
+}
diff --git a/Private/HALKit/AMD64/HalCoreMultiProcessingAMD64.cpp b/Private/HALKit/AMD64/HalCoreMultiProcessingAMD64.cpp
index 98d64215..0761114d 100644
--- a/Private/HALKit/AMD64/HalCoreMultiProcessingAMD64.cpp
+++ b/Private/HALKit/AMD64/HalCoreMultiProcessingAMD64.cpp
@@ -92,14 +92,14 @@ STATIC MadtType* kApicInfoBlock = nullptr;
///////////////////////////////////////////////////////////////////////////////////////
void hal_system_get_cores(voidPtr rsdPtr) {
- kcout << "NewOS: Constructing ACPIFactoryInterface...\r\n";
+ kcout << "New OS: Constructing ACPIFactoryInterface...\r\n";
auto acpi = ACPIFactoryInterface(rsdPtr);
kApicMadt = acpi.Find(kApicSignature).Leak().Leak();
MUST_PASS(kApicMadt); // MADT must exist.
- kcout << "NewOS: Successfuly fetched the MADT!\r\n";
+ kcout << "New OS: Successfuly fetched the MADT!\r\n";
kApicInfoBlock = (MadtType*)kApicMadt;
}
diff --git a/Private/HALKit/AMD64/HalHardwareMP.cpp b/Private/HALKit/AMD64/HalHardwareMP.cpp
index 0e9f3022..135222b9 100644
--- a/Private/HALKit/AMD64/HalHardwareMP.cpp
+++ b/Private/HALKit/AMD64/HalHardwareMP.cpp
@@ -19,20 +19,12 @@ void rt_wakeup_thread(HAL::StackFrame* stack) {
HAL::rt_sti();
}
-/// @brief Hangs until RCX register is cleared.
-/// @param stack
-static void __rt_hang_proc(HAL::StackFrame* stack) {
- while (stack->Rcx == 1) {
- ;
- }
-}
-
/// @brief makes thread sleep.
/// hooks and hangs thread to prevent code from executing.
void rt_hang_thread(HAL::StackFrame* stack) {
HAL::rt_cli();
- __rt_hang_proc(stack);
+ stack->Rcx = 1;
HAL::rt_sti();
}
diff --git a/Private/HALKit/AMD64/HalKernelMain.cxx b/Private/HALKit/AMD64/HalKernelMain.cxx
index f6b8e957..57c37778 100644
--- a/Private/HALKit/AMD64/HalKernelMain.cxx
+++ b/Private/HALKit/AMD64/HalKernelMain.cxx
@@ -5,7 +5,6 @@
------------------------------------------- */
#include <ArchKit/ArchKit.hpp>
-#include <Builtins/Toolbox/Rsrc/Splash.rsrc>
#include <Builtins/Toolbox/Toolbox.hxx>
#include <FirmwareKit/Handover.hxx>
#include <KernelKit/FileManager.hpp>
@@ -17,7 +16,7 @@
#include <NewKit/Json.hpp>
EXTERN_C NewOS::VoidPtr kInterruptVectorTable[];
-EXTERN_C void RuntimeMain();
+EXTERN_C void AppMain();
namespace NewOS::HAL {
/// @brief Gets the system cores using the MADT.
@@ -74,16 +73,7 @@ EXTERN_C void hal_init_platform(
/// END POST
- ToolboxInitRsrc();
-
- ToolboxDrawRsrc(
- MahroussLogic, MAHROUSSLOGIC_HEIGHT, MAHROUSSLOGIC_WIDTH,
- ((kHandoverHeader->f_GOP.f_Width - MAHROUSSLOGIC_WIDTH) / 2),
- ((kHandoverHeader->f_GOP.f_Height - MAHROUSSLOGIC_HEIGHT) / 2));
-
- ToolboxClearRsrc();
-
- RuntimeMain();
+ AppMain();
NewOS::ke_stop(RUNTIME_CHECK_BOOTSTRAP);
}
diff --git a/Private/HALKit/AMD64/Processor.hpp b/Private/HALKit/AMD64/Processor.hpp
index 7e2624d7..70452d1d 100644
--- a/Private/HALKit/AMD64/Processor.hpp
+++ b/Private/HALKit/AMD64/Processor.hpp
@@ -26,11 +26,11 @@
#define IsActiveLow(FLG) (FLG & 2)
#define IsLevelTriggered(FLG) (FLG & 8)
-#define kInterruptGate 0x8E
-#define kTrapGate 0xEF
-#define kTaskGate 0b10001100
-#define kGdtCodeSelector 0x08
-#define kVirtualAddressStartOffset 0x100
+#define kInterruptGate (0x8E)
+#define kTrapGate (0xEF)
+#define kTaskGate (0b10001100)
+#define kGdtCodeSelector (0x08)
+#define kVirtualAddressStartOffset (0x100)
namespace NewOS {
namespace Detail::AMD64 {
diff --git a/Private/HALKit/AMD64/Storage/ATA-PIO.cxx b/Private/HALKit/AMD64/Storage/ATA-PIO.cxx
index ebced11c..3cbba6f7 100644
--- a/Private/HALKit/AMD64/Storage/ATA-PIO.cxx
+++ b/Private/HALKit/AMD64/Storage/ATA-PIO.cxx
@@ -72,7 +72,7 @@ ATAInit_Retry:
auto statRdy = In8(IO + ATA_REG_STATUS);
if (statRdy & ATA_SR_ERR) {
- kcout << "NewOS: ATA: Select error, not an IDE based hard-drive.\r\n";
+ kcout << "New OS: ATA: Select error, not an IDE based hard-drive.\r\n";
return false;
}
@@ -107,21 +107,21 @@ ATAInit_Retry:
/* differentiate ATA, ATAPI, SATA and SATAPI */
if (cl == 0x14 && ch == 0xEB) {
- kcout << "NewOS: PATAPI drive detected.\r\n";
+ kcout << "New OS: PATAPI drive detected.\r\n";
kATADeviceType = kATADevicePATA_PI;
}
if (cl == 0x69 && ch == 0x96) {
- kcout << "NewOS: SATAPI drive detected.\r\n";
+ kcout << "New OS: SATAPI drive detected.\r\n";
kATADeviceType = kATADeviceSATA_PI;
}
if (cl == 0x0 && ch == 0x0) {
- kcout << "NewOS: PATA drive detected.\r\n";
+ kcout << "New OS: PATA drive detected.\r\n";
kATADeviceType = kATADevicePATA;
}
if (cl == 0x3c && ch == 0xc3) {
- kcout << "NewOS: SATA drive detected.\r\n";
+ kcout << "New OS: SATA drive detected.\r\n";
kATADeviceType = kATADeviceSATA;
}
@@ -148,7 +148,7 @@ Void drv_std_read(UInt64 Lba, UInt16 IO, UInt8 Master, Char* Buf,
for (SizeT IndexOff = 0; IndexOff < Size; ++IndexOff) {
WideChar chr = In16(IO + ATA_REG_DATA);
-
+
Buf[IndexOff] = chr;
}
}
@@ -171,11 +171,11 @@ Void drv_std_write(UInt64 Lba, UInt16 IO, UInt8 Master, Char* Buf,
for (SizeT IndexOff = 0; IndexOff < Size; ++IndexOff) {
Out16(IO + ATA_REG_DATA, Buf[IndexOff]);
-
+
}
}
/// @check is ATA detected?
Boolean drv_std_detected(Void) { return kATADetected; }
-#endif /* ifdef __ATA_PIO__ */ \ No newline at end of file
+#endif /* ifdef __ATA_PIO__ */
diff --git a/Private/HALKit/PowerPC/.gitkeep b/Private/HALKit/POWER/.gitkeep
index e69de29b..e69de29b 100644
--- a/Private/HALKit/PowerPC/.gitkeep
+++ b/Private/HALKit/POWER/.gitkeep
diff --git a/Private/HALKit/PowerPC/APM/.gitkeep b/Private/HALKit/POWER/APM/.gitkeep
index e69de29b..e69de29b 100644
--- a/Private/HALKit/PowerPC/APM/.gitkeep
+++ b/Private/HALKit/POWER/APM/.gitkeep
diff --git a/Private/HALKit/POWER/HalContextSwitchPowerPC.s b/Private/HALKit/POWER/HalContextSwitchPowerPC.s
new file mode 100644
index 00000000..75c9f37a
--- /dev/null
+++ b/Private/HALKit/POWER/HalContextSwitchPowerPC.s
@@ -0,0 +1,28 @@
+/* -------------------------------------------
+
+ Copyright Mahrouss Logic
+
+------------------------------------------- */
+
+.align 4
+.type name, @function
+.text
+.globl rt_do_context_switch
+
+/* r3 (3) = assigner stack, r4 (4) = assignee stack */
+rt_do_context_switch:
+ lwz 0(%4), 0(%3)
+ lwz 4(%4), 4(%3)
+ lwz 8(%4), 8(%3)
+ lwz 12(%4), 12(%3)
+ lwz 14(%4), 14(%3)
+ lwz 18(%4), 18(%3)
+ lwz 22(%4), 22(%3)
+ lwz 24(%4), 24(%3)
+ lwz 28(%4), 28(%3)
+ lwz 32(%4), 32(%3)
+ lwz 34(%4), 34(%3)
+ lwz 38(%4), 38(%3)
+
+ /* we are done here, the assignee should start executing code now. */
+ blr
diff --git a/Private/HALKit/PowerPC/HalHardware.cxx b/Private/HALKit/POWER/HalHardware.cxx
index 5d09805d..693bf70e 100644
--- a/Private/HALKit/PowerPC/HalHardware.cxx
+++ b/Private/HALKit/POWER/HalHardware.cxx
@@ -4,7 +4,7 @@
------------------------------------------- */
-#include <HALKit/PowerPC/Processor.hpp>
+#include <HALKit/POWER/Processor.hpp>
#include <KernelKit/DebugOutput.hpp>
namespace NewOS {
diff --git a/Private/HALKit/PowerPC/HalSMPManager.cxx b/Private/HALKit/POWER/HalHart.cxx
index 26ebc399..75eeb3f7 100644
--- a/Private/HALKit/PowerPC/HalSMPManager.cxx
+++ b/Private/HALKit/POWER/HalHart.cxx
@@ -4,8 +4,9 @@
------------------------------------------- */
-#include <HALKit/PowerPC/Processor.hpp>
+#include <HALKit/POWER/Processor.hpp>
#include <KernelKit/DebugOutput.hpp>
+#include <HALKit/POWER/Hart.hxx>
using namespace NewOS;
@@ -15,4 +16,4 @@ void rt_wakeup_thread(HAL::StackFramePtr stack) {}
/// @brief makes thread sleep.
/// hooks and hangs thread to prevent code from executing.
-void rt_hang_thread(HAL::StackFramePtr stack) {} \ No newline at end of file
+void rt_hang_thread(HAL::StackFramePtr stack) {}
diff --git a/Private/HALKit/PowerPC/HalSerialPort.cxx b/Private/HALKit/POWER/HalSerialPort.cxx
index 36878b61..cf943371 100644
--- a/Private/HALKit/PowerPC/HalSerialPort.cxx
+++ b/Private/HALKit/POWER/HalSerialPort.cxx
@@ -4,13 +4,13 @@
------------------------------------------- */
-#include <HALKit/PowerPC/Processor.hpp>
+#include <HALKit/POWER/Processor.hpp>
#include <KernelKit/DebugOutput.hpp>
using namespace NewOS;
/// @brief Writes to COM1.
-/// @param bytes
+/// @param bytes
void ke_io_write(const Char* bytes) {
if (!bytes) return;
@@ -21,4 +21,4 @@ void ke_io_write(const Char* bytes) {
// TODO
++index;
}
-} \ No newline at end of file
+}
diff --git a/Private/HALKit/POWER/HalStartSequence.s b/Private/HALKit/POWER/HalStartSequence.s
new file mode 100644
index 00000000..f50a4d4f
--- /dev/null
+++ b/Private/HALKit/POWER/HalStartSequence.s
@@ -0,0 +1,14 @@
+/* -------------------------------------------
+
+ Copyright Mahrouss Logic
+
+------------------------------------------- */
+
+.globl Main
+.extern HalKernelMain
+.align 4
+.text
+
+Main:
+ bl HalKernelMain
+ blr
diff --git a/Private/HALKit/PowerPC/HalThread.cxx b/Private/HALKit/POWER/HalThread.cxx
index a91e7f28..c79b4fb7 100644
--- a/Private/HALKit/PowerPC/HalThread.cxx
+++ b/Private/HALKit/POWER/HalThread.cxx
@@ -4,7 +4,7 @@
------------------------------------------- */
-#include <HALKit/PowerPC/Processor.hpp>
+#include <HALKit/POWER/Processor.hpp>
#include <KernelKit/DebugOutput.hpp>
extern "C" NewOS::HAL::StackFramePtr rt_get_current_context() { return nullptr; }
diff --git a/Private/HALKit/PowerPC/HalVirtualMemory.cxx b/Private/HALKit/POWER/HalVirtualMemory.cxx
index 301bda0c..c138d76f 100644
--- a/Private/HALKit/PowerPC/HalVirtualMemory.cxx
+++ b/Private/HALKit/POWER/HalVirtualMemory.cxx
@@ -4,14 +4,13 @@
------------------------------------------- */
-#include <HALKit/PowerPC/ppc-cpu.h>
-#include <HALKit/PowerPC/ppc-mmu.h>
+#include <HALKit/POWER/ppc-cpu.h>
+#include <HALKit/POWER/ppc-mmu.h>
-#include <HALKit/PowerPC/Processor.hpp>
+#include <HALKit/POWER/Processor.hpp>
#include <KernelKit/DebugOutput.hpp>
-/// NOTE: refer to: https://www.nxp.com/docs/en/white-paper/POWRPCARCPRMRM.pdf,
-/// or in /Developer/PDF/POWRPCARCPRMRM.pdf
+/// @note refer to our SoC documentation.
using namespace NewOS;
diff --git a/Private/HALKit/POWER/Hart.hxx b/Private/HALKit/POWER/Hart.hxx
new file mode 100644
index 00000000..2a908fcf
--- /dev/null
+++ b/Private/HALKit/POWER/Hart.hxx
@@ -0,0 +1,27 @@
+/* -------------------------------------------
+
+ Copyright Mahrouss Logic
+
+ File: Hart.hxx
+ Purpose: POWER hardware threads.
+
+ Revision History:
+
+ 14/04/24: Added file (amlel)
+
+------------------------------------------- */
+
+#pragma once
+
+#include <NewKit/Defines.hpp>
+
+/// @brief hardware thread indentification type.
+typedef NewOS::Int32 PPCHartType;
+
+/// @brief Hardware thread information structure.
+typedef struct HalHardwareThread {
+ NewOS::UIntPtr fStartAddress;
+ NewOS::UInt8 fPrivleged : 1;
+ NewOS::UInt32 fPageFlags;
+ PPCHartType fIdentNumber;
+} HalHardwareThread;
diff --git a/Private/HALKit/PowerPC/PCI/.gitkeep b/Private/HALKit/POWER/MBCI/.gitkeep
index e69de29b..e69de29b 100644
--- a/Private/HALKit/PowerPC/PCI/.gitkeep
+++ b/Private/HALKit/POWER/MBCI/.gitkeep
diff --git a/Private/HALKit/POWER/MBCI/HalMBCIHost.cxx b/Private/HALKit/POWER/MBCI/HalMBCIHost.cxx
new file mode 100644
index 00000000..8ad039fe
--- /dev/null
+++ b/Private/HALKit/POWER/MBCI/HalMBCIHost.cxx
@@ -0,0 +1,8 @@
+/* -------------------------------------------
+
+ Copyright Mahrouss Logic
+
+------------------------------------------- */
+
+#include <HALKit/POWER/Processor.hpp>
+#include <KernelKit/DebugOutput.hpp>
diff --git a/Private/HALKit/PowerPC/Processor.hpp b/Private/HALKit/POWER/Processor.hpp
index 19f8e799..d6fbfb89 100644
--- a/Private/HALKit/PowerPC/Processor.hpp
+++ b/Private/HALKit/POWER/Processor.hpp
@@ -2,7 +2,7 @@
Copyright Mahrouss Logic
- Purpose: PowerPC processor header.
+ Purpose: POWER processor header.
------------------------------------------- */
@@ -11,12 +11,12 @@
#include <NewKit/Defines.hpp>
#include <NewKit/Utils.hpp>
-#define __PPC_ALIGN __attribute__((aligned(4)))
+#define kHalPPCAlignment __attribute__((aligned(4)))
namespace NewOS::HAL {
typedef UIntPtr Reg;
-struct __PPC_ALIGN StackFrame {
+struct kHalPPCAlignment StackFrame {
Reg R0;
Reg R1;
Reg R2;
@@ -34,13 +34,17 @@ typedef StackFrame* StackFramePtr;
inline void rt_halt() {
while (1) {
-
+ asm volatile("mr 0, 0"); // no oop.
}
}
-inline void rt_cli() {}
+inline void rt_cli() {
+ asm volatile ("mr 0, 0"); // no oop
+}
} // namespace NewOS::HAL
-extern "C" void int_handle_math(NewOS::UIntPtr sp);
-extern "C" void int_handle_pf(NewOS::UIntPtr sp);
-extern "C" void* __ppc_alloca(size_t sz);
+EXTERN_C void int_handle_math(NewOS::UIntPtr sp);
+EXTERN_C void int_handle_pf(NewOS::UIntPtr sp);
+
+/// @brief Flush system TLB.
+EXTERN_C void hal_flush_tlb();
diff --git a/Private/HALKit/PowerPC/ppc-cpu.h b/Private/HALKit/POWER/ppc-cpu.h
index 4bc6e9f0..74003329 100644
--- a/Private/HALKit/PowerPC/ppc-cpu.h
+++ b/Private/HALKit/POWER/ppc-cpu.h
@@ -17,7 +17,7 @@ struct pt_regs {
unsigned long nip;
};
-#else
+#else
#include <asm/ptrace.h>
#include <asm/types.h>
#endif
@@ -880,8 +880,8 @@ struct pt_regs {
#define PVR_REV(pvr) (((pvr) >> 0) & 0xFFFF) /* Revison field */
/*
- * AMCC has further subdivided the standard PowerPC 16-bit version and
- * revision subfields of the PVR for the PowerPC 403s into the following:
+ * AMCC has further subdivided the standard ppc 16-bit version and
+ * revision subfields of the PVR for the ppc 403s into the following:
*/
#define PVR_FAM(pvr) (((pvr) >> 20) & 0xFFF) /* Family field */
@@ -990,7 +990,7 @@ struct pt_regs {
/*
* For the 8xx processors, all of them report the same PVR family for
- * the PowerPC core. The various versions of these processors must be
+ * the ppc core. The various versions of these processors must be
* differentiated by the version number in the Communication Processor
* Module (CPM).
*/
diff --git a/Private/HALKit/PowerPC/ppc-mmu.h b/Private/HALKit/POWER/ppc-mmu.h
index 372935aa..5a149243 100644
--- a/Private/HALKit/PowerPC/ppc-mmu.h
+++ b/Private/HALKit/POWER/ppc-mmu.h
@@ -1,6 +1,3 @@
-/*
- * PowerPC memory management structures
- */
#ifndef _PPC_MMU_H_
#define _PPC_MMU_H_
@@ -252,7 +249,7 @@ extern void print_bats(void);
#define MI_IDXMASK 0x00001f00 /* TLB index to be loaded */
#define MI_RESETVAL 0x00000000 /* Value of register at reset */
-/* These are the Ks and Kp from the PowerPC books. For proper operation,
+/* These are the Ks and Kp from the ppc books. For proper operation,
* Ks = 0, Kp = 1.
*/
#define MI_AP 786
@@ -311,7 +308,7 @@ extern void print_bats(void);
#define MC_ASIDMASK 0x0000000f /* Bits used for ASID value */
-/* These are the Ks and Kp from the PowerPC books. For proper operation,
+/* These are the Ks and Kp from the ppc books. For proper operation,
* Ks = 0, Kp = 1.
*/
#define MD_AP 794
@@ -368,7 +365,7 @@ extern void print_bats(void);
#define M_TW 799
/*
- * At present, all PowerPC 400-class processors share a similar TLB
+ * At present, all ppc 400-class processors share a similar TLB
* architecture. The instruction and data sides share a unified,
* 64-entry, fully-associative TLB which is maintained totally under
* software control. In addition, the instruction side has a
@@ -797,4 +794,4 @@ void change_tlb(uint32_t vaddr, uint32_t size, uint32_t tlb_word2_i_value);
#endif /* __ASSEMBLY__ */
#endif /* CONFIG_440 */
-#endif /* _PPC_MMU_H_ */ \ No newline at end of file
+#endif /* _PPC_MMU_H_ */
diff --git a/Private/HALKit/PowerPC/HalCoreContextSwitchPowerPC.s b/Private/HALKit/PowerPC/HalCoreContextSwitchPowerPC.s
deleted file mode 100644
index 0bf6418d..00000000
--- a/Private/HALKit/PowerPC/HalCoreContextSwitchPowerPC.s
+++ /dev/null
@@ -1,30 +0,0 @@
-/* -------------------------------------------
-
- Copyright Mahrouss Logic
-
-------------------------------------------- */
-
-.align 4
-.type name, @function
-.text
-.globl rt_do_context_switch
-
-/* r3 = assigner stack, r4 = assignee stack */
-rt_do_context_switch:
-
- lwz 0(%r4), 0(%r3)
- lwz 4(%r4), 4(%r3)
- lwz 8(%r4), 8(%r3)
- lwz 12(%r4), 12(%r3)
- lwz 14(%r4), 14(%r3)
- lwz 18(%r4), 18(%r3)
- lwz 22(%r4), 22(%r3)
- lwz 24(%r4), 24(%r3)
- lwz 28(%r4), 28(%r3)
- lwz 32(%r4), 32(%r3)
- lwz 34(%r4), 34(%r3)
- lwz 38(%r4), 38(%r3)
-
- mr %r31, %r4
-
- bl
diff --git a/Private/HALKit/PowerPC/HalStartSequence.s b/Private/HALKit/PowerPC/HalStartSequence.s
deleted file mode 100644
index 112ac73f..00000000
--- a/Private/HALKit/PowerPC/HalStartSequence.s
+++ /dev/null
@@ -1,6 +0,0 @@
-.globl Main
-.align 4
-.text
-
-Main:
- b Main
diff --git a/Private/HALKit/PowerPC/Hart.hxx b/Private/HALKit/PowerPC/Hart.hxx
deleted file mode 100644
index 618cbd97..00000000
--- a/Private/HALKit/PowerPC/Hart.hxx
+++ /dev/null
@@ -1,20 +0,0 @@
-/* -------------------------------------------
-
- Copyright Mahrouss Logic
-
- File: Hart.hxx
- Purpose: PowerPC hardware threads.
-
- Revision History:
-
- 14/04/24: Added file (amlel)
-
-------------------------------------------- */
-
-#pragma once
-
-#include <NewKit/Defines.hpp>
-
-typedef NewOS::Int32 PPCHartType;
-
-
diff --git a/Private/HALKit/PowerPC/PCI/HalDevice.cxx b/Private/HALKit/PowerPC/PCI/HalDevice.cxx
deleted file mode 100644
index 8b137891..00000000
--- a/Private/HALKit/PowerPC/PCI/HalDevice.cxx
+++ /dev/null
@@ -1 +0,0 @@
-