summaryrefslogtreecommitdiffhomepage
path: root/Private
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-01-28 16:26:33 +0100
committerAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-01-28 16:26:33 +0100
commit06be6d65bb71152be8a28d7bb6b1028b5a588654 (patch)
treeb47625ad70e5ec6093187f9d454f4edeaffb5ed1 /Private
parentf69bd40d5d97e371451d2e9c27721422141d828f (diff)
NewKernel: Final things are getting done for the first prototype.
NewBoot: Add ARM64 to HEL. SPEC: Update it to include NewFS into it. Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'Private')
-rw-r--r--Private/ArchKit/Arch.hpp2
-rw-r--r--Private/HALKit/AMD64/ArchAMD64.cpp55
-rw-r--r--Private/HALKit/AMD64/HardwareInit.cpp2
-rw-r--r--Private/HALKit/AMD64/PlatformAMD64.cpp58
-rw-r--r--Private/HALKit/AMD64/StartSequence.asm34
-rw-r--r--Private/HALKit/PowerPC/Processor.cpp2
-rw-r--r--Private/KernelKit/FileManager.hpp6
-rw-r--r--Private/KernelKit/PEF.hpp127
-rw-r--r--Private/Linker/AMD64.ld12
-rw-r--r--Private/NewBoot/Source/HEL/ARM64/.gitkeep0
-rw-r--r--Private/NewKit/Json.hpp128
-rw-r--r--Private/NewKit/KHeap.hpp4
-rw-r--r--Private/NewKit/Panic.hpp20
-rw-r--r--Private/Source/Json.cxx16
-rw-r--r--Private/Source/KHeap.cxx159
-rw-r--r--Private/Source/MeBus/Database.cxx (renamed from Private/Source/MeBus/Database.cpp)0
-rw-r--r--Private/Source/NewFS-IO.cxx19
-rw-r--r--Private/Source/PermissionSelector.cxx34
-rw-r--r--Private/Source/ProcessManager.cxx12
-rw-r--r--Private/Source/RuntimeMain.cxx (renamed from Private/Source/KMain.cxx)20
-rw-r--r--Private/makefile2
21 files changed, 393 insertions, 319 deletions
diff --git a/Private/ArchKit/Arch.hpp b/Private/ArchKit/Arch.hpp
index 3a1eb148..75b5aada 100644
--- a/Private/ArchKit/Arch.hpp
+++ b/Private/ArchKit/Arch.hpp
@@ -71,7 +71,7 @@ namespace hCore
return hash;
}
- bool initialize_hardware_components();
+ bool init_hal();
} // namespace hCore
#define kMaxSyscalls 0x100
diff --git a/Private/HALKit/AMD64/ArchAMD64.cpp b/Private/HALKit/AMD64/ArchAMD64.cpp
deleted file mode 100644
index 75d46bb8..00000000
--- a/Private/HALKit/AMD64/ArchAMD64.cpp
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * ========================================================
- *
- * hCore
- * Copyright 2024 Mahrouss Logic, all rights reserved.
- *
- * ========================================================
- */
-
-#include <ArchKit/Arch.hpp>
-
-namespace hCore::HAL
-{
- struct RegisterAMD64
- {
- UIntPtr base;
- UShort limit;
- };
-
- void GDTLoader::Load(Register64 &gdt)
- {
- RegisterAMD64* reg = new RegisterAMD64();
- MUST_PASS(reg);
-
- reg->base = gdt.Base;
- reg->limit = gdt.Limit;
-
- rt_cli();
- load_gdt(reg);
- rt_sti();
- }
-
- void IDTLoader::Load(Register64 &idt)
- {
- RegisterAMD64* reg = new RegisterAMD64();
- MUST_PASS(reg);
-
- reg->base = idt.Base;
- reg->limit = idt.Limit;
-
- rt_cli();
- load_idt(reg);
- rt_sti();
- }
-
- void GDTLoader::Load(Ref<Register64> &gdt)
- {
- GDTLoader::Load(gdt.Leak());
- }
-
- void IDTLoader::Load(Ref<Register64> &idt)
- {
- IDTLoader::Load(idt.Leak());
- }
-} // namespace hCore::HAL
diff --git a/Private/HALKit/AMD64/HardwareInit.cpp b/Private/HALKit/AMD64/HardwareInit.cpp
index 18e2a19c..367f083b 100644
--- a/Private/HALKit/AMD64/HardwareInit.cpp
+++ b/Private/HALKit/AMD64/HardwareInit.cpp
@@ -13,7 +13,7 @@
namespace hCore
{
- bool initialize_hardware_components()
+ bool init_hal()
{
// TODO: Hardware Specific stuff.
diff --git a/Private/HALKit/AMD64/PlatformAMD64.cpp b/Private/HALKit/AMD64/PlatformAMD64.cpp
new file mode 100644
index 00000000..0bade8dc
--- /dev/null
+++ b/Private/HALKit/AMD64/PlatformAMD64.cpp
@@ -0,0 +1,58 @@
+/*
+ * ========================================================
+ *
+ * hCore
+ * Copyright 2024 Mahrouss Logic, all rights reserved.
+ *
+ * ========================================================
+ */
+
+#include <ArchKit/Arch.hpp>
+
+namespace hCore::HAL
+{
+namespace Detail
+{
+struct RegisterAMD64 final
+{
+ UIntPtr base;
+ UShort limit;
+};
+} // namespace Detail
+
+void GDTLoader::Load(Register64 &gdt)
+{
+ Detail::RegisterAMD64 *reg = new Detail::RegisterAMD64();
+ MUST_PASS(reg);
+
+ reg->base = gdt.Base;
+ reg->limit = gdt.Limit;
+
+ rt_cli();
+ load_gdt(reg);
+ rt_sti();
+}
+
+void IDTLoader::Load(Register64 &idt)
+{
+ Detail::RegisterAMD64 *reg = new Detail::RegisterAMD64();
+ MUST_PASS(reg);
+
+ reg->base = idt.Base;
+ reg->limit = idt.Limit;
+
+ rt_cli();
+ load_idt(reg);
+ rt_sti();
+}
+
+void GDTLoader::Load(Ref<Register64> &gdt)
+{
+ GDTLoader::Load(gdt.Leak());
+}
+
+void IDTLoader::Load(Ref<Register64> &idt)
+{
+ IDTLoader::Load(idt.Leak());
+}
+} // namespace hCore::HAL
diff --git a/Private/HALKit/AMD64/StartSequence.asm b/Private/HALKit/AMD64/StartSequence.asm
new file mode 100644
index 00000000..533db858
--- /dev/null
+++ b/Private/HALKit/AMD64/StartSequence.asm
@@ -0,0 +1,34 @@
+;; /*
+;; * ========================================================
+;; *
+;; * hCore
+;; * Copyright 2024 Mahrouss Logic, all rights reserved.
+;; *
+;; * ========================================================
+;; */
+
+[bits 64]
+[global Main]
+[extern RuntimeMain]
+
+section .text
+
+NewBootMagic: dw 0x55FF66
+NewBootKernel: db "h-core", 0
+NewBootVersion: dw 1
+
+;; This NewBootStart points to Main.
+NewBootStart:
+;; Just a simple setup, we'd also need to tell some before
+Main:
+ mov rsp, __SYSTEM_STACK_END
+ mov ebp, RuntimeMain
+ jmp RuntimeMain
+L0:
+ cli
+ hlt
+ jmp $
+
+MainBIOS:
+ cli hlt
+ jmp $
diff --git a/Private/HALKit/PowerPC/Processor.cpp b/Private/HALKit/PowerPC/Processor.cpp
index b134cf92..dc614fa9 100644
--- a/Private/HALKit/PowerPC/Processor.cpp
+++ b/Private/HALKit/PowerPC/Processor.cpp
@@ -44,7 +44,7 @@ void rt_hang_thread(HAL::StackFrame* stack)
}
// @brief main HAL entrypoint
-void initialize_hardware_components()
+void init_hal()
{
}
diff --git a/Private/KernelKit/FileManager.hpp b/Private/KernelKit/FileManager.hpp
index b3754f88..a1391c34 100644
--- a/Private/KernelKit/FileManager.hpp
+++ b/Private/KernelKit/FileManager.hpp
@@ -223,14 +223,14 @@ template <typename Encoding = char, typename FSClass = NewFilesystemManager> cla
}
public:
- const char *MIME() noexcept
+ char *MIME() noexcept
{
- return fMime;
+ return const_cast<char *>(fMime);
}
private:
NodePtr fFile;
- Char *fMime{"application-type/*"};
+ const Char *fMime{"application-type/*"};
};
using FileStreamUTF8 = FileStream<char>;
diff --git a/Private/KernelKit/PEF.hpp b/Private/KernelKit/PEF.hpp
index a2f5c5b8..ecf90348 100644
--- a/Private/KernelKit/PEF.hpp
+++ b/Private/KernelKit/PEF.hpp
@@ -10,11 +10,11 @@
#ifndef _INC_LOADER_PEF_HPP
#define _INC_LOADER_PEF_HPP
-#include <NewKit/Defines.hpp>
-#include <KernelKit/Loader.hpp>
#include <CompilerKit/Compiler.hpp>
+#include <KernelKit/Loader.hpp>
+#include <NewKit/Defines.hpp>
-#define kPefMagic "PEF"
+#define kPefMagic "PEF"
#define kPefMagicFat "FEP"
#define kPefMagicLen 3
@@ -26,68 +26,69 @@
namespace hCore
{
- enum
- {
- kPefArchIntel86S,
- kPefArchAMD64,
- kPefArchRISCV,
- kPefArch64x0, /* 64x000. */
- kPefArch32x0,
- kPefArchInvalid = 0xFF,
- };
-
- enum
- {
- kPefKindExec = 1, /* .exe */
- kPefKindSharedObject = 2, /* .lib */
- kPefKindObject = 4, /* .obj */
- kPefKindDebug = 5, /* .debug */
- };
-
- typedef struct PEFContainer final
- {
- Char Magic[kPefMagicLen];
- UInt32 Linker;
- UInt32 Version;
- UInt32 Kind;
- UInt32 Abi;
- UInt32 Cpu;
- UInt32 SubCpu; /* Cpu specific information */
- UIntPtr Start;
- SizeT HdrSz; /* Size of header */
- SizeT Count; /* container header count */
- } __attribute__((packed)) PEFContainer;
-
- /* First PEFCommandHeader starts after PEFContainer */
- /* Last container is __exec_end */
-
- /* PEF executable section and commands. */
-
- typedef struct PEFCommandHeader final
- {
- Char Name[kPefNameLen]; /* container name */
- UInt32 Flags; /* container flags */
- UInt16 Kind; /* container kind */
- UIntPtr Offset; /* content offset */
- SizeT Size; /* content Size */
- } __attribute__((packed)) PEFCommandHeader;
-
- enum
- {
- kPefCode = 0xC,
- kPefData = 0xD,
- kPefZero = 0xE,
- kPefLinkerID = 0x1,
- };
-}
-
-#define kPefExt ".o"
-#define kPefDylibExt ".so"
-#define kPefObjectExt ".o"
-#define kPefDebugExt ".dbg"
+enum
+{
+ kPefArchIntel86S,
+ kPefArchAMD64,
+ kPefArchRISCV,
+ kPefArch64x0, /* 64x000. */
+ kPefArch32x0,
+ kPefArchInvalid = 0xFF,
+};
+
+enum
+{
+ kPefKindExec = 1, /* .exe */
+ kPefKindSharedObject = 2, /* .lib */
+ kPefKindObject = 4, /* .obj */
+ kPefKindDebug = 5, /* .debug */
+};
+
+typedef struct PEFContainer final
+{
+ Char Magic[kPefMagicLen];
+ UInt32 Linker;
+ UInt32 Version;
+ UInt32 Kind;
+ UInt32 Abi;
+ UInt32 Cpu;
+ UInt32 SubCpu; /* Cpu specific information */
+ UIntPtr Start;
+ SizeT HdrSz; /* Size of header */
+ SizeT Count; /* container header count */
+} __attribute__((packed)) PEFContainer;
+
+/* First PEFCommandHeader starts after PEFContainer */
+/* Last container is __exec_end */
+
+/* PEF executable section and commands. */
+
+typedef struct PEFCommandHeader final
+{
+ Char Name[kPefNameLen]; /* container name */
+ UInt32 Flags; /* container flags */
+ UInt16 Kind; /* container kind */
+ UIntPtr Offset; /* content offset */
+ SizeT Size; /* content Size */
+} __attribute__((packed)) PEFCommandHeader;
+
+enum
+{
+ kPefCode = 0xC,
+ kPefData = 0xD,
+ kPefZero = 0xE,
+ kPefLinkerID = 0x1,
+};
+} // namespace hCore
+
+#define kPefExt ".cm"
+#define kPefDylibExt ".dlib"
+#define kPefLibExt ".lib"
+#define kPefObjectExt ".obj"
+#define kPefDebugExt ".cmdbg"
// hCore System Binary Interface.
-#define kPefAbi (0xDEAD2)
+#define kPefAbi (0xDEAD2)
#define kPefStart "__start"
diff --git a/Private/Linker/AMD64.ld b/Private/Linker/AMD64.ld
index 695d17c4..81e87dc6 100644
--- a/Private/Linker/AMD64.ld
+++ b/Private/Linker/AMD64.ld
@@ -10,10 +10,9 @@ PHDRS {
}
SECTIONS {
- . = 0x00080000;
+ . = 1M;
.text : {
- KEEP(*(.multiboot))
*(.text .text.*)
} :text
@@ -21,7 +20,9 @@ SECTIONS {
.init : {
*(.initl)
- }
+ } :init
+
+ __SYSTEM_INIT_END = .;
. += CONSTANT(MAXPAGESIZE);
@@ -41,4 +42,7 @@ SECTIONS {
*(COMMON)
*(.bss .bss.*)
} :data
-} \ No newline at end of file
+
+ __SYSTEM_STACK_PTR = .;
+ __SYSTEM_STACK_END = . + 0x4000;
+}
diff --git a/Private/NewBoot/Source/HEL/ARM64/.gitkeep b/Private/NewBoot/Source/HEL/ARM64/.gitkeep
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/Private/NewBoot/Source/HEL/ARM64/.gitkeep
diff --git a/Private/NewKit/Json.hpp b/Private/NewKit/Json.hpp
index 867df909..7c1a85e4 100644
--- a/Private/NewKit/Json.hpp
+++ b/Private/NewKit/Json.hpp
@@ -13,95 +13,101 @@
// last-rev: 5/11/23
#include <NewKit/Defines.hpp>
-#include <NewKit/String.hpp>
#include <NewKit/Stream.hpp>
+#include <NewKit/String.hpp>
#include <NewKit/Utils.hpp>
#include <CompilerKit/Compiler.hpp>
namespace hCore
{
- class JsonType final
+class JsonType final
+{
+ public:
+ explicit JsonType() : hCore::JsonType(1, 1)
{
- public:
- explicit JsonType(SizeT lhsLen, SizeT rhsLen)
- : fKey(lhsLen), fValue(rhsLen)
- {}
+ }
- ~JsonType() = default;
+ explicit JsonType(SizeT lhsLen, SizeT rhsLen) : fKey(lhsLen), fValue(rhsLen)
+ {
+ }
- HCORE_COPY_DEFAULT(JsonType);
+ ~JsonType() = default;
- private:
- StringView fKey;
- StringView fValue;
+ HCORE_COPY_DEFAULT(JsonType);
- public:
- StringView& AsKey() { return fKey; }
- StringView& AsValue() { return fValue; }
+ private:
+ StringView fKey;
+ StringView fValue;
- static JsonType kUndefined;
+ public:
+ StringView &AsKey()
+ {
+ return fKey;
+ }
- };
-
- struct JsonStreamTraits final
+ StringView &AsValue()
{
- JsonType In(const char* full_array)
+ return fValue;
+ }
+
+ static JsonType kUndefined;
+};
+
+struct JsonStreamTraits final
+{
+ JsonType In(const char *full_array)
+ {
+ SizeT len = string_length(full_array);
+
+ if (full_array[0] == '\"' && full_array[len - 1] == ',' || full_array[len - 1] == '\"')
{
- SizeT len = string_length(full_array);
+ Boolean probe_key = true;
+
+ SizeT key_len = 0;
+ SizeT value_len = 0;
- if (full_array[0] == '\"' &&
- full_array[len - 1] == ',' ||
- full_array[len - 1] == '\"')
+ for (SizeT i = 1; i < len; i++)
{
- Boolean probe_key = true;
+ if (full_array[i] == ' ')
+ continue;
- SizeT key_len = 0;
- SizeT value_len = 0;
+ JsonType type(255, 255);
- for (SizeT i = 1; i < len; i++)
+ if (probe_key)
{
- if (full_array[i] == ' ')
- continue;
+ type.AsKey().Data()[key_len] = full_array[i];
+ ++key_len;
- JsonType type(255, 255);
-
- if (probe_key)
+ if (full_array[i] == '\"')
{
- type.AsKey().Data()[key_len] = full_array[i];
- ++key_len;
-
- if (full_array[i] == '\"')
- {
- probe_key = false;
- type.AsKey().Data()[key_len] = 0;
-
- ++i;
- }
+ probe_key = false;
+ type.AsKey().Data()[key_len] = 0;
+
+ ++i;
}
- else
- {
- type.AsValue().Data()[value_len] = full_array[i];
- ++value_len;
+ }
+ else
+ {
+ type.AsValue().Data()[value_len] = full_array[i];
+ ++value_len;
- if (full_array[i] == '\"')
- {
- type.AsValue().Data()[value_len] = 0;
- }
+ if (full_array[i] == '\"')
+ {
+ type.AsValue().Data()[value_len] = 0;
}
}
-
}
-
- return JsonType::kUndefined;
}
- JsonType Out(JsonType& out)
- {
- return out;
- }
-
- };
+ return JsonType::kUndefined;
+ }
+
+ JsonType Out(JsonType &out)
+ {
+ return out;
+ }
+};
- using JsonStream = Stream<JsonStreamTraits, JsonType>;
-} \ No newline at end of file
+using JsonStream = Stream<JsonStreamTraits, JsonType>;
+} // namespace hCore
diff --git a/Private/NewKit/KHeap.hpp b/Private/NewKit/KHeap.hpp
index debe23ee..7c9802d7 100644
--- a/Private/NewKit/KHeap.hpp
+++ b/Private/NewKit/KHeap.hpp
@@ -18,6 +18,6 @@
namespace hCore
{
- Int32 kernel_delete_ptr(voidPtr ptr);
- voidPtr kernel_new_ptr(const SizeT& sz, const bool rw, const bool user);
+Int32 kernel_delete_ptr(voidPtr allocatedPtr);
+voidPtr kernel_new_ptr(const SizeT &sz, const bool rw, const bool user);
} // namespace hCore
diff --git a/Private/NewKit/Panic.hpp b/Private/NewKit/Panic.hpp
index b894d852..4e461587 100644
--- a/Private/NewKit/Panic.hpp
+++ b/Private/NewKit/Panic.hpp
@@ -14,7 +14,7 @@
namespace hCore
{
- void runtime_check(bool bExpression, const char *file, const char *line);
+void runtime_check(bool bExpression, const char *file, const char *line);
}
#define MUST_PASS_COMPILER(EXPR, MSG) static_assert(EXPR, MSG)
@@ -41,22 +41,24 @@ enum RUNTIME_CHECK
namespace hCore
{
- class DumpManager final
+class DumpManager final
+{
+ public:
+ static void Dump(void)
{
- public:
- static void Dump(void)
- {
- // TODO:
- }
- };
+ // TODO:
+ }
+};
- void panic(const Int &id);
+void panic(const Int &id);
} // namespace hCore
#ifdef TRY
#undef TRY
#endif
+#define INIT(OBJ, TYPE, ...) TYPE OBJ = TYPE(__VA_ARGS__)
+
#define TRY(FN) \
if (!FN()) \
{ \
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))
{
diff --git a/Private/makefile b/Private/makefile
index c3e12823..a4a2ec01 100644
--- a/Private/makefile
+++ b/Private/makefile
@@ -36,7 +36,7 @@ kernel-link:
.PHONY: all
all: kernel-build kernel-link
- @echo "[hKernel] JOB DONE."
+ @echo "[hKernel] Job is done."
.PHONY: kernel-clean
kernel-clean: