summaryrefslogtreecommitdiffhomepage
path: root/Private/KernelKit/DeviceManager.hpp
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-05-05 21:10:18 +0200
committerAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-05-05 21:10:18 +0200
commitf95d8bf159d10b5a9521dcaa0bc37aa0e9dfc02b (patch)
treebf8186f1a0521a64983bb0bca4f7b54883542195 /Private/KernelKit/DeviceManager.hpp
parent5a903c1d8f80ca8d7bc5fbea0aea710ce0133f9d (diff)
MHR-23: Add run_format.sh, kernel patches.
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'Private/KernelKit/DeviceManager.hpp')
-rw-r--r--Private/KernelKit/DeviceManager.hpp185
1 files changed, 103 insertions, 82 deletions
diff --git a/Private/KernelKit/DeviceManager.hpp b/Private/KernelKit/DeviceManager.hpp
index 490ebc71..e9baa194 100644
--- a/Private/KernelKit/DeviceManager.hpp
+++ b/Private/KernelKit/DeviceManager.hpp
@@ -26,85 +26,106 @@
// Last Rev
// Wed, Apr 3, 2024 9:09:41 AM
-namespace NewOS {
-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);
- void (*fIn)(T Data);
-};
-
-///
-/// @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 NewOS
+namespace NewOS
+{
+ 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);
+ void (*fIn)(T Data);
+ };
+
+ ///
+ /// @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 NewOS