diff options
Diffstat (limited to 'Private/Source')
| -rw-r--r-- | Private/Source/Json.cxx | 16 | ||||
| -rw-r--r-- | Private/Source/KHeap.cxx | 159 | ||||
| -rw-r--r-- | Private/Source/MeBus/Database.cxx (renamed from Private/Source/MeBus/Database.cpp) | 0 | ||||
| -rw-r--r-- | Private/Source/NewFS-IO.cxx | 19 | ||||
| -rw-r--r-- | Private/Source/PermissionSelector.cxx | 34 | ||||
| -rw-r--r-- | Private/Source/ProcessManager.cxx | 12 | ||||
| -rw-r--r-- | Private/Source/RuntimeMain.cxx (renamed from Private/Source/KMain.cxx) | 20 |
7 files changed, 142 insertions, 118 deletions
diff --git a/Private/Source/Json.cxx b/Private/Source/Json.cxx index 25987f70..adfd571d 100644 --- a/Private/Source/Json.cxx +++ b/Private/Source/Json.cxx @@ -1,15 +1,15 @@ /* -* ======================================================== -* -* hCore -* Copyright 2024 Mahrouss Logic, all rights reserved. -* -* ======================================================== -*/ + * ======================================================== + * + * hCore + * Copyright 2024 Mahrouss Logic, all rights reserved. + * + * ======================================================== + */ #include <NewKit/Json.hpp> using namespace hCore; /// @brief Undefined object, is null in length. -JsonType JsonType::kUndefined(0, 0);
\ No newline at end of file +INIT(hCore::JsonType::kUndefined, hCore::JsonType); diff --git a/Private/Source/KHeap.cxx b/Private/Source/KHeap.cxx index 5f394e51..c36c6ad7 100644 --- a/Private/Source/KHeap.cxx +++ b/Private/Source/KHeap.cxx @@ -16,114 +16,111 @@ namespace hCore { - static Ref<PTEWrapper*> kWrapperList[kMaxWrappers]; - static SizeT kWrapperCount = 0UL; - static Ref<PTEWrapper*> kLastWrapper; - static Pmm kPmm; +static Ref<PTEWrapper *> kWrapperList[kMaxWrappers]; +static SizeT kWrapperCount = 0UL; +static Ref<PTEWrapper *> kLastWrapper; +static Pmm kPmm; - namespace Detail +namespace Detail +{ +static voidPtr find_ptr(const SizeT &sz, const bool rw, const bool user) +{ + for (SizeT indexWrapper = 0; indexWrapper < kMaxWrappers; ++indexWrapper) { - static voidPtr try_find_ptr(const SizeT &sz, const bool rw, const bool user) + if (!kWrapperList[indexWrapper]->Present()) { - for (SizeT indexWrapper = 0; indexWrapper < kMaxWrappers; ++indexWrapper) - { - if (!kWrapperList[indexWrapper]->Present()) - { - kWrapperList[indexWrapper]->Reclaim(); /* very straight-forward as you can see. */ - return reinterpret_cast<voidPtr>(kWrapperList[indexWrapper]->VirtualAddress()); - } - } - - return nullptr; + kWrapperList[indexWrapper]->Reclaim(); /* very straight-forward as you can see. */ + return reinterpret_cast<voidPtr>(kWrapperList[indexWrapper]->VirtualAddress()); } - } // namespace Detail - - /// @brief manual allocation - /// @param sz size of pointer - /// @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) - { - if (kWrapperCount < sz) - return nullptr; + } - if (auto ptr = Detail::try_find_ptr(sz, rw, user); - ptr) - return ptr; + return nullptr; +} +} // namespace Detail + +/// @brief manual allocation +/// @param sz size of pointer +/// @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) +{ + if (kWrapperCount < sz) + return nullptr; - Ref<PTEWrapper*> wrapper = kPmm.RequestPage(user, rw); + if (auto ptr = Detail::find_ptr(sz, rw, user); ptr) + return ptr; - if (wrapper) - { - kLastWrapper = wrapper; + Ref<PTEWrapper *> wrapper = kPmm.RequestPage(user, rw); - kWrapperList[kWrapperCount] = wrapper; - ++kWrapperCount; + if (wrapper) + { + kLastWrapper = wrapper; - return reinterpret_cast<voidPtr>(wrapper->VirtualAddress()); - } + kWrapperList[kWrapperCount] = wrapper; + ++kWrapperCount; - return nullptr; + return reinterpret_cast<voidPtr>(wrapper->VirtualAddress()); } - /// @brief Declare pointer as free. - /// @param ptr the pointer. - /// @return - Int32 kernel_delete_ptr(voidPtr ptr) + return nullptr; +} + +/// @brief Declare pointer as free. +/// @param ptr the pointer. +/// @return +Int32 kernel_delete_ptr(voidPtr ptr) +{ + if (ptr) { - if (ptr) - { - const UIntPtr virtualAddress = reinterpret_cast<UIntPtr>(ptr); + const UIntPtr virtualAddress = reinterpret_cast<UIntPtr>(ptr); - if (kLastWrapper && - virtualAddress == kLastWrapper->VirtualAddress()) - { - return kPmm.FreePage(kLastWrapper); - } + if (kLastWrapper && virtualAddress == kLastWrapper->VirtualAddress()) + { + return kPmm.FreePage(kLastWrapper); + } - Ref<PTEWrapper*> wrapper; + Ref<PTEWrapper *> wrapper; - for (SizeT indexWrapper = 0; indexWrapper < kWrapperCount; ++indexWrapper) + for (SizeT indexWrapper = 0; indexWrapper < kWrapperCount; ++indexWrapper) + { + if (kWrapperList[indexWrapper]->VirtualAddress() == virtualAddress) { - if (kWrapperList[indexWrapper]->VirtualAddress() == virtualAddress) - { - wrapper = kWrapperList[indexWrapper]; - return kPmm.FreePage(wrapper); - } + wrapper = kWrapperList[indexWrapper]; + return kPmm.FreePage(wrapper); } } - - return -1; } - /// @brief find pointer in kernel heap - /// @param ptr the pointer - /// @return if it exists. - Boolean kernel_valid_ptr(voidPtr ptr) + return -1; +} + +/// @brief find pointer in kernel heap +/// @param ptr the pointer +/// @return if it exists. +Boolean kernel_valid_ptr(voidPtr ptr) +{ + if (ptr) { - if (ptr) - { - const UIntPtr virtualAddress = reinterpret_cast<UIntPtr>(ptr); + const UIntPtr virtualAddress = reinterpret_cast<UIntPtr>(ptr); - if (kLastWrapper && - virtualAddress == kLastWrapper->VirtualAddress()) - { - return true; - } + if (kLastWrapper && virtualAddress == kLastWrapper->VirtualAddress()) + { + return true; + } - Ref<PTEWrapper*> wrapper; + Ref<PTEWrapper *> wrapper; - for (SizeT indexWrapper = 0; indexWrapper < kWrapperCount; ++indexWrapper) + for (SizeT indexWrapper = 0; indexWrapper < kWrapperCount; ++indexWrapper) + { + if (kWrapperList[indexWrapper]->VirtualAddress() == virtualAddress) { - if (kWrapperList[indexWrapper]->VirtualAddress() == virtualAddress) - { - wrapper = kWrapperList[indexWrapper]; - return true; - } + wrapper = kWrapperList[indexWrapper]; + return true; } } - - return false; } + + return false; +} } // namespace hCore diff --git a/Private/Source/MeBus/Database.cpp b/Private/Source/MeBus/Database.cxx index 3c7594d5..3c7594d5 100644 --- a/Private/Source/MeBus/Database.cpp +++ b/Private/Source/MeBus/Database.cxx diff --git a/Private/Source/NewFS-IO.cxx b/Private/Source/NewFS-IO.cxx index ce81db40..b9ecfd52 100644 --- a/Private/Source/NewFS-IO.cxx +++ b/Private/Source/NewFS-IO.cxx @@ -1,15 +1,14 @@ /* -* ======================================================== -* -* hCore -* Copyright 2024 Mahrouss Logic, all rights reserved. -* -* ======================================================== -*/ + * ======================================================== + * + * hCore + * Copyright 2024 Mahrouss Logic, all rights reserved. + * + * ======================================================== + */ #include <FSKit/NewFS.hxx> -#include <Private/KernelKit/FileManager.hpp> -#include <Private/KernelKit/DriveManager.hpp> +#include <KernelKit/DriveManager.hpp> +#include <KernelKit/FileManager.hpp> /// bugs 0 - diff --git a/Private/Source/PermissionSelector.cxx b/Private/Source/PermissionSelector.cxx index a14f146d..04245502 100644 --- a/Private/Source/PermissionSelector.cxx +++ b/Private/Source/PermissionSelector.cxx @@ -5,7 +5,7 @@ * Copyright 2024 Mahrouss Logic, all rights reserved. * * File: PermissionSelector.cpp - * Purpose: Permission primitives and types. + * Purpose: Permission primitive type. * * ======================================================== */ @@ -15,19 +15,29 @@ namespace hCore { - PermissionSelector::PermissionSelector(const Int32& sel) - : fRing((RingKind)sel) - { MUST_PASS(sel > 0); } +PermissionSelector::PermissionSelector(const Int32 &sel) : fRing((RingKind)sel) +{ + MUST_PASS(sel > 0); +} + +PermissionSelector::PermissionSelector(const RingKind &ringKind) : fRing(ringKind) +{ +} - PermissionSelector::PermissionSelector(const RingKind& ringKind) - : fRing(ringKind) - {} +PermissionSelector::~PermissionSelector() = default; - PermissionSelector::~PermissionSelector() = default; +bool PermissionSelector::operator==(const PermissionSelector &lhs) +{ + return lhs.fRing == this->fRing; +} - bool PermissionSelector::operator==(const PermissionSelector& lhs) { return lhs.fRing == this->fRing; } - - bool PermissionSelector::operator!=(const PermissionSelector& lhs) { return lhs.fRing != this->fRing; } +bool PermissionSelector::operator!=(const PermissionSelector &lhs) +{ + return lhs.fRing != this->fRing; +} - const RingKind& PermissionSelector::Ring() noexcept { return this->fRing; } +const RingKind &PermissionSelector::Ring() noexcept +{ + return this->fRing; +} } // namespace hCore diff --git a/Private/Source/ProcessManager.cxx b/Private/Source/ProcessManager.cxx index 5dcc98f2..4679daff 100644 --- a/Private/Source/ProcessManager.cxx +++ b/Private/Source/ProcessManager.cxx @@ -7,6 +7,7 @@ * ======================================================== */ +#include "NewKit/Panic.hpp" #include <KernelKit/ProcessManager.hpp> #include <KernelKit/SMPManager.hpp> #include <NewKit/KHeap.hpp> @@ -121,19 +122,25 @@ const ProcessStatus &Process::GetStatus() return this->Status; } +/** +@brief Affinity is the time slot allowed for the process. +*/ const AffinityKind &Process::GetAffinity() { return this->Affinity; } +/** +@brief Standard exit proc. +*/ void Process::Exit(Int32 exit_code) { if (this->ProcessId != ProcessManager::Shared().Leak().GetCurrent().Leak().ProcessId) - return; + panic(RUNTIME_CHECK_PROCESS); if (this->Ring == (Int32)ProcessSelector::kRingKernel && ProcessManager::Shared().Leak().GetCurrent().Leak().Ring > 0) - return; + panic(RUNTIME_CHECK_PROCESS); kExitCode = exit_code; @@ -200,6 +207,7 @@ SizeT ProcessManager::Run() noexcept for (; processIndex < this->m_Headers.Count(); ++processIndex) { auto process = this->m_Headers[processIndex]; + MUST_PASS( process); //! no need for a MUST_PASS(process.Leak());, it is recursive because of the nature of the class; diff --git a/Private/Source/KMain.cxx b/Private/Source/RuntimeMain.cxx index d2dac924..4b91bb5f 100644 --- a/Private/Source/KMain.cxx +++ b/Private/Source/RuntimeMain.cxx @@ -7,16 +7,26 @@ * ======================================================== */ -#include <KernelKit/FileManager.hpp> -#include <KernelKit/CodeManager.hpp> +#include "NewKit/Defines.hpp" #include <ArchKit/Arch.hpp> +#include <KernelKit/CodeManager.hpp> +#include <KernelKit/FileManager.hpp> +#include <NewKit/Json.hpp> -extern "C" void KMain(hCore::VoidPtr this_image) +extern void (*__SYSTEM_INIT_END)(); +extern void (**init)(); + +extern "C" void RuntimeMain() { - MUST_PASS(hCore::initialize_hardware_components()); + for (hCore::SizeT index_init = 0UL; init[index_init] != __SYSTEM_INIT_END; ++index_init) + { + init[index_init](); + } + + MUST_PASS(hCore::init_hal()); hCore::IFilesystemManager::Mount(new hCore::NewFilesystemManager()); - hCore::PEFLoader img("/System/SeekerSrv.out"); + hCore::PEFLoader img("/System/Seeker.cm"); if (!hCore::Utils::execute_from_image(img)) { |
