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 | |
| parent | 44b7347157830e17fdb376d27a5d1cd402d2bd6f (diff) | |
Kernel: fixes and improvements.
Signed-off-by: Amlal El Mahrouss <amlalelmahrouss@icloud.com>
Diffstat (limited to 'Private/HALKit')
| -rw-r--r-- | Private/HALKit/AMD64/HalDebugOutput.cxx | 2 | ||||
| -rw-r--r-- | Private/HALKit/AMD64/HalHardwareInit.cpp | 2 | ||||
| -rw-r--r-- | Private/HALKit/AMD64/HalPageAlloc.cpp | 19 | ||||
| -rw-r--r-- | Private/HALKit/AMD64/HalPageAlloc.hpp | 2 | ||||
| -rw-r--r-- | Private/HALKit/AMD64/HalPlatformAMD64.cpp | 1 |
5 files changed, 10 insertions, 16 deletions
diff --git a/Private/HALKit/AMD64/HalDebugOutput.cxx b/Private/HALKit/AMD64/HalDebugOutput.cxx index 635537ae..f4d81338 100644 --- a/Private/HALKit/AMD64/HalDebugOutput.cxx +++ b/Private/HALKit/AMD64/HalDebugOutput.cxx @@ -69,8 +69,6 @@ void ke_io_print(const char *bytes) { ++index; } - HAL::Out8(Detail::PORT, '\r'); - HAL::Out8(Detail::PORT, '\n'); Detail::kState = kStateReady; } diff --git a/Private/HALKit/AMD64/HalHardwareInit.cpp b/Private/HALKit/AMD64/HalHardwareInit.cpp index 2a44f696..1c857ff7 100644 --- a/Private/HALKit/AMD64/HalHardwareInit.cpp +++ b/Private/HALKit/AMD64/HalHardwareInit.cpp @@ -18,7 +18,7 @@ bool ke_init_hal() { HCore::HAL::Register64 kIdtRegister; kIdtRegister.Base = (UIntPtr)__EXEC_IVT; - kIdtRegister.Limit = sizeof(HAL::Register64) * 256; + kIdtRegister.Limit = sizeof(HAL::Register64) * 255; HAL::IDTLoader idt; idt.Load(kIdtRegister); 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 diff --git a/Private/HALKit/AMD64/HalPageAlloc.hpp b/Private/HALKit/AMD64/HalPageAlloc.hpp index 9ca2c580..8717f3db 100644 --- a/Private/HALKit/AMD64/HalPageAlloc.hpp +++ b/Private/HALKit/AMD64/HalPageAlloc.hpp @@ -76,8 +76,6 @@ struct PageDirectory64 final { }; PageTable64* hal_alloc_page(SizeT sz, Boolean rw, Boolean user); -UIntPtr& hal_page_base() noexcept; -void hal_page_base(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 6374d06b..71b7542e 100644 --- a/Private/HALKit/AMD64/HalPlatformAMD64.cpp +++ b/Private/HALKit/AMD64/HalPlatformAMD64.cpp @@ -31,7 +31,6 @@ void GDTLoader::Load(Register64 &gdt) { void IDTLoader::Load(Register64 &idt) { Detail::RegisterAMD64 *reg = new Detail::RegisterAMD64(); - MUST_PASS(reg); reg->base = idt.Base; reg->limit = idt.Limit; |
