From 09dd11ddf800898c00ecb04a65fb5cd10fb481fa Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Wed, 8 May 2024 12:32:41 +0200 Subject: MHR-23: :boom: changes, reworked project tree. Signed-off-by: Amlal El Mahrouss --- NewKernel/StorageKit/AHCI.hpp | 33 ++++++++++++++++++++++++++++++ NewKernel/StorageKit/ATA.hpp | 39 ++++++++++++++++++++++++++++++++++++ NewKernel/StorageKit/NVME.hpp | 43 ++++++++++++++++++++++++++++++++++++++++ NewKernel/StorageKit/PRDT.hpp | 36 +++++++++++++++++++++++++++++++++ NewKernel/StorageKit/SCSI.hxx | 11 ++++++++++ NewKernel/StorageKit/Storage.hpp | 16 +++++++++++++++ 6 files changed, 178 insertions(+) create mode 100644 NewKernel/StorageKit/AHCI.hpp create mode 100644 NewKernel/StorageKit/ATA.hpp create mode 100644 NewKernel/StorageKit/NVME.hpp create mode 100644 NewKernel/StorageKit/PRDT.hpp create mode 100644 NewKernel/StorageKit/SCSI.hxx create mode 100644 NewKernel/StorageKit/Storage.hpp (limited to 'NewKernel/StorageKit') diff --git a/NewKernel/StorageKit/AHCI.hpp b/NewKernel/StorageKit/AHCI.hpp new file mode 100644 index 00000000..a792691b --- /dev/null +++ b/NewKernel/StorageKit/AHCI.hpp @@ -0,0 +1,33 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + +------------------------------------------- */ + +#pragma once + +#include +#include +#include + +namespace NewOS +{ + class AHCIDeviceInterface : public DeviceInterface + { + public: + explicit AHCIDeviceInterface(void (*Out)(MountpointInterface* outpacket), + void (*In)(MountpointInterface* inpacket), + void (*Cleanup)(void)); + + virtual ~AHCIDeviceInterface(); + + public: + AHCIDeviceInterface& operator=(const AHCIDeviceInterface&) = default; + AHCIDeviceInterface(const AHCIDeviceInterface&) = default; + + const char* Name() const override; + + private: + void (*fCleanup)(void); + }; +} // namespace NewOS \ No newline at end of file diff --git a/NewKernel/StorageKit/ATA.hpp b/NewKernel/StorageKit/ATA.hpp new file mode 100644 index 00000000..98e9fbc6 --- /dev/null +++ b/NewKernel/StorageKit/ATA.hpp @@ -0,0 +1,39 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + +------------------------------------------- */ + +#pragma once + +#include +#include +#include +#include + +namespace NewOS +{ + /// @brief ATA device interface type. + class ATADeviceInterface : public DeviceInterface + { + public: + explicit ATADeviceInterface(void (*Out)(MountpointInterface* outpacket), + void (*In)(MountpointInterface* inpacket), + void (*Cleanup)(void)); + + virtual ~ATADeviceInterface(); + + public: + ATADeviceInterface& operator<<(MountpointInterface* Data) override; + ATADeviceInterface& operator>>(MountpointInterface* Data) override; + + public: + ATADeviceInterface& operator=(const ATADeviceInterface&) = default; + ATADeviceInterface(const ATADeviceInterface&) = default; + + const char* Name() const override; + + private: + void (*fCleanup)(void); + }; +} // namespace NewOS \ No newline at end of file diff --git a/NewKernel/StorageKit/NVME.hpp b/NewKernel/StorageKit/NVME.hpp new file mode 100644 index 00000000..7b570cf2 --- /dev/null +++ b/NewKernel/StorageKit/NVME.hpp @@ -0,0 +1,43 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + +------------------------------------------- */ + +#pragma once + +#include +#include +#include + +namespace NewOS +{ + class NVMEDeviceInterface : public DeviceInterface + { + public: + explicit NVMEDeviceInterface(void (*Out)(MountpointInterface* outpacket), + void (*In)(MountpointInterface* inpacket), + void (*Cleanup)(void)) + : DeviceInterface(Out, In), fCleanup(Cleanup) + { + } + + virtual ~NVMEDeviceInterface() + { + if (fCleanup) + fCleanup(); + } + + public: + NVMEDeviceInterface& operator=(const NVMEDeviceInterface&) = default; + NVMEDeviceInterface(const NVMEDeviceInterface&) = default; + + const char* Name() const override; + + public: + OwnPtr operator()(UInt32 dmaLow, UInt32 dmaHigh, SizeT sz); + + private: + void (*fCleanup)(void); + }; +} // namespace NewOS diff --git a/NewKernel/StorageKit/PRDT.hpp b/NewKernel/StorageKit/PRDT.hpp new file mode 100644 index 00000000..a1dcbc4c --- /dev/null +++ b/NewKernel/StorageKit/PRDT.hpp @@ -0,0 +1,36 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + +------------------------------------------- */ + +#pragma once + +#include +#include +#include + +#define kPrdtTransferSize (sizeof(NewOS::UShort)) + +namespace NewOS +{ + /// @brief Tranfer information about PRD. + enum kPRDTTransfer + { + kPRDTTransferInProgress, + kPRDTTransferIsDone, + kPRDTTransferCount, + }; + + /// @brief Physical Region Descriptor Table. + struct PRDT + { + UInt32 fPhysAddress; + UInt32 fSectorCount; + UInt8 fEndBit; + }; + + void construct_prdt(Ref& prd); + + EXTERN_C Int32 kPRDTTransferStatus; +} // namespace NewOS diff --git a/NewKernel/StorageKit/SCSI.hxx b/NewKernel/StorageKit/SCSI.hxx new file mode 100644 index 00000000..54d58cf0 --- /dev/null +++ b/NewKernel/StorageKit/SCSI.hxx @@ -0,0 +1,11 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + +------------------------------------------- */ + +#pragma once + +#include + +extern const scsi_packet_type kCDRomPacketTemplate; diff --git a/NewKernel/StorageKit/Storage.hpp b/NewKernel/StorageKit/Storage.hpp new file mode 100644 index 00000000..37159b50 --- /dev/null +++ b/NewKernel/StorageKit/Storage.hpp @@ -0,0 +1,16 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + +------------------------------------------- */ + +#pragma once + +#include +#include +#include +#include + +#define kDriveSectorSizeHDD (512) +#define kDriveSectorSizeSSD (4096) +#define kDriveSectorSizeCDROM (2048) -- cgit v1.2.3