diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2025-05-25 09:56:46 +0200 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal@nekernel.org> | 2025-05-25 09:56:46 +0200 |
| commit | 5b30cacacf0f0ca6fb06bb34389f04b05ceb2b15 (patch) | |
| tree | 85c1fb5b167d3089483affe7060155a7d148d641 /dev/kernel/HALKit/AMD64 | |
| parent | ef3e3db6fafb43afd3e254b17c7169c603cdf416 (diff) | |
kernel!: lots of changes, see commit details.
refactor(hal): unify file naming and drop redundant architecture suffixes
feat(build): rename kernel and bootloader to 'ne_kernel' and 'ne_bootz'
refactor(memory): replace mm_get_phys_address with mm_get_page_addr
feat(bitmap): track bitmap allocator usage and add out-of-memory error
fix(heap): correct heap magic naming and alignment logic
chore(fs): downgrade HeFS disk size check to warning
chore(tools): clean up formatting in 'ping' and 'manual'
docs(design): update OS_DESIGN.drawio to reflect Hypr86 and new layout
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'dev/kernel/HALKit/AMD64')
12 files changed, 26 insertions, 23 deletions
diff --git a/dev/kernel/HALKit/AMD64/HalApplicationProcessor.cc b/dev/kernel/HALKit/AMD64/HalApplicationProcessor.cc index 7926289f..2ce05e7c 100644 --- a/dev/kernel/HALKit/AMD64/HalApplicationProcessor.cc +++ b/dev/kernel/HALKit/AMD64/HalApplicationProcessor.cc @@ -128,6 +128,7 @@ EXTERN_C BOOL mp_register_task(HAL::StackFramePtr stack_frame, ProcessID thrdid) /// @brief Is the current config SMP aware? /// @return True if YES, False if not. /***********************************************************************************/ + Bool mp_is_smp(Void) noexcept { return kSMPAware; } diff --git a/dev/kernel/HALKit/AMD64/HalControlRegister.s b/dev/kernel/HALKit/AMD64/HalControlRegisterAPI.s index 631d1d55..631d1d55 100644 --- a/dev/kernel/HALKit/AMD64/HalControlRegister.s +++ b/dev/kernel/HALKit/AMD64/HalControlRegisterAPI.s diff --git a/dev/kernel/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cc b/dev/kernel/HALKit/AMD64/HalCoreInterruptHandler.cc index b70cd51f..01456ae5 100644 --- a/dev/kernel/HALKit/AMD64/HalCoreInterruptHandlerAMD64.cc +++ b/dev/kernel/HALKit/AMD64/HalCoreInterruptHandler.cc @@ -19,7 +19,7 @@ STATIC BOOL kIsRunning = NO; /// @note STATIC void hal_idt_send_eoi(UInt8 vector) { ((volatile UInt32*) kApicBaseAddress)[0xB0 / 4] = 0; - + if (vector >= kPICCommand && vector <= 0x2F) { if (vector >= 0x28) { Kernel::HAL::rt_out8(kPIC2Command, kPICCommand); @@ -57,7 +57,7 @@ EXTERN_C void idt_handle_pf(Kernel::UIntPtr rsp) { /// @brief Handle scheduler interrupt. EXTERN_C void idt_handle_scheduler(Kernel::UIntPtr rsp) { NE_UNUSED(rsp); - + hal_idt_send_eoi(32); while (kIsRunning) diff --git a/dev/kernel/HALKit/AMD64/HalKernelMain.cc b/dev/kernel/HALKit/AMD64/HalKernelMain.cc index c1558892..edbe058a 100644 --- a/dev/kernel/HALKit/AMD64/HalKernelMain.cc +++ b/dev/kernel/HALKit/AMD64/HalKernelMain.cc @@ -146,17 +146,19 @@ EXTERN_C Kernel::Void hal_real_init(Kernel::Void) noexcept { HAL::mp_init_cores(kHandoverHeader->f_HardwareTables.f_VendorPtr); #ifdef __FSKIT_INCLUDES_HEFS__ - if (HeFS::fs_init_hefs()) { - goto hal_spin_kernel; + if (!HeFS::fs_init_hefs()) { + kout << "HeFS cannot be formated on disk. Aborting\r"; + DBG_TRAP(); } #endif +#ifdef __FSKIT_INCLUDES_NEFS__ if (!NeFS::fs_init_nefs()) { - kout << "NeFS cannot be formated on the disk. Aborting\r"; + kout << "NeFS cannot be formated on disk. Aborting\r"; DBG_TRAP(); } +#endif -hal_spin_kernel: HAL::Register64 idt_reg; idt_reg.Base = reinterpret_cast<UIntPtr>(kInterruptVectorTable); diff --git a/dev/kernel/HALKit/AMD64/HalPagingMgrAMD64.cc b/dev/kernel/HALKit/AMD64/HalPagingMgr.cc index 4681b5e5..048cb7c2 100644 --- a/dev/kernel/HALKit/AMD64/HalPagingMgrAMD64.cc +++ b/dev/kernel/HALKit/AMD64/HalPagingMgr.cc @@ -57,7 +57,7 @@ STATIC Void mmi_page_status(Detail::PTE* pte) { /// @param virt a valid virtual address. /// @return Physical address. /***********************************************************************************/ -UIntPtr mm_get_phys_address(VoidPtr virt) { +EXTERN_C UIntPtr mm_get_page_addr(VoidPtr virt) { const UInt64 kVMAddr = (UInt64) virt; const UInt64 kMask9Bits = 0x1FFULL; const UInt64 kPageOffsetMask = 0xFFFULL; @@ -102,7 +102,7 @@ UIntPtr mm_get_phys_address(VoidPtr virt) { /// @brief clflush+mfence helper function. /***********************************************************************************/ EXTERN_C Int32 mm_memory_fence(VoidPtr virtual_address) { - if (!virtual_address || !mm_get_phys_address(virtual_address)) return kErrorInvalidData; + if (!virtual_address || !mm_get_page_addr(virtual_address)) return kErrorInvalidData; asm volatile("clflush (%0)" : : "r"(virtual_address) : "memory"); asm volatile("mfence" ::: "memory"); diff --git a/dev/kernel/HALKit/AMD64/HalProcessorAMD64.cc b/dev/kernel/HALKit/AMD64/HalProcessor.cc index 2fc18e2f..6ebbea08 100644 --- a/dev/kernel/HALKit/AMD64/HalProcessorAMD64.cc +++ b/dev/kernel/HALKit/AMD64/HalProcessor.cc @@ -16,6 +16,15 @@ */ namespace Kernel::HAL { +inline Bool hal_has_msr() noexcept { + static UInt32 eax, unused, edx; // eax, edx + + __get_cpuid(1, &eax, &unused, &unused, &edx); + + // edx returns the flag for MSR (which is 1 shifted to 5.) + return edx & (1 << 5); +} + Void hal_get_msr(UInt32 msr, UInt32* lo, UInt32* hi) noexcept { if (!lo || !hi) return; asm volatile("rdmsr" : "=a"(*lo), "=d"(*hi) : "c"(msr)); diff --git a/dev/kernel/HALKit/AMD64/HalSchedulerCorePrimitivesAMD64.cc b/dev/kernel/HALKit/AMD64/HalSchedulerCorePrimitives.cc index 0c468e14..0c468e14 100644 --- a/dev/kernel/HALKit/AMD64/HalSchedulerCorePrimitivesAMD64.cc +++ b/dev/kernel/HALKit/AMD64/HalSchedulerCorePrimitives.cc diff --git a/dev/kernel/HALKit/AMD64/HalTimerAMD64.cc b/dev/kernel/HALKit/AMD64/HalTimer.cc index 13573880..13573880 100644 --- a/dev/kernel/HALKit/AMD64/HalTimerAMD64.cc +++ b/dev/kernel/HALKit/AMD64/HalTimer.cc diff --git a/dev/kernel/HALKit/AMD64/HalUtilsAPI.asm b/dev/kernel/HALKit/AMD64/HalUtilsAPI.asm index ab639992..11336229 100644 --- a/dev/kernel/HALKit/AMD64/HalUtilsAPI.asm +++ b/dev/kernel/HALKit/AMD64/HalUtilsAPI.asm @@ -22,5 +22,3 @@ rt_install_tib: ret ;; //////////////////////////////////////////////////// ;; - -[extern kApicMadtAddressesCount] diff --git a/dev/kernel/HALKit/AMD64/Network/Generic+Basic+RTL8139.cc b/dev/kernel/HALKit/AMD64/Network/Generic+Basic+RTL8139.cc index 7c611c26..3ccbfa24 100644 --- a/dev/kernel/HALKit/AMD64/Network/Generic+Basic+RTL8139.cc +++ b/dev/kernel/HALKit/AMD64/Network/Generic+Basic+RTL8139.cc @@ -79,7 +79,7 @@ EXTERN_C void rtl_rtl8139_interrupt_handler() { // While we receive data. while ((rt_in8(kRTLIOBase + 0x37) & 0x01) == 0) { // We grab an offset from the RX buffer. - UInt32 offset = kRXOffset % kRXBufferSize; + UInt32 offset = kRXOffset % kRXBufferSize; // If the offset is too high, we reset it. if (offset >= (kRXBufferSize - 16)) { diff --git a/dev/kernel/HALKit/AMD64/Processor.h b/dev/kernel/HALKit/AMD64/Processor.h index 5a70b465..80dc7a1d 100644 --- a/dev/kernel/HALKit/AMD64/Processor.h +++ b/dev/kernel/HALKit/AMD64/Processor.h @@ -174,16 +174,7 @@ Void mp_init_cores(VoidPtr vendor_ptr) noexcept; /// @retval true it does exists. /// @retval false it doesn't. /***********************************************************************************/ -inline Bool hal_has_msr() noexcept { - static UInt32 eax, unused, edx; // eax, edx - - __get_cpuid(1, &eax, &unused, &unused, &edx); - - // edx returns the flag for MSR (which is 1 shifted to 5.) - return edx & (1 << 5); -} - -UIntPtr mm_get_phys_address(VoidPtr virtual_address); +Bool hal_has_msr() noexcept; /***********************************************************************************/ /// @brief Get Model specific register inside core. @@ -271,6 +262,8 @@ EXTERN_C Void rt_sti(); EXTERN_C Void rt_cld(); EXTERN_C Void rt_std(); +EXTERN_C UIntPtr mm_get_page_addr(VoidPtr virtual_address); + EXTERN_C Int32 mm_memory_fence(VoidPtr virtual_address); } // namespace Kernel::HAL diff --git a/dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc b/dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc index b530a730..b30bfc32 100644 --- a/dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc +++ b/dev/kernel/HALKit/AMD64/Storage/AHCI+Generic.cc @@ -359,7 +359,7 @@ STATIC Bool drv_init_command_structures_ahci() { return NO; } - UIntPtr clb_phys = HAL::mm_get_phys_address(clb_mem); + UIntPtr clb_phys = HAL::mm_get_page_addr(clb_mem); kSATAHba->Ports[kSATAIndex].Clb = (UInt32) (clb_phys & 0xFFFFFFFF); kSATAHba->Ports[kSATAIndex].Clbu = (UInt32) (clb_phys >> 32); @@ -379,7 +379,7 @@ STATIC Bool drv_init_command_structures_ahci() { return NO; } - UIntPtr ct_phys = HAL::mm_get_phys_address(ct_mem); + UIntPtr ct_phys = HAL::mm_get_page_addr(ct_mem); header[i].Ctba = (UInt32) (ct_phys & 0xFFFFFFFF); header[i].Ctbau = (UInt32) (ct_phys >> 32); |
