diff options
Diffstat (limited to 'Boot/BootKit/HW')
| -rw-r--r-- | Boot/BootKit/HW/ATA.hxx | 58 | ||||
| -rw-r--r-- | Boot/BootKit/HW/SATA.hxx | 46 |
2 files changed, 104 insertions, 0 deletions
diff --git a/Boot/BootKit/HW/ATA.hxx b/Boot/BootKit/HW/ATA.hxx new file mode 100644 index 00000000..8f06739b --- /dev/null +++ b/Boot/BootKit/HW/ATA.hxx @@ -0,0 +1,58 @@ +/* ------------------------------------------- + + Copyright SoftwareLabs + +------------------------------------------- */ + +#pragma once + +#include <Builtins/ATA/ATA.hxx> +#include <BootKit/Device.hxx> + +using namespace NewOS; + +class BootDeviceATA final : public Device +{ +public: + enum + { + kPrimary = ATA_PRIMARY_IO, + kSecondary = ATA_SECONDARY_IO, + }; + + explicit BootDeviceATA() noexcept; + ~BootDeviceATA() = default; + + NEWOS_COPY_DEFAULT(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/Boot/BootKit/HW/SATA.hxx b/Boot/BootKit/HW/SATA.hxx new file mode 100644 index 00000000..1ad87493 --- /dev/null +++ b/Boot/BootKit/HW/SATA.hxx @@ -0,0 +1,46 @@ +/* ------------------------------------------- + + Copyright SoftwareLabs + +------------------------------------------- */ + +#pragma once + +#include <CompilerKit/CompilerKit.hxx> +#include <Builtins/AHCI/AHCI.hxx> + +class BootDeviceSATA final +{ +public: + explicit BootDeviceSATA() noexcept; + ~BootDeviceSATA() = default; + + NEWOS_COPY_DEFAULT(BootDeviceSATA); + + struct SATATrait final + { + NewOS::SizeT mBase{1024}; + NewOS::Boolean mErr{false}; + NewOS::Boolean mDetected{false}; + + operator bool() + { + return !this->mErr; + } + }; + + operator bool() + { + return this->Leak().mDetected; + } + + BootDeviceSATA& Read(NewOS::WideChar* Buf, const NewOS::SizeT& SecCount); + BootDeviceSATA& Write(NewOS::WideChar* Buf, const NewOS::SizeT& SecCount); + + SATATrait& Leak(); + +private: + SATATrait mTrait; +}; + +#define kAHCISectorSz 4096 |
