diff options
| author | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-02-01 08:26:34 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlalelmahrouss@icloud.com> | 2024-02-01 08:29:24 +0100 |
| commit | b052cb4fbb7b83c1292a3098ee7d00e9f3f3fba1 (patch) | |
| tree | fde735516201f30890e5ec740529f813463ed0e9 | |
| parent | be3ec5e358fcf47ab1136b38f03c7348bb5390e9 (diff) | |
New commit: see below.
- Add Internal directory.
- Add Drivers directory.
- Add DDKit in Kits directory.
Signed-off-by: Amlal El Mahrouss <amlalelmahrouss@icloud.com>
| -rw-r--r-- | Drivers/.gitkeep (renamed from Public/DDK/.gitkeep) | 0 | ||||
| -rw-r--r-- | Drivers/AHCI/.gitkeep (renamed from Public/Tools/.gitkeep) | 0 | ||||
| -rw-r--r-- | Drivers/Ethernet/.gitkeep | 0 | ||||
| -rw-r--r-- | Drivers/WiFi/.gitkeep | 0 | ||||
| -rw-r--r-- | Drivers/XHCI/.gitkeep | 0 | ||||
| -rw-r--r-- | Internal/Tools/.gitkeep | 0 | ||||
| -rw-r--r-- | Internal/Tools/NewFSPartTool.cxx (renamed from Public/Tools/MakeNewFS.cxx) | 11 | ||||
| -rw-r--r-- | Private/KernelKit/ProcessManager.hpp | 266 | ||||
| -rw-r--r-- | Private/NewBoot/Source/makefile | 1 | ||||
| -rw-r--r-- | Private/Source/ProcessManager.cxx | 5 | ||||
| -rw-r--r-- | Private/Source/ThreadLocalStorage.cxx | 2 | ||||
| -rw-r--r-- | Public/Kits/DDKit/.gitkeep | 0 | ||||
| -rw-r--r-- | Public/Kits/DDKit/README.TXT (renamed from Public/DDK/README.TXT) | 0 |
13 files changed, 137 insertions, 148 deletions
diff --git a/Public/DDK/.gitkeep b/Drivers/.gitkeep index e69de29b..e69de29b 100644 --- a/Public/DDK/.gitkeep +++ b/Drivers/.gitkeep diff --git a/Public/Tools/.gitkeep b/Drivers/AHCI/.gitkeep index e69de29b..e69de29b 100644 --- a/Public/Tools/.gitkeep +++ b/Drivers/AHCI/.gitkeep diff --git a/Drivers/Ethernet/.gitkeep b/Drivers/Ethernet/.gitkeep new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/Drivers/Ethernet/.gitkeep diff --git a/Drivers/WiFi/.gitkeep b/Drivers/WiFi/.gitkeep new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/Drivers/WiFi/.gitkeep diff --git a/Drivers/XHCI/.gitkeep b/Drivers/XHCI/.gitkeep new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/Drivers/XHCI/.gitkeep diff --git a/Internal/Tools/.gitkeep b/Internal/Tools/.gitkeep new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/Internal/Tools/.gitkeep diff --git a/Public/Tools/MakeNewFS.cxx b/Internal/Tools/NewFSPartTool.cxx index 8871d627..41bdd392 100644 --- a/Public/Tools/MakeNewFS.cxx +++ b/Internal/Tools/NewFSPartTool.cxx @@ -3,7 +3,7 @@ Copyright Mahrouss Logic File: MakeNewFS.cpp - Purpose: + Purpose: Partition a drive with a NewFS/EPM filesystem in it. Revision History: @@ -16,4 +16,11 @@ /// @brief NewFS partition program. /***********************************************************************************/ -int main() { return 0; } +#include <iostream> + +int main() { + std::cout + << "NewFSPartTool: Make a NewFS partition image from a directory!\n" + << "Copyright Mahrouss Logic, all rights reserved. (INTERNAL TOOL)\n"; + return 0; +} diff --git a/Private/KernelKit/ProcessManager.hpp b/Private/KernelKit/ProcessManager.hpp index 724dd34a..dbcd08b2 100644 --- a/Private/KernelKit/ProcessManager.hpp +++ b/Private/KernelKit/ProcessManager.hpp @@ -9,20 +9,20 @@ #pragma once -#include "NewKit/Defines.hpp" #include <ArchKit/Arch.hpp> #include <KernelKit/FileManager.hpp> #include <KernelKit/PermissionSelector.hxx> -#include <NewKit/UserHeap.hpp> #include <NewKit/LockDelegate.hpp> #include <NewKit/MutableArray.hpp> +#include <NewKit/UserHeap.hpp> + +#include "NewKit/Defines.hpp" #define kMinMicroTime AffinityKind::kStandard //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -namespace HCore -{ +namespace HCore { //! @brief Process identifier. typedef Int64 ProcessID; @@ -35,59 +35,53 @@ class ProcessManager; class ProcessHelper; //! @brief Process status enum. -enum class ProcessStatus : Int32 -{ - kStarting, - kRunning, - kKilled, - kFrozen, - kDead +enum class ProcessStatus : Int32 { + kStarting, + kRunning, + kKilled, + kFrozen, + kDead }; //! @brief Affinity is the amount of nano-seconds this process is going //! to run. -enum class AffinityKind : Int32 -{ - kInvalid = 300, - kVeryHigh = 250, - kHigh = 200, - kStandard = 150, - kLowUsage = 100, - kVeryLowUsage = 50, +enum class AffinityKind : Int32 { + kInvalid = 300, + kVeryHigh = 250, + kHigh = 200, + kStandard = 150, + kLowUsage = 100, + kVeryLowUsage = 50, }; // operator overloading. -inline bool operator<(AffinityKind lhs, AffinityKind rhs) -{ - Int32 lhs_int = static_cast<Int>(lhs); - Int32 rhs_int = static_cast<Int>(rhs); +inline bool operator<(AffinityKind lhs, AffinityKind rhs) { + Int32 lhs_int = static_cast<Int>(lhs); + Int32 rhs_int = static_cast<Int>(rhs); - return lhs_int < rhs_int; + return lhs_int < rhs_int; } -inline bool operator>(AffinityKind lhs, AffinityKind rhs) -{ - Int32 lhs_int = static_cast<Int>(lhs); - Int32 rhs_int = static_cast<Int>(rhs); +inline bool operator>(AffinityKind lhs, AffinityKind rhs) { + Int32 lhs_int = static_cast<Int>(lhs); + Int32 rhs_int = static_cast<Int>(rhs); - return lhs_int > rhs_int; + return lhs_int > rhs_int; } -inline bool operator<=(AffinityKind lhs, AffinityKind rhs) -{ - Int32 lhs_int = static_cast<Int>(lhs); - Int32 rhs_int = static_cast<Int>(rhs); +inline bool operator<=(AffinityKind lhs, AffinityKind rhs) { + Int32 lhs_int = static_cast<Int>(lhs); + Int32 rhs_int = static_cast<Int>(rhs); - return lhs_int <= rhs_int; + return lhs_int <= rhs_int; } -inline bool operator>=(AffinityKind lhs, AffinityKind rhs) -{ - Int32 lhs_int = static_cast<Int>(lhs); - Int32 rhs_int = static_cast<Int>(rhs); +inline bool operator>=(AffinityKind lhs, AffinityKind rhs) { + Int32 lhs_int = static_cast<Int>(lhs); + Int32 rhs_int = static_cast<Int>(rhs); - return lhs_int >= rhs_int; + return lhs_int >= rhs_int; } // end of operator overloading. @@ -97,11 +91,10 @@ using ProcessTime = UInt64; using PID = Int64; // for permission manager, tells where we run the code. -enum class ProcessSelector : Int -{ - kRingUser, /* user ring (or ring 3 in x86) */ - kRingDriver, /* ring 2 in x86, hypervisor privileges in other archs */ - kRingKernel, /* machine privileges */ +enum class ProcessSelector : Int { + kRingUser, /* user ring (or ring 3 in x86) */ + kRingDriver, /* ring 2 in x86, hypervisor privileges in other archs */ + kRingKernel, /* machine privileges */ }; // Helper types. @@ -109,126 +102,113 @@ using ImagePtr = VoidPtr; using HeapPtr = VoidPtr; // @brief Process header structure. -class Process final -{ - public: - explicit Process(VoidPtr startImage = nullptr) : Image(startImage) - { - MUST_PASS(startImage); - } - ~Process() = default; - - HCORE_COPY_DEFAULT(Process) - - public: - void AssignStart(UIntPtr &imageStart) noexcept; - - public: - Char Name[kProcessLen] = {"HCore Process"}; - ProcessSubsystem SubSystem; - ProcessSelector Selector; - HAL::StackFrame *StackFrame{nullptr}; - AffinityKind Affinity; - ProcessStatus Status; - - // Memory, images. - HeapPtr PoolCursor{nullptr}; - ImagePtr Image{nullptr}; - HeapPtr Pool{nullptr}; - - // memory usage - SizeT UsedMemory{0}; - SizeT FreeMemory{0}; - - ProcessTime PTime; - PID ProcessId{-1}; - Int32 Ring{3}; - - public: - //! @brief boolean operator, check status. - operator bool() - { - return Status != ProcessStatus::kDead; - } - - //! @brief Crash program, exits with code ~0. - void Crash(); - - //! @brief Exits program. - void Exit(Int32 exit_code = 0); - - //! @brief TLS new - VoidPtr New(const SizeT &sz); - - //! @brief TLS delete. - Boolean Delete(VoidPtr ptr, const SizeT &sz); - - //! @brief Process name getter, example: "C RunTime" - const Char *GetName(); - - //! @brief Wakes up threads. - void Wake(const bool wakeup = false); - - public: - const ProcessSelector &GetSelector(); - const ProcessStatus &GetStatus(); - const AffinityKind &GetAffinity(); - - private: - friend ProcessManager; - friend ProcessHelper; +class Process final { + public: + explicit Process(VoidPtr startImage = nullptr) : Image(startImage) { + MUST_PASS(startImage); + } + ~Process() = default; + + HCORE_COPY_DEFAULT(Process) + + public: + void AssignStart(UIntPtr &imageStart) noexcept; + + public: + Char Name[kProcessLen] = {"HCore Process"}; + ProcessSubsystem SubSystem; + ProcessSelector Selector; + HAL::StackFrame *StackFrame{nullptr}; + AffinityKind Affinity; + ProcessStatus Status; + + // Memory, images. + HeapPtr PoolCursor{nullptr}; + ImagePtr Image{nullptr}; + HeapPtr Pool{nullptr}; + + // memory usage + SizeT UsedMemory{0}; + SizeT FreeMemory{0}; + + ProcessTime PTime; + PID ProcessId{-1}; + Int32 Ring{3}; + + public: + //! @brief boolean operator, check status. + operator bool() { return Status != ProcessStatus::kDead; } + + //! @brief Crash program, exits with code ~0. + void Crash(); + + //! @brief Exits program. + void Exit(Int32 exit_code = 0); + + //! @brief TLS Allocate + VoidPtr New(const SizeT &sz); + + //! @brief TLS Free. + Boolean Delete(VoidPtr ptr, const SizeT &sz); + + //! @brief Process name getter, example: "C RunTime" + const Char *GetName(); + + //! @brief Wakes up threads. + void Wake(const bool wakeup = false); + + public: + const ProcessSelector &GetSelector(); + const ProcessStatus &GetStatus(); + const AffinityKind &GetAffinity(); + + private: + friend ProcessManager; + friend ProcessHelper; }; using ProcessPtr = Process *; //! @brief Kernel scheduler.. -class ProcessManager final -{ - private: - explicit ProcessManager() = default; +class ProcessManager final { + private: + explicit ProcessManager() = default; - public: - ~ProcessManager() = default; + public: + ~ProcessManager() = default; - HCORE_COPY_DEFAULT(ProcessManager) + HCORE_COPY_DEFAULT(ProcessManager) - operator bool() - { - return m_Headers.Count() > 0; - } - bool operator!() - { - return m_Headers.Count() == 0; - } + operator bool() { return m_Headers.Count() > 0; } + bool operator!() { return m_Headers.Count() == 0; } - bool Add(Ref<Process> &Header); - bool Remove(SizeT Header); + bool Add(Ref<Process> &Header); + bool Remove(SizeT Header); - Ref<Process> &GetCurrent(); - SizeT Run() noexcept; + Ref<Process> &GetCurrent(); + SizeT Run() noexcept; - static Ref<ProcessManager> Shared(); + static Ref<ProcessManager> Shared(); - private: - MutableArray<Ref<Process>> m_Headers; - Ref<Process> m_CurrentProcess; + private: + MutableArray<Ref<Process>> m_Headers; + Ref<Process> m_CurrentProcess; }; /* * Just a helper class, which contains some utilities for the scheduler. */ -class ProcessHelper final -{ - public: - static bool Switch(HAL::StackFrame *newStack, const PID &newPid); - static bool CanBeScheduled(Ref<Process> &process); - static PID &GetCurrentPID(); - static bool StartScheduling(); +class ProcessHelper final { + public: + static bool Switch(HAL::StackFrame *newStack, const PID &newPid); + static bool CanBeScheduled(Ref<Process> &process); + static PID &GetCurrentPID(); + static bool StartScheduling(); }; const Int32 &rt_get_exit_code() noexcept; -} // namespace HCore +} // namespace HCore #include <KernelKit/ThreadLocalStorage.hxx> diff --git a/Private/NewBoot/Source/makefile b/Private/NewBoot/Source/makefile index 4e8f17d2..0a2e1d91 100644 --- a/Private/NewBoot/Source/makefile +++ b/Private/NewBoot/Source/makefile @@ -17,7 +17,6 @@ bootloader-amd64: $(CC_GNU) $(FLAG_GNU) HEL/AMD64/*.cxx $(LD_GNU) *.o -e efi_main -filealign:16 -shared --subsystem=10 -ffreestanding -o HCoreLdr.exe cp HCoreLdr.exe CDROM/EFI/BOOT/BOOTX64.EFI - cp -r ../../Root ./CDROM/MAHROUSS .PHONY: run-efi-debug run-efi-debug: diff --git a/Private/Source/ProcessManager.cxx b/Private/Source/ProcessManager.cxx index fce7a58f..a8a03b52 100644 --- a/Private/Source/ProcessManager.cxx +++ b/Private/Source/ProcessManager.cxx @@ -39,7 +39,10 @@ const Int32 &rt_get_exit_code() noexcept { return kExitCode; } /***********************************************************************************/ void Process::Crash() { - kcout << this->Name << ": Crashed\n"; + kcout << this->Name << ": Crashed, ExitCode: -1\n"; + + // TODO: Bug check the system. + this->Exit(-1); } diff --git a/Private/Source/ThreadLocalStorage.cxx b/Private/Source/ThreadLocalStorage.cxx index edb5faa5..8aeb0431 100644 --- a/Private/Source/ThreadLocalStorage.cxx +++ b/Private/Source/ThreadLocalStorage.cxx @@ -42,7 +42,7 @@ Boolean hcore_tls_check(VoidPtr ptr) { */ Void hcore_tls_check_syscall_impl(ThreadInformationBlock ptr) noexcept { if (!hcore_tls_check(ptr.Cookie)) { - kcout << "TLS: Verification failure, crashing...\n"; + kcout << "TLS: Verification failure, Crashing...\n"; ProcessManager::Shared().Leak().GetCurrent().Leak().Crash(); } diff --git a/Public/Kits/DDKit/.gitkeep b/Public/Kits/DDKit/.gitkeep new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/Public/Kits/DDKit/.gitkeep diff --git a/Public/DDK/README.TXT b/Public/Kits/DDKit/README.TXT index fec20a60..fec20a60 100644 --- a/Public/DDK/README.TXT +++ b/Public/Kits/DDKit/README.TXT |
