From 06be6d65bb71152be8a28d7bb6b1028b5a588654 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Sun, 28 Jan 2024 16:26:33 +0100 Subject: 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 --- Private/ArchKit/Arch.hpp | 2 +- Private/HALKit/AMD64/ArchAMD64.cpp | 55 ----------- Private/HALKit/AMD64/HardwareInit.cpp | 2 +- Private/HALKit/AMD64/PlatformAMD64.cpp | 58 +++++++++++ Private/HALKit/AMD64/StartSequence.asm | 34 +++++++ Private/HALKit/PowerPC/Processor.cpp | 2 +- Private/KernelKit/FileManager.hpp | 6 +- Private/KernelKit/PEF.hpp | 127 ++++++++++++------------ Private/Linker/AMD64.ld | 12 ++- Private/NewBoot/Source/HEL/ARM64/.gitkeep | 0 Private/NewKit/Json.hpp | 128 ++++++++++++------------ Private/NewKit/KHeap.hpp | 4 +- Private/NewKit/Panic.hpp | 20 ++-- Private/Source/Json.cxx | 16 +-- Private/Source/KHeap.cxx | 159 +++++++++++++++--------------- Private/Source/KMain.cxx | 25 ----- Private/Source/MeBus/Database.cpp | 10 -- Private/Source/MeBus/Database.cxx | 10 ++ Private/Source/NewFS-IO.cxx | 19 ++-- Private/Source/PermissionSelector.cxx | 34 ++++--- Private/Source/ProcessManager.cxx | 12 ++- Private/Source/RuntimeMain.cxx | 35 +++++++ Private/makefile | 2 +- SPECIFICATION.TXT | 14 ++- 24 files changed, 435 insertions(+), 351 deletions(-) delete mode 100644 Private/HALKit/AMD64/ArchAMD64.cpp create mode 100644 Private/HALKit/AMD64/PlatformAMD64.cpp create mode 100644 Private/HALKit/AMD64/StartSequence.asm create mode 100644 Private/NewBoot/Source/HEL/ARM64/.gitkeep delete mode 100644 Private/Source/KMain.cxx delete mode 100644 Private/Source/MeBus/Database.cpp create mode 100644 Private/Source/MeBus/Database.cxx create mode 100644 Private/Source/RuntimeMain.cxx 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 - -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 &gdt) - { - GDTLoader::Load(gdt.Leak()); - } - - void IDTLoader::Load(Ref &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 + +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 &gdt) +{ + GDTLoader::Load(gdt.Leak()); +} + +void IDTLoader::Load(Ref &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 cla } public: - const char *MIME() noexcept + char *MIME() noexcept { - return fMime; + return const_cast(fMime); } private: NodePtr fFile; - Char *fMime{"application-type/*"}; + const Char *fMime{"application-type/*"}; }; using FileStreamUTF8 = FileStream; 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 -#include #include +#include +#include -#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 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 -#include #include +#include #include #include 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; -} \ No newline at end of file +using JsonStream = Stream; +} // 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 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 kWrapperList[kMaxWrappers]; - static SizeT kWrapperCount = 0UL; - static Ref kLastWrapper; - static Pmm kPmm; +static Ref kWrapperList[kMaxWrappers]; +static SizeT kWrapperCount = 0UL; +static Ref 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(kWrapperList[indexWrapper]->VirtualAddress()); - } - } - - return nullptr; + kWrapperList[indexWrapper]->Reclaim(); /* very straight-forward as you can see. */ + return reinterpret_cast(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 wrapper = kPmm.RequestPage(user, rw); + if (auto ptr = Detail::find_ptr(sz, rw, user); ptr) + return ptr; - if (wrapper) - { - kLastWrapper = wrapper; + Ref wrapper = kPmm.RequestPage(user, rw); - kWrapperList[kWrapperCount] = wrapper; - ++kWrapperCount; + if (wrapper) + { + kLastWrapper = wrapper; - return reinterpret_cast(wrapper->VirtualAddress()); - } + kWrapperList[kWrapperCount] = wrapper; + ++kWrapperCount; - return nullptr; + return reinterpret_cast(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(ptr); + const UIntPtr virtualAddress = reinterpret_cast(ptr); - if (kLastWrapper && - virtualAddress == kLastWrapper->VirtualAddress()) - { - return kPmm.FreePage(kLastWrapper); - } + if (kLastWrapper && virtualAddress == kLastWrapper->VirtualAddress()) + { + return kPmm.FreePage(kLastWrapper); + } - Ref wrapper; + Ref 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(ptr); + const UIntPtr virtualAddress = reinterpret_cast(ptr); - if (kLastWrapper && - virtualAddress == kLastWrapper->VirtualAddress()) - { - return true; - } + if (kLastWrapper && virtualAddress == kLastWrapper->VirtualAddress()) + { + return true; + } - Ref wrapper; + Ref 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/KMain.cxx b/Private/Source/KMain.cxx deleted file mode 100644 index d2dac924..00000000 --- a/Private/Source/KMain.cxx +++ /dev/null @@ -1,25 +0,0 @@ -/* - * ======================================================== - * - * hCore - * Copyright 2024 Mahrouss Logic, all rights reserved. - * - * ======================================================== - */ - -#include -#include -#include - -extern "C" void KMain(hCore::VoidPtr this_image) -{ - MUST_PASS(hCore::initialize_hardware_components()); - - hCore::IFilesystemManager::Mount(new hCore::NewFilesystemManager()); - hCore::PEFLoader img("/System/SeekerSrv.out"); - - if (!hCore::Utils::execute_from_image(img)) - { - hCore::panic(RUNTIME_CHECK_BOOTSTRAP); - } -} diff --git a/Private/Source/MeBus/Database.cpp b/Private/Source/MeBus/Database.cpp deleted file mode 100644 index 3c7594d5..00000000 --- a/Private/Source/MeBus/Database.cpp +++ /dev/null @@ -1,10 +0,0 @@ -/* - * ======================================================== - * - * hCore - * Copyright 2024 Mahrouss Logic, all rights reserved. - * - * ======================================================== - */ - -//! Add this unit to compilation. diff --git a/Private/Source/MeBus/Database.cxx b/Private/Source/MeBus/Database.cxx new file mode 100644 index 00000000..3c7594d5 --- /dev/null +++ b/Private/Source/MeBus/Database.cxx @@ -0,0 +1,10 @@ +/* + * ======================================================== + * + * hCore + * Copyright 2024 Mahrouss Logic, all rights reserved. + * + * ======================================================== + */ + +//! Add this unit to compilation. 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 -#include -#include +#include +#include /// 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 #include #include @@ -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/RuntimeMain.cxx b/Private/Source/RuntimeMain.cxx new file mode 100644 index 00000000..4b91bb5f --- /dev/null +++ b/Private/Source/RuntimeMain.cxx @@ -0,0 +1,35 @@ +/* + * ======================================================== + * + * hCore + * Copyright 2024 Mahrouss Logic, all rights reserved. + * + * ======================================================== + */ + +#include "NewKit/Defines.hpp" +#include +#include +#include +#include + +extern void (*__SYSTEM_INIT_END)(); +extern void (**init)(); + +extern "C" void RuntimeMain() +{ + 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/Seeker.cm"); + + if (!hCore::Utils::execute_from_image(img)) + { + hCore::panic(RUNTIME_CHECK_BOOTSTRAP); + } +} 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: diff --git a/SPECIFICATION.TXT b/SPECIFICATION.TXT index 6cae3058..4e5365c8 100644 --- a/SPECIFICATION.TXT +++ b/SPECIFICATION.TXT @@ -10,9 +10,9 @@ 1: The hCore Microkernel =================================== -hCore mounts NewFS by default, +hCore mounts NewFS by default, a journal filesystem meant for GUI use. -It makes use of a concept named 'Fork' +It makes use of a concept named 'Fork' It contains data about a specific 'Catalog' Programs are load using the PEF. PEF is a multiplatform container @@ -41,3 +41,13 @@ It is a C API, they're mostly system calls, use this to make hCore optimizations. +=================================== +5: The New Filesystem +=================================== + +Based on HFS+ design of catalogs and forks, it is designed with journaling and recovery in mind. +It's going to take advantage of the disk hardware. + +Such as RAID for NVME. + +SPECS: -- cgit v1.2.3