diff options
| author | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-11-21 08:50:57 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-11-21 08:51:40 +0100 |
| commit | 6ed8a39c1bd3083297b41e981a2bf4bdbe2abd1f (patch) | |
| tree | 183713eb331a92e4e1ce061263cf91a208c7c400 /dev/ZKAKit/KernelKit | |
| parent | 50439432a85976605dbb18e3cd2161f888d2e17d (diff) | |
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 <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'dev/ZKAKit/KernelKit')
| -rw-r--r-- | dev/ZKAKit/KernelKit/DebugOutput.h | 2 | ||||
| -rw-r--r-- | dev/ZKAKit/KernelKit/DeviceMgr.h | 20 | ||||
| -rw-r--r-- | dev/ZKAKit/KernelKit/UserProcessScheduler.h | 37 |
3 files changed, 36 insertions, 23 deletions
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<const Char*>(print, get) + : IDeviceObject<const Char*>(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 <typename T> - class DeviceInterface; + class IDeviceObject; /***********************************************************************************/ /// @brief Device contract interface, represents an HW device. /***********************************************************************************/ template <typename T> - 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<T>&) = default; - DeviceInterface(const DeviceInterface<T>&) = default; + IDeviceObject& operator=(const IDeviceObject<T>&) = default; + IDeviceObject(const IDeviceObject<T>&) = default; public: - virtual DeviceInterface<T>& operator<<(T Data) + virtual IDeviceObject<T>& operator<<(T Data) { fOut(Data); return *this; } - virtual DeviceInterface<T>& operator>>(T Data) + virtual IDeviceObject<T>& 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<PID> TheCurrentPID(); STATIC SizeT StartScheduling(); - STATIC Void InitScheduler(); }; const UInt32& sched_get_exit_code(void) noexcept; |
