diff options
| author | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-05-09 00:42:44 +0200 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-05-09 00:42:44 +0200 |
| commit | af8a516fc22865abd80d6e26f1541fa3d6bebfdc (patch) | |
| tree | 96d42a10945fc03df022389aef54708383c1d616 /Kernel/StorageKit | |
| parent | a874e9cc98df994178d55996943fe81799c61d2f (diff) | |
MHR-23: :boom:, refactors.
- Move NewBoot to /Boot, thus making Kernel directory only containing the kernel.
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'Kernel/StorageKit')
| -rw-r--r-- | Kernel/StorageKit/AHCI.hpp | 33 | ||||
| -rw-r--r-- | Kernel/StorageKit/ATA.hpp | 39 | ||||
| -rw-r--r-- | Kernel/StorageKit/NVME.hpp | 43 | ||||
| -rw-r--r-- | Kernel/StorageKit/PRDT.hpp | 36 | ||||
| -rw-r--r-- | Kernel/StorageKit/SCSI.hxx | 11 | ||||
| -rw-r--r-- | Kernel/StorageKit/Storage.hpp | 16 |
6 files changed, 178 insertions, 0 deletions
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 <KernelKit/DeviceManager.hpp> +#include <KernelKit/DriveManager.hxx> +#include <NewKit/OwnPtr.hpp> + +namespace NewOS +{ + class AHCIDeviceInterface : public DeviceInterface<MountpointInterface*> + { + 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 <KernelKit/DeviceManager.hpp> +#include <KernelKit/DriveManager.hxx> +#include <NewKit/OwnPtr.hpp> +#include <NewKit/Utils.hpp> + +namespace NewOS +{ + /// @brief ATA device interface type. + class ATADeviceInterface : public DeviceInterface<MountpointInterface*> + { + 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 <KernelKit/DeviceManager.hpp> +#include <KernelKit/DriveManager.hxx> +#include <NewKit/OwnPtr.hpp> + +namespace NewOS +{ + class NVMEDeviceInterface : public DeviceInterface<MountpointInterface*> + { + 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<MountpointInterface*> 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 <KernelKit/PCI/Dma.hpp> +#include <KernelKit/PCI/Iterator.hpp> +#include <NewKit/Ref.hpp> + +#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<PRDT>& 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 <Builtins/SCSI/SCSI.hxx> + +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 <NewKit/Defines.hpp> +#include <StorageKit/NVME.hpp> +#include <StorageKit/AHCI.hpp> +#include <StorageKit/SCSI.hxx> + +#define kDriveSectorSizeHDD (512) +#define kDriveSectorSizeSSD (4096) +#define kDriveSectorSizeCDROM (2048) |
