diff options
| author | Amlal El Mahrouss <amlalelmahrouss@icloud.com> | 2024-02-21 22:22:54 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlalelmahrouss@icloud.com> | 2024-02-21 22:22:54 +0100 |
| commit | 223aad0fd3f8af6f69eb6429e5514bc888afe0d9 (patch) | |
| tree | 7de1e607423f3af6791d659a8f72556ecc798f72 /Private/HALKit/AMD64/HalPageAlloc.cpp | |
| parent | 44b7347157830e17fdb376d27a5d1cd402d2bd6f (diff) | |
Kernel: fixes and improvements.
Signed-off-by: Amlal El Mahrouss <amlalelmahrouss@icloud.com>
Diffstat (limited to 'Private/HALKit/AMD64/HalPageAlloc.cpp')
| -rw-r--r-- | Private/HALKit/AMD64/HalPageAlloc.cpp | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/Private/HALKit/AMD64/HalPageAlloc.cpp b/Private/HALKit/AMD64/HalPageAlloc.cpp index d94d994d..8920f295 100644 --- a/Private/HALKit/AMD64/HalPageAlloc.cpp +++ b/Private/HALKit/AMD64/HalPageAlloc.cpp @@ -7,33 +7,36 @@ * ======================================================== */ +#include <ArchKit/ArchKit.hpp> #include <HALKit/AMD64/HalPageAlloc.hpp> -#include <NewKit/RuntimeCheck.hpp> #include <NewKit/Defines.hpp> +#include <NewKit/RuntimeCheck.hpp> // this files handles paging. -static HCore::UIntPtr kPagePtr = 0; static HCore::SizeT kPageCnt = 0UL; +#define kPagePad 512 + namespace HCore { namespace HAL { static auto hal_try_alloc_new_page(SizeT sz, Boolean rw, Boolean user) -> PageTable64 * { - char *ptr = &(reinterpret_cast<char *>(kPagePtr))[kPageCnt + 1]; - - PageTable64 *pte = reinterpret_cast<PageTable64 *>(ptr); + PageTable64 *pte = reinterpret_cast<PageTable64 *>( + (UIntPtr)kKernelVirtualStart + kPageCnt + kPagePad); pte->Rw = rw; pte->User = user; pte->Present = true; + kKernelVirtualStart = (VoidPtr)((UIntPtr)kKernelVirtualStart + kPageCnt + sz); return pte; } auto hal_alloc_page(SizeT sz, Boolean rw, Boolean user) -> PageTable64 * { for (SizeT i = 0; i < kPageCnt; ++i) { - PageTable64 *pte = (reinterpret_cast<PageTable64 *>(&kPagePtr) + i); + PageTable64 *pte = reinterpret_cast<PageTable64 *>( + (UIntPtr)kKernelVirtualStart + kPageCnt); if (!pte->Present) { pte->User = user; @@ -53,9 +56,5 @@ auto hal_create_page(Boolean rw, Boolean user) -> UIntPtr { return reinterpret_cast<UIntPtr>(new_pte); } - -UIntPtr& hal_page_base() noexcept { return kPagePtr; } - -void hal_page_base(const UIntPtr& newPagePtr) noexcept { kPagePtr = newPagePtr; } } // namespace HAL } // namespace HCore |
