diff options
Diffstat (limited to 'Private')
37 files changed, 156 insertions, 97 deletions
diff --git a/Private/ArchKit/Arch.hpp b/Private/ArchKit/ArchKit.hpp index 4216f9b3..eefd6f5f 100644 --- a/Private/ArchKit/Arch.hpp +++ b/Private/ArchKit/ArchKit.hpp @@ -84,3 +84,8 @@ extern "C" void rt_syscall_handle(HCore::HAL::StackFrame* stackFrame); extern "C" HCore::HAL::StackFrame* rt_get_current_context(); extern "C" int rt_do_context_switch(HCore::HAL::StackFrame* stackFrame); +inline HCore::VoidPtr kKernelVirtualStart; +inline HCore::UIntPtr kKernelVirtualSize; + +inline HCore::VoidPtr kKernelPhysicalStart; +inline HCore::UIntPtr kKernelPhysicalSize; diff --git a/Private/ArchKit/SyscallImpl.hpp b/Private/ArchKit/SyscallImpl.hpp index 7d379197..26acdd38 100644 --- a/Private/ArchKit/SyscallImpl.hpp +++ b/Private/ArchKit/SyscallImpl.hpp @@ -9,4 +9,5 @@ #pragma once -#include <ArchKit/Arch.hpp>
\ No newline at end of file +#include <ArchKit/ArchKit.hpp> + diff --git a/Private/EFIKit/BootProtocol.hxx b/Private/EFIKit/BootProtocol.hxx index 2978cfed..1acfcc18 100644 --- a/Private/EFIKit/BootProtocol.hxx +++ b/Private/EFIKit/BootProtocol.hxx @@ -71,6 +71,8 @@ struct HandoverInformationHeader { voidPtr f_RsdPtr; voidPtr f_SmBIOS; voidPtr f_RTC; + voidPtr f_GOP; + voidPtr f_GOPSize; }; /** diff --git a/Private/HALKit/AMD64/CPUID.hxx b/Private/HALKit/AMD64/CPUID.hxx index 16e73eb6..85eb4893 100644 --- a/Private/HALKit/AMD64/CPUID.hxx +++ b/Private/HALKit/AMD64/CPUID.hxx @@ -76,3 +76,4 @@ typedef enum { CPU_FEATURE_EDX_IA64 = 1 << 30, CPU_FEATURE_EDX_PBE = 1 << 31 } CPU_FEATURE; + diff --git a/Private/HALKit/AMD64/CoreInterruptHandlerAMD64.cpp b/Private/HALKit/AMD64/CoreInterruptHandlerAMD64.cpp index 8399d9ce..caf891d1 100644 --- a/Private/HALKit/AMD64/CoreInterruptHandlerAMD64.cpp +++ b/Private/HALKit/AMD64/CoreInterruptHandlerAMD64.cpp @@ -7,7 +7,7 @@ * ======================================================== */ -#include <ArchKit/Arch.hpp> +#include <ArchKit/ArchKit.hpp> #include <KernelKit/ProcessManager.hpp> #include <NewKit/String.hpp> diff --git a/Private/HALKit/AMD64/CoreSyscallHandlerAMD64.cpp b/Private/HALKit/AMD64/CoreSyscallHandlerAMD64.cpp index b41b8285..4f1ed4da 100644 --- a/Private/HALKit/AMD64/CoreSyscallHandlerAMD64.cpp +++ b/Private/HALKit/AMD64/CoreSyscallHandlerAMD64.cpp @@ -7,7 +7,7 @@ * ======================================================== */ -#include <ArchKit/Arch.hpp> +#include <ArchKit/ArchKit.hpp> #include <HALKit/AMD64/Processor.hpp> #include <KernelKit/PermissionSelector.hxx> diff --git a/Private/HALKit/AMD64/DebugOutput.cxx b/Private/HALKit/AMD64/DebugOutput.cxx index ad9fc8c5..c4e9cc48 100644 --- a/Private/HALKit/AMD64/DebugOutput.cxx +++ b/Private/HALKit/AMD64/DebugOutput.cxx @@ -7,7 +7,7 @@ * ======================================================== */ -#include <ArchKit/Arch.hpp> +#include <ArchKit/ArchKit.hpp> #include <KernelKit/DebugOutput.hpp> #include <NewKit/Utils.hpp> diff --git a/Private/HALKit/AMD64/DebugPort.cxx b/Private/HALKit/AMD64/DebugPort.cxx index b0f2f6d1..d292f95d 100644 --- a/Private/HALKit/AMD64/DebugPort.cxx +++ b/Private/HALKit/AMD64/DebugPort.cxx @@ -10,7 +10,7 @@ //! @file DebuggerPort.cxx //! @brief UART debug via packets. -#include <ArchKit/Arch.hpp> +#include <ArchKit/ArchKit.hpp> #define kDebugMaxPorts 16 diff --git a/Private/HALKit/AMD64/HalHardwareAPIC.cpp b/Private/HALKit/AMD64/HalHardwareAPIC.cpp index c2bcc007..4e985f8e 100644 --- a/Private/HALKit/AMD64/HalHardwareAPIC.cpp +++ b/Private/HALKit/AMD64/HalHardwareAPIC.cpp @@ -7,7 +7,7 @@ * ======================================================== */ -#include <ArchKit/Arch.hpp> +#include <ArchKit/ArchKit.hpp> // bugs = 0 diff --git a/Private/HALKit/AMD64/HalHardwareInit.cpp b/Private/HALKit/AMD64/HalHardwareInit.cpp index bc002e3d..adcacce4 100644 --- a/Private/HALKit/AMD64/HalHardwareInit.cpp +++ b/Private/HALKit/AMD64/HalHardwareInit.cpp @@ -7,7 +7,7 @@ * ======================================================== */ -#include <ArchKit/Arch.hpp> +#include <ArchKit/ArchKit.hpp> // bugs = 0 diff --git a/Private/HALKit/AMD64/HalPageAlloc.cpp b/Private/HALKit/AMD64/HalPageAlloc.cpp index 86631e57..6d6e4ba5 100644 --- a/Private/HALKit/AMD64/HalPageAlloc.cpp +++ b/Private/HALKit/AMD64/HalPageAlloc.cpp @@ -8,12 +8,12 @@ */ #include <HALKit/AMD64/HalPageAlloc.hpp> -#include <NewKit/Defines.hpp> #include <NewKit/RuntimeCheck.hpp> +#include <NewKit/Defines.hpp> // this files handles paging. -static HCore::UIntPtr kPagePtr = kPagePtrAddress; +static HCore::UIntPtr kPagePtr = 0; static HCore::SizeT kPageCnt = 0UL; namespace HCore { @@ -23,6 +23,7 @@ static auto hal_try_alloc_new_page(SizeT sz, Boolean rw, Boolean user) char *ptr = &(reinterpret_cast<char *>(kPagePtr))[kPageCnt + 1]; PageTable64 *pte = reinterpret_cast<PageTable64 *>(ptr); + pte->Rw = rw; pte->User = user; pte->Present = true; @@ -52,5 +53,9 @@ auto hal_create_page(Boolean rw, Boolean user) -> UIntPtr { return reinterpret_cast<UIntPtr>(new_pte); } + +UIntPtr& hal_get_page_ptr() noexcept { return kPagePtr; } + +void hal_set_page_ptr(const UIntPtr& newPagePtr) noexcept { kPagePtr = newPagePtr; } } // namespace HAL } // namespace HCore diff --git a/Private/HALKit/AMD64/HalPageAlloc.hpp b/Private/HALKit/AMD64/HalPageAlloc.hpp index 3f9428b9..711dc27d 100644 --- a/Private/HALKit/AMD64/HalPageAlloc.hpp +++ b/Private/HALKit/AMD64/HalPageAlloc.hpp @@ -19,8 +19,6 @@ #define PTE_ALIGN (4096) #endif //! PTE_ALIGN -#define kPagePtrAddress 0x9000000 - extern "C" void flush_tlb(HCore::UIntPtr VirtualAddr); extern "C" void write_cr3(HCore::UIntPtr pde); extern "C" void write_cr0(HCore::UIntPtr bit); @@ -44,6 +42,7 @@ struct PageTable64 { }; PageTable64 *hal_alloc_page(SizeT sz, Boolean rw, Boolean user); - +UIntPtr& hal_get_page_ptr() noexcept; +void hal_set_page_ptr(const UIntPtr& newPagePtr) noexcept; UIntPtr hal_create_page(Boolean rw, Boolean user); } // namespace HCore::HAL diff --git a/Private/HALKit/AMD64/HalPlatformAMD64.cpp b/Private/HALKit/AMD64/HalPlatformAMD64.cpp index ab03659a..6374d06b 100644 --- a/Private/HALKit/AMD64/HalPlatformAMD64.cpp +++ b/Private/HALKit/AMD64/HalPlatformAMD64.cpp @@ -7,7 +7,7 @@ * ======================================================== */ -#include <ArchKit/Arch.hpp> +#include <ArchKit/ArchKit.hpp> namespace HCore::HAL { namespace Detail { diff --git a/Private/HALKit/AMD64/PCI/Device.cpp b/Private/HALKit/AMD64/PCI/Device.cpp index 815043c9..b353d2a6 100644 --- a/Private/HALKit/AMD64/PCI/Device.cpp +++ b/Private/HALKit/AMD64/PCI/Device.cpp @@ -7,7 +7,7 @@ * ======================================================== */ -#include <ArchKit/Arch.hpp> +#include <ArchKit/ArchKit.hpp> #include <KernelKit/PCI/Device.hpp> HCore::UInt LumiaPCIReadRaw(HCore::UInt bar, HCore::UShort bus, diff --git a/Private/HALKit/AMD64/SMPCoreManager.asm b/Private/HALKit/AMD64/SMPCoreManager.asm index 1a994258..9741d092 100644 --- a/Private/HALKit/AMD64/SMPCoreManager.asm +++ b/Private/HALKit/AMD64/SMPCoreManager.asm @@ -14,6 +14,8 @@ section .text rt_do_context_switch: + mov rcx, r15 + mov [r15+0], rax mov [r15+8], rbx mov [r15+16], rcx diff --git a/Private/HALKit/AMD64/StartSequence.asm b/Private/HALKit/AMD64/StartSequence.asm index 5ef8ed55..c8e0a4e2 100644 --- a/Private/HALKit/AMD64/StartSequence.asm +++ b/Private/HALKit/AMD64/StartSequence.asm @@ -15,7 +15,6 @@ ;; External symbols needed by this unit. [extern RuntimeMain] -[extern __SYSTEM_STACK_END] %define kTypeKernel 100 %define kArchAmd64 122 @@ -32,7 +31,9 @@ section .text ;; Just a simple setup, we'd also need to tell some before Main: + push rcx jmp RuntimeMain + pop rcx L0: cli hlt diff --git a/Private/HALKit/AXP/CoreSyscallHandlerDEC.cpp b/Private/HALKit/AXP/CoreSyscallHandlerDEC.cpp index 11965ff7..5d1c6d2b 100644 --- a/Private/HALKit/AXP/CoreSyscallHandlerDEC.cpp +++ b/Private/HALKit/AXP/CoreSyscallHandlerDEC.cpp @@ -7,7 +7,7 @@ * ======================================================== */ -#include <ArchKit/Arch.hpp> +#include <ArchKit/ArchKit.hpp> #include <HALKit/Alpha/Processor.hpp> HCore::Array<void (*)(HCore::Int32 id, HCore::HAL::StackFrame *), kMaxSyscalls> kSyscalls; diff --git a/Private/HALKit/PowerPC/CoreSyscallHandlerPowerPC.cpp b/Private/HALKit/PowerPC/CoreSyscallHandlerPowerPC.cpp index 7c7d7683..c1672e68 100644 --- a/Private/HALKit/PowerPC/CoreSyscallHandlerPowerPC.cpp +++ b/Private/HALKit/PowerPC/CoreSyscallHandlerPowerPC.cpp @@ -7,7 +7,7 @@ * ======================================================== */ -#include <ArchKit/Arch.hpp> +#include <ArchKit/ArchKit.hpp> #include <NewKit/Array.hpp> HCore::Array<void (*)(HCore::Int32 id, HCore::HAL::StackFrame *), kMaxSyscalls> diff --git a/Private/KernelKit/Framebuffer.hpp b/Private/KernelKit/Framebuffer.hpp index 8ad23571..feb34d3a 100644 --- a/Private/KernelKit/Framebuffer.hpp +++ b/Private/KernelKit/Framebuffer.hpp @@ -37,7 +37,7 @@ class Framebuffer final { Framebuffer &operator=(const Framebuffer &) = delete; Framebuffer(const Framebuffer &) = default; - volatile UIntPtr *operator[](const UIntPtr &width_and_height); + volatile UIntPtr *operator[](const UIntPtr &pos); operator bool() { return m_FrameBufferAddr && m_Colour != FramebufferColorKind::INVALID; diff --git a/Private/KernelKit/PCI/IO.hpp b/Private/KernelKit/PCI/IO.hpp index 778650b6..4511fca1 100644 --- a/Private/KernelKit/PCI/IO.hpp +++ b/Private/KernelKit/PCI/IO.hpp @@ -9,7 +9,7 @@ #pragma once -#include <ArchKit/Arch.hpp> +#include <ArchKit/ArchKit.hpp> #include <NewKit/Array.hpp> #include <NewKit/Defines.hpp> #include <NewKit/Ref.hpp> diff --git a/Private/KernelKit/PEF.hpp b/Private/KernelKit/PEF.hpp index 8c67c6ae..0cee2e90 100644 --- a/Private/KernelKit/PEF.hpp +++ b/Private/KernelKit/PEF.hpp @@ -22,7 +22,11 @@ #define kPefVersion 1 #define kPefNameLen 64 -// @brief Preferred Executable Format, a format designed for any computer. +/// @brief Preferred Executable Format, a format designed +/// for RISC/CISC Von-neumann processor types. + +/// The PEF also uses the x64 PE calling convention and ABI. +/// It's just that the container are different. namespace HCore { enum { diff --git a/Private/KernelKit/PermissionSelector.hxx b/Private/KernelKit/PermissionSelector.hxx index 7b799c50..14bb5a9e 100644 --- a/Private/KernelKit/PermissionSelector.hxx +++ b/Private/KernelKit/PermissionSelector.hxx @@ -28,7 +28,8 @@ enum class RingKind { kRingUser = 3, kRingDriver = 2, kRingKernel = 0, - kUnknown = -1, + kRingUnknown = -1, + kRingCount = 4, }; class PermissionSelector final { diff --git a/Private/KernelKit/ProcessManager.hpp b/Private/KernelKit/ProcessManager.hpp index 14c6eb28..8c536a3b 100644 --- a/Private/KernelKit/ProcessManager.hpp +++ b/Private/KernelKit/ProcessManager.hpp @@ -10,7 +10,7 @@ #ifndef __PROCESS_MANAGER__ #define __PROCESS_MANAGER__ -#include <ArchKit/Arch.hpp> +#include <ArchKit/ArchKit.hpp> #include <KernelKit/FileManager.hpp> #include <KernelKit/PermissionSelector.hxx> #include <NewKit/LockDelegate.hpp> diff --git a/Private/KernelKit/SMPManager.hpp b/Private/KernelKit/SMPManager.hpp index f7b048ad..0a71a165 100644 --- a/Private/KernelKit/SMPManager.hpp +++ b/Private/KernelKit/SMPManager.hpp @@ -10,7 +10,7 @@ #ifndef _INC_SMP_MANAGER_HPP #define _INC_SMP_MANAGER_HPP -#include <ArchKit/Arch.hpp> +#include <ArchKit/ArchKit.hpp> #include <CompilerKit/CompilerKit.hpp> #include <NewKit/Ref.hpp> diff --git a/Private/KernelKit/Timer.hpp b/Private/KernelKit/Timer.hpp index af03a7d0..eeeeac3e 100644 --- a/Private/KernelKit/Timer.hpp +++ b/Private/KernelKit/Timer.hpp @@ -9,7 +9,7 @@ #pragma once -#include <ArchKit/Arch.hpp> +#include <ArchKit/ArchKit.hpp> #include <CompilerKit/CompilerKit.hpp> #include <NewKit/ErrorID.hpp> diff --git a/Private/NewKit/Macros.hpp b/Private/NewKit/Macros.hpp index 94fd8fe8..50d44946 100644 --- a/Private/NewKit/Macros.hpp +++ b/Private/NewKit/Macros.hpp @@ -86,3 +86,6 @@ #define PACKED ATTRIBUTE(packed) #define NO_EXEC ATTRIBUTE(noexec) + +#define EXTERN extern +#define STATIC static
\ No newline at end of file diff --git a/Private/Source/Framebuffer.cxx b/Private/Source/Framebuffer.cxx index 3b8fa229..61f946a7 100644 --- a/Private/Source/Framebuffer.cxx +++ b/Private/Source/Framebuffer.cxx @@ -3,20 +3,32 @@ Copyright Mahrouss Logic File: Framebuffer.cxx - Purpose: EFI C++ library + Purpose: Framebuffer object Revision History: 01/02/24: Added file (amlel) + 02/02/24: Add documentation (amlel) ------------------------------------------- */ #include <KernelKit/Framebuffer.hpp> +/** + * @brief Framebuffer object implementation. + * + */ + using namespace HCore; -volatile UIntPtr *Framebuffer::operator[](const UIntPtr &width_and_height) { - return (UIntPtr *)(m_FrameBufferAddr->m_Base * width_and_height); +/** + * @brief Get Pixel at + * + * @param pos position of pixel. + * @return volatile* + */ +volatile UIntPtr *Framebuffer::operator[](const UIntPtr &pos) { + return (UIntPtr *)(m_FrameBufferAddr->m_Base * pos); } const FramebufferColorKind &Framebuffer::Color( diff --git a/Private/Source/GUIDWizard.cxx b/Private/Source/GUIDWizard.cxx index 96c00efc..8befb071 100644 --- a/Private/Source/GUIDWizard.cxx +++ b/Private/Source/GUIDWizard.cxx @@ -1,11 +1,13 @@ -/* - * ======================================================== - * - * HCore - * Copyright Mahrouss Logic, all rights reserved. - * - * ======================================================== - */ +/* ------------------------------------------- + + Copyright Mahrouss Logic + + File: GUIDWizard.cxx + Purpose: GUID helper code + + Revision History: + +------------------------------------------- */ #include <CFKit/GUIDWizard.hpp> #include <NewKit/Ref.hpp> diff --git a/Private/Source/PageAllocator.cxx b/Private/Source/PageAllocator.cxx index c2de0232..060ce011 100644 --- a/Private/Source/PageAllocator.cxx +++ b/Private/Source/PageAllocator.cxx @@ -7,7 +7,7 @@ * ======================================================== */ -#include <ArchKit/Arch.hpp> +#include <ArchKit/ArchKit.hpp> #include <KernelKit/DebugOutput.hpp> #include <NewKit/PageAllocator.hpp> diff --git a/Private/Source/RuntimeCheck.cxx b/Private/Source/RuntimeCheck.cxx index bbeecb74..a84a0b7a 100644 --- a/Private/Source/RuntimeCheck.cxx +++ b/Private/Source/RuntimeCheck.cxx @@ -7,7 +7,7 @@ * ======================================================== */ -#include <ArchKit/Arch.hpp> +#include <ArchKit/ArchKit.hpp> #include <KernelKit/DebugOutput.hpp> #include <NewKit/RuntimeCheck.hpp> #include <NewKit/String.hpp> diff --git a/Private/Source/RuntimeMain.cxx b/Private/Source/RuntimeMain.cxx index 8c18c0a3..0cbdac1c 100644 --- a/Private/Source/RuntimeMain.cxx +++ b/Private/Source/RuntimeMain.cxx @@ -7,7 +7,7 @@ * ======================================================== */ -#include <ArchKit/Arch.hpp> +#include <ArchKit/ArchKit.hpp> #include <EFIKit/BootProtocol.hxx> #include <KernelKit/FileManager.hpp> #include <KernelKit/PEFCodeManager.hxx> @@ -20,6 +20,14 @@ extern "C" void RuntimeMain( HCore::ke_init_heap(); HCore::ke_init_ke_heap(); + kKernelVirtualSize = HandoverHeader->f_VirtualSize; + kKernelVirtualStart = HandoverHeader->f_VirtualStart; + + kKernelPhysicalSize = HandoverHeader->f_VirtualSize; + kKernelPhysicalStart = HandoverHeader->f_VirtualStart; + + HCore::HAL::hal_set_page_ptr((HCore::UIntPtr)kKernelVirtualStart); + MUST_PASS(HCore::ke_init_hal()); HCore::IFilesystemManager::Mount(new HCore::NewFilesystemManager()); diff --git a/Private/Source/SMPManager.cxx b/Private/Source/SMPManager.cxx index 37c2e592..87e82da1 100644 --- a/Private/Source/SMPManager.cxx +++ b/Private/Source/SMPManager.cxx @@ -7,7 +7,7 @@ * ======================================================== */ -#include <ArchKit/Arch.hpp> +#include <ArchKit/ArchKit.hpp> #include <KernelKit/ProcessManager.hpp> #include <KernelKit/SMPManager.hpp> diff --git a/Private/Source/Storage/ATA.cxx b/Private/Source/Storage/ATA.cxx index 184bb043..9d7a204e 100644 --- a/Private/Source/Storage/ATA.cxx +++ b/Private/Source/Storage/ATA.cxx @@ -7,7 +7,7 @@ * ======================================================== */ -#include <ArchKit/Arch.hpp> +#include <ArchKit/ArchKit.hpp> #include <StorageKit/ATA.hpp> //! @brief ATA DMA Driver diff --git a/Private/Source/Stream.cxx b/Private/Source/Stream.cxx index 668d5aee..ab1ca742 100644 --- a/Private/Source/Stream.cxx +++ b/Private/Source/Stream.cxx @@ -1,10 +1,12 @@ -/* - * ======================================================== - * - * HCore - * Copyright Mahrouss Logic, all rights reserved. - * - * ======================================================== - */ +/* ------------------------------------------- + + Copyright Mahrouss Logic + + File: Stream.cxx + Purpose: Stream object + + Revision History: + +------------------------------------------- */ #include <NewKit/Stream.hpp> diff --git a/Private/Source/URL.cxx b/Private/Source/URL.cxx index f1df4ee1..ab289a66 100644 --- a/Private/Source/URL.cxx +++ b/Private/Source/URL.cxx @@ -18,7 +18,7 @@ Url::Url(StringView &strUrl) : m_urlView(strUrl, false) {} Url::~Url() = default; -constexpr const char *kProtos[] = { +constexpr const char *kURLProtocols[] = { "https", // http with the secure. "http", // http without the secure "file", // filesystem protocol @@ -43,8 +43,8 @@ static ErrorOr<StringView> url_extract_location(const char *url) { for (; i < string_length(url); ++i) { if (!scheme_found) { for (int y = 0; kProtosCount; ++y) { - if (rt_string_in_string(view.CData(), kProtos[y])) { - i += string_length(kProtos[y]) + kUrlOutSz; + if (rt_string_in_string(view.CData(), kURLProtocols[y])) { + i += string_length(kURLProtocols[y]) + kUrlOutSz; scheme_found = true; break; diff --git a/Private/Source/UserHeap.cxx b/Private/Source/UserHeap.cxx index 0b6680a3..e22fe4f9 100644 --- a/Private/Source/UserHeap.cxx +++ b/Private/Source/UserHeap.cxx @@ -11,25 +11,30 @@ #include <NewKit/UserHeap.hpp> /// @file Heap.cxx -/// @brief Heap Manager, user mode allocator. -/// @note if you want to look at kernel allocs, please look for KHeap.cxx +/// @brief Heap Manager, Process heap allocator. +/// @note if you want to look at the kernel allocator, please look for KernelHeap.cxx /// bugs: 0 namespace HCore { +/** + * @brief Heap Manager class, takes care of allocating the process pools. + * @note This rely on Virtual Memory! Consider adding good vmem support when + * @note porting to a new arch. + */ class HeapManager final { public: - static SizeT& GetCount() { return s_NumPools; } - static Ref<Pmm>& GetPmm() { return s_Pmm; } - static Boolean& IsEnabled() { return s_PoolsAreEnabled; } - static Array<Ref<PTEWrapper*>, kPoolMaxSz>& The() { return s_Pool; } + STATIC SizeT& Count() { return s_NumPools; } + STATIC Ref<Pmm>& Leak() { return s_Pmm; } + STATIC Boolean& IsEnabled() { return s_PoolsAreEnabled; } + STATIC Array<Ref<PTEWrapper*>, kPoolMaxSz>& The() { return s_Pool; } private: - static Size s_NumPools; - static Ref<Pmm> s_Pmm; + STATIC Size s_NumPools; + STATIC Ref<Pmm> s_Pmm; private: - static Boolean s_PoolsAreEnabled; - static Array<Ref<PTEWrapper*>, kPoolMaxSz> s_Pool; + STATIC Boolean s_PoolsAreEnabled; + STATIC Array<Ref<PTEWrapper*>, kPoolMaxSz> s_Pool; }; //! declare fields @@ -39,16 +44,16 @@ Ref<Pmm> HeapManager::s_Pmm; Boolean HeapManager::s_PoolsAreEnabled = true; Array<Ref<PTEWrapper*>, kPoolMaxSz> HeapManager::s_Pool; -static voidPtr ke_find_unused_heap(Int flags); -static void ke_free_heap_internal(voidPtr vaddr); -static voidPtr ke_make_heap(voidPtr vaddr, Int flags); -static bool ke_check_and_free_heap(const SizeT& index, voidPtr ptr); +STATIC voidPtr ke_find_unused_heap(Int flags); +STATIC void ke_free_heap_internal(voidPtr vaddr); +STATIC voidPtr ke_make_heap(voidPtr vaddr, Int flags); +STATIC Boolean ke_check_and_free_heap(const SizeT& index, voidPtr ptr); -static voidPtr ke_find_unused_heap(Int flags) { +STATIC voidPtr ke_find_unused_heap(Int flags) { for (SizeT index = 0; index < kPoolMaxSz; ++index) { if (HeapManager::The()[index] && !HeapManager::The()[index].Leak().Leak().Leak()->Present()) { - HeapManager::GetPmm().Leak().TogglePresent( + HeapManager::Leak().Leak().TogglePresent( HeapManager::The()[index].Leak().Leak(), true); kcout << "[ke_find_unused_heap] Done, trying now to make a pool\r\n"; @@ -64,7 +69,7 @@ static voidPtr ke_find_unused_heap(Int flags) { return nullptr; } -static voidPtr ke_make_heap(voidPtr virtualAddress, Int flags) { +STATIC voidPtr ke_make_heap(voidPtr virtualAddress, Int flags) { if (virtualAddress) { HeapHeader* pool_hdr = reinterpret_cast<HeapHeader*>(virtualAddress); @@ -86,7 +91,7 @@ static voidPtr ke_make_heap(voidPtr virtualAddress, Int flags) { return nullptr; } -static void ke_free_heap_internal(voidPtr virtualAddress) { +STATIC void ke_free_heap_internal(voidPtr virtualAddress) { HeapHeader* pool_hdr = reinterpret_cast<HeapHeader*>( reinterpret_cast<UIntPtr>(virtualAddress) - sizeof(HeapHeader)); @@ -98,23 +103,29 @@ static void ke_free_heap_internal(voidPtr virtualAddress) { } } -static bool ke_check_and_free_heap(const SizeT& index, voidPtr ptr) { +/** + * @brief Check for the ptr and frees it. + * + * @param index Where to look at. + * @param ptr The ptr to check. + * @return Boolean true if successful. + */ +STATIC Boolean ke_check_and_free_heap(const SizeT& index, voidPtr ptr) { if (HeapManager::The()[index]) { - // ErrorOr<>::operator bool - if (!HeapManager::The()[index].Leak().Leak().IsStrong()) { - // we want them to be weak - // because we allocated it. - if (HeapManager::The()[index].Leak().Leak().Leak()->VirtualAddress() == - (UIntPtr)ptr) { - HeapManager::GetPmm().Leak().FreePage( - HeapManager::The()[index].Leak().Leak()); - --HeapManager::GetCount(); - - ke_free_heap_internal(ptr); - ptr = nullptr; - - return true; - } + // ErrorOr<>::operator Boolean + /// if address matches + /// -> Free Pool. + if (HeapManager::The()[index].Leak().Leak().Leak()->VirtualAddress() == + (UIntPtr)ptr) { + HeapManager::Leak().Leak().FreePage( + HeapManager::The()[index].Leak().Leak()); + + --HeapManager::Count(); + + ke_free_heap_internal(ptr); + ptr = nullptr; + + return true; } } @@ -127,20 +138,20 @@ static bool ke_check_and_free_heap(const SizeT& index, voidPtr ptr) { voidPtr ke_new_heap(Int32 flags) { if (!HeapManager::IsEnabled()) return nullptr; - if (HeapManager::GetCount() > kPoolMaxSz) return nullptr; + if (HeapManager::Count() > kPoolMaxSz) return nullptr; if (voidPtr ret = ke_find_unused_heap(flags)) return ret; // this wasn't set to true - auto ref_page = HeapManager::GetPmm().Leak().RequestPage( + auto ref_page = HeapManager::Leak().Leak().RequestPage( ((flags & kPoolUser)), (flags & kPoolRw)); + if (ref_page) { ///! reserve page. - HeapManager::The()[HeapManager::GetCount()].Leak() = ref_page; - auto& ref = HeapManager::GetCount(); - ++ref; // increment the number of addresses we have now. + HeapManager::The()[HeapManager::Count()].Leak() = ref_page; + auto& ref = HeapManager::Count(); - kcout << "[ke_new_heap] New Address found!\r\n"; + ++ref; // increment the number of addresses we have now. // finally make the pool address. return ke_make_heap( @@ -157,7 +168,7 @@ Int32 ke_free_heap(voidPtr ptr) { if (!HeapManager::IsEnabled()) return -1; if (ptr) { - SizeT base = HeapManager::GetCount(); + SizeT base = HeapManager::Count(); if (ke_check_and_free_heap(base, ptr)) return 0; @@ -171,10 +182,10 @@ Int32 ke_free_heap(voidPtr ptr) { return -1; } -/// @brief Init HeapManager, set GetCount to zero and IsEnabled to true. -/// @return +/// @brief Init HeapManager, set Count to zero and IsEnabled to true. +/// @return Void ke_init_heap() { - HeapManager::GetCount() = 0UL; + HeapManager::Count() = 0UL; HeapManager::IsEnabled() = true; } } // namespace HCore diff --git a/Private/StorageKit/ATA.hpp b/Private/StorageKit/ATA.hpp index f44c2843..279258ca 100644 --- a/Private/StorageKit/ATA.hpp +++ b/Private/StorageKit/ATA.hpp @@ -23,7 +23,7 @@ namespace HCore kRead48, kWrite28, kWrite48, - kUnknown + kATAUnknown }; const char* ata_read_28(ULong lba); @@ -90,7 +90,7 @@ namespace HCore return {}; } - case PATAType::kUnknown: + case PATAType::kATAUnknown: { kcout << "ErrorOr<CT> ata_read<CT, Command>: Unknown ATA Command...\n"; return {}; |
