diff options
Diffstat (limited to 'dev/boot/BootKit/HW')
| -rw-r--r-- | dev/boot/BootKit/HW/ATA.h | 58 | ||||
| -rw-r--r-- | dev/boot/BootKit/HW/SATA.h | 46 |
2 files changed, 104 insertions, 0 deletions
diff --git a/dev/boot/BootKit/HW/ATA.h b/dev/boot/BootKit/HW/ATA.h new file mode 100644 index 00000000..39b66db4 --- /dev/null +++ b/dev/boot/BootKit/HW/ATA.h @@ -0,0 +1,58 @@ +/* ------------------------------------------- + + Copyright (C) 2024-2025, Amlal EL Mahrouss, all rights reserved. + +------------------------------------------- */ + +#pragma once + +#include <modules/ATA/ATA.h> +#include <BootKit/Device.h> + +using namespace NeOS; + +class BootDeviceATA final : public Device +{ +public: + enum + { + kPrimary = ATA_PRIMARY_IO, + kSecondary = ATA_SECONDARY_IO, + }; + + explicit BootDeviceATA() noexcept; + ~BootDeviceATA() = default; + + NE_COPY_DELETE(BootDeviceATA); + + enum + { + kSectorSize = kATASectorSize + }; + + struct ATATrait final : public Device::Trait + { + UInt16 mBus{kPrimary}; + UInt8 mMaster{0}; + Boolean mErr{false}; + + operator bool() + { + return !mErr; + } + }; + +public: + operator bool(); + + SizeT GetSectorsCount() noexcept; + SizeT GetDiskSize() noexcept; + + BootDeviceATA& Read(Char* Buf, const SizeT& SecCount) override; + BootDeviceATA& Write(Char* Buf, const SizeT& SecCount) override; + + ATATrait& Leak() override; + +private: + ATATrait mTrait; +}; diff --git a/dev/boot/BootKit/HW/SATA.h b/dev/boot/BootKit/HW/SATA.h new file mode 100644 index 00000000..10868cd9 --- /dev/null +++ b/dev/boot/BootKit/HW/SATA.h @@ -0,0 +1,46 @@ +/* ------------------------------------------- + + Copyright (C) 2024-2025, Amlal EL Mahrouss, all rights reserved. + +------------------------------------------- */ + +#pragma once + +#include <CompilerKit/CompilerKit.h> +#include <modules/AHCI/AHCI.h> + +class BootDeviceSATA final +{ +public: + explicit BootDeviceSATA() noexcept; + ~BootDeviceSATA() = default; + + NE_COPY_DEFAULT(BootDeviceSATA); + + struct SATATrait final + { + NeOS::SizeT mBase{1024}; + NeOS::Boolean mErr{false}; + NeOS::Boolean mDetected{false}; + + operator bool() + { + return !this->mErr; + } + }; + + operator bool() + { + return this->Leak().mDetected; + } + + BootDeviceSATA& Read(NeOS::WideChar* Buf, const NeOS::SizeT& SecCount); + BootDeviceSATA& Write(NeOS::WideChar* Buf, const NeOS::SizeT& SecCount); + + SATATrait& Leak(); + +private: + SATATrait mTrait; +}; + +#define kAHCISectorSz 4096 |
