From 6ed8a39c1bd3083297b41e981a2bf4bdbe2abd1f Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Thu, 21 Nov 2024 08:50:57 +0100 Subject: IMP: Add UserProcessImage structure to hold the code/entrypoint of the process. IMP: Use IDLLObject instead of IPEFDLLObject. IMP: Refactor DeviceInterface to IDeviceObject. ADD: rt_jump_to_address when you want to use a custom stack. Signed-off-by: Amlal El Mahrouss --- dev/ZKAKit/KernelKit/DebugOutput.h | 2 +- dev/ZKAKit/KernelKit/DeviceMgr.h | 20 ++++++++-------- dev/ZKAKit/KernelKit/UserProcessScheduler.h | 37 +++++++++++++++++++---------- 3 files changed, 36 insertions(+), 23 deletions(-) (limited to 'dev/ZKAKit/KernelKit') diff --git a/dev/ZKAKit/KernelKit/DebugOutput.h b/dev/ZKAKit/KernelKit/DebugOutput.h index b268d874..da37d3a0 100644 --- a/dev/ZKAKit/KernelKit/DebugOutput.h +++ b/dev/ZKAKit/KernelKit/DebugOutput.h @@ -39,7 +39,7 @@ namespace Kernel { public: TerminalDevice(void (*print)(const Char*), void (*get)(const Char*)) - : DeviceInterface(print, get) + : IDeviceObject(print, get) { } diff --git a/dev/ZKAKit/KernelKit/DeviceMgr.h b/dev/ZKAKit/KernelKit/DeviceMgr.h index cbdfb542..a7b7a2d0 100644 --- a/dev/ZKAKit/KernelKit/DeviceMgr.h +++ b/dev/ZKAKit/KernelKit/DeviceMgr.h @@ -24,39 +24,39 @@ #define kDeviceMgrRootDirPath "/Devices/" -#define ZKA_DEVICE : public ::Kernel::DeviceInterface +#define ZKA_DEVICE : public ::Kernel::IDeviceObject // Last Rev: Wed, Apr 3, 2024 9:09:41 AM namespace Kernel { template - class DeviceInterface; + class IDeviceObject; /***********************************************************************************/ /// @brief Device contract interface, represents an HW device. /***********************************************************************************/ template - class DeviceInterface + class IDeviceObject { public: - explicit DeviceInterface(void (*Out)(T), void (*In)(T)) + explicit IDeviceObject(void (*Out)(T), void (*In)(T)) : fOut(Out), fIn(In) {} - virtual ~DeviceInterface() = default; + virtual ~IDeviceObject() = default; public: - DeviceInterface& operator=(const DeviceInterface&) = default; - DeviceInterface(const DeviceInterface&) = default; + IDeviceObject& operator=(const IDeviceObject&) = default; + IDeviceObject(const IDeviceObject&) = default; public: - virtual DeviceInterface& operator<<(T Data) + virtual IDeviceObject& operator<<(T Data) { fOut(Data); return *this; } - virtual DeviceInterface& operator>>(T Data) + virtual IDeviceObject& operator>>(T Data) { fIn(Data); return *this; @@ -64,7 +64,7 @@ namespace Kernel virtual const char* Name() const { - return "DeviceInterface"; + return "IDeviceObject"; } operator bool() diff --git a/dev/ZKAKit/KernelKit/UserProcessScheduler.h b/dev/ZKAKit/KernelKit/UserProcessScheduler.h index 1c9f4a94..808a8457 100644 --- a/dev/ZKAKit/KernelKit/UserProcessScheduler.h +++ b/dev/ZKAKit/KernelKit/UserProcessScheduler.h @@ -27,10 +27,10 @@ namespace Kernel { - //! @note Forward declarations. + //! @note Forward class declarations. class UserProcess; - class IPEFDLLObject; + class IDLLObject; class UserProcessTeam; class UserProcessScheduler; class UserProcessHelper; @@ -39,7 +39,8 @@ namespace Kernel typedef Int64 ProcessID; //! @brief Local Process name length. - inline constexpr SizeT kProcessNameLen = 129U; + inline constexpr SizeT kProcessNameLen = 128U; + inline constexpr ProcessID kProcessInvalidID = -1; //! @brief Local Process status enum. enum class ProcessStatusKind : Int32 @@ -123,18 +124,32 @@ namespace Kernel kRingCount = 5, }; - // Helper types. + /// @brief Helper type to describe a code image. using ImagePtr = VoidPtr; + struct UserProcessImage + { + ImagePtr fCode; + ImagePtr fBlob; + + operator bool() + { + return this->fCode; + } + + Bool HasImage() + { + return this->fBlob != nullptr; + } + }; + /// @name UserProcess - /// @brief User process header. + /// @brief User process class. /// Holds information about the running process/thread. class UserProcess final { public: - explicit UserProcess(VoidPtr start_image); - explicit UserProcess() = default; - + explicit UserProcess(); ~UserProcess(); public: @@ -148,10 +163,9 @@ namespace Kernel AffinityKind Affinity{AffinityKind::kStandard}; ProcessStatusKind Status{ProcessStatusKind::kDead}; UInt8* StackReserve{nullptr}; - ImagePtr Code{nullptr}; - ImagePtr ExecImg{nullptr}; + UserProcessImage Image; SizeT StackSize{kSchedMaxStackSz}; - IPEFDLLObject* PefDLLDelegate{nullptr}; + IDLLObject* PefDLLDelegate{nullptr}; SizeT MemoryCursor{0}; SizeT MemoryLimit{kSchedMaxMemoryLimit}; @@ -306,7 +320,6 @@ namespace Kernel STATIC Bool CanBeScheduled(const UserProcess& process); STATIC ErrorOr TheCurrentPID(); STATIC SizeT StartScheduling(); - STATIC Void InitScheduler(); }; const UInt32& sched_get_exit_code(void) noexcept; -- cgit v1.2.3