summaryrefslogtreecommitdiffhomepage
path: root/dev/Boot/BootKit/HW
diff options
context:
space:
mode:
authorAmlal EL Mahrouss <amlalelmahrouss@icloud.com>2024-08-15 18:35:34 +0200
committerAmlal EL Mahrouss <amlalelmahrouss@icloud.com>2024-08-15 18:35:34 +0200
commitf3d931aa7cfaf96baef8383b59a8938779541ee7 (patch)
treefdb9fc51badb3dbd03e46ab0766a49d9522e13e2 /dev/Boot/BootKit/HW
parent86640816e8b1d3595365f1fcc8a2a9e61fb40ff1 (diff)
[IMP] Moved source code into dev/ folder.
Signed-off-by: Amlal EL Mahrouss <amlalelmahrouss@icloud.com>
Diffstat (limited to 'dev/Boot/BootKit/HW')
-rw-r--r--dev/Boot/BootKit/HW/ATA.hxx58
-rw-r--r--dev/Boot/BootKit/HW/SATA.hxx46
2 files changed, 104 insertions, 0 deletions
diff --git a/dev/Boot/BootKit/HW/ATA.hxx b/dev/Boot/BootKit/HW/ATA.hxx
new file mode 100644
index 00000000..2c6416f8
--- /dev/null
+++ b/dev/Boot/BootKit/HW/ATA.hxx
@@ -0,0 +1,58 @@
+/* -------------------------------------------
+
+ Copyright ZKA Technologies.
+
+------------------------------------------- */
+
+#pragma once
+
+#include <Modules/ATA/ATA.hxx>
+#include <BootKit/Device.hxx>
+
+using namespace Kernel;
+
+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/dev/Boot/BootKit/HW/SATA.hxx b/dev/Boot/BootKit/HW/SATA.hxx
new file mode 100644
index 00000000..4704ece4
--- /dev/null
+++ b/dev/Boot/BootKit/HW/SATA.hxx
@@ -0,0 +1,46 @@
+/* -------------------------------------------
+
+ Copyright ZKA Technologies.
+
+------------------------------------------- */
+
+#pragma once
+
+#include <CompilerKit/CompilerKit.hxx>
+#include <Modules/AHCI/AHCI.hxx>
+
+class BootDeviceSATA final
+{
+public:
+ explicit BootDeviceSATA() noexcept;
+ ~BootDeviceSATA() = default;
+
+ NEWOS_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