From 80b76666074aa94f165e3db7b3dda2145ca6efc0 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Thu, 21 Mar 2024 22:39:57 +0100 Subject: unstable, kernel+api: important breaking changes. Signed-off-by: Amlal El Mahrouss --- Private/Builtins/ACPI/ACPI.hpp | 1 - Private/HALKit/AMD64/HalSMPCore.cxx | 2 +- Private/KernelKit/ProcessScheduler.hpp | 63 +++--- Private/KernelKit/Semaphore.hpp | 8 +- Private/Source/PEFCodeManager.cxx | 4 +- Private/Source/ProcessScheduler.cxx | 32 +-- Private/Source/ProcessTeam.cxx | 6 +- Private/Source/Semaphore.cxx | 4 +- Public/BUG_LIST.TXT | 1 - Public/Documentation/.gitkeep | 0 Public/Documentation/BUG_LIST.TXT | 1 + Public/Documentation/SPECIFICATION.TXT | 53 +++++ Public/Documentation/TODO_LIST.TXT | 25 +++ Public/Documentation/compile_flags.txt | 5 + Public/Kits/System.Core/Containers/ODF.hxx | 43 ---- Public/Kits/System.Core/Containers/XIFF.hxx | 42 ---- Public/Kits/System.Core/Defs.hxx | 190 ---------------- Public/Kits/System.Core/File.hxx | 71 ------ Public/Kits/System.Core/Headers/Containers/ODF.hxx | 43 ++++ .../Kits/System.Core/Headers/Containers/XIFF.hxx | 42 ++++ Public/Kits/System.Core/Headers/Defs.hxx | 248 +++++++++++++++++++++ Public/Kits/System.Core/Headers/File.hxx | 70 ++++++ Public/Kits/System.Core/Headers/Heap.hxx | 63 ++++++ Public/Kits/System.Core/Headers/Hint.hxx | 18 ++ Public/Kits/System.Core/Headers/Thread.hxx | 49 ++++ Public/Kits/System.Core/Heap.cxx | 45 ---- Public/Kits/System.Core/Heap.hxx | 79 ------- Public/Kits/System.Core/HeapRuntime.cxx | 44 ---- Public/Kits/System.Core/Hint.hxx | 18 -- Public/Kits/System.Core/InitRuntime.cxx | 14 -- Public/Kits/System.Core/Makefile | 2 +- Public/Kits/System.Core/New+Delete.cxx | 50 ----- Public/Kits/System.Core/RISCV/.gitkeep | 0 Public/Kits/System.Core/Sources/DllMain.cxx | 14 ++ Public/Kits/System.Core/Sources/Heap.cxx | 83 +++++++ Public/Kits/System.Core/Sources/New+Delete.cxx | 65 ++++++ Public/Kits/System.Core/System.Core.hxx | 14 -- Public/Kits/System.Core/System.hxx | 18 -- Public/Kits/System.Core/Threading.hxx | 34 --- Public/Kits/System.Grahpics.GPU/.gitkeep | 0 Public/Kits/System.Graphics/.gitkeep | 0 Public/Kits/System.Graphics/Core.cxx | 14 -- Public/Kits/System.Graphics/Core.hxx | 185 --------------- Public/Kits/System.Graphics/Dim2d.cxx | 20 -- Public/Kits/System.Graphics/Dim2d.hxx | 38 ---- Public/Kits/System.Graphics/Frame.cxx | 18 -- Public/Kits/System.Graphics/Frame.hxx | 60 ----- Public/Kits/System.Graphics/Makefile | 20 -- Public/Kits/System.Graphics/Stylesheet.hxx | 50 ----- Public/Kits/System.Graphics/compile_flags.txt | 4 - Public/Kits/System.Zip/Defines.hpp | 30 --- Public/Kits/System.Zip/Makefile | 22 -- Public/Kits/System.Zip/Shell.hpp | 17 -- Public/Kits/System.Zip/Zip.cxx | 43 ---- Public/Kits/System.Zip/Zip.hpp | 37 --- Public/Kits/System.Zip/compile_flags.txt | 4 - Public/SPECIFICATION.TXT | 53 ----- Public/TODO_LIST.TXT | 25 --- Public/compile_flags.txt | 5 - 59 files changed, 839 insertions(+), 1370 deletions(-) delete mode 100644 Public/BUG_LIST.TXT create mode 100644 Public/Documentation/.gitkeep create mode 100644 Public/Documentation/BUG_LIST.TXT create mode 100644 Public/Documentation/SPECIFICATION.TXT create mode 100644 Public/Documentation/TODO_LIST.TXT create mode 100644 Public/Documentation/compile_flags.txt delete mode 100644 Public/Kits/System.Core/Containers/ODF.hxx delete mode 100644 Public/Kits/System.Core/Containers/XIFF.hxx delete mode 100644 Public/Kits/System.Core/Defs.hxx delete mode 100644 Public/Kits/System.Core/File.hxx create mode 100644 Public/Kits/System.Core/Headers/Containers/ODF.hxx create mode 100644 Public/Kits/System.Core/Headers/Containers/XIFF.hxx create mode 100644 Public/Kits/System.Core/Headers/Defs.hxx create mode 100644 Public/Kits/System.Core/Headers/File.hxx create mode 100644 Public/Kits/System.Core/Headers/Heap.hxx create mode 100644 Public/Kits/System.Core/Headers/Hint.hxx create mode 100644 Public/Kits/System.Core/Headers/Thread.hxx delete mode 100644 Public/Kits/System.Core/Heap.cxx delete mode 100644 Public/Kits/System.Core/Heap.hxx delete mode 100644 Public/Kits/System.Core/HeapRuntime.cxx delete mode 100644 Public/Kits/System.Core/Hint.hxx delete mode 100644 Public/Kits/System.Core/InitRuntime.cxx delete mode 100644 Public/Kits/System.Core/New+Delete.cxx create mode 100644 Public/Kits/System.Core/RISCV/.gitkeep create mode 100644 Public/Kits/System.Core/Sources/DllMain.cxx create mode 100644 Public/Kits/System.Core/Sources/Heap.cxx create mode 100644 Public/Kits/System.Core/Sources/New+Delete.cxx delete mode 100644 Public/Kits/System.Core/System.Core.hxx delete mode 100644 Public/Kits/System.Core/System.hxx delete mode 100644 Public/Kits/System.Core/Threading.hxx delete mode 100644 Public/Kits/System.Grahpics.GPU/.gitkeep delete mode 100644 Public/Kits/System.Graphics/.gitkeep delete mode 100644 Public/Kits/System.Graphics/Core.cxx delete mode 100644 Public/Kits/System.Graphics/Core.hxx delete mode 100644 Public/Kits/System.Graphics/Dim2d.cxx delete mode 100644 Public/Kits/System.Graphics/Dim2d.hxx delete mode 100644 Public/Kits/System.Graphics/Frame.cxx delete mode 100644 Public/Kits/System.Graphics/Frame.hxx delete mode 100644 Public/Kits/System.Graphics/Makefile delete mode 100644 Public/Kits/System.Graphics/Stylesheet.hxx delete mode 100644 Public/Kits/System.Graphics/compile_flags.txt delete mode 100644 Public/Kits/System.Zip/Defines.hpp delete mode 100644 Public/Kits/System.Zip/Makefile delete mode 100644 Public/Kits/System.Zip/Shell.hpp delete mode 100644 Public/Kits/System.Zip/Zip.cxx delete mode 100644 Public/Kits/System.Zip/Zip.hpp delete mode 100644 Public/Kits/System.Zip/compile_flags.txt delete mode 100644 Public/SPECIFICATION.TXT delete mode 100644 Public/TODO_LIST.TXT delete mode 100644 Public/compile_flags.txt diff --git a/Private/Builtins/ACPI/ACPI.hpp b/Private/Builtins/ACPI/ACPI.hpp index 1a4329fc..c17acac9 100644 --- a/Private/Builtins/ACPI/ACPI.hpp +++ b/Private/Builtins/ACPI/ACPI.hpp @@ -9,7 +9,6 @@ /** https://uefi.org/specs/ACPI/6.5/05_ACPI_Software_Programming_Model.html - https://wiki.osdev.org/RSDT */ #include diff --git a/Private/HALKit/AMD64/HalSMPCore.cxx b/Private/HALKit/AMD64/HalSMPCore.cxx index 87bfae3b..d213b2fc 100644 --- a/Private/HALKit/AMD64/HalSMPCore.cxx +++ b/Private/HALKit/AMD64/HalSMPCore.cxx @@ -7,7 +7,7 @@ #include using namespace HCore; -Void Process::SetStart(UIntPtr &imageStart) noexcept { +Void ProcessHeader::SetStart(UIntPtr &imageStart) noexcept { if (imageStart == 0) this->Crash(); this->StackFrame->Rbp = imageStart; diff --git a/Private/KernelKit/ProcessScheduler.hpp b/Private/KernelKit/ProcessScheduler.hpp index caff1125..bc974a9b 100644 --- a/Private/KernelKit/ProcessScheduler.hpp +++ b/Private/KernelKit/ProcessScheduler.hpp @@ -9,10 +9,10 @@ #include #include -#include #include -#include +#include #include +#include #define kMinMicroTime AffinityKind::kHartStandard #define kPIDInvalid (-1) @@ -24,22 +24,22 @@ //////////////////////////////////////////////////// namespace HCore { -class Process; +class ProcessHeader; class ProcessTeam; class ProcessManager; -//! @brief Process identifier. +//! @brief ProcessHeader identifier. typedef Int64 ProcessID; -//! @brief Process name length. +//! @brief ProcessHeader name length. inline constexpr SizeT kProcessLen = 256U; //! @brief Forward declaration. -class Process; +class ProcessHeader; class ProcessManager; class ProcessHelper; -//! @brief Process status enum. +//! @brief ProcessHeader status enum. enum class ProcessStatus : Int32 { kStarting, kRunning, @@ -106,25 +106,25 @@ enum class ProcessSelector : Int { using ImagePtr = VoidPtr; using HeapPtr = VoidPtr; -// @name Process -// @brief Process Information Header (PIH) +// @name ProcessHeader +// @brief Process Header (PH) // Holds information about the running process. // Thread execution is being abstracted away. -class Process final { +class ProcessHeader final { public: - explicit Process(VoidPtr startImage = nullptr) : Image(startImage) { + explicit ProcessHeader(VoidPtr startImage = nullptr) : Image(startImage) { MUST_PASS(startImage); } - ~Process() = default; + ~ProcessHeader() = default; - HCORE_COPY_DEFAULT(Process) + HCORE_COPY_DEFAULT(ProcessHeader) public: void SetStart(UIntPtr &imageStart) noexcept; public: - Char Name[kProcessLen] = {"Process"}; + Char Name[kProcessLen] = {"HCore Process"}; ProcessSubsystem SubSystem{0}; ProcessSelector Selector{ProcessSelector::kRingUser}; HAL::StackFramePtr StackFrame{nullptr}; @@ -171,9 +171,9 @@ class Process final { //! @brief Wakes up threads. void Wake(const bool wakeup = false); - // Process getters. + // ProcessHeader getters. public: - //! @brief Process name getter, example: "C RunTime" + //! @brief ProcessHeader name getter, example: "C RunTime" const Char *GetName(); const ProcessSelector &GetSelector(); @@ -188,24 +188,23 @@ class Process final { /// \brief Processs Team (contains multiple processes inside it.) /// Equivalent to a process batch class ProcessTeam final { -public: - explicit ProcessTeam() = default; - ~ProcessTeam() = default; - - HCORE_COPY_DEFAULT(ProcessTeam); + public: + explicit ProcessTeam() = default; + ~ProcessTeam() = default; - MutableArray>& AsArray(); - Ref& AsRef(); + HCORE_COPY_DEFAULT(ProcessTeam); -public: - MutableArray> mProcessList; - Ref mCurrentProcess; + MutableArray> &AsArray(); + Ref &AsRef(); + public: + MutableArray> mProcessList; + Ref mCurrentProcess; }; -using ProcessPtr = Process *; +using ProcessPtr = ProcessHeader *; -/// @brief Process manager class. +/// @brief ProcessHeader manager class. /// The main class which you call to schedule an app. class ProcessManager final { private: @@ -219,12 +218,12 @@ class ProcessManager final { operator bool() { return mTeam.AsArray().Count() > 0; } bool operator!() { return mTeam.AsArray().Count() == 0; } - ProcessTeam& CurrentTeam() { return mTeam; } + ProcessTeam &CurrentTeam() { return mTeam; } - SizeT Add(Ref &headerRef); + SizeT Add(Ref &headerRef); bool Remove(SizeT headerIndex); - Ref &GetCurrent(); + Ref &GetCurrent(); SizeT Run() noexcept; static Ref Shared(); @@ -240,7 +239,7 @@ class ProcessManager final { class ProcessHelper final { public: static bool Switch(HAL::StackFrame *newStack, const PID &newPid); - static bool CanBeScheduled(Ref &process); + static bool CanBeScheduled(Ref &process); static PID &GetCurrentPID(); static bool StartScheduling(); }; diff --git a/Private/KernelKit/Semaphore.hpp b/Private/KernelKit/Semaphore.hpp index 6be56f21..9b9dbef3 100644 --- a/Private/KernelKit/Semaphore.hpp +++ b/Private/KernelKit/Semaphore.hpp @@ -11,9 +11,9 @@ namespace HCore { - class Process; + class ProcessHeader; - typedef Process* ProcessPtr; + typedef ProcessHeader* ProcessPtr; /// @brief Access control class, which locks a task until one is done. class Semaphore final @@ -30,8 +30,8 @@ namespace HCore void Sync() noexcept; public: - bool Lock(Process* process); - bool LockOrWait(Process* process, const Int64& seconds); + bool Lock(ProcessHeader* process); + bool LockOrWait(ProcessHeader* process, const Int64& seconds); public: HCORE_COPY_DEFAULT(Semaphore); diff --git a/Private/Source/PEFCodeManager.cxx b/Private/Source/PEFCodeManager.cxx index bd529dca..ec8756d1 100644 --- a/Private/Source/PEFCodeManager.cxx +++ b/Private/Source/PEFCodeManager.cxx @@ -141,8 +141,8 @@ bool execute_from_image(PEFLoader &exec) noexcept { if (errOrStart.Error() != 0) return false; - Process proc(errOrStart.Leak().Leak()); - Ref refProc = proc; + ProcessHeader proc(errOrStart.Leak().Leak()); + Ref refProc = proc; return ProcessManager::Shared().Leak().Add(refProc); } diff --git a/Private/Source/ProcessScheduler.cxx b/Private/Source/ProcessScheduler.cxx index 3432fe70..2ab30e94 100644 --- a/Private/Source/ProcessScheduler.cxx +++ b/Private/Source/ProcessScheduler.cxx @@ -6,7 +6,7 @@ /***********************************************************************************/ /// @file ProcessManager.cxx -/// @brief Process Scheduler API. +/// @brief ProcessHeader Scheduler API. /***********************************************************************************/ #include @@ -31,21 +31,21 @@ const Int32 &rt_get_exit_code() noexcept { return kExitCode; } /***********************************************************************************/ -void Process::Crash() { +void ProcessHeader::Crash() { kcout << "ProcessManager: Crashed, ExitCode: -1.\r\n"; MUST_PASS(!ke_bug_check()); this->Exit(-1); } -void Process::Wake(const bool should_wakeup) { +void ProcessHeader::Wake(const bool should_wakeup) { this->Status = should_wakeup ? ProcessStatus::kRunning : ProcessStatus::kFrozen; } /***********************************************************************************/ -VoidPtr Process::New(const SizeT &sz) { +VoidPtr ProcessHeader::New(const SizeT &sz) { if (this->FreeMemory < 1) return nullptr; if (this->HeapCursor) { @@ -78,7 +78,7 @@ bool rt_in_pool_region(VoidPtr pool_ptr, VoidPtr pool, const SizeT &sz) { } /* @brief free pointer from usage. */ -Boolean Process::Delete(VoidPtr ptr, const SizeT &sz) { +Boolean ProcessHeader::Delete(VoidPtr ptr, const SizeT &sz) { if (sz < 1 || this->HeapCursor == this->HeapPtr) return false; // also check for the amount of allocations we've done so far. @@ -97,23 +97,23 @@ Boolean Process::Delete(VoidPtr ptr, const SizeT &sz) { return false; } -const Char *Process::GetName() { return this->Name; } +const Char *ProcessHeader::GetName() { return this->Name; } -const ProcessSelector &Process::GetSelector() { return this->Selector; } +const ProcessSelector &ProcessHeader::GetSelector() { return this->Selector; } -const ProcessStatus &Process::GetStatus() { return this->Status; } +const ProcessStatus &ProcessHeader::GetStatus() { return this->Status; } /***********************************************************************************/ /** @brief Affinity is the time slot allowed for the process. */ -const AffinityKind &Process::GetAffinity() { return this->Affinity; } +const AffinityKind &ProcessHeader::GetAffinity() { return this->Affinity; } /** @brief Standard exit proc. */ -void Process::Exit(Int32 exit_code) { +void ProcessHeader::Exit(Int32 exit_code) { if (this->ProcessId != ProcessManager::Shared().Leak().GetCurrent().Leak().ProcessId) ke_stop(RUNTIME_CHECK_PROCESS); @@ -144,12 +144,12 @@ void Process::Exit(Int32 exit_code) { ProcessManager::Shared().Leak().Remove(this->ProcessId); } -SizeT ProcessManager::Add(Ref &process) { +SizeT ProcessManager::Add(Ref &process) { if (!process) return -1; if (process.Leak().Ring != (Int32)ProcessSelector::kRingKernel) return -1; - kcout << "ProcessManager::Add(Ref& process)\r\n"; + kcout << "ProcessManager::Add(Ref& process)\r\n"; process.Leak().HeapPtr = rt_new_heap(kUserHeapUser | kUserHeapRw); process.Leak().ProcessId = mTeam.AsArray().Count(); @@ -166,11 +166,11 @@ SizeT ProcessManager::Add(Ref &process) { mTeam.AsArray().Add(process); - if (!imageStart && process.Leak().Kind == Process::ExecutableType) { + if (!imageStart && process.Leak().Kind == ProcessHeader::ExecutableType) { process.Leak().Crash(); } - if (!imageStart && process.Leak().Kind == Process::DriverType) { + if (!imageStart && process.Leak().Kind == ProcessHeader::DriverType) { if (process.Leak().Ring == 3) process.Leak().Crash(); else @@ -224,14 +224,14 @@ Ref ProcessManager::Shared() { return {ref}; } -Ref &ProcessManager::GetCurrent() { return mTeam.AsRef(); } +Ref &ProcessManager::GetCurrent() { return mTeam.AsRef(); } PID &ProcessHelper::GetCurrentPID() { kcout << "ProcessHelper::GetCurrentPID: Leaking ProcessId...\r\n"; return ProcessManager::Shared().Leak().GetCurrent().Leak().ProcessId; } -bool ProcessHelper::CanBeScheduled(Ref &process) { +bool ProcessHelper::CanBeScheduled(Ref &process) { if (process.Leak().Status == ProcessStatus::kFrozen || process.Leak().Status == ProcessStatus::kDead) return false; diff --git a/Private/Source/ProcessTeam.cxx b/Private/Source/ProcessTeam.cxx index 9e16c0cd..53b55a0f 100644 --- a/Private/Source/ProcessTeam.cxx +++ b/Private/Source/ProcessTeam.cxx @@ -6,14 +6,14 @@ /***********************************************************************************/ /// @file ProcessTeam.cxx -/// @brief Process Team API. +/// @brief ProcessHeader Team API. /***********************************************************************************/ #include namespace HCore { -MutableArray>& ProcessTeam::AsArray() { return mProcessList; } -Ref& ProcessTeam::AsRef() { return mCurrentProcess; } +MutableArray>& ProcessTeam::AsArray() { return mProcessList; } +Ref& ProcessTeam::AsRef() { return mCurrentProcess; } } // namespace HCore // last rev 05-03-24 diff --git a/Private/Source/Semaphore.cxx b/Private/Source/Semaphore.cxx index 75ebfc44..9767c8bb 100644 --- a/Private/Source/Semaphore.cxx +++ b/Private/Source/Semaphore.cxx @@ -15,7 +15,7 @@ bool Semaphore::Unlock() noexcept { return fLockingProcess == nullptr; } -bool Semaphore::Lock(Process* process) { +bool Semaphore::Lock(ProcessHeader* process) { if (!process || fLockingProcess) return false; fLockingProcess = process; @@ -25,7 +25,7 @@ bool Semaphore::Lock(Process* process) { bool Semaphore::IsLocked() const { return fLockingProcess; } -bool Semaphore::LockOrWait(Process* process, const Int64& seconds) { +bool Semaphore::LockOrWait(ProcessHeader* process, const Int64& seconds) { if (process == nullptr) return false; HardwareTimer timer(Seconds(seconds)); diff --git a/Public/BUG_LIST.TXT b/Public/BUG_LIST.TXT deleted file mode 100644 index 6075a6ac..00000000 --- a/Public/BUG_LIST.TXT +++ /dev/null @@ -1 +0,0 @@ -- PS/2 Mouse doesn't raise interrupt on qemu q35, pc machines. [WontFix] \ No newline at end of file diff --git a/Public/Documentation/.gitkeep b/Public/Documentation/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/Public/Documentation/BUG_LIST.TXT b/Public/Documentation/BUG_LIST.TXT new file mode 100644 index 00000000..6075a6ac --- /dev/null +++ b/Public/Documentation/BUG_LIST.TXT @@ -0,0 +1 @@ +- PS/2 Mouse doesn't raise interrupt on qemu q35, pc machines. [WontFix] \ No newline at end of file diff --git a/Public/Documentation/SPECIFICATION.TXT b/Public/Documentation/SPECIFICATION.TXT new file mode 100644 index 00000000..11ee62e3 --- /dev/null +++ b/Public/Documentation/SPECIFICATION.TXT @@ -0,0 +1,53 @@ +=================================== +0: General Information +=================================== + +- ABI and Format: PEF/PE32+. +- Kernel architecture: Microkernel. +- Language: C++/(Assembly (AMD64, X64000, X86S, ARM64)) + +=================================== +1: The HCore Microkernel +=================================== + +- Drive/Device Abstraction. +- SMP, Preemptive Multi Threading. +- Separation of Files/Devices. +- Networking. +- Hardware Abstraction Layer. +- Native Filesystem support (NewFS, FAT32 and HCFS). +- Program Loaders. +- Thread Local Storage. +- Semaphore, Locks, Timers. +- Canary mechanisms. +- Dynamic Libraries. +- Cross Platform. +- Permission Selectors. + +=================================== +2: The Filesystem +=================================== + +- Catalog based with forks. +- Large storage support. +- Long file names. +- UNIX path style. + +================================== +3: Common naming conventions: +================================== + +- Kernel -> ke_init_x +- RunTime -> rt_copy_mem +- Hal -> hal_foo_bar + +=================================== +4: The HCore Bootloader +=================================== + +- Capable of booting from a network drive. +- Loads a PE file which is the kernel +- Sanity checks, based on the number of sections. +- Handover compliant. +- Does check for a valid invalid of HCore (useful in the case of recovering) + diff --git a/Public/Documentation/TODO_LIST.TXT b/Public/Documentation/TODO_LIST.TXT new file mode 100644 index 00000000..5e49eb04 --- /dev/null +++ b/Public/Documentation/TODO_LIST.TXT @@ -0,0 +1,25 @@ +- We need preemptive multi-threading. [ X ] +- We then need sync primitives. [ X ] +- We also need a system library for the OS. [ X ] +- We need a bootloader for AMD64 [ X ] + - Implement Boot Services [ X ] + - Design Handover [ X ] + - Load kernel into memory [ X ] + - Fix bug in kernel loader, which causes a 06 #UD. [ X ] + - Load Kernel [ X ] + - Add IDT [ X ] + - AHCI driver [ WiP ] +- Context switch x87/SSE/AVX registers [ X ] +- Framebuffer [ X ] +- AHCI support [ ] +- HCore API and HCore Forms. [ ] +- Make installer form class [ ] + +Status: + +NewBoot: Working. +HCoreKrnl: Not run yet. + +Prioritize: +NewBoot: Protocol and API. +HCoreKrnl: Complying to specs. diff --git a/Public/Documentation/compile_flags.txt b/Public/Documentation/compile_flags.txt new file mode 100644 index 00000000..21296223 --- /dev/null +++ b/Public/Documentation/compile_flags.txt @@ -0,0 +1,5 @@ +-nostdlib +-ffreestanding +-std=c++20 +-I./SDK/ +-I../Private diff --git a/Public/Kits/System.Core/Containers/ODF.hxx b/Public/Kits/System.Core/Containers/ODF.hxx deleted file mode 100644 index 3c4e81fc..00000000 --- a/Public/Kits/System.Core/Containers/ODF.hxx +++ /dev/null @@ -1,43 +0,0 @@ -/** =========================================== - (C) Mahrouss Logic - ===========================================*/ - -#ifndef __ODF__ -#define __ODF__ - -#include - -/** - * @brief Open Document Format - * @file ODF.hxx -*/ - -/// @brief four-character code for ODF. -#define kFourCCLength_ODF 4 - -/// @brief Document file header. -typedef struct ODFFileHeader -{ - CHAR f_Ident[kFourCCLength_ODF]; - - INT32 f_DocumentKind; - INT32 f_DocumentSize; - - INT64 f_MetaForkOffset; - INT64 f_DocumentForkOffset; - - CHAR f_Padding[4]; -} PACKED ODFFileHeader; - -/// @brief ODF Fork header -typedef struct ODFForkHeader -{ - CHAR f_MetadataName[255]; - - INT32 f_MetadataKind; - INT32 f_MetadataSize; - - CHAR f_Padding; -} PACKED ODFForkHeader; - -#endif // !__ODF__ \ No newline at end of file diff --git a/Public/Kits/System.Core/Containers/XIFF.hxx b/Public/Kits/System.Core/Containers/XIFF.hxx deleted file mode 100644 index 622a5a87..00000000 --- a/Public/Kits/System.Core/Containers/XIFF.hxx +++ /dev/null @@ -1,42 +0,0 @@ -/** =========================================== - (C) Mahrouss Logic - ===========================================*/ - -#ifndef __XIFF__ -#define __XIFF__ - -/** --------------------------------------------------- - - * THIS FILE CONTAINS CODE FOR THE eXtended Information File Format. - * XIFF is used to make setup programs/audio/video files. - -------------------------------------------------------- */ - -#include - -/// @brief four-character code for XIFF. -#define kFourCCLength_XIFF 4 - -#define kXIFFContainerVideo "XVFF" -#define kXIFFContainerAudio "XAFF" -#define kXIFFContainerInstaller "XNFF" -#define kXIFFContainerGeneric "XIFF" -#define kXIFFContainerBinary "XBFF" - -/*** - * @brief Generic XIFF header - * Used by XIFF based containers. - */ - -struct PACKED XiffHeader final { - BYTE f_Magic[kFourCCLength_XIFF]; // XIFF string (includes \0) - DWORD f_Size; // overall size of header (XiffHeader) in bytes - DWORD f_FormatType; // format type. generic - BYTE f_SpecificMag[kFourCCLength_XIFF]; // The sub header magic - DWORD f_SpecificSize; // length of the format data - DWORD f_SpecificFormatType; // format type. generic -}; - -typedef struct XiffHeader XiffHeader; - -#endif // ifndef __XIFF__ diff --git a/Public/Kits/System.Core/Defs.hxx b/Public/Kits/System.Core/Defs.hxx deleted file mode 100644 index 6d0fb99a..00000000 --- a/Public/Kits/System.Core/Defs.hxx +++ /dev/null @@ -1,190 +0,0 @@ -/* ------------------------------------------- - - Copyright Mahrouss Logic - -------------------------------------------- */ - -#pragma once - -#ifndef __cplusplus -#error This API is meant to be used with C++. -#endif - -#ifdef CA_MUST_PASS -#undef CA_MUST_PASS -#endif - -#include - -#ifdef _DEBUG -#define CA_MUST_PASS(e) { if (!e) { __assert_chk_fail() } } -#else -#define CA_MUST_PASS(e) CA_UNREFERENCED_PARAMETER(e) -#endif - -#ifdef __cplusplus - -#define CA_EXTERN_C extern "C" - -#else - -#define CA_EXTERN_C extern - -#endif - -CA_EXTERN_C void __assert_chk_fail(void); - -#define CA_STDCALL __attribute__((stdcall)) -#define CA_CDECL __attribute__((cdecl)) -#define CA_MSCALL __attribute__((ms_abi)) - -#define CA_PASCAL CA_STDCALL - -typedef __UINT8_TYPE__ BYTE; -typedef __UINT16_TYPE__ WORD; -typedef __UINT32_TYPE__ DWORD; -typedef __UINT64_TYPE__ QWORD; - -typedef char CHAR; -typedef CHAR* PCHAR; - -typedef void* PVOID; -typedef void VOID; - -typedef __UINTPTR_TYPE__ UINT_PTR; -typedef __INTPTR_TYPE__ INT_PTR; -typedef __UINT64_TYPE__ UINT64; -typedef __INT64_TYPE__ INT64; -typedef __UINT32_TYPE__ UINT32; -typedef __INT32_TYPE__ INT32; - -typedef __WCHAR_TYPE__ WCHAR; -typedef WCHAR* PWCHAR; - -typedef CHAR BOOL; - -#define TRUE 1 -#define FALSE 0 - -#define CA_PTR * - -#define CA_FAR __far -#define CA_NEAR __near - -#define CA_UNREFERENCED_PARAMETER(e) ((VOID)e) - -#ifdef __x86_64__ -# define _M_AMD64 2 -#endif - -#ifdef __aarch64__ -# define _M_AARCH64 3 -#endif - -#ifdef __powerpc64__ -# define _M_PPC64 4 -#endif - -#ifdef __64x0__ -# define _M_64000 5 -#endif - -#ifdef __riscv__ -# define _M_RISCV 6 -#endif - -#define CA_STATIC static -#define CA_INLINE inline -#define CA_CONST const - -#ifdef __cplusplus -#define CA_CONSTEXPR constexpr -#else -#define CA_CONSTEXPR -#endif // __cplusplus - -CA_INLINE ObjectPtr kInstanceObject; - -enum HcProcessCall { - kProcessCallAllocPtr = 1, - kProcessCallFreePtr, - kProcessCallSizePtr, - kProcessCallCheckPtr, - kProcessCallAllocStack, - kProcessCallOpenHandle, - kProcessCallCloseHandle, - kProcessCallsCount = 7, -}; - -#include - -class SystemException { - public: - explicit SystemException() = default; - virtual ~SystemException() = default; - - public: - HCORE_COPY_DEFAULT(SystemException); - - public: - virtual const char *Name() = 0; - virtual const char *Reason() = 0; - -}; - -/// @brief Object exception -/// Throws when the object isn't found. -class ObjectNotFoundException : public SystemException { - public: - explicit ObjectNotFoundException() = default; - virtual ~ObjectNotFoundException() = default; - - public: - HCORE_COPY_DEFAULT(ObjectNotFoundException); - - public: - const char *Name() override { return "ObjectNotFoundException"; } - const char *Reason() override { return mReason; } - - private: - const char *mReason{ - "System.Core: ObjectNotFoundException: Catastrophic failure!"}; -}; - -/// @brief pointer exception -/// Throws when the object isn't found. -class PointerException : public SystemException { - public: - explicit PointerException() = default; - virtual ~PointerException() = default; - - public: - HCORE_COPY_DEFAULT(PointerException); - - public: - const char *Name() override { return "PointerException"; } - const char *Reason() override { return mReason; } - - private: - const char *mReason{ - "System.Core: PointerException: Catastrophic failure!"}; -}; - -/// @brief pointer exception -/// Throws when the object isn't found. -class NullPointerException : public SystemException { - public: - explicit NullPointerException() = default; - virtual ~NullPointerException() = default; - - public: - HCORE_COPY_DEFAULT(NullPointerException); - - public: - const char *Name() override { return "NullPointerException"; } - const char *Reason() override { return mReason; } - - private: - const char *mReason{ - "System.Core: NullPointerException: Catastrophic failure!"}; -}; diff --git a/Public/Kits/System.Core/File.hxx b/Public/Kits/System.Core/File.hxx deleted file mode 100644 index 7ae70faf..00000000 --- a/Public/Kits/System.Core/File.hxx +++ /dev/null @@ -1,71 +0,0 @@ -/* ------------------------------------------- - - Copyright Mahrouss Logic - -------------------------------------------- */ - -#ifndef __FILE_API__ -#define __FILE_API__ - -#include -#include - -/// @brief SOM class, translated to C++ - -namespace System { -class File final { - public: - explicit File(const char *path) { - mHandle = kInstanceObject->Invoke(kInstanceObject, kProcessCallOpenHandle, - 0, path); - } - - ~File() { - kInstanceObject->Invoke(kInstanceObject, kProcessCallCloseHandle, 0, - mHandle); - } - - public: - HCORE_COPY_DEFAULT(File); - - public: - voidPtr Read(UIntPtr off, SizeT sz) { return (VoidPtr)kInstanceObject->Invoke(kInstanceObject, mHandle, 2, off, sz); } - voidPtr Read(SizeT sz) { return (VoidPtr)kInstanceObject->Invoke(kInstanceObject, mHandle, 3, sz); } - - void Write(VoidPtr buf, UIntPtr off, SizeT sz) { kInstanceObject->Invoke(kInstanceObject, mHandle, 4, buf, off, sz); } - void Write(VoidPtr buf, SizeT sz) { kInstanceObject->Invoke(kInstanceObject, mHandle, 5, buf, sz); } - - void Seek(UIntPtr off) { kInstanceObject->Invoke(kInstanceObject, mHandle, 5); } - void Rewind() { kInstanceObject->Invoke(kInstanceObject, mHandle, 6); } - - public: - const char *MIME(); - void MIME(const char *mime); - - private: - IntPtr mHandle; -}; - -typedef File *FilePtr; - -/// @brief file exception -/// Throws when the file isn't found or invalid. -class FileException : public SystemException { - public: - explicit FileException() = default; - virtual ~FileException() = default; - - public: - HCORE_COPY_DEFAULT(FileException); - - public: - const char *Name() override { return "FileException"; } - const char *Reason() override { return mReason; } - - private: - const char *mReason{"System.Core: FileException: Catastrophic failure!"}; -}; - -} // namespace System - -#endif // ifndef __FILE_API__ diff --git a/Public/Kits/System.Core/Headers/Containers/ODF.hxx b/Public/Kits/System.Core/Headers/Containers/ODF.hxx new file mode 100644 index 00000000..53098c3f --- /dev/null +++ b/Public/Kits/System.Core/Headers/Containers/ODF.hxx @@ -0,0 +1,43 @@ +/** =========================================== + (C) Mahrouss Logic + ===========================================*/ + +#ifndef __ODF__ +#define __ODF__ + +#include + +/** + * @brief Open Document Format + * @file ODF.hxx +*/ + +/// @brief four-character code for ODF. +#define kFourCCLength_ODF 4 + +/// @brief Document file header. +typedef struct ODFFileHeader +{ + CharacterType f_Ident[kFourCCLength_ODF]; + + Int32Type f_DocumentKind; + Int32Type f_DocumentSize; + + Int64Type f_MetaForkOffset; + Int64Type f_DocumentForkOffset; + + CharacterType f_Padding[4]; +} PACKED ODFFileHeader; + +/// @brief ODF Fork header +typedef struct ODFForkHeader +{ + CharacterType f_MetadataName[255]; + + Int32Type f_MetadataKind; + Int32Type f_MetadataSize; + + CharacterType f_Padding; +} PACKED ODFForkHeader; + +#endif // !__ODF__ \ No newline at end of file diff --git a/Public/Kits/System.Core/Headers/Containers/XIFF.hxx b/Public/Kits/System.Core/Headers/Containers/XIFF.hxx new file mode 100644 index 00000000..e14868a6 --- /dev/null +++ b/Public/Kits/System.Core/Headers/Containers/XIFF.hxx @@ -0,0 +1,42 @@ +/** =========================================== + (C) Mahrouss Logic + ===========================================*/ + +#ifndef __XIFF__ +#define __XIFF__ + +/** --------------------------------------------------- + + * THIS FILE CONTAINS CODE FOR THE eXtended Information File Format. + * XIFF is used to make setup programs/audio/video files. + +------------------------------------------------------- */ + +#include + +/// @brief four-character code for XIFF. +#define kFourCCLength_XIFF 4 + +#define kXIFFContainerVideo "XVFF" +#define kXIFFContainerAudio "XAFF" +#define kXIFFContainerInstaller "XNFF" +#define kXIFFContainerGeneric "XIFF" +#define kXIFFContainerBinary "XBFF" + +/*** + * @brief Generic XIFF header + * Used by XIFF based containers. + */ + +struct PACKED XiffHeader final { + ByteType f_Magic[kFourCCLength_XIFF]; // XIFF string (includes \0) + DWordType f_Size; // overall size of header (XiffHeader) in bytes + DWordType f_FormatType; // format type. generic + ByteType f_SpecificMag[kFourCCLength_XIFF]; // The sub header magic + DWordType f_SpecificSize; // length of the format data + DWordType f_SpecificFormatType; // format type. generic +}; + +typedef struct XiffHeader XiffHeader; + +#endif // ifndef __XIFF__ diff --git a/Public/Kits/System.Core/Headers/Defs.hxx b/Public/Kits/System.Core/Headers/Defs.hxx new file mode 100644 index 00000000..367849da --- /dev/null +++ b/Public/Kits/System.Core/Headers/Defs.hxx @@ -0,0 +1,248 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + +------------------------------------------- */ + +#pragma once + +#ifndef __cplusplus +#error This API is meant to be used with C++. +#endif + +#ifdef CA_MUST_PASS +#undef CA_MUST_PASS +#endif + +#ifdef _DEBUG +#define CA_MUST_PASS(e) { if (!e) { __assert_chk_fail() } } +#else +#define CA_MUST_PASS(e) CA_UNREFERENCED_PARAMETER(e) +#endif + +#ifdef __cplusplus + +#define CA_EXTERN_C extern "C" + +#else + +#define CA_EXTERN_C extern + +#endif + +CA_EXTERN_C void __assert_chk_fail(void); + +#define CA_STDCALL __attribute__((stdcall)) +#define CA_CDECL __attribute__((cdecl)) +#define CA_MSCALL __attribute__((ms_abi)) + +#define CA_PASCAL CA_STDCALL + +typedef __UINT8_TYPE__ ByteType; +typedef __UINT16_TYPE__ WordType; +typedef __UINT32_TYPE__ DWordType; +typedef __UINT64_TYPE__ QWordType; +typedef __SIZE_TYPE__ SizeType; + +typedef char CharacterType; +typedef CharacterType* PtrCharacterType; + +typedef void* PtrVoidType; +typedef void VoidType; + +typedef __UINTPTR_TYPE__ UIntPtrType; +typedef __INTPTR_TYPE__ IntPtrType; +typedef __UINT64_TYPE__ UInt64Type; +typedef __INT64_TYPE__ Int64Type; +typedef __UINT32_TYPE__ UInt32Type; +typedef __INT32_TYPE__ Int32Type; + +typedef CharacterType BooleanType; + +#define CA_COPY_DELETE(KLASS) \ + KLASS &operator=(const KLASS &) = delete; \ + KLASS(const KLASS &) = delete; + + +#define CA_COPY_DEFAULT(KLASS) \ + KLASS &operator=(const KLASS &) = default; \ + KLASS(const KLASS &) = default; + + +#define CA_MOVE_DELETE(KLASS) \ + KLASS &operator=(KLASS &&) = delete; \ + KLASS(KLASS &&) = delete; + + +#define CA_MOVE_DEFAULT(KLASS) \ + KLASS &operator=(KLASS &&) = default; \ + KLASS(KLASS &&) = default; + + +#define Yes 1 +#define No 0 + +#define CA_PTR * + +#define CA_FAR __far +#define CA_NEAR __near + +#define CA_UNREFERENCED_PARAMETER(e) ((VoidType)e) + +#ifdef __x86_64__ +# define _M_AMD64 2 +#endif + +#ifdef __aarch64__ +# define _M_AARCH64 3 +#endif + +#ifdef __powerpc64__ +# define _M_PPC64 4 +#endif + +#ifdef __64x0__ +# define _M_64000 5 +#endif + +#ifdef __riscv__ +# define _M_RISCV 6 +#endif + +#define CA_STATIC static +#define CA_INLINE inline +#define CA_CONST const + +#ifdef __cplusplus +#define CA_CONSTEXPR constexpr +#else +#define CA_CONSTEXPR +#endif // __cplusplus + +enum HcProcessCall { + kProcessCallAllocPtr = 1, + kProcessCallFreePtr, + kProcessCallSizePtr, + kProcessCallCheckPtr, + kProcessCallAllocStack, + /// @brief Open a specific handle (can be used as sel to call methods related to it.) + kProcessCallOpenHandle, + kProcessCallCloseHandle, + /// @brief Number of process calls. + kProcessCallsCount = 7, +}; + +#include + +class SystemException { + public: + explicit SystemException() = default; + virtual ~SystemException() = default; + + public: + CA_COPY_DEFAULT(SystemException); + + public: + virtual const char *Name() = 0; + virtual const char *Reason() = 0; + +}; + +/// @brief Object exception +/// Throws when the object isn't found. +class ObjectNotFoundException : public SystemException { + public: + explicit ObjectNotFoundException() = default; + virtual ~ObjectNotFoundException() = default; + + public: + CA_COPY_DEFAULT(ObjectNotFoundException); + + public: + const char *Name() override { return "ObjectNotFoundException"; } + const char *Reason() override { return mReason; } + + private: + const char *mReason{ + "System.Core: ObjectNotFoundException: Catastrophic failure!"}; +}; + +/// @brief pointer exception +/// Throws when the object isn't found. +class PointerException : public SystemException { + public: + explicit PointerException() = default; + virtual ~PointerException() = default; + + public: + CA_COPY_DEFAULT(PointerException); + + public: + const char *Name() override { return "PointerException"; } + const char *Reason() override { return mReason; } + + private: + const char *mReason{ + "System.Core: PointerException: Catastrophic failure!"}; +}; + +/// @brief pointer exception +/// Throws when the object isn't found. +class NullPointerException : public SystemException { + public: + explicit NullPointerException() = default; + virtual ~NullPointerException() = default; + + public: + CA_COPY_DEFAULT(NullPointerException); + + public: + const char *Name() override { return "NullPointerException"; } + const char *Reason() override { return mReason; } + + private: + const char *mReason{ + "System.Core: NullPointerException: Catastrophic failure!"}; +}; + +#define kObjectGlobalNamespaceSystem "HCORE_ROOT\\" +#define kObjectGlobalNamespaceUser "HCORE_USER_ROOT\\" + +enum { + kObjectTypeProcess, + kObjectTypeFile, + kObjectTypeDevice, + kObjectTypeNetwork, + kObjectTypeInvalid, + KObjectTypeUserDefined = 0xCF, + kObjectTypeCount = 5, +}; + +/** + * @brief GUID type, something you can also find in CFKit. + * @author AMlal El Mahrouss + */ +typedef struct GUID final { + DWordType Data1; + WordType Data2; + WordType Data3; + ByteType Data4[8]; +} GUIDType, *PtrGUIDType; + +/// \brief Object handle. +/// \author Amlal El Mahrouss +typedef struct Object final { + CharacterType ObjectName[255]; + DWordType ObjectType; + CharacterType ObjectNamespace[255]; + + VoidType(*Release)(struct Object* Self); + IntPtrType(*Invoke)(struct Object* Self, DWordType Sel, ...); + VoidType(*Query)(struct Object* Self, PtrVoidType* Dst, SizeType SzDst, struct GUID* GuidOf); +} Object, *ObjectPtr; + +#define object_cast reinterpret_cast + +CA_EXTERN_C ObjectPtr HcGetInstanceObject(void); + +CA_INLINE ObjectPtr kInstanceObject; diff --git a/Public/Kits/System.Core/Headers/File.hxx b/Public/Kits/System.Core/Headers/File.hxx new file mode 100644 index 00000000..48331c15 --- /dev/null +++ b/Public/Kits/System.Core/Headers/File.hxx @@ -0,0 +1,70 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + +------------------------------------------- */ + +#ifndef __FILE_API__ +#define __FILE_API__ + +#include + +/// @brief SOM class, translated to C++ + +namespace System { +class FileInterface final { + public: + explicit FileInterface(const char *path) { + mHandle = kInstanceObject->Invoke(kInstanceObject, kProcessCallOpenHandle, + 0, path); + } + + ~FileInterface() { + kInstanceObject->Invoke(kInstanceObject, kProcessCallCloseHandle, 0, + mHandle); + } + + public: + CA_COPY_DEFAULT(FileInterface); + + public: + PtrVoidType Read(UIntPtrType off, SizeType sz) { return (PtrVoidType)kInstanceObject->Invoke(kInstanceObject, mHandle, 2, off, sz); } + PtrVoidType Read(SizeType sz) { return (PtrVoidType)kInstanceObject->Invoke(kInstanceObject, mHandle, 3, sz); } + + void Write(PtrVoidType buf, UIntPtrType off, SizeType sz) { kInstanceObject->Invoke(kInstanceObject, mHandle, 4, buf, off, sz); } + void Write(PtrVoidType buf, SizeType sz) { kInstanceObject->Invoke(kInstanceObject, mHandle, 5, buf, sz); } + + void Seek(UIntPtrType off) { kInstanceObject->Invoke(kInstanceObject, mHandle, 5); } + void Rewind() { kInstanceObject->Invoke(kInstanceObject, mHandle, 6); } + + public: + const char *MIME(); + void MIME(const char *mime); + + private: + IntPtrType mHandle; +}; + +typedef FileInterface *FilePtr; + +/// @brief file exception +/// Throws when the file isn't found or invalid. +class FileException : public SystemException { + public: + explicit FileException() = default; + virtual ~FileException() = default; + + public: + CA_COPY_DEFAULT(FileException); + + public: + const char *Name() override { return "FileException"; } + const char *Reason() override { return mReason; } + + private: + const char *mReason{"System.Core: FileException: Catastrophic failure!"}; +}; + +} // namespace System + +#endif // ifndef __FILE_API__ diff --git a/Public/Kits/System.Core/Headers/Heap.hxx b/Public/Kits/System.Core/Headers/Heap.hxx new file mode 100644 index 00000000..43eaacab --- /dev/null +++ b/Public/Kits/System.Core/Headers/Heap.hxx @@ -0,0 +1,63 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + +------------------------------------------- */ + +#pragma once + +#include + +namespace System { +class MemoryException; + +typedef PtrVoidType HeapPtr; + +enum { + kHeapExpandable = 2, + kHeapNoExecute = 4, + kHeapShared = 6, + kHeapReadOnly = 8, + kHeapNoFlags = 0 +}; + +class HeapInterface final { + private: + explicit HeapInterface(); + + public: + ~HeapInterface(); + + public: + CA_COPY_DEFAULT(HeapInterface); + + public: + static HeapInterface *Shared() noexcept; + + public: + void Delete(HeapPtr me) noexcept; + SizeType Size(HeapPtr me) noexcept; + HeapPtr New(const SizeType &sz, + const DWordType flags = kHeapNoFlags); +}; + + +/// @brief heap exception +/// Throws when the heap pointer isn't found or invalid. +class HeapException : public SystemException { + public: + explicit HeapException() = default; + virtual ~HeapException() = default; + + public: + CA_COPY_DEFAULT(HeapException); + + public: + const char *Name() override { return "HeapException"; } + const char *Reason() override { return mReason; } + + private: + const char *mReason{"System.Core: HeapException: Catastrophic failure!"}; +}; + +} // namespace System \ No newline at end of file diff --git a/Public/Kits/System.Core/Headers/Hint.hxx b/Public/Kits/System.Core/Headers/Hint.hxx new file mode 100644 index 00000000..86faf455 --- /dev/null +++ b/Public/Kits/System.Core/Headers/Hint.hxx @@ -0,0 +1,18 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + +------------------------------------------- */ + +#pragma once + +#define _Input +#define _Output + +#define _Optional + +#define _StrictCheckInput +#define _StrictCheckOutput + +#define _InOut +#define _StrictInOut diff --git a/Public/Kits/System.Core/Headers/Thread.hxx b/Public/Kits/System.Core/Headers/Thread.hxx new file mode 100644 index 00000000..306419b3 --- /dev/null +++ b/Public/Kits/System.Core/Headers/Thread.hxx @@ -0,0 +1,49 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + +------------------------------------------- */ + +// +// Created by Amlal on 3/18/24 +// + +#ifndef __THREAD_API__ +#define __THREAD_API__ + +#include + +/// @brief Thread Information Block, which holds information about the running thread. +typedef PtrVoidType PtrThread; + +/// @brief Creates a new thread. +/// @param StartProc +/// @param OptionalHeap +/// @param OptionalStack +/// @param Detach +/// @param Join +/// @return +PtrThread HcCreateThread(_Input PtrVoidType StartProc, + _Optional _InOut PtrVoidType OptionalHeap, + _Optional _InOut PtrVoidType OptionalStack, + _Optional _Input BooleanType Detach, + _Optional _Input BooleanType Join); + +/// @brief Destroys the thread object. +/// @param ThreadPtr +/// @return +BooleanType HcDestroyThread(_Input PtrThread ThreadPtr); + +/// @brief Stops the thread. +/// @param ThreadPtr +/// @return +BooleanType HcStopThread(_Input PtrThread ThreadPtr); + +/// @brief Resumes it. +/// @param ThreadPtr +/// @return +BooleanType HcResumeThread(_Input PtrThread ThreadPtr); + +QWordType HcProcessIdThread(_Input PtrThread ThreadPtr); + +#endif // __THREAD_API__ diff --git a/Public/Kits/System.Core/Heap.cxx b/Public/Kits/System.Core/Heap.cxx deleted file mode 100644 index 55850b1a..00000000 --- a/Public/Kits/System.Core/Heap.cxx +++ /dev/null @@ -1,45 +0,0 @@ -/* ------------------------------------------- - - Copyright Mahrouss Logic - -------------------------------------------- */ - -#include -#include - -using namespace System; - -/// @brief Shared instance of the heap. -/// @return -Heap* Heap::Shared() noexcept { - static Heap* heap = nullptr; - - if (!heap) { - heap = new Heap(); - } - - return heap; -} - -Heap::Heap() { - CA_MUST_PASS(HcProcessHeapExists(kInstanceObject, (VoidPtr)this)); -} - -Heap::~Heap() { delete this; } - -void Heap::Delete(HeapPtr me) noexcept { - CA_MUST_PASS(me); - HcFreeProcessHeap(kInstanceObject, me); -} - -SizeT Heap::Size(HeapPtr me) noexcept { - CA_MUST_PASS(me); - return HcProcessHeapSize(kInstanceObject, me); -} - -HeapPtr Heap::New(const SizeT& sz, const Int32 flags) { - SizeT _sz = sz; - if (!_sz) ++_sz; - - return HcAllocateProcessHeap(kInstanceObject, _sz, flags); -} \ No newline at end of file diff --git a/Public/Kits/System.Core/Heap.hxx b/Public/Kits/System.Core/Heap.hxx deleted file mode 100644 index ff0fc75a..00000000 --- a/Public/Kits/System.Core/Heap.hxx +++ /dev/null @@ -1,79 +0,0 @@ -/* ------------------------------------------- - - Copyright Mahrouss Logic - -------------------------------------------- */ - -#pragma once - -#include -#include - -#define kAllocationTypes 2 - -CA_EXTERN_C PVOID HcAllocateProcessHeap(ObjectPtr refObj, QWORD sz, - DWORD flags); -CA_EXTERN_C BOOL HcProcessHeapExists(ObjectPtr refObj, PVOID ptr); -CA_EXTERN_C QWORD HcProcessHeapSize(ObjectPtr refObj, PVOID ptr); -CA_EXTERN_C VOID HcFreeProcessHeap(ObjectPtr refObj, PVOID ptr); -CA_EXTERN_C ObjectPtr HcGetInstanceObject(void); - -enum HcAllocationKind { - kStandardAllocation = 0xC, - kArrayAllocation = 0xD, -}; - -namespace System { -using namespace HCore; - -class MemoryException; - -typedef PVOID HeapPtr; - -enum { - kHeapExpandable = 2, - kHeapNoExecute = 4, - kHeapShared = 6, - kHeapReadOnly = 8, - kHeapNoFlags = 0 -}; - -class Heap final { - private: - explicit Heap(); - - public: - ~Heap(); - - public: - HCORE_COPY_DEFAULT(Heap); - - public: - static Heap *Shared() noexcept; - - public: - void Delete(HeapPtr me) noexcept; - SizeT Size(HeapPtr me) noexcept; - HeapPtr New(const SizeT &sz, const Int32 flags = kHeapNoFlags); -}; - - -/// @brief heap exception -/// Throws when the heap pointer isn't found or invalid. -class HeapException : public SystemException { - public: - explicit HeapException() = default; - virtual ~HeapException() = default; - - public: - HCORE_COPY_DEFAULT(HeapException); - - public: - const char *Name() override { return "HeapException"; } - const char *Reason() override { return mReason; } - - private: - const char *mReason{"System.Core: HeapException: Catastrophic failure!"}; -}; - -} // namespace System \ No newline at end of file diff --git a/Public/Kits/System.Core/HeapRuntime.cxx b/Public/Kits/System.Core/HeapRuntime.cxx deleted file mode 100644 index c2f1f0e9..00000000 --- a/Public/Kits/System.Core/HeapRuntime.cxx +++ /dev/null @@ -1,44 +0,0 @@ -/** =========================================== - (C) Mahrouss Logic - ===========================================*/ - -#include - -/// @brief Allocate from the user's heap. -/// @param refObj Process object. -/// @param sz size of object. -/// @param flags flags. -/// @return -CA_EXTERN_C PVOID HcAllocateProcessHeap(ObjectPtr refObj, QWORD sz, - DWORD flags) { - CA_MUST_PASS(sz); - CA_MUST_PASS(flags); - - return (PVOID)refObj->Invoke(refObj, kProcessCallAllocPtr, sz, flags); -} - -/// @brief Free pointer from the user's heap. -/// @param refObj Process object. -/// @param ptr the pointer to free. -CA_EXTERN_C VOID HcFreeProcessHeap(ObjectPtr refObj, PVOID ptr) { - CA_MUST_PASS(ptr); - CA_UNREFERENCED_PARAMETER(refObj->Invoke(refObj, kProcessCallFreePtr, ptr)); -} - -/// @brief Get pointer size. -/// @param refObj Process object. -/// @param ptr the pointer to find. -/// @return the size. -CA_EXTERN_C QWORD HcProcessHeapSize(ObjectPtr refObj, PVOID ptr) { - CA_MUST_PASS(ptr); - return refObj->Invoke(refObj, kProcessCallSizePtr, ptr); -} - -/// @brief Check if the pointer exists. -/// @param refObj Process object. -/// @param ptr the pointer to check. -/// @return if it exists -CA_EXTERN_C BOOL HcProcessHeapExists(ObjectPtr refObj, PVOID ptr) { - CA_MUST_PASS(ptr); - return refObj->Invoke(refObj, kProcessCallCheckPtr, ptr); -} diff --git a/Public/Kits/System.Core/Hint.hxx b/Public/Kits/System.Core/Hint.hxx deleted file mode 100644 index 86faf455..00000000 --- a/Public/Kits/System.Core/Hint.hxx +++ /dev/null @@ -1,18 +0,0 @@ -/* ------------------------------------------- - - Copyright Mahrouss Logic - -------------------------------------------- */ - -#pragma once - -#define _Input -#define _Output - -#define _Optional - -#define _StrictCheckInput -#define _StrictCheckOutput - -#define _InOut -#define _StrictInOut diff --git a/Public/Kits/System.Core/InitRuntime.cxx b/Public/Kits/System.Core/InitRuntime.cxx deleted file mode 100644 index 8d5596ca..00000000 --- a/Public/Kits/System.Core/InitRuntime.cxx +++ /dev/null @@ -1,14 +0,0 @@ -/** =========================================== - (C) Mahrouss Logic - ===========================================*/ - -#include - -/// @brief Inits the process runtime -/// @return if it was succesful or not. -DWORD HcInitRuntime(VOID) { - kInstanceObject = HcGetInstanceObject(); - CA_MUST_PASS(kInstanceObject); - - return 0; -} \ No newline at end of file diff --git a/Public/Kits/System.Core/Makefile b/Public/Kits/System.Core/Makefile index fb0f3e87..13fdf960 100644 --- a/Public/Kits/System.Core/Makefile +++ b/Public/Kits/System.Core/Makefile @@ -9,7 +9,7 @@ OUTPUT=System.Core.dll .PHONY: build-core-amd64 build-core-amd64: - $(CC) -I../ -I$(HOME) -I../../../Private/ $(CCFLAGS) $(wildcard *.cxx) $(wildcard AMD64/*.s) -o $(OUTPUT) + $(CC) -I../ -I$(HOME) -I../../../Private/ $(CCFLAGS) $(wildcard Sources/*.cxx) $(wildcard AMD64/*.s) -o $(OUTPUT) .PHONY: all all: build-core diff --git a/Public/Kits/System.Core/New+Delete.cxx b/Public/Kits/System.Core/New+Delete.cxx deleted file mode 100644 index 507cb7a3..00000000 --- a/Public/Kits/System.Core/New+Delete.cxx +++ /dev/null @@ -1,50 +0,0 @@ -/* ------------------------------------------- - - Copyright Mahrouss Logic - -------------------------------------------- */ - -#include - -void* operator new[](size_t sz) -{ - if (sz == 0) - ++sz; - - return HcAllocateProcessHeap(kInstanceObject, sz, kStandardAllocation); -} - -void* operator new(size_t sz) -{ - if (sz == 0) - ++sz; - - return HcAllocateProcessHeap(kInstanceObject, sz, kArrayAllocation); -} - -void operator delete[](void* ptr) -{ - if (ptr == nullptr) - return; - - HcFreeProcessHeap(kInstanceObject, ptr); -} - -void operator delete(void* ptr) -{ - if (ptr == nullptr) - return; - - HcFreeProcessHeap(kInstanceObject, ptr); -} - -void operator delete(void* ptr, size_t sz) -{ - if (ptr == nullptr) - return; - - (void)sz; - - HcFreeProcessHeap(kInstanceObject, ptr); -} - diff --git a/Public/Kits/System.Core/RISCV/.gitkeep b/Public/Kits/System.Core/RISCV/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/Public/Kits/System.Core/Sources/DllMain.cxx b/Public/Kits/System.Core/Sources/DllMain.cxx new file mode 100644 index 00000000..9412cbbb --- /dev/null +++ b/Public/Kits/System.Core/Sources/DllMain.cxx @@ -0,0 +1,14 @@ +/** =========================================== + (C) Mahrouss Logic + ===========================================*/ + +#include + +/// @brief Inits the DLL. +/// @return if it was succesful or not. +DWordType __DllMain(VoidType) { + kInstanceObject = HcGetInstanceObject(); + CA_MUST_PASS(kInstanceObject); + + return 0; +} \ No newline at end of file diff --git a/Public/Kits/System.Core/Sources/Heap.cxx b/Public/Kits/System.Core/Sources/Heap.cxx new file mode 100644 index 00000000..b3f43ad3 --- /dev/null +++ b/Public/Kits/System.Core/Sources/Heap.cxx @@ -0,0 +1,83 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + +------------------------------------------- */ + +#include + +/// @brief Allocate from the user's heap. +/// @param refObj Process object. +/// @param sz size of object. +/// @param flags flags. +/// @return +CA_EXTERN_C PtrVoidType HcAllocateProcessHeap(ObjectPtr refObj, QWordType sz, + DWordType flags) { + CA_MUST_PASS(sz); + CA_MUST_PASS(flags); + + return (PtrVoidType)refObj->Invoke(refObj, kProcessCallAllocPtr, sz, flags); +} + +/// @brief Free pointer from the user's heap. +/// @param refObj Process object. +/// @param ptr the pointer to free. +CA_EXTERN_C VoidType HcFreeProcessHeap(ObjectPtr refObj, PtrVoidType ptr) { + CA_MUST_PASS(ptr); + CA_UNREFERENCED_PARAMETER(refObj->Invoke(refObj, kProcessCallFreePtr, ptr)); +} + +/// @brief Get pointer size. +/// @param refObj Process object. +/// @param ptr the pointer to find. +/// @return the size. +CA_EXTERN_C QWordType HcProcessHeapSize(ObjectPtr refObj, PtrVoidType ptr) { + CA_MUST_PASS(ptr); + return refObj->Invoke(refObj, kProcessCallSizePtr, ptr); +} + +/// @brief Check if the pointer exists. +/// @param refObj Process object. +/// @param ptr the pointer to check. +/// @return if it exists +CA_EXTERN_C BooleanType HcProcessHeapExists(ObjectPtr refObj, PtrVoidType ptr) { + CA_MUST_PASS(ptr); + return refObj->Invoke(refObj, kProcessCallCheckPtr, ptr); +} + +using namespace System; + +/// @brief Shared instance of the heap. +/// @return +HeapInterface* HeapInterface::Shared() noexcept { + static HeapInterface* heap = nullptr; + + if (!heap) { + heap = new HeapInterface(); + } + + return heap; +} + +HeapInterface::HeapInterface() { + CA_MUST_PASS(HcProcessHeapExists(kInstanceObject, (PtrVoidType)this)); +} + +HeapInterface::~HeapInterface() { delete this; } + +void HeapInterface::Delete(HeapPtr me) noexcept { + CA_MUST_PASS(me); + HcFreeProcessHeap(kInstanceObject, me); +} + +SizeType HeapInterface::Size(HeapPtr me) noexcept { + CA_MUST_PASS(me); + return HcProcessHeapSize(kInstanceObject, me); +} + +HeapPtr HeapInterface::New(const SizeType& sz, const DWordType flags) { + SizeType _sz = sz; + if (!_sz) ++_sz; + + return HcAllocateProcessHeap(kInstanceObject, _sz, flags); +} diff --git a/Public/Kits/System.Core/Sources/New+Delete.cxx b/Public/Kits/System.Core/Sources/New+Delete.cxx new file mode 100644 index 00000000..019db66c --- /dev/null +++ b/Public/Kits/System.Core/Sources/New+Delete.cxx @@ -0,0 +1,65 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + +------------------------------------------- */ + +#include + +#define kAllocationTypes 2 + +enum HcAllocationKind { + kStandardAllocation = 0xC, + kArrayAllocation = 0xD, +}; + +CA_EXTERN_C PtrVoidType HcAllocateProcessHeap(ObjectPtr refObj, QWordType sz, + DWordType flags); +CA_EXTERN_C BooleanType HcProcessHeapExists(ObjectPtr refObj, PtrVoidType ptr); +CA_EXTERN_C QWordType HcProcessHeapSize(ObjectPtr refObj, PtrVoidType ptr); +CA_EXTERN_C VoidType HcFreeProcessHeap(ObjectPtr refObj, PtrVoidType ptr); + +typedef SizeType size_t; + +void* operator new[](size_t sz) +{ + if (sz == 0) + ++sz; + + return HcAllocateProcessHeap(kInstanceObject, sz, kStandardAllocation); +} + +void* operator new(size_t sz) +{ + if (sz == 0) + ++sz; + + return HcAllocateProcessHeap(kInstanceObject, sz, kArrayAllocation); +} + +void operator delete[](void* ptr) +{ + if (ptr == nullptr) + return; + + HcFreeProcessHeap(kInstanceObject, ptr); +} + +void operator delete(void* ptr) +{ + if (ptr == nullptr) + return; + + HcFreeProcessHeap(kInstanceObject, ptr); +} + +void operator delete(void* ptr, size_t sz) +{ + if (ptr == nullptr) + return; + + (void)sz; + + HcFreeProcessHeap(kInstanceObject, ptr); +} + diff --git a/Public/Kits/System.Core/System.Core.hxx b/Public/Kits/System.Core/System.Core.hxx deleted file mode 100644 index 96ab45be..00000000 --- a/Public/Kits/System.Core/System.Core.hxx +++ /dev/null @@ -1,14 +0,0 @@ -/** =========================================== - (C) Mahrouss Logic - ===========================================*/ - -#pragma once - -/// Process Heap API -#include - -/// File API & Device API. -#include - -/// Process & Threading API -#include diff --git a/Public/Kits/System.Core/System.hxx b/Public/Kits/System.Core/System.hxx deleted file mode 100644 index 05028d87..00000000 --- a/Public/Kits/System.Core/System.hxx +++ /dev/null @@ -1,18 +0,0 @@ -/*** =========================================== - (C) Mahrouss Logic - ===========================================*/ - -#pragma once - -/** --------------------------------------------------- - - * THIS FILE CONTAINS CODE FOR THE STANDARD HCORE API. - -------------------------------------------------------- */ - -#include -#include -#include -#include - -using namespace HCore; diff --git a/Public/Kits/System.Core/Threading.hxx b/Public/Kits/System.Core/Threading.hxx deleted file mode 100644 index bddbbf3f..00000000 --- a/Public/Kits/System.Core/Threading.hxx +++ /dev/null @@ -1,34 +0,0 @@ -/* ------------------------------------------- - - Copyright Mahrouss Logic - -------------------------------------------- */ - -// -// Created by Amlal on 3/18/24 -// - -#ifndef __THREAD_API__ -#define __THREAD_API__ - -#include - -/// @brief Thread Information Block variant for scheduling. -struct PACKED ThreadInformationBlock final { - const UINT_PTR StartAddress; // Start Address - const UINT_PTR StartHeap; // Allocation Heap - const UINT_PTR StartStack; // Stack Pointer. - const WORD ThreadID; // Execution Thread ID. -}; - -ThreadInformationBlock* HcCreateThread(_Input PVOID Start, - _Optional _InOut PVOID HeapOpt, - _Optional _InOut PVOID StackOpt); - -BOOL HcDestroyThread(_Input ThreadInformationBlock* TIB); - -BOOL HcStopThread(_Input ThreadInformationBlock* TIB); - -BOOL HcResumeThread(_Input ThreadInformationBlock* TIB); - -#endif // __THREAD_API__ diff --git a/Public/Kits/System.Grahpics.GPU/.gitkeep b/Public/Kits/System.Grahpics.GPU/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/Public/Kits/System.Graphics/.gitkeep b/Public/Kits/System.Graphics/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/Public/Kits/System.Graphics/Core.cxx b/Public/Kits/System.Graphics/Core.cxx deleted file mode 100644 index 9a4ef7a7..00000000 --- a/Public/Kits/System.Graphics/Core.cxx +++ /dev/null @@ -1,14 +0,0 @@ -/* ------------------------------------------- - - Copyright Mahrouss Logic - - File: Core.cxx - Purpose: - - Revision History: - - 31/01/24: Added file (amlel) - -------------------------------------------- */ - -#include diff --git a/Public/Kits/System.Graphics/Core.hxx b/Public/Kits/System.Graphics/Core.hxx deleted file mode 100644 index a453e095..00000000 --- a/Public/Kits/System.Graphics/Core.hxx +++ /dev/null @@ -1,185 +0,0 @@ -/* ------------------------------------------- - - Copyright Mahrouss Logic - - File: Core.hxx - Purpose: - - Revision History: - - 31/01/24: Added file (amlel) - 08/02/24: Update Form to GForm. (amlel) - -------------------------------------------- */ - -#pragma once - -#include -#include -#include -#include -#include - -#define $() HCore::GApplication::Shared()->Document() - -#ifndef __EXPORT_LIB -#define G_API __attribute__((pef_container(".IMPORT"))) -#else -#define G_API __attribute__((pef_container(".EXPORT"))) -#endif // ifdef __EXPORT_LIB - -namespace System::Graphics { -template -class GAction; - -class GString; -class GNumber; -class GVector2; -class GBoolean; -class GDocument; -class GApplication; -class GFrame; - -class G_API GBoolean { - private: - explicit GBoolean() : m_Value(false) {} - - HCore::Boolean m_Value; - - friend class GForm; - - public: - static const GBoolean Construct(HCore::StringView& sw, HCore::Boolean value) { - GBoolean boolean; - boolean.m_Value = value; - - return boolean; - } -}; - -template -class G_API GAction { - explicit GAction(HCore::StringView& sw) { m_Name = sw; } - - HCore::StringView m_Name; - void (*m_Action)(T&&... args); - - friend class GForm; - - public: - static const GAction Construct(HCore::StringView& sw, - void (*action)(T&&... args)) { - GAction actcls{sw}; - actcls.m_Action = action; - - return actcls; - } -}; - -class G_API GVector2 { - explicit GVector2(HCore::StringView& sw) : m_Vec2() {} - - HCore::Array m_Vec2; - - friend class GForm; - - public: - static const GVector2 Construct(HCore::StringView& sw, - HCore::Array& vec2) { - GVector2 vec{sw}; - vec.m_Vec2 = vec2; - - return vec; - } -}; - -class G_API GNumber { - HCore::Int m_Number{0}; - friend class GForm; - - public: - static const GNumber Construct(HCore::Int& number) { - GNumber num; - num.m_Number = number; - - return num; - } -}; - -class G_API GString { - explicit GString(HCore::StringView& content) { - m_Content = new HCore::StringView(); - *m_Content = content; - } - - HCore::StringView* m_Content; - - friend class GForm; - - public: - static const GString Construct(HCore::StringView& value) { - GString str{value}; - return str; - } -}; - -class G_API GApplication final { - public: - explicit GApplication() = default; - ~GApplication() = default; - - HCORE_COPY_DEFAULT(GApplication); - - GDocument* Document() noexcept { return nullptr; } - - static GApplication* Shared() noexcept { - STATIC GApplication* kApp = nullptr; - - if (!kApp) kApp = new GApplication(); - - return kApp; - } -}; - -class G_API GDocument final { - public: - explicit GDocument(HCore::StringView& sv) : mString(GString::Construct(sv)) {} - ~GDocument() = default; - - HCORE_COPY_DEFAULT(GDocument); - - GFrame** GetAddressOf() noexcept { return &mFrame; } - GFrame* Get() noexcept { return mFrame; } - - GString& Name() { return mString; } - - private: - GFrame* mFrame{nullptr}; - GString mString; -}; - -class GException final { - public: - explicit GException() = default; - ~GException() = default; - - public: - HCORE_COPY_DEFAULT(GException); - - public: - const char* Name() { return "User Interface error."; } - const char* Reason() { return mReason; } - - private: - const char* mReason{"System.Graphics: Graphics exception. Check HError."}; -}; - -template -inline GFrameType* frame_cast(GFrameBase* Frame) { - if (!dynamic_cast(Frame)) { - throw GException(); - } - - return dynamic_cast(Frame); -} -} // namespace System::Graphics diff --git a/Public/Kits/System.Graphics/Dim2d.cxx b/Public/Kits/System.Graphics/Dim2d.cxx deleted file mode 100644 index 5925660d..00000000 --- a/Public/Kits/System.Graphics/Dim2d.cxx +++ /dev/null @@ -1,20 +0,0 @@ -/* ------------------------------------------- - - Copyright Mahrouss Logic - - File: Dim2d.cpp - Purpose: - - Revision History: - - 31/01/24: Added file (amlel) - -------------------------------------------- */ - -#include - -namespace System::Graphics { -HCore::UInt& Dim2d::X() { return m_X; } - -HCore::UInt& Dim2d::Y() { return m_Y; } -} // namespace System::Graphics diff --git a/Public/Kits/System.Graphics/Dim2d.hxx b/Public/Kits/System.Graphics/Dim2d.hxx deleted file mode 100644 index 77d42c90..00000000 --- a/Public/Kits/System.Graphics/Dim2d.hxx +++ /dev/null @@ -1,38 +0,0 @@ -/* ------------------------------------------- - - Copyright Mahrouss Logic - - File: Dim2d.hpp - Purpose: - - Revision History: - - 31/01/24: Added file (amlel) - 3/10/24: Remname extension to .hxx - -------------------------------------------- */ - -#ifndef __DIM2D__ -#define __DIM2D__ - -#include - -namespace System::Graphics { -class G_API Dim2d final { - public: - explicit Dim2d() = delete; - explicit Dim2d(const HCore::UInt& x, const HCore::UInt& y) : m_X(x), m_Y(y) {} - - Dim2d& operator=(const Dim2d&) = default; - Dim2d(const Dim2d&) = default; - - HCore::UInt& X(); - HCore::UInt& Y(); - - private: - HCore::UInt m_X{0}; - HCore::UInt m_Y{0}; -}; -} // namespace System::Graphics - -#endif /* ifndef __DIM2D__ */ diff --git a/Public/Kits/System.Graphics/Frame.cxx b/Public/Kits/System.Graphics/Frame.cxx deleted file mode 100644 index ddb7b5ce..00000000 --- a/Public/Kits/System.Graphics/Frame.cxx +++ /dev/null @@ -1,18 +0,0 @@ -/* ------------------------------------------- - - Copyright Mahrouss Logic - - File: Frame.cpp - Purpose: - - Revision History: - - 31/01/24: Added file (amlel) - -------------------------------------------- */ - -#include - -namespace System::Graphics { - -} // namespace System::Graphics diff --git a/Public/Kits/System.Graphics/Frame.hxx b/Public/Kits/System.Graphics/Frame.hxx deleted file mode 100644 index 318f01cd..00000000 --- a/Public/Kits/System.Graphics/Frame.hxx +++ /dev/null @@ -1,60 +0,0 @@ -/* ------------------------------------------- - - Copyright Mahrouss Logic - - File: Frame.hxx - Purpose: - - Revision History: - - 31/01/24: Added file (amlel) - -------------------------------------------- */ - -#pragma once - -#include -#include -#include -#include - -namespace System::Graphics { -class G_API GFrame { - public: - explicit GFrame(GFrame* parent = nullptr) : m_ParentFrame(parent) {} - ~GFrame() {} - - GFrame& operator=(const GFrame&) = default; - GFrame(const GFrame&) = default; - - virtual void Update() { - if (m_Frames.Count() == 0) return; - - for (DWORD x = 0; x < m_Frames.Count(); ++x) { - if (!m_Frames[x]->ShouldBeUpdated()) continue; - - m_Frames[x]->Update(); - } - - this->Paint(); - } - - virtual void UpdateInput() { - if (m_Frames.Count() == 0) return; - - for (DWORD x = 0; x < m_Frames.Count(); ++x) { - if (!m_Frames[x]->ShouldBeUpdated()) continue; - - m_Frames[x]->UpdateInput(); - } - } - - virtual bool ShouldBeUpdated() { return false; } - - virtual void Paint() {} - - private: - HCore::MutableArray m_Frames; - GFrame* m_ParentFrame{nullptr}; -}; -} // namespace System::Graphics diff --git a/Public/Kits/System.Graphics/Makefile b/Public/Kits/System.Graphics/Makefile deleted file mode 100644 index 1530f699..00000000 --- a/Public/Kits/System.Graphics/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -################################################## -# (C) Mahrouss Logic, 2024, all rights reserved. -# This is the System.Graphics Makefile. -################################################## - -CC=x86_64-w64-mingw32-g++ -CCFLAGS=-shared -ffreestanding -fno-rtti -fno-exceptions -std=c++20 -OUTPUT=System.Graphics.dll - -.PHONY: build-gfx -build-gfx: - $(CC) -I../ -I$(HOME) -I../../../Private/ $(CCFLAGS) *.cxx -o $(OUTPUT) - -.PHONY: all -all: build-gfx - @echo "[System.Graphics.dll] Build done." - -.PHONY: clean -clean: - rm -f *.o diff --git a/Public/Kits/System.Graphics/Stylesheet.hxx b/Public/Kits/System.Graphics/Stylesheet.hxx deleted file mode 100644 index f4106a7b..00000000 --- a/Public/Kits/System.Graphics/Stylesheet.hxx +++ /dev/null @@ -1,50 +0,0 @@ -/* ------------------------------------------- - - Copyright Mahrouss Logic - - File: Stylesheet.hxx - Purpose: - - Revision History: - - 08/02/24: Added file (amlel) - -------------------------------------------- */ - -#pragma once - -/// TODO: Stylesheets for GUI. - -#include -#include -#include - -namespace HCore { -class G_API GStylesheet final { - public: - explicit GStylesheet() = default; - ~GStylesheet() = default; - - HCORE_COPY_DEFAULT(GStylesheet); - - MutableArray& Props() { return mProps; } - - private: - MutableArray mProps; -}; - -class StylesheetParser final { - public: - static MutableArray FromBlob(Char* Blob, SizeT BlobSz) { - MutableArray stylesheet; - - if (!Blob || BlobSz < 1) return stylesheet; - - for (auto BlobIndex = 0UL; BlobIndex < BlobSz; ++BlobIndex) { - - } - - return stylesheet; - } -}; -} // namespace HCore diff --git a/Public/Kits/System.Graphics/compile_flags.txt b/Public/Kits/System.Graphics/compile_flags.txt deleted file mode 100644 index 6e721e73..00000000 --- a/Public/Kits/System.Graphics/compile_flags.txt +++ /dev/null @@ -1,4 +0,0 @@ --I./ --I../ --I../../../Private --std=c++20 diff --git a/Public/Kits/System.Zip/Defines.hpp b/Public/Kits/System.Zip/Defines.hpp deleted file mode 100644 index a894b672..00000000 --- a/Public/Kits/System.Zip/Defines.hpp +++ /dev/null @@ -1,30 +0,0 @@ -/* ------------------------------------------- - - Copyright Mahrouss Logic - -------------------------------------------- */ - -#pragma once - -#include - -#define ZIPKIT_VERSION "1.01" - -/// @brief Zip compression function -/// @param dest -/// @param destLen -/// @param source -/// @param sourceLen -/// @return -CA_EXTERN_C DWORD HcCompress(BYTE *dest, QWORD *destLen, const BYTE *source, - QWORD sourceLen); - -/// @brief Zip uncompression function -/// @param dest -/// @param destLen -/// @param source -/// @param sourceLen -/// @return -CA_EXTERN_C DWORD HcUncompress(BYTE *dest, QWORD *destLen, - const BYTE *source, QWORD sourceLen); - diff --git a/Public/Kits/System.Zip/Makefile b/Public/Kits/System.Zip/Makefile deleted file mode 100644 index 8069ce4b..00000000 --- a/Public/Kits/System.Zip/Makefile +++ /dev/null @@ -1,22 +0,0 @@ -################################################## -# (C) Mahrouss Logic, 2024, all rights reserved. -# This is the System.Zip Makefile. -################################################## - -CC=x86_64-w64-mingw32-g++ -CCFLAGS=-shared -ffreestanding -fno-rtti -fno-exceptions -std=c++20 -Xlinker --subsystem=17 -ASM=nasm -ASMFLAGS=-f elf64 -OUTPUT=System.Zip.dll - -.PHONY: build-zip -build-zip: - $(CC) -I../ -I../../../Private/ $(CCFLAGS) *.cxx -o $(OUTPUT) - -.PHONY: all -all: build-zip - @echo "[System.Zip.dll] Done." - -.PHONY: clean -clean: - rm -f *.o diff --git a/Public/Kits/System.Zip/Shell.hpp b/Public/Kits/System.Zip/Shell.hpp deleted file mode 100644 index 19de8f07..00000000 --- a/Public/Kits/System.Zip/Shell.hpp +++ /dev/null @@ -1,17 +0,0 @@ -/* ------------------------------------------- - - Copyright Mahrouss Logic - -------------------------------------------- */ - -#pragma once - -/// TODO: integrate compression into the shell. - -/// @brief NewFS catalog is compressed. -#define kNewFSIsZip 255 - -/// @brief NewFS catalog has password attached to it. -#define kNewFSHasPassword 256 - -class ShellInterface; diff --git a/Public/Kits/System.Zip/Zip.cxx b/Public/Kits/System.Zip/Zip.cxx deleted file mode 100644 index 60d53ffb..00000000 --- a/Public/Kits/System.Zip/Zip.cxx +++ /dev/null @@ -1,43 +0,0 @@ -/* ------------------------------------------- - - Copyright Mahrouss Logic - -------------------------------------------- */ - -#include -#include - -#define kZipInitialSize 4096 - -namespace System::Zip { -ZipStream::ZipStream() - : fSharedData(System::Heap::Shared()->New(kZipInitialSize, kHeapExpandable)), - fSharedSz(kZipInitialSize) {} - -ZipStream::~ZipStream() noexcept { - if (fSharedData) System::Heap::Shared()->Delete(fSharedData); -} - -FilePtr ZipStream::FlushToFile(const char *name) { - FilePtr fp = new File(name); - CA_MUST_PASS(fp); - - this->fSharedSz = System::Heap::Shared()->Size(this->fSharedData); - - fp->MIME(kZipKitMime); - fp->Write(this->fSharedData, this->fSharedSz); - - return fp; -} - -void *ZipStream::Deflate(const char *name) { - QWORD tmpSharedSz = this->fSharedSz; - HcUncompress((BYTE*)this->fSharedData, &this->fSharedSz, (BYTE*)this->fSharedData, tmpSharedSz); - - return this->fSharedData; -} - -void ZipStream::Inflate(const char *name, BYTE *data, QWORD dataLen) { - HcCompress((BYTE*)this->fSharedData, &this->fSharedSz, (BYTE*)data, dataLen); -} -} // namespace System.Zip diff --git a/Public/Kits/System.Zip/Zip.hpp b/Public/Kits/System.Zip/Zip.hpp deleted file mode 100644 index 425d3cc8..00000000 --- a/Public/Kits/System.Zip/Zip.hpp +++ /dev/null @@ -1,37 +0,0 @@ -/* ------------------------------------------- - - Copyright Mahrouss Logic - -------------------------------------------- */ - -#pragma once - -#define Z_SOLO 1 - -#include -#include - -namespace System::Zip { -class ZipStream; - -class ZipStream final { - public: - explicit ZipStream(); - ~ZipStream() noexcept; - - public: - HCORE_COPY_DEFAULT(ZipStream); - - public: - FilePtr FlushToFile(const char *name); - void *Deflate(const char *name); - void Inflate(const char *name, BYTE *data, QWORD sz); - - private: - VoidPtr fSharedData{nullptr}; - SizeT fSharedSz{0}; - -}; -} // namespace System.Zip - -#define kZipKitMime "application/x-bzip" diff --git a/Public/Kits/System.Zip/compile_flags.txt b/Public/Kits/System.Zip/compile_flags.txt deleted file mode 100644 index 6e721e73..00000000 --- a/Public/Kits/System.Zip/compile_flags.txt +++ /dev/null @@ -1,4 +0,0 @@ --I./ --I../ --I../../../Private --std=c++20 diff --git a/Public/SPECIFICATION.TXT b/Public/SPECIFICATION.TXT deleted file mode 100644 index 11ee62e3..00000000 --- a/Public/SPECIFICATION.TXT +++ /dev/null @@ -1,53 +0,0 @@ -=================================== -0: General Information -=================================== - -- ABI and Format: PEF/PE32+. -- Kernel architecture: Microkernel. -- Language: C++/(Assembly (AMD64, X64000, X86S, ARM64)) - -=================================== -1: The HCore Microkernel -=================================== - -- Drive/Device Abstraction. -- SMP, Preemptive Multi Threading. -- Separation of Files/Devices. -- Networking. -- Hardware Abstraction Layer. -- Native Filesystem support (NewFS, FAT32 and HCFS). -- Program Loaders. -- Thread Local Storage. -- Semaphore, Locks, Timers. -- Canary mechanisms. -- Dynamic Libraries. -- Cross Platform. -- Permission Selectors. - -=================================== -2: The Filesystem -=================================== - -- Catalog based with forks. -- Large storage support. -- Long file names. -- UNIX path style. - -================================== -3: Common naming conventions: -================================== - -- Kernel -> ke_init_x -- RunTime -> rt_copy_mem -- Hal -> hal_foo_bar - -=================================== -4: The HCore Bootloader -=================================== - -- Capable of booting from a network drive. -- Loads a PE file which is the kernel -- Sanity checks, based on the number of sections. -- Handover compliant. -- Does check for a valid invalid of HCore (useful in the case of recovering) - diff --git a/Public/TODO_LIST.TXT b/Public/TODO_LIST.TXT deleted file mode 100644 index 5e49eb04..00000000 --- a/Public/TODO_LIST.TXT +++ /dev/null @@ -1,25 +0,0 @@ -- We need preemptive multi-threading. [ X ] -- We then need sync primitives. [ X ] -- We also need a system library for the OS. [ X ] -- We need a bootloader for AMD64 [ X ] - - Implement Boot Services [ X ] - - Design Handover [ X ] - - Load kernel into memory [ X ] - - Fix bug in kernel loader, which causes a 06 #UD. [ X ] - - Load Kernel [ X ] - - Add IDT [ X ] - - AHCI driver [ WiP ] -- Context switch x87/SSE/AVX registers [ X ] -- Framebuffer [ X ] -- AHCI support [ ] -- HCore API and HCore Forms. [ ] -- Make installer form class [ ] - -Status: - -NewBoot: Working. -HCoreKrnl: Not run yet. - -Prioritize: -NewBoot: Protocol and API. -HCoreKrnl: Complying to specs. diff --git a/Public/compile_flags.txt b/Public/compile_flags.txt deleted file mode 100644 index 21296223..00000000 --- a/Public/compile_flags.txt +++ /dev/null @@ -1,5 +0,0 @@ --nostdlib --ffreestanding --std=c++20 --I./SDK/ --I../Private -- cgit v1.2.3