From 4a9b18d4fc40aae00dc8c658ecf28bee73c4643a Mon Sep 17 00:00:00 2001 From: Amlal Date: Wed, 2 Oct 2024 09:07:16 +0200 Subject: IMP: Updated Kernel with refactors and fixes. - Fix HalPagingMgr.cxx, use a ZKA_PDE* struct before accessing PTE. - Refactor Kernel files and refactor ATA driver. Signed-off-by: Amlal --- dev/zka/KernelKit/PCI/DMA.hxx | 81 +++++++++++++++++++++++++++++++++++++++++++ dev/zka/KernelKit/PCI/DMA.inl | 20 +++++++++++ dev/zka/KernelKit/PCI/Dma.hxx | 81 ------------------------------------------- dev/zka/KernelKit/PCI/Dma.inl | 20 ----------- 4 files changed, 101 insertions(+), 101 deletions(-) create mode 100644 dev/zka/KernelKit/PCI/DMA.hxx create mode 100644 dev/zka/KernelKit/PCI/DMA.inl delete mode 100644 dev/zka/KernelKit/PCI/Dma.hxx delete mode 100644 dev/zka/KernelKit/PCI/Dma.inl (limited to 'dev/zka/KernelKit') diff --git a/dev/zka/KernelKit/PCI/DMA.hxx b/dev/zka/KernelKit/PCI/DMA.hxx new file mode 100644 index 00000000..6aa06d1e --- /dev/null +++ b/dev/zka/KernelKit/PCI/DMA.hxx @@ -0,0 +1,81 @@ +/* ------------------------------------------- + + Copyright ZKA Technologies. + +------------------------------------------- */ + +#pragma once + +#include +#include +#include +#include +#include + +namespace Kernel +{ + 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; + + public: + explicit DMAWrapper(nullPtr) = delete; + explicit DMAWrapper(voidPtr Ptr, DmaKind Kind = DmaKind::PCI) + : fAddress(Ptr), fKind(Kind) + { + } + + public: + DMAWrapper& operator=(voidPtr Ptr); + + public: + DMAWrapper& operator=(const DMAWrapper&) = default; + DMAWrapper(const DMAWrapper&) = default; + + public: + ~DMAWrapper() = default; + + template + T* operator->(); + + template + T* Get(const UIntPtr off = 0); + + 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: + UIntPtr operator[](const UIntPtr& offset); + + private: + voidPtr fAddress{nullptr}; + DmaKind fKind{DmaKind::Invalid}; + + private: + friend class DMAFactory; + }; + + class DMAFactory final + { + public: + static OwnPtr> Construct(OwnPtr& dma); + }; +} // namespace Kernel + +#include diff --git a/dev/zka/KernelKit/PCI/DMA.inl b/dev/zka/KernelKit/PCI/DMA.inl new file mode 100644 index 00000000..1c164af8 --- /dev/null +++ b/dev/zka/KernelKit/PCI/DMA.inl @@ -0,0 +1,20 @@ +/* ------------------------------------------- + + Copyright ZKA Technologies. + +------------------------------------------- */ + +namespace Kernel +{ + template + T* DMAWrapper::operator->() + { + return fAddress; + } + + template + T* DMAWrapper::Get(const UIntPtr offset) + { + return reinterpret_cast((UIntPtr)fAddress + offset); + } +} // namespace Kernel diff --git a/dev/zka/KernelKit/PCI/Dma.hxx b/dev/zka/KernelKit/PCI/Dma.hxx deleted file mode 100644 index b265f738..00000000 --- a/dev/zka/KernelKit/PCI/Dma.hxx +++ /dev/null @@ -1,81 +0,0 @@ -/* ------------------------------------------- - - Copyright ZKA Technologies. - -------------------------------------------- */ - -#pragma once - -#include -#include -#include -#include -#include - -namespace Kernel -{ - 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; - - public: - explicit DMAWrapper(nullPtr) = delete; - explicit DMAWrapper(voidPtr Ptr, DmaKind Kind = DmaKind::PCI) - : fAddress(Ptr), fKind(Kind) - { - } - - public: - DMAWrapper& operator=(voidPtr Ptr); - - public: - DMAWrapper& operator=(const DMAWrapper&) = default; - DMAWrapper(const DMAWrapper&) = default; - - public: - ~DMAWrapper() = default; - - template - T* operator->(); - - template - T* Get(const UIntPtr off = 0); - - 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: - UIntPtr operator[](const UIntPtr& offset); - - private: - voidPtr fAddress{nullptr}; - DmaKind fKind{DmaKind::Invalid}; - - private: - friend class DMAFactory; - }; - - class DMAFactory final - { - public: - static OwnPtr> Construct(OwnPtr& dma); - }; -} // namespace Kernel - -#include diff --git a/dev/zka/KernelKit/PCI/Dma.inl b/dev/zka/KernelKit/PCI/Dma.inl deleted file mode 100644 index 1c164af8..00000000 --- a/dev/zka/KernelKit/PCI/Dma.inl +++ /dev/null @@ -1,20 +0,0 @@ -/* ------------------------------------------- - - Copyright ZKA Technologies. - -------------------------------------------- */ - -namespace Kernel -{ - template - T* DMAWrapper::operator->() - { - return fAddress; - } - - template - T* DMAWrapper::Get(const UIntPtr offset) - { - return reinterpret_cast((UIntPtr)fAddress + offset); - } -} // namespace Kernel -- cgit v1.2.3