summaryrefslogtreecommitdiffhomepage
path: root/Private/HALKit
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@el-mahrouss-logic.com>2024-03-20 18:24:58 +0100
committerAmlal El Mahrouss <amlal@el-mahrouss-logic.com>2024-03-20 18:25:02 +0100
commitf48c5b2cda43241919d3ea1b263bef01e014c537 (patch)
tree5bf74621fcff0a98163b3908d35cef2a6339bfb7 /Private/HALKit
parent4ba02280f19b8a2beb1ad8445be7df6b7f9e1805 (diff)
Kernel: See below.
- Fix: Kernel page alloc. Inside HalPageAlloc.cpp. - Made NewFSJournalRunner fields private. - Rework StorageKit for current ticket 14. - :boom: Breaking changes to virtual memory api. Signed-off-by: Amlal El Mahrouss <amlal@el-mahrouss-logic.com>
Diffstat (limited to 'Private/HALKit')
-rw-r--r--Private/HALKit/AMD64/HalKernelMain.cxx2
-rw-r--r--Private/HALKit/AMD64/HalPageAlloc.cpp56
-rw-r--r--Private/HALKit/AMD64/HalPageAlloc.hpp3
-rw-r--r--Private/HALKit/PowerPC/HalHardware.cxx3
4 files changed, 20 insertions, 44 deletions
diff --git a/Private/HALKit/AMD64/HalKernelMain.cxx b/Private/HALKit/AMD64/HalKernelMain.cxx
index 2b420bb9..6c2ad263 100644
--- a/Private/HALKit/AMD64/HalKernelMain.cxx
+++ b/Private/HALKit/AMD64/HalKernelMain.cxx
@@ -32,8 +32,6 @@ EXTERN_C void RuntimeMain(
kKernelPhysicalSize = HandoverHeader->f_PhysicalSize;
kKernelPhysicalStart = HandoverHeader->f_PhysicalStart;
- hal_write_cr3((HCore::UIntPtr)kKernelVirtualStart);
-
STATIC HCore::HAL::Detail::HCoreGDT GDT = {
{0, 0, 0, 0x00, 0x00, 0}, // null entry
{0, 0, 0, 0x9a, 0xaf, 0}, // kernel code
diff --git a/Private/HALKit/AMD64/HalPageAlloc.cpp b/Private/HALKit/AMD64/HalPageAlloc.cpp
index 91bde617..5f6564c0 100644
--- a/Private/HALKit/AMD64/HalPageAlloc.cpp
+++ b/Private/HALKit/AMD64/HalPageAlloc.cpp
@@ -9,13 +9,7 @@
#include <NewKit/Defines.hpp>
#include <NewKit/KernelCheck.hpp>
-// this files handles paging.
-
-STATIC HCore::SizeT kPageCnt = 0UL;
STATIC HCore::Boolean kAllocationInProgress = false;
-
-#define kKernelPagingPadding kPTEAlign
-
namespace HCore {
namespace HAL {
/// @brief Allocates a new page of memory.
@@ -23,47 +17,33 @@ namespace HAL {
/// @param rw read/write flag.
/// @param user user flag.
/// @return the page table of it.
-STATIC auto hal_try_alloc_new_page(SizeT sz, Boolean rw, Boolean user)
- -> VoidPtr {
- MUST_PASS(sz > 0);
-
+STATIC auto hal_try_alloc_new_page(Boolean rw, Boolean user) -> VoidPtr {
kAllocationInProgress = true;
- PDE* cr3 = (PDE*)hal_read_cr3();
+ PTE* newAddress = (PTE*)kKernelVirtualStart;
- kcout << "HCoreKrnl.exe: CR3: " << hex_number((UIntPtr)cr3) << endl;
-
- for (size_t i = 0; i < kPTESize; ++i)
- {
- if (cr3->Pte[i].Present) continue;
- kcout << "HCoreKrnl.exe: Page index: " << hex_number(i) << endl;
-
- cr3->Pte[i].Rw = rw;
- cr3->Pte[i].User = user;
- cr3->Pte[i].Present = true;
+ while (newAddress->Present) {
+ newAddress = newAddress + sizeof(PTE);
+ }
- ++kPageCnt;
+ newAddress->Present = true;
+ newAddress->Rw = rw;
+ newAddress->User = user;
- kAllocationInProgress = false;
- kcout << "HCoreKrnl.exe: Allocation done for: " << hex_number(i) << endl;
- return (VoidPtr)cr3->Pte[i].PhysicalAddress;
- }
-
kAllocationInProgress = false;
- return nullptr;
-}
-auto hal_alloc_page(SizeT sz, Boolean rw, Boolean user) -> VoidPtr {
- while (kAllocationInProgress) {}
+ return reinterpret_cast<VoidPtr>(newAddress);
+}
- if (sz == 0)
- ++sz;
+/// @brief Allocate a new page to be used by the OS.
+/// @param rw
+/// @param user
+/// @return
+auto hal_alloc_page(Boolean rw, Boolean user) -> VoidPtr {
+ while (kAllocationInProgress) {
+ }
/// allocate new page.
- return hal_try_alloc_new_page(sz, rw, user);
-}
-
-auto hal_create_page(Boolean rw, Boolean user) -> UIntPtr {
- return reinterpret_cast<UIntPtr>(hal_alloc_page(sizeof(PageTable64), rw, user));
+ return hal_try_alloc_new_page(rw, user);
}
} // namespace HAL
} // namespace HCore
diff --git a/Private/HALKit/AMD64/HalPageAlloc.hpp b/Private/HALKit/AMD64/HalPageAlloc.hpp
index 2ce56b5a..5fe55992 100644
--- a/Private/HALKit/AMD64/HalPageAlloc.hpp
+++ b/Private/HALKit/AMD64/HalPageAlloc.hpp
@@ -72,8 +72,7 @@ struct PageDirectory64 final {
PageTable64 ALIGN(kPTEAlign) Pte[kPTEMax];
};
-VoidPtr hal_alloc_page(SizeT sz, Boolean rw, Boolean user);
-UIntPtr hal_create_page(Boolean rw, Boolean user);
+VoidPtr hal_alloc_page(Boolean rw, Boolean user);
} // namespace HCore::HAL
namespace HCore {
diff --git a/Private/HALKit/PowerPC/HalHardware.cxx b/Private/HALKit/PowerPC/HalHardware.cxx
index 340f515e..49e85138 100644
--- a/Private/HALKit/PowerPC/HalHardware.cxx
+++ b/Private/HALKit/PowerPC/HalHardware.cxx
@@ -9,8 +9,7 @@
namespace HCore {
namespace HAL {
-UIntPtr hal_create_page(bool rw, bool user) { return 0; }
-UIntPtr hal_alloc_page(UIntPtr offset, bool rw, bool user) { return 0; }
+UIntPtr hal_alloc_page(bool rw, bool user) { return 0; }
} // namespace HAL
// @brief wakes up thread.