summaryrefslogtreecommitdiffhomepage
path: root/src/kernel/KernelKit/DeviceMgr.h
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@nekernel.org>2025-12-22 07:38:52 +0100
committerAmlal El Mahrouss <amlal@nekernel.org>2025-12-22 07:42:26 +0100
commit36dee4f0d8ea806b2f061ed66a89e812ab007ed2 (patch)
tree8fe0f6895abb96eb40ee390d6411099b4decf489 /src/kernel/KernelKit/DeviceMgr.h
parentf7023f6a08e117d483b5928fd4301062a3384abf (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/DeviceMgr.h')
-rw-r--r--src/kernel/KernelKit/DeviceMgr.h30
1 files changed, 17 insertions, 13 deletions
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};
};
///