diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2025-12-22 07:38:52 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal@nekernel.org> | 2025-12-22 07:42:26 +0100 |
| commit | 36dee4f0d8ea806b2f061ed66a89e812ab007ed2 (patch) | |
| tree | 8fe0f6895abb96eb40ee390d6411099b4decf489 /src/kernel/KernelKit | |
| parent | f7023f6a08e117d483b5928fd4301062a3384abf (diff) | |
feat: test: Add `kout` test and rename DeviceInterface to IDevice in KernelKit.
introduce UserPtr and unburden vettable by removing the IVettable helper.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'src/kernel/KernelKit')
| -rw-r--r-- | src/kernel/KernelKit/DebugOutput.h | 11 | ||||
| -rw-r--r-- | src/kernel/KernelKit/DeviceMgr.h | 30 | ||||
| -rw-r--r-- | src/kernel/KernelKit/PE32CodeMgr.h | 11 | ||||
| -rw-r--r-- | src/kernel/KernelKit/PEFCodeMgr.h | 2 | ||||
| -rw-r--r-- | src/kernel/KernelKit/TraceSrv.h | 6 | ||||
| -rw-r--r-- | src/kernel/KernelKit/UserMgr.h | 8 | ||||
| -rw-r--r-- | src/kernel/KernelKit/UserProcessScheduler.h | 15 |
7 files changed, 48 insertions, 35 deletions
diff --git a/src/kernel/KernelKit/DebugOutput.h b/src/kernel/KernelKit/DebugOutput.h index 301a3a9e..0818a712 100644 --- a/src/kernel/KernelKit/DebugOutput.h +++ b/src/kernel/KernelKit/DebugOutput.h @@ -25,9 +25,8 @@ inline TerminalDevice hex_number(const Long& x); // @brief Emulates a VT100 terminal. class TerminalDevice final NE_DEVICE<const Char*> { public: - TerminalDevice(void (*print)(DeviceInterface*, const Char*), - void (*gets)(DeviceInterface*, const Char*)) - : DeviceInterface<const Char*>(print, gets) {} + TerminalDevice(void (*print)(IDevice*, const Char*), void (*gets)(IDevice*, const Char*)) + : IDevice<const Char*>(print, gets) {} ~TerminalDevice() override; @@ -42,9 +41,9 @@ class TerminalDevice final NE_DEVICE<const Char*> { class Utf8TerminalDevice final NE_DEVICE<const Utf8Char*> { public: - Utf8TerminalDevice(void (*print)(DeviceInterface*, const Utf8Char*), - void (*gets)(DeviceInterface*, const Utf8Char*)) - : DeviceInterface<const Utf8Char*>(print, gets) {} + Utf8TerminalDevice(void (*print)(IDevice*, const Utf8Char*), + void (*gets)(IDevice*, const Utf8Char*)) + : IDevice<const Utf8Char*>(print, gets) {} ~Utf8TerminalDevice() override; diff --git a/src/kernel/KernelKit/DeviceMgr.h b/src/kernel/KernelKit/DeviceMgr.h index 1dbad161..56208140 100644 --- a/src/kernel/KernelKit/DeviceMgr.h +++ b/src/kernel/KernelKit/DeviceMgr.h @@ -24,13 +24,13 @@ #define kDeviceMgrRootDirPath "/devices/" -#define NE_DEVICE : public ::Kernel::DeviceInterface +#define NE_DEVICE : public ::Kernel::IDevice // Last Rev: Wed, May 27, 2025 6:22 PM namespace Kernel { template <typename T> -class DeviceInterface; +class IDevice; template <typename T> class IOBuf; @@ -39,26 +39,30 @@ class IOBuf; /// @brief Device contract interface, represents an HW device. /***********************************************************************************/ template <typename T> -class DeviceInterface { +class IDevice { public: - DeviceInterface() = default; + IDevice() = default; - explicit DeviceInterface(void (*Out)(DeviceInterface<T>*, T), void (*In)(DeviceInterface<T>*, T)) - : fOut(Out), fIn(In) {} + explicit IDevice(void (*Out)(IDevice<T>*, T), void (*In)(IDevice<T>*, T)) : fOut(Out), fIn(In) {} - virtual ~DeviceInterface() = default; + virtual ~IDevice() = default; public: - DeviceInterface& operator=(const DeviceInterface<T>&) = default; - DeviceInterface(const DeviceInterface<T>&) = default; + using Type = T; + using TypeRef = T&; + using ConstType = const T&; + using TypePtr = T*; + + IDevice& operator=(const IDevice<T>&) = default; + IDevice(const IDevice<T>&) = default; public: - virtual DeviceInterface<T>& operator<<(T Data) { + virtual IDevice<T>& operator<<(T Data) { fOut(this, Data); return *this; } - virtual DeviceInterface<T>& operator>>(T Data) { + virtual IDevice<T>& operator>>(T Data) { fIn(this, Data); return *this; } @@ -70,8 +74,8 @@ class DeviceInterface { Bool operator!() { return !fOut || !fIn; } protected: - Void (*fOut)(DeviceInterface<T>*, T Data) = {nullptr}; - Void (*fIn)(DeviceInterface<T>*, T Data) = {nullptr}; + Void (*fOut)(IDevice<T>*, T Data) = {nullptr}; + Void (*fIn)(IDevice<T>*, T Data) = {nullptr}; }; /// diff --git a/src/kernel/KernelKit/PE32CodeMgr.h b/src/kernel/KernelKit/PE32CodeMgr.h index 03a68363..c62cd518 100644 --- a/src/kernel/KernelKit/PE32CodeMgr.h +++ b/src/kernel/KernelKit/PE32CodeMgr.h @@ -66,7 +66,7 @@ class PE32Loader : public ILoader { ErrorOr<VoidPtr> GetBlob() override; public: - bool IsLoaded(); + BOOL IsLoaded(); private: #ifdef __FSKIT_INCLUDES_NEFS__ @@ -78,14 +78,15 @@ class PE32Loader : public ILoader { #endif // __FSKIT_INCLUDES_NEFS__ Ref<KString> fPath; - VoidPtr fCachedBlob; - BOOL fBad; + RefAny fCachedBlob{}; + BOOL fBad{}; }; enum { kPEPlatformInvalid, kPEPlatformAMD64 = 100, kPEPlatformARM64 }; enum { kPETypeInvalid, kPETypeText = 100, kPETypeData, kPETypeBSS }; -typedef LDR_SECTION_HEADER PE_SECTION_INFO; +using PE_SECTION_INFO = LDR_SECTION_HEADER; -ProcessID rtl_create_user_process(PE32Loader& exec, const Int32& process_kind); +ProcessID rtl_create_user_process(PE32Loader& exec, + const UserProcess::ExecutableKind& process_kind); } // namespace Kernel
\ No newline at end of file diff --git a/src/kernel/KernelKit/PEFCodeMgr.h b/src/kernel/KernelKit/PEFCodeMgr.h index f7b6672a..db19eb0d 100644 --- a/src/kernel/KernelKit/PEFCodeMgr.h +++ b/src/kernel/KernelKit/PEFCodeMgr.h @@ -68,7 +68,7 @@ class PEFLoader : public ILoader { }; namespace Utils { - ProcessID rtl_create_user_process(PEFLoader& exec, const Int32& procKind); + ProcessID rtl_create_user_process(PEFLoader& exec, const UserProcess::ExecutableKind& procKind); } // namespace Utils } // namespace Kernel diff --git a/src/kernel/KernelKit/TraceSrv.h b/src/kernel/KernelKit/TraceSrv.h index 389357ec..2dced719 100644 --- a/src/kernel/KernelKit/TraceSrv.h +++ b/src/kernel/KernelKit/TraceSrv.h @@ -12,9 +12,9 @@ namespace Kernel { namespace Detail { - inline constexpr auto kDebugCmdLen = 256U; - inline constexpr auto kDebugPort = 51820; - /// \brief Debug Magic Value + inline constexpr auto kDebugCmdLen = 256U; + inline constexpr auto kDebugPort = 51820; + /// \brief Debug Magic Value inline constexpr auto kDebugMagic = "NE1.0.0;"; inline constexpr auto kDebugVersion = 0x0100; inline constexpr auto kDebugDelim = ';'; diff --git a/src/kernel/KernelKit/UserMgr.h b/src/kernel/KernelKit/UserMgr.h index 77356aae..8f14fe9d 100644 --- a/src/kernel/KernelKit/UserMgr.h +++ b/src/kernel/KernelKit/UserMgr.h @@ -88,8 +88,14 @@ class User final { UInt64 mUserFNV{0UL}; }; +/// \brief Alias for user ptr. +using UserPtr = User*; + +/// \brief Current running user. inline User* kCurrentUser = nullptr; -inline User* kRootUser = nullptr; + +/// \brief Super user. +inline User* kRootUser = nullptr; } // namespace Kernel #endif /* ifndef __KERNEL_KIT_USER_MGR_H__ */ diff --git a/src/kernel/KernelKit/UserProcessScheduler.h b/src/kernel/KernelKit/UserProcessScheduler.h index c8790352..9a679c87 100644 --- a/src/kernel/KernelKit/UserProcessScheduler.h +++ b/src/kernel/KernelKit/UserProcessScheduler.h @@ -32,7 +32,7 @@ class UserProcessHelper; /// @name UserProcess /// @brief UserProcess class, holds information about the running process/thread. /***********************************************************************************/ -class UserProcess NE_VETTABLE { +class UserProcess { public: UserProcess(); ~UserProcess(); @@ -55,20 +55,23 @@ class UserProcess NE_VETTABLE { SizeT MemoryLimit{kSchedMaxMemoryLimit}; SizeT UsedMemory{0UL}; - struct USER_PROCESS_SIGNAL final { + struct UserProcessSignal { UIntPtr SignalArg{0}; ProcessStatusKind Status{ProcessStatusKind::kKilled}; UIntPtr SignalID{0}; }; - USER_PROCESS_SIGNAL Signal; + UserProcessSignal Signal; ProcessFileTree<VoidPtr>* FileTree{nullptr}; ProcessHeapTree<VoidPtr>* HeapTree{nullptr}; UserProcessTeam* ParentTeam; + public: + using VMReg = VoidPtr; + VoidPtr VMRegister{0UL}; - enum { + enum struct ExecutableKind { kInvalidExecutableKind, kExecutableKind, kExecutableDylibKind, @@ -79,8 +82,8 @@ class UserProcess NE_VETTABLE { ProcessTime RTime{0}; //! @brief Process run time. ProcessTime UTime{0}; //! #brief Process used time. - ProcessID ProcessId{kSchedInvalidPID}; - Int32 Kind{kExecutableKind}; + ProcessID ProcessId{kSchedInvalidPID}; + ExecutableKind Kind{ExecutableKind::kExecutableKind}; public: /***********************************************************************************/ |
