From b75417b44d5f63ea0ead68cbe8f62bd76df62229 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Tue, 13 Feb 2024 17:20:30 +0100 Subject: HCR-15: Merge to master branch. Important commit and end of ticket. Signed-off-by: Amlal El Mahrouss --- Private/KernelKit/DebugOutput.hpp | 2 +- Private/KernelKit/Device.hpp | 93 ------------------------------------- Private/KernelKit/DeviceManager.hpp | 93 +++++++++++++++++++++++++++++++++++++ Private/KernelKit/DriveManager.hpp | 2 +- Private/KernelKit/PCI/Dma.hpp | 91 ++++++++++++++++++------------------ 5 files changed, 139 insertions(+), 142 deletions(-) delete mode 100644 Private/KernelKit/Device.hpp create mode 100644 Private/KernelKit/DeviceManager.hpp (limited to 'Private/KernelKit') diff --git a/Private/KernelKit/DebugOutput.hpp b/Private/KernelKit/DebugOutput.hpp index dd34df8e..6e651924 100644 --- a/Private/KernelKit/DebugOutput.hpp +++ b/Private/KernelKit/DebugOutput.hpp @@ -9,7 +9,7 @@ #pragma once -#include +#include #include #include diff --git a/Private/KernelKit/Device.hpp b/Private/KernelKit/Device.hpp deleted file mode 100644 index 9a689b26..00000000 --- a/Private/KernelKit/Device.hpp +++ /dev/null @@ -1,93 +0,0 @@ -/* - * ======================================================== - * - * HCore - * Copyright Mahrouss Logic, all rights reserved. - * - * ======================================================== - */ - -/* ------------------------------------------- - - Revision History: - - 31/01/24: Add kDeviceCnt (amlel) - - ------------------------------------------- */ - -#pragma once - -/* HCore */ -/* File: KernelKit/Device.hpp */ -/* Device abstraction and I/O buffer. */ - -#include -#include - -namespace HCore { -template -class DeviceInterface; - -template -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 &) = default; - DeviceInterface(const DeviceInterface &) = default; - - public: - DeviceInterface &operator<<(T Data) { - m_Out(Data); - return *this; - } - - DeviceInterface &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 -class IOBuf final { - public: - explicit IOBuf(T Dat) : m_Data(Dat) {} - - IOBuf &operator=(const IOBuf &) = default; - IOBuf(const IOBuf &) = 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 { - kDeviceTypeIDE, - kDeviceTypeEthernet, - kDeviceTypeWiFi, - kDeviceTypeRS232, - kDeviceTypeSCSI, - kDeviceTypeSHCI, - kDeviceTypeUSB, - kDeviceTypeCount, -}; -} // namespace HCore diff --git a/Private/KernelKit/DeviceManager.hpp b/Private/KernelKit/DeviceManager.hpp new file mode 100644 index 00000000..9a689b26 --- /dev/null +++ b/Private/KernelKit/DeviceManager.hpp @@ -0,0 +1,93 @@ +/* + * ======================================================== + * + * HCore + * Copyright Mahrouss Logic, all rights reserved. + * + * ======================================================== + */ + +/* ------------------------------------------- + + Revision History: + + 31/01/24: Add kDeviceCnt (amlel) + + ------------------------------------------- */ + +#pragma once + +/* HCore */ +/* File: KernelKit/Device.hpp */ +/* Device abstraction and I/O buffer. */ + +#include +#include + +namespace HCore { +template +class DeviceInterface; + +template +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 &) = default; + DeviceInterface(const DeviceInterface &) = default; + + public: + DeviceInterface &operator<<(T Data) { + m_Out(Data); + return *this; + } + + DeviceInterface &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 +class IOBuf final { + public: + explicit IOBuf(T Dat) : m_Data(Dat) {} + + IOBuf &operator=(const IOBuf &) = default; + IOBuf(const IOBuf &) = 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 { + kDeviceTypeIDE, + kDeviceTypeEthernet, + kDeviceTypeWiFi, + kDeviceTypeRS232, + kDeviceTypeSCSI, + kDeviceTypeSHCI, + kDeviceTypeUSB, + kDeviceTypeCount, +}; +} // namespace HCore diff --git a/Private/KernelKit/DriveManager.hpp b/Private/KernelKit/DriveManager.hpp index ac39c177..8e6aaefd 100644 --- a/Private/KernelKit/DriveManager.hpp +++ b/Private/KernelKit/DriveManager.hpp @@ -11,7 +11,7 @@ #define __DRIVE_MANAGER__ #include -#include +#include #include #include diff --git a/Private/KernelKit/PCI/Dma.hpp b/Private/KernelKit/PCI/Dma.hpp index 8e027179..0b4b55b8 100644 --- a/Private/KernelKit/PCI/Dma.hpp +++ b/Private/KernelKit/PCI/Dma.hpp @@ -9,73 +9,70 @@ #pragma once -#include +#include #include #include #include #include -namespace HCore -{ -enum class DmaKind -{ - PCI, // Bus mastering is required to be turned on. Basiaclly a request - // control system. 64-Bit access depends on the PAE bit and the device - // (if Double Address Cycle is available) - ISA, // Four DMA channels 0-3; 8 bit transfers and only a megabyte of RAM. - Invalid, +namespace HCore { +enum class DmaKind { + PCI, // Bus mastering is required to be turned on. Basiaclly a request + // control system. 64-Bit access depends on the PAE bit and the device + // (if Double Address Cycle is available) + ISA, // Four DMA channels 0-3; 8 bit transfers and only a megabyte of RAM. + Invalid, }; -class DMAWrapper final -{ - public: - explicit DMAWrapper() = delete; +class DMAWrapper final { + public: + explicit DMAWrapper() = delete; - public: - explicit DMAWrapper(nullPtr) = delete; - explicit DMAWrapper(voidPtr Ptr, DmaKind Kind = DmaKind::PCI) : m_Address(Ptr), m_Kind(Kind) - { - } + public: + explicit DMAWrapper(nullPtr) = delete; + explicit DMAWrapper(voidPtr Ptr, DmaKind Kind = DmaKind::PCI) + : m_Address(Ptr), m_Kind(Kind) {} - public: - DMAWrapper &operator=(voidPtr Ptr); + public: + DMAWrapper &operator=(voidPtr Ptr); - public: - DMAWrapper &operator=(const DMAWrapper &) = default; - DMAWrapper(const DMAWrapper &) = default; + public: + DMAWrapper &operator=(const DMAWrapper &) = default; + DMAWrapper(const DMAWrapper &) = default; - public: - ~DMAWrapper() = default; + public: + ~DMAWrapper() = default; - template T *operator->(); + template + T *operator->(); - template T *Get(const UIntPtr off = 0); + template + T *Get(const UIntPtr off = 0); - public: - operator bool(); - bool operator!(); + public: + operator bool(); + bool operator!(); - public: - bool Write(const UIntPtr &bit, const UIntPtr &offset); - UIntPtr Read(const UIntPtr &offset); - Boolean Check(UIntPtr offset) const; + public: + bool Write(const UIntPtr &bit, const UIntPtr &offset); + UIntPtr Read(const UIntPtr &offset); + Boolean Check(UIntPtr offset) const; - public: - UIntPtr operator[](const UIntPtr &offset); + public: + UIntPtr operator[](const UIntPtr &offset); - private: - voidPtr m_Address{nullptr}; - DmaKind m_Kind{DmaKind::Invalid}; + private: + voidPtr m_Address{nullptr}; + DmaKind m_Kind{DmaKind::Invalid}; - private: - friend class DMAFactory; + private: + friend class DMAFactory; }; -class DMAFactory final -{ - public: - static OwnPtr> Construct(OwnPtr &dma); +class DMAFactory final { + public: + static OwnPtr> Construct(OwnPtr &dma); }; -} // namespace HCore +} // namespace HCore #include -- cgit v1.2.3