diff options
| author | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-08-18 21:39:29 +0200 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-08-18 21:39:29 +0200 |
| commit | da70596895d8135e08f8caac6978117697b4c021 (patch) | |
| tree | 2516785b5434df8453687f05dc8dd877438901ab /dev/Kernel/KernelKit/DeviceManager.hxx | |
| parent | 005de79004c9d30e64bdee6e14e06f9d47d1f2ab (diff) | |
[REFACTOR]
Improved project structure.
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'dev/Kernel/KernelKit/DeviceManager.hxx')
| -rw-r--r-- | dev/Kernel/KernelKit/DeviceManager.hxx | 129 |
1 files changed, 0 insertions, 129 deletions
diff --git a/dev/Kernel/KernelKit/DeviceManager.hxx b/dev/Kernel/KernelKit/DeviceManager.hxx deleted file mode 100644 index d9497da8..00000000 --- a/dev/Kernel/KernelKit/DeviceManager.hxx +++ /dev/null @@ -1,129 +0,0 @@ -/* ------------------------------------------- - - Copyright ZKA Technologies. - -------------------------------------------- */ - -/* ------------------------------------------- - - Revision History: - - 31/01/24: Add kDeviceCnt (amlel) - - ------------------------------------------- */ - -#pragma once - -/* Kernel device interface manager. */ -/* @file KernelKit/DeviceManager.hpp */ -/* @brief Device abstraction and I/O buffer. */ - -#include <NewKit/ErrorOr.hxx> -#include <NewKit/Ref.hxx> - -// Last Rev -// Wed, Apr 3, 2024 9:09:41 AM - -namespace Kernel -{ - template <typename T> - class DeviceInterface; - - template <typename T> - class DeviceInterface - { - public: - explicit DeviceInterface(void (*Out)(T), void (*In)(T)) - : fOut(Out), fIn(In) - { - } - - virtual ~DeviceInterface() = default; - - public: - DeviceInterface& operator=(const DeviceInterface<T>&) = default; - DeviceInterface(const DeviceInterface<T>&) = default; - - public: - virtual DeviceInterface<T>& operator<<(T Data) - { - fOut(Data); - return *this; - } - - virtual DeviceInterface<T>& operator>>(T Data) - { - fIn(Data); - return *this; - } - - virtual const char* Name() const - { - return "DeviceInterface"; - } - - operator bool() - { - return fOut && fIn; - } - bool operator!() - { - return !fOut || !fIn; - } - - private: - void (*fOut)(T Data) = {nullptr}; - void (*fIn)(T Data) = {nullptr}; - }; - - /// - /// @brief Input Output Buffer - /// Used mainly to communicate between hardware. - /// - template <typename T> - class IOBuf final - { - public: - explicit IOBuf(T Dat) - : fData(Dat) - { - // at least pass something valid when instancating this struct. - MUST_PASS(Dat); - } - - IOBuf& operator=(const IOBuf<T>&) = default; - IOBuf(const IOBuf<T>&) = default; - - ~IOBuf() = default; - - public: - template <typename R> - R operator->() const - { - return fData; - } - - template <typename R> - R& operator[](Size index) const - { - return fData[index]; - } - - private: - T fData; - }; - - ///! @brief Device enum types. - enum - { - kDeviceTypeIDE, - kDeviceTypeEthernet, - kDeviceTypeWiFi, - kDeviceTypeRS232, - kDeviceTypeSCSI, - kDeviceTypeSHCI, - kDeviceTypeUSB, - kDeviceTypeMedia, - kDeviceTypeCount, - }; -} // namespace Kernel |
