diff options
| author | Amlal <amlal.elmahrouss@icloud.com> | 2024-10-26 19:49:02 +0200 |
|---|---|---|
| committer | Amlal <amlal.elmahrouss@icloud.com> | 2024-10-26 19:49:02 +0200 |
| commit | 6dcf5b87da65de2254d6102f567183eaeca03088 (patch) | |
| tree | b281ecd4cf0bcd60eaa476979f4f2183b0f4d04d /dev/zka/HALKit | |
| parent | 88b5be35623fb573cfa0d53cfc407ae1005ccad9 (diff) | |
IMP: This commit contains fixes and improvements regarding the kernel, a next one will be done soon.
Signed-off-by: Amlal <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'dev/zka/HALKit')
14 files changed, 50 insertions, 65 deletions
diff --git a/dev/zka/HALKit/AMD64/HalACPIFactoryInterface.cc b/dev/zka/HALKit/AMD64/HalACPIFactoryInterface.cc index 2ed013ef..ccb5983f 100644 --- a/dev/zka/HALKit/AMD64/HalACPIFactoryInterface.cc +++ b/dev/zka/HALKit/AMD64/HalACPIFactoryInterface.cc @@ -56,7 +56,7 @@ namespace Kernel UInt8 Century; // reserved in ACPI 1.0; used since ACPI 2.0+ - UInt16 BootArchitectureFlags; + UInt16 BootArchitecturkMMFlags; UInt8 Reserved2; UInt32 Flags; diff --git a/dev/zka/HALKit/AMD64/HalCPU.cc b/dev/zka/HALKit/AMD64/HalCPUAMD64.cc index d24bfc0a..d24bfc0a 100644 --- a/dev/zka/HALKit/AMD64/HalCPU.cc +++ b/dev/zka/HALKit/AMD64/HalCPUAMD64.cc diff --git a/dev/zka/HALKit/AMD64/HalMPContextSwitch.asm b/dev/zka/HALKit/AMD64/HalContextSwitchAMD64.asm index cb054a0d..cb054a0d 100644 --- a/dev/zka/HALKit/AMD64/HalMPContextSwitch.asm +++ b/dev/zka/HALKit/AMD64/HalContextSwitchAMD64.asm diff --git a/dev/zka/HALKit/AMD64/HalDescriptorLoader.cc b/dev/zka/HALKit/AMD64/HalDescriptorLoader.cc index f0eff4e1..5f7bde36 100644 --- a/dev/zka/HALKit/AMD64/HalDescriptorLoader.cc +++ b/dev/zka/HALKit/AMD64/HalDescriptorLoader.cc @@ -82,7 +82,7 @@ namespace Kernel::HAL Void IDTLoader::Load(Register64& idt) { - const auto kPITTickForScheduler = 100; + const Int16 kPITTickForScheduler = 100; volatile ::Kernel::UIntPtr** ptr_ivt = (volatile ::Kernel::UIntPtr**)idt.Base; diff --git a/dev/zka/HALKit/AMD64/HalKernelMain.cc b/dev/zka/HALKit/AMD64/HalKernelMain.cc index eb195bcc..cd700eef 100644 --- a/dev/zka/HALKit/AMD64/HalKernelMain.cc +++ b/dev/zka/HALKit/AMD64/HalKernelMain.cc @@ -81,21 +81,28 @@ EXTERN_C void hal_init_platform( Kernel::ke_stop(RUNTIME_CHECK_BOOTSTRAP); } +EXTERN_C Kernel::Void hal_kernel_server(Kernel::Void) noexcept +{ + while (Yes) + ; +} + EXTERN_C Kernel::Void hal_real_init(Kernel::Void) noexcept { /* Initialize filesystem. */ - Kernel::NeFileSystemMgr* mgr = Kernel::mm_new_class<Kernel::NeFileSystemMgr>(); - Kernel::NeFileSystemMgr::Mount(mgr); + Kernel::NeFileSystemMgr::Mount(new Kernel::NeFileSystemMgr()); /* Initialize scheduler. */ Kernel::UserProcessHelper::InitializeScheduler(); + const Kernel::Char kKernelServerName[255] = "KernelServer"; + + Kernel::rtl_create_process(&hal_kernel_server, kKernelServerName); + /* Start any cores. */ if (kHandoverHeader->f_HardwareTables.f_MultiProcessingEnabled) Kernel::HAL::mp_get_cores(kHandoverHeader->f_HardwareTables.f_VendorPtr); - /* Load OSLdr.exe here (TODO) */ - Kernel::HAL::Register64 idt_reg; idt_reg.Base = (Kernel::UIntPtr)kInterruptVectorTable; diff --git a/dev/zka/HALKit/AMD64/HalPagingMgr.cc b/dev/zka/HALKit/AMD64/HalPagingMgrAMD64.cc index 1a7202d7..39f53fe4 100644 --- a/dev/zka/HALKit/AMD64/HalPagingMgr.cc +++ b/dev/zka/HALKit/AMD64/HalPagingMgrAMD64.cc @@ -123,24 +123,21 @@ namespace Kernel::HAL /// @internal Internal function. STATIC Int32 mmi_map_page_table_entry(VoidPtr virtual_address, UInt32 flags, PTE* pt_entry) { - if (flags & ~eFlagsPresent) - pt_entry->Present = false; - else if (flags & eFlagsPresent) - pt_entry->Present = true; + pt_entry->Present = true; - if (flags & eFlagsWr) + if (flags & kMMFlagsWr) pt_entry->Wr = true; - else if (flags & ~eFlagsWr) + else if (flags & ~kMMFlagsWr) pt_entry->Wr = false; - if (flags & eFlagsNX) + if (flags & kMMFlagsNX) pt_entry->ExecDisable = true; - else if (flags & ~eFlagsNX) + else if (flags & ~kMMFlagsNX) pt_entry->ExecDisable = false; - if (flags & eFlagsUser) + if (flags & kMMFlagsUser) pt_entry->User = true; - else if (flags & ~eFlagsUser) + else if (flags & ~kMMFlagsUser) pt_entry->User = false; hal_invl_tlb(reinterpret_cast<VoidPtr>(pt_entry)); diff --git a/dev/zka/HALKit/AMD64/HalSchedulerCore.cc b/dev/zka/HALKit/AMD64/HalSchedulerCoreAMD64.cc index 214b889b..d4ca494c 100644 --- a/dev/zka/HALKit/AMD64/HalSchedulerCore.cc +++ b/dev/zka/HALKit/AMD64/HalSchedulerCoreAMD64.cc @@ -7,16 +7,6 @@ #include <HALKit/AMD64/Processor.h> #include <KernelKit/UserProcessScheduler.h> -using namespace Kernel; - -Void UserProcess::SetImageStart(VoidPtr imageStart) noexcept -{ - if (imageStart == nullptr) - this->Crash(); - - this->Image = imageStart; -} - namespace Kernel { /***********************************************************************************/ diff --git a/dev/zka/HALKit/AMD64/HalTimer.cc b/dev/zka/HALKit/AMD64/HalTimerAMD64.cc index c7f6bea3..c7f6bea3 100644 --- a/dev/zka/HALKit/AMD64/HalTimer.cc +++ b/dev/zka/HALKit/AMD64/HalTimerAMD64.cc diff --git a/dev/zka/HALKit/AMD64/Processor.h b/dev/zka/HALKit/AMD64/Processor.h index 8dbac715..968cf5e9 100644 --- a/dev/zka/HALKit/AMD64/Processor.h +++ b/dev/zka/HALKit/AMD64/Processor.h @@ -71,11 +71,12 @@ namespace Kernel::HAL /// @brief Memory Manager mapping flags. enum { - eFlagsPresent = 1 << 0, - eFlagsWr = 1 << 1, - eFlagsUser = 1 << 2, - eFlagsNX = 1 << 3, - eFlagsCount = 3, + kMMFlagsInvalid = 0 << 0, + kMMFlagsPresent = 1 << 0, + kMMFlagsWr = 1 << 1, + kMMFlagsUser = 1 << 2, + kMMFlagsNX = 1 << 3, + kMMFlagsCount = 4, }; struct PACKED Register64 final diff --git a/dev/zka/HALKit/ARM64/HalSchedulerCore.cc b/dev/zka/HALKit/ARM64/HalSchedulerCoreARM64.cc index a384db22..49927c84 100644 --- a/dev/zka/HALKit/ARM64/HalSchedulerCore.cc +++ b/dev/zka/HALKit/ARM64/HalSchedulerCoreARM64.cc @@ -13,22 +13,15 @@ namespace Kernel UserProcessScheduler::The().CurrentProcess().Leak().Crash(); } - Void UserProcess::SetImageStart(VoidPtr image_start) noexcept - { - if (image_start == 0) - this->Crash(); - - this->Image = image_start; - } - bool hal_check_stack(HAL::StackFramePtr stackPtr) { if (!stackPtr) - return false; + return No; + if (stackPtr->BP == 0 || stackPtr->SP == 0) - return false; + return No; - return true; + return Yes; } /// @brief Wakes up thread. @@ -42,9 +35,6 @@ namespace Kernel /// hooks and hangs thread to prevent code from executing. Void mp_hang_thread(HAL::StackFrame* stack) { - while (Yes) - { - /* Nothing to do, code is spinning */ - } + ZKA_UNUSUED(stack); } } // namespace Kernel diff --git a/dev/zka/HALKit/ARM64/Processor.h b/dev/zka/HALKit/ARM64/Processor.h index 5f00e345..793761e2 100644 --- a/dev/zka/HALKit/ARM64/Processor.h +++ b/dev/zka/HALKit/ARM64/Processor.h @@ -24,11 +24,11 @@ namespace Kernel::HAL /// @brief Memory Manager mapping flags. enum { - eFlagsPresent = 1 << 0, - eFlagsWr = 1 << 1, - eFlagsUser = 1 << 2, - eFlagsNX = 1 << 3, - eFlagsCount = 3, + kMMFlagsPresent = 1 << 0, + kMMFlagsWr = 1 << 1, + kMMFlagsUser = 1 << 2, + kMMFlagsNX = 1 << 3, + kMMFlagsCount = 3, }; /// @brief Set a PTE from pd_base. diff --git a/dev/zka/HALKit/POWER/HalVirtualMemory.cc b/dev/zka/HALKit/POWER/HalVirtualMemory.cc index 8d8db849..e21d7074 100644 --- a/dev/zka/HALKit/POWER/HalVirtualMemory.cc +++ b/dev/zka/HALKit/POWER/HalVirtualMemory.cc @@ -4,32 +4,30 @@ ------------------------------------------- */ -#include <HALKit/POWER/ppc-cpu.h> -#include <HALKit/POWER/ppc-mmu.h> - #include <HALKit/POWER/Processor.h> #include <KernelKit/DebugOutput.h> +#include <HALKit/POWER/MMU.h> -/// @note refer to the SoC documentation. +/// @note Refer to SoC documentation. using namespace Kernel; -Void hal_write_tlb(UInt32 mas0, UInt32 mas1, UInt32 mas2, UInt32 mas3, UInt32 mas7) +EXTERN_C Void hal_write_tlb(UInt32 mas0, UInt32 mas1, UInt32 mas2, UInt32 mas3, UInt32 mas7) { - mtspr(MAS0, mas0); - mtspr(MAS1, mas1); - mtspr(MAS2, mas2); - mtspr(MAS3, mas3); - mtspr(MAS7, mas7); + hal_mtspr(MAS0, mas0); + hal_mtspr(MAS1, mas1); + hal_mtspr(MAS2, mas2); + hal_mtspr(MAS3, mas3); + hal_mtspr(MAS7, mas7); hal_flush_tlb(); } -Bool hal_set_tlb(UInt8 tlb, UInt32 epn, UInt64 rpn, UInt8 perms, UInt8 wimge, UInt8 ts, UInt8 esel, UInt8 tsize, UInt8 iprot) +EXTERN_C Bool hal_set_tlb(UInt8 tlb, UInt32 epn, UInt64 rpn, UInt8 perms, UInt8 wimge, UInt8 ts, UInt8 esel, UInt8 tsize, UInt8 iprot) { - if ((mfspr(SPRN_MMUCFG) & MMUCFG_MAVN) == MMUCFG_MAVN_V1 && (tsize & 1)) + if ((hal_mfspr(SPRN_MMUCFG) & MMUCFG_MAVN) == MMUCFG_MAVN_V1 && (tsize & 1)) { - // this mmu-version does not allow odd tsize values + // this MMU does not allow odd tsize values return false; } diff --git a/dev/zka/HALKit/POWER/Hart.h b/dev/zka/HALKit/POWER/Hart.h index eaf00493..2e40784e 100644 --- a/dev/zka/HALKit/POWER/Hart.h +++ b/dev/zka/HALKit/POWER/Hart.h @@ -25,7 +25,7 @@ typedef struct HAL_HARDWARE_THREAD { Kernel::UIntPtr fStartAddress; Kernel::UInt8 fPrivleged : 1; - Kernel::UInt32 fPageFlags; + Kernel::UInt32 fPagkMMFlags; PPCHartType fIdentNumber; } HAL_HARDWARE_THREAD; diff --git a/dev/zka/HALKit/POWER/Processor.h b/dev/zka/HALKit/POWER/Processor.h index 95c1f1c6..4df55fc4 100644 --- a/dev/zka/HALKit/POWER/Processor.h +++ b/dev/zka/HALKit/POWER/Processor.h @@ -29,6 +29,8 @@ namespace Kernel::HAL Reg R13{0}; Reg R14{0}; Reg R15{0}; + Reg SP{0}; + Reg BP{0}; }; typedef StackFrame* StackFramePtr; |
