diff options
| author | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-01-31 13:59:56 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-01-31 14:01:08 +0100 |
| commit | c660c54ef256688553e3face26a8f6b5fe8553a7 (patch) | |
| tree | 4900030c965dfe254a24cd1eeb9a3b155b2fd8f1 | |
| parent | f7edf08d067b4c52c3183e8ad0467293e54075e8 (diff) | |
Kernel: Add documentation and found codename for it.
Next: BFileReader class to load PE file.
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
| -rw-r--r-- | Private/KernelKit/Device.hpp | 155 | ||||
| -rw-r--r-- | Private/KernelKit/FileManager.hpp | 17 | ||||
| -rw-r--r-- | ReadMe.md | 2 |
3 files changed, 94 insertions, 80 deletions
diff --git a/Private/KernelKit/Device.hpp b/Private/KernelKit/Device.hpp index e172880b..13022896 100644 --- a/Private/KernelKit/Device.hpp +++ b/Private/KernelKit/Device.hpp @@ -7,88 +7,89 @@ * ======================================================== */ +/* ------------------------------------------- + + Revision History: + + 31/01/24: Add kDeviceCnt (amlel) + + ------------------------------------------- */ + #pragma once /* HCore */ /* File: KernelKit/Device.hpp */ -/* Device abstraction utilities. */ +/* Device abstraction and I/O buffer. */ #include <NewKit/ErrorOr.hpp> #include <NewKit/Ref.hpp> -namespace HCore -{ - template<typename T> - class DeviceInterface; - - template<typename T> - class DeviceInterface - { - public: - explicit DeviceInterface(void (*Out)(T), void (*In)(T)) - : m_Out(Out), m_In(In) {} - - virtual ~DeviceInterface() = default; - - public: - DeviceInterface &operator=(const DeviceInterface<T> &) = default; - DeviceInterface(const DeviceInterface<T> &) = default; - - public: - DeviceInterface<T>& operator<<(T Data) - { - m_Out(Data); - return *this; - } - - DeviceInterface<T>& operator>>(T Data) - { - m_In(Data); - return *this; - } - - virtual const char* Name() const { return "DeviceInterface"; } - - operator bool() { return m_Out && m_In; } - bool operator!() { return !m_Out && !m_In; } - - private: - void (*m_Out)(T Data); - void (*m_In)(T Data); - - }; - - template<typename T> - class IOBuf final - { - public: - explicit IOBuf(T Dat) : m_Data(Dat) {} - - IOBuf &operator=(const IOBuf<T> &) = default; - IOBuf(const IOBuf<T> &) = default; - - ~IOBuf() = default; - - public: - T operator->() const { return m_Data; } - T &operator[](Size index) const { return m_Data[index]; } - - private: - T m_Data; - - }; - - ///! device types. - enum - { - kDeviceIde, - kDeviceNetwork, - kDevicePrinter, - kDeviceGSDB, - kDeviceScsi, - kDeviceSata, - kDeviceUsb, - kDeviceCD, - kDeviceSwap, - }; -} // namespace HCore +namespace HCore { +template <typename T> +class DeviceInterface; + +template <typename T> +class DeviceInterface { + public: + explicit DeviceInterface(void (*Out)(T), void (*In)(T)) + : m_Out(Out), m_In(In) {} + + virtual ~DeviceInterface() = default; + + public: + DeviceInterface &operator=(const DeviceInterface<T> &) = default; + DeviceInterface(const DeviceInterface<T> &) = default; + + public: + DeviceInterface<T> &operator<<(T Data) { + m_Out(Data); + return *this; + } + + DeviceInterface<T> &operator>>(T Data) { + m_In(Data); + return *this; + } + + virtual const char *Name() const { return "DeviceInterface"; } + + operator bool() { return m_Out && m_In; } + bool operator!() { return !m_Out && !m_In; } + + private: + void (*m_Out)(T Data); + void (*m_In)(T Data); +}; + +template <typename T> +class IOBuf final { + public: + explicit IOBuf(T Dat) : m_Data(Dat) {} + + IOBuf &operator=(const IOBuf<T> &) = default; + IOBuf(const IOBuf<T> &) = default; + + ~IOBuf() = default; + + public: + T operator->() const { return m_Data; } + T &operator[](Size index) const { return m_Data[index]; } + + private: + T m_Data; +}; + +///! @brief Device types enum. +enum { + kDeviceIde, + kDeviceNetwork, + kDevicePrinter, + kDeviceGSDB, + kDeviceScsi, + kDeviceSata, + kDeviceUsb, + kDeviceCD, + kDeviceSwap, + kDeviceCnt, +}; +} // namespace HCore diff --git a/Private/KernelKit/FileManager.hpp b/Private/KernelKit/FileManager.hpp index 1d7c33b2..75f64373 100644 --- a/Private/KernelKit/FileManager.hpp +++ b/Private/KernelKit/FileManager.hpp @@ -7,6 +7,14 @@ * ======================================================== */ +/* ------------------------------------------- + + Revision History: + + 31/01/24: Update documentation (amlel) + + ------------------------------------------- */ + #pragma once #include <FSKit/NewFS.hxx> @@ -35,6 +43,10 @@ enum { typedef VoidPtr NodePtr; +/** + @brief Filesystem Manager Interface class + @brief Used to provide common I/O for a specific filesystem. +*/ class IFilesystemManager { public: IFilesystemManager() = default; @@ -71,10 +83,11 @@ class IFilesystemManager { virtual bool Rewind(NodePtr node) = 0; }; -#define kNPos (SizeT)0xFFFFFF; +/** @brief invalid position. (n-pos) */ +#define kNPos (SizeT)(-1); /** - * @brief Child of IFilesystemManager, takes care of managing NewFS disks. + * @brief Based of IFilesystemManager, takes care of managing NewFS disks. */ class NewFilesystemManager final : public IFilesystemManager { public: @@ -1,4 +1,4 @@ -# h-core +# h-core (codename: SuperTrouper) ## Microkernel and it's components source code. |
