diff options
| author | Amlal <amlalelmahrouss@icloud.com> | 2024-05-11 06:43:54 +0000 |
|---|---|---|
| committer | Amlal <amlalelmahrouss@icloud.com> | 2024-05-11 06:43:54 +0000 |
| commit | ca675beb41dba8d7d16c5793b55d1672f38be3b4 (patch) | |
| tree | c995ada42729ac2059a0ed87a4539d1a7e10b14a /Boot/BootKit/HW | |
| parent | 2b4a4792abf51487ab4a16106f9376f43acf381a (diff) | |
| parent | bc57a29a24b98b00ba17710ba84ec2188ab73504 (diff) | |
Merged in MHR-23 (pull request #12)
MHR-23: Merge work.
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 |
