summaryrefslogtreecommitdiffhomepage
path: root/Private/Source
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-01-30 17:59:15 +0100
committerAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-01-30 17:59:15 +0100
commit1be243700efc9e36060c5fb65c951d5db6b98e94 (patch)
tree2f57d5092f4de4798e80e80b6dd29f984edb7683 /Private/Source
parent1d3bed385c9666db5b1803ee8e02a2c4fdcc9f29 (diff)
Add ROADMAP details, add EFI Library for bootloader.
Add assignee to code in MailMap. Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'Private/Source')
-rw-r--r--Private/Source/CodeManager.cxx4
-rw-r--r--Private/Source/KernelHeap.cxx13
-rw-r--r--Private/Source/New+Delete.cxx10
-rw-r--r--Private/Source/PageManager.cxx2
-rw-r--r--Private/Source/ProcessManager.cxx10
-rw-r--r--Private/Source/RuntimeMain.cxx7
-rw-r--r--Private/Source/URL.cxx2
-rw-r--r--Private/Source/UserHeap.cxx24
-rw-r--r--Private/Source/Utils.cxx8
9 files changed, 43 insertions, 37 deletions
diff --git a/Private/Source/CodeManager.cxx b/Private/Source/CodeManager.cxx
index 364a94f6..911aefd3 100644
--- a/Private/Source/CodeManager.cxx
+++ b/Private/Source/CodeManager.cxx
@@ -57,7 +57,7 @@ PEFLoader::PEFLoader(const char *path) : fCachedBlob(nullptr), fBad(false) {
"started!\n";
fBad = true;
- kernel_delete_ptr(fCachedBlob);
+ ke_delete_ke_heap(fCachedBlob);
fCachedBlob = nullptr;
};
@@ -78,7 +78,7 @@ PEFLoader::PEFLoader(const char *path) : fCachedBlob(nullptr), fBad(false) {
}
PEFLoader::~PEFLoader() {
- if (fCachedBlob) kernel_delete_ptr(fCachedBlob);
+ if (fCachedBlob) ke_delete_ke_heap(fCachedBlob);
}
VoidPtr PEFLoader::FindSymbol(const char *name, Int32 kind) {
diff --git a/Private/Source/KernelHeap.cxx b/Private/Source/KernelHeap.cxx
index 94e9156c..3e61a733 100644
--- a/Private/Source/KernelHeap.cxx
+++ b/Private/Source/KernelHeap.cxx
@@ -40,7 +40,7 @@ static voidPtr find_ptr(const SizeT &sz, const bool rw, const bool user) {
/// @param rw read write (true to enable it)
/// @param user is it accesible by user processes?
/// @return the pointer
-VoidPtr kernel_new_ptr(const SizeT &sz, const bool rw, const bool user) {
+VoidPtr ke_new_ke_heap(const SizeT &sz, const bool rw, const bool user) {
if (kWrapperCount < sz) return nullptr;
if (auto ptr = Detail::find_ptr(sz, rw, user); ptr) return ptr;
@@ -62,7 +62,7 @@ VoidPtr kernel_new_ptr(const SizeT &sz, const bool rw, const bool user) {
/// @brief Declare pointer as free.
/// @param ptr the pointer.
/// @return
-Int32 kernel_delete_ptr(voidPtr ptr) {
+Int32 ke_delete_ke_heap(voidPtr ptr) {
if (ptr) {
const UIntPtr virtualAddress = reinterpret_cast<UIntPtr>(ptr);
@@ -106,4 +106,13 @@ Boolean kernel_valid_ptr(voidPtr ptr) {
return false;
}
+
+/// @brief The Kernel heap initializer function.
+/// @return
+Void ke_init_ke_heap() noexcept
+{
+ kWrapperCount = 0UL;
+ Ref<PTEWrapper *> kLastWrapper = Ref<PTEWrapper*>(nullptr);
+ Pmm kPmm = Pmm();
+}
} // namespace HCore
diff --git a/Private/Source/New+Delete.cxx b/Private/Source/New+Delete.cxx
index e4dba396..274258a4 100644
--- a/Private/Source/New+Delete.cxx
+++ b/Private/Source/New+Delete.cxx
@@ -15,7 +15,7 @@ void* operator new[](size_t sz)
if (sz == 0)
++sz;
- return HCore::kernel_new_ptr(sz, true, false);
+ return HCore::ke_new_ke_heap(sz, true, false);
}
void* operator new(size_t sz)
@@ -23,7 +23,7 @@ void* operator new(size_t sz)
if (sz == 0)
++sz;
- return HCore::kernel_new_ptr(sz, true, false);
+ return HCore::ke_new_ke_heap(sz, true, false);
}
void operator delete[](void* ptr)
@@ -31,7 +31,7 @@ void operator delete[](void* ptr)
if (ptr == nullptr)
return;
- HCore::kernel_delete_ptr(ptr);
+ HCore::ke_delete_ke_heap(ptr);
}
void operator delete(void* ptr)
@@ -39,7 +39,7 @@ void operator delete(void* ptr)
if (ptr == nullptr)
return;
- HCore::kernel_delete_ptr(ptr);
+ HCore::ke_delete_ke_heap(ptr);
}
void operator delete(void* ptr, size_t sz)
@@ -49,6 +49,6 @@ void operator delete(void* ptr, size_t sz)
(void)sz;
- HCore::kernel_delete_ptr(ptr);
+ HCore::ke_delete_ke_heap(ptr);
}
diff --git a/Private/Source/PageManager.cxx b/Private/Source/PageManager.cxx
index 95300bd9..8ae083a3 100644
--- a/Private/Source/PageManager.cxx
+++ b/Private/Source/PageManager.cxx
@@ -65,7 +65,7 @@ PTEWrapper *PageManager::Request(Boolean Rw, Boolean User,
HCore::HAL::hal_alloc_page(sizeof(PTEWrapper), Rw, User));
if (PageTableEntry == nullptr) {
- kcout << "PTEWrapper : Page table is nullptr!, kernel_new_ptr failed!";
+ kcout << "PTEWrapper : Page table is nullptr!, ke_new_ke_heap failed!";
return nullptr;
}
diff --git a/Private/Source/ProcessManager.cxx b/Private/Source/ProcessManager.cxx
index 9d1792a2..404e05e6 100644
--- a/Private/Source/ProcessManager.cxx
+++ b/Private/Source/ProcessManager.cxx
@@ -132,7 +132,7 @@ void Process::Exit(Int32 exit_code) {
if (this->Ring != (Int32)ProcessSelector::kRingDriver &&
this->Ring != (Int32)ProcessSelector::kRingKernel) {
- pool_free_ptr(this->Pool);
+ ke_free_heap(this->Pool);
this->PoolCursor = nullptr;
@@ -141,9 +141,9 @@ void Process::Exit(Int32 exit_code) {
}
//! Delete image if not done already.
- if (this->Image) kernel_delete_ptr(this->Image);
+ if (this->Image) ke_delete_ke_heap(this->Image);
- if (this->StackFrame) kernel_delete_ptr((VoidPtr)this->StackFrame);
+ if (this->StackFrame) ke_delete_ke_heap((VoidPtr)this->StackFrame);
ProcessManager::Shared().Leak().Remove(this->ProcessId);
}
@@ -153,12 +153,12 @@ bool ProcessManager::Add(Ref<Process> &process) {
kcout << "ProcessManager::Add(Ref<Process>& process)\r\n";
- process.Leak().Pool = pool_new_ptr(kPoolUser | kPoolRw);
+ process.Leak().Pool = ke_new_heap(kPoolUser | kPoolRw);
process.Leak().ProcessId = this->m_Headers.Count();
process.Leak().PoolCursor = process.Leak().Pool;
process.Leak().StackFrame = reinterpret_cast<HAL::StackFrame *>(
- kernel_new_ptr(sizeof(HAL::StackFrame), true, false));
+ ke_new_ke_heap(sizeof(HAL::StackFrame), true, false));
MUST_PASS(process.Leak().StackFrame);
diff --git a/Private/Source/RuntimeMain.cxx b/Private/Source/RuntimeMain.cxx
index 6ae257bc..94a483c5 100644
--- a/Private/Source/RuntimeMain.cxx
+++ b/Private/Source/RuntimeMain.cxx
@@ -11,6 +11,8 @@
#include <KernelKit/CodeManager.hpp>
#include <KernelKit/FileManager.hpp>
#include <NewKit/Json.hpp>
+#include <NewKit/KernelHeap.hpp>
+#include <NewKit/UserHeap.hpp>
/// PRIVATE SYMBOLS EXPORTED BY GCC.
extern "C" void (*__SYSTEM_FINI)();
@@ -22,7 +24,10 @@ extern "C" void RuntimeMain() {
__SYSTEM_INIT[index_init]();
}
- MUST_PASS(HCore::init_hal());
+ MUST_PASS(HCore::ke_init_hal());
+
+ HCore::ke_init_heap();
+ HCore::ke_init_ke_heap();
HCore::IFilesystemManager::Mount(new HCore::NewFilesystemManager());
HCore::PEFLoader img("/System/Seeker.cm");
diff --git a/Private/Source/URL.cxx b/Private/Source/URL.cxx
index cd676c30..f242dd32 100644
--- a/Private/Source/URL.cxx
+++ b/Private/Source/URL.cxx
@@ -43,7 +43,7 @@ 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 (string_in_string(view.CData(), kProtos[y])) {
+ if (rt_string_in_string(view.CData(), kProtos[y])) {
i += string_length(kProtos[y]) + kUrlOutSz;
scheme_found = true;
diff --git a/Private/Source/UserHeap.cxx b/Private/Source/UserHeap.cxx
index 9df475e7..b34e123e 100644
--- a/Private/Source/UserHeap.cxx
+++ b/Private/Source/UserHeap.cxx
@@ -124,7 +124,7 @@ static bool ke_check_and_free_heap(const SizeT& index, voidPtr ptr) {
/// @brief Creates a new pool pointer.
/// @param flags the flags attached to it.
/// @return a pool pointer with selected permissions.
-voidPtr pool_new_ptr(Int32 flags) {
+voidPtr ke_new_heap(Int32 flags) {
if (!HeapManager::IsEnabled()) return nullptr;
if (HeapManager::GetCount() > kPoolMaxSz) return nullptr;
@@ -140,7 +140,7 @@ voidPtr pool_new_ptr(Int32 flags) {
auto& ref = HeapManager::GetCount();
++ref; // increment the number of addresses we have now.
- kcout << "[pool_new_ptr] New Address found!\r\n";
+ kcout << "[ke_new_heap] New Address found!\r\n";
// finally make the pool address.
return ke_make_heap(
@@ -153,7 +153,7 @@ voidPtr pool_new_ptr(Int32 flags) {
/// @brief free a pool pointer.
/// @param ptr The pool pointer to free.
/// @return status code
-Int32 pool_free_ptr(voidPtr ptr) {
+Int32 ke_free_heap(voidPtr ptr) {
if (!HeapManager::IsEnabled()) return -1;
if (ptr) {
@@ -171,18 +171,10 @@ Int32 pool_free_ptr(voidPtr ptr) {
return -1;
}
-/// @brief Checks if pointer is valid.
-/// @param thePool the pool pointer.
-/// @param thePtr the pointer.
-/// @param theLimit the last address of the pool.
-/// @return if it is valid.
-Boolean pool_ptr_exists(UIntPtr thePool, UIntPtr thePtr, SizeT theLimit) {
- if (HeapManager::GetCount() < 1) return false;
-
- if (thePool == 0 || thePtr == 0 || theLimit == 0) {
- return false;
- }
-
- return ((thePool) < (thePtr) < (theLimit));
+/// @brief Init HeapManager, set GetCount to zero and IsEnabled to true.
+/// @return
+Void ke_init_heap() {
+ HeapManager::GetCount() = 0UL;
+ HeapManager::IsEnabled() = true;
}
} // namespace HCore
diff --git a/Private/Source/Utils.cxx b/Private/Source/Utils.cxx
index 3a3ba2a0..7c61ec96 100644
--- a/Private/Source/Utils.cxx
+++ b/Private/Source/Utils.cxx
@@ -107,13 +107,13 @@ const Char *alloc_string(const Char *text) {
return string;
}
-Int to_uppercase(Int character) {
+Int rt_to_uppercase(Int character) {
if (character >= 'a' && character <= 'z') return character - 0x20;
return character;
}
-Int to_lower(Int character) {
+Int rt_to_lower(Int character) {
if (character >= 'A' && character <= 'Z') return character + 0x20;
return character;
@@ -143,7 +143,7 @@ Boolean is_space(Char chr) { return chr == ' '; }
Boolean is_newln(Char chr) { return chr == '\n'; }
-voidPtr string_in_string(const char *in, const char *needle) {
+voidPtr rt_string_in_string(const char *in, const char *needle) {
for (size_t i = 0; i < string_length(in); ++i) {
if (string_compare(in + i, needle, string_length(needle)) == 0)
return reinterpret_cast<voidPtr>(const_cast<char *>(in + i));
@@ -154,7 +154,7 @@ voidPtr string_in_string(const char *in, const char *needle) {
// @brief Checks for a string start at the character.
-char *string_from_char(char *str, const char chr) {
+char *rt_string_from_char(char *str, const char chr) {
while (*str != chr) {
++str;