From af8a516fc22865abd80d6e26f1541fa3d6bebfdc Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Thu, 9 May 2024 00:42:44 +0200 Subject: MHR-23: :boom:, refactors. - Move NewBoot to /Boot, thus making Kernel directory only containing the kernel. Signed-off-by: Amlal El Mahrouss --- Kernel/StorageKit/AHCI.hpp | 33 +++++++++++++++++++++++++++++++++ Kernel/StorageKit/ATA.hpp | 39 +++++++++++++++++++++++++++++++++++++++ Kernel/StorageKit/NVME.hpp | 43 +++++++++++++++++++++++++++++++++++++++++++ Kernel/StorageKit/PRDT.hpp | 36 ++++++++++++++++++++++++++++++++++++ Kernel/StorageKit/SCSI.hxx | 11 +++++++++++ Kernel/StorageKit/Storage.hpp | 16 ++++++++++++++++ 6 files changed, 178 insertions(+) create mode 100644 Kernel/StorageKit/AHCI.hpp create mode 100644 Kernel/StorageKit/ATA.hpp create mode 100644 Kernel/StorageKit/NVME.hpp create mode 100644 Kernel/StorageKit/PRDT.hpp create mode 100644 Kernel/StorageKit/SCSI.hxx create mode 100644 Kernel/StorageKit/Storage.hpp (limited to 'Kernel/StorageKit') diff --git a/Kernel/StorageKit/AHCI.hpp b/Kernel/StorageKit/AHCI.hpp new file mode 100644 index 00000000..5f8908cb --- /dev/null +++ b/Kernel/StorageKit/AHCI.hpp @@ -0,0 +1,33 @@ +/* ------------------------------------------- + + Copyright SoftwareLabs + +------------------------------------------- */ + +#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/Kernel/StorageKit/ATA.hpp b/Kernel/StorageKit/ATA.hpp new file mode 100644 index 00000000..2cffb092 --- /dev/null +++ b/Kernel/StorageKit/ATA.hpp @@ -0,0 +1,39 @@ +/* ------------------------------------------- + + Copyright SoftwareLabs + +------------------------------------------- */ + +#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/Kernel/StorageKit/NVME.hpp b/Kernel/StorageKit/NVME.hpp new file mode 100644 index 00000000..4f1c6362 --- /dev/null +++ b/Kernel/StorageKit/NVME.hpp @@ -0,0 +1,43 @@ +/* ------------------------------------------- + + Copyright SoftwareLabs + +------------------------------------------- */ + +#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/Kernel/StorageKit/PRDT.hpp b/Kernel/StorageKit/PRDT.hpp new file mode 100644 index 00000000..ae6166ce --- /dev/null +++ b/Kernel/StorageKit/PRDT.hpp @@ -0,0 +1,36 @@ +/* ------------------------------------------- + + Copyright SoftwareLabs + +------------------------------------------- */ + +#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/Kernel/StorageKit/SCSI.hxx b/Kernel/StorageKit/SCSI.hxx new file mode 100644 index 00000000..4a11c6e5 --- /dev/null +++ b/Kernel/StorageKit/SCSI.hxx @@ -0,0 +1,11 @@ +/* ------------------------------------------- + + Copyright SoftwareLabs + +------------------------------------------- */ + +#pragma once + +#include + +extern const scsi_packet_type kCDRomPacketTemplate; diff --git a/Kernel/StorageKit/Storage.hpp b/Kernel/StorageKit/Storage.hpp new file mode 100644 index 00000000..6093a5f0 --- /dev/null +++ b/Kernel/StorageKit/Storage.hpp @@ -0,0 +1,16 @@ +/* ------------------------------------------- + + Copyright SoftwareLabs + +------------------------------------------- */ + +#pragma once + +#include +#include +#include +#include + +#define kDriveSectorSizeHDD (512) +#define kDriveSectorSizeSSD (4096) +#define kDriveSectorSizeCDROM (2048) -- cgit v1.2.3