diff options
| author | Amlal <amlal.elmahrouss@icloud.com> | 2025-01-24 10:38:36 +0100 |
|---|---|---|
| committer | Amlal <amlal.elmahrouss@icloud.com> | 2025-01-24 10:38:36 +0100 |
| commit | 7b4bd3577a31d0f0adc7371840642791ae1567f4 (patch) | |
| tree | 1a8afc973aaa739d0d763315cad2fd376d1cea9c /dev/Boot/BootKit/HW | |
ADD: Open version, with important changes kept out.
Signed-off-by: Amlal <amlal.elmahrouss@icloud.com>
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..c58bbd61 --- /dev/null +++ b/dev/Boot/BootKit/HW/ATA.h @@ -0,0 +1,58 @@ +/* ------------------------------------------- + + Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved. + +------------------------------------------- */ + +#pragma once + +#include <Mod/ATA/ATA.h> +#include <BootKit/Device.h> + +using namespace Kernel; + +class BootDeviceATA final : public Device +{ +public: + enum + { + kPrimary = ATA_PRIMARY_IO, + kSecondary = ATA_SECONDARY_IO, + }; + + explicit BootDeviceATA() noexcept; + ~BootDeviceATA() = default; + + ZKA_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..a7ece124 --- /dev/null +++ b/dev/Boot/BootKit/HW/SATA.h @@ -0,0 +1,46 @@ +/* ------------------------------------------- + + Copyright (C) 2024, Amlal EL Mahrouss, all rights reserved. + +------------------------------------------- */ + +#pragma once + +#include <CompilerKit/CompilerKit.h> +#include <Mod/AHCI/AHCI.h> + +class BootDeviceSATA final +{ +public: + explicit BootDeviceSATA() noexcept; + ~BootDeviceSATA() = default; + + ZKA_COPY_DEFAULT(BootDeviceSATA); + + struct SATATrait final + { + Kernel::SizeT mBase{1024}; + Kernel::Boolean mErr{false}; + Kernel::Boolean mDetected{false}; + + operator bool() + { + return !this->mErr; + } + }; + + operator bool() + { + return this->Leak().mDetected; + } + + BootDeviceSATA& Read(Kernel::WideChar* Buf, const Kernel::SizeT& SecCount); + BootDeviceSATA& Write(Kernel::WideChar* Buf, const Kernel::SizeT& SecCount); + + SATATrait& Leak(); + +private: + SATATrait mTrait; +}; + +#define kAHCISectorSz 4096 |
