summaryrefslogtreecommitdiffhomepage
path: root/dev/ZBAKit/BootKit/HW
diff options
context:
space:
mode:
authorAmlal <amlal.elmahrouss@icloud.com>2024-10-28 07:01:58 +0100
committerAmlal <amlal.elmahrouss@icloud.com>2024-10-28 07:01:58 +0100
commite0024d9ea688ee91a77abc0e28c5ea24b13ca67d (patch)
treea4e29bd919cbeccf2689e81a5d52bfc02f2a8b77 /dev/ZBAKit/BootKit/HW
parent36a3600ff7fc65a63b7386b7a680dbe8e647bd8f (diff)
IMP: Refactor whole source code to make it even.
- That is because previously the source was both in lowercase and lettercase. Signed-off-by: Amlal <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'dev/ZBAKit/BootKit/HW')
-rw-r--r--dev/ZBAKit/BootKit/HW/ATA.h58
-rw-r--r--dev/ZBAKit/BootKit/HW/SATA.h46
2 files changed, 104 insertions, 0 deletions
diff --git a/dev/ZBAKit/BootKit/HW/ATA.h b/dev/ZBAKit/BootKit/HW/ATA.h
new file mode 100644
index 00000000..8c7a9c40
--- /dev/null
+++ b/dev/ZBAKit/BootKit/HW/ATA.h
@@ -0,0 +1,58 @@
+/* -------------------------------------------
+
+ Copyright ZKA Web Services Co.
+
+------------------------------------------- */
+
+#pragma once
+
+#include <Modules/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/ZBAKit/BootKit/HW/SATA.h b/dev/ZBAKit/BootKit/HW/SATA.h
new file mode 100644
index 00000000..f0af4650
--- /dev/null
+++ b/dev/ZBAKit/BootKit/HW/SATA.h
@@ -0,0 +1,46 @@
+/* -------------------------------------------
+
+ Copyright ZKA Web Services Co.
+
+------------------------------------------- */
+
+#pragma once
+
+#include <CompilerKit/CompilerKit.h>
+#include <Modules/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