summaryrefslogtreecommitdiffhomepage
path: root/Private/Source/Storage
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-01-26 22:26:48 +0100
committerAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-01-26 22:27:09 +0100
commiteba8b7ddd0a455d9e49f32dcae712c5612c0093c (patch)
tree749a3d34546d055507a920bce4ab10e8a9945719 /Private/Source/Storage
parentdd192787a70a973f2474720aea49af3f6ddabb7a (diff)
Kernel: Major repository refactor.
Rework the repo into Private and Public modules. Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'Private/Source/Storage')
-rw-r--r--Private/Source/Storage/ATA.cxx99
-rw-r--r--Private/Source/Storage/NVME.cxx18
-rw-r--r--Private/Source/Storage/Storage.cxx12
3 files changed, 129 insertions, 0 deletions
diff --git a/Private/Source/Storage/ATA.cxx b/Private/Source/Storage/ATA.cxx
new file mode 100644
index 00000000..08fa43b3
--- /dev/null
+++ b/Private/Source/Storage/ATA.cxx
@@ -0,0 +1,99 @@
+/*
+ * ========================================================
+ *
+ * hCore
+ * Copyright 2024 Mahrouss Logic, all rights reserved.
+ *
+ * ========================================================
+ */
+
+#include <StorageKit/ATA.hpp>
+#include <ArchKit/Arch.hpp>
+
+//! @brief Driver for ATA, listens to a specific address for data to come.
+//! mapped by NewFirmware.
+
+#define kATAError 2
+
+namespace hCore
+{
+ Ref<PRDT*> kPrdt = nullptr;
+
+ bool set_prdt_struct(Ref<PRDT*>& refCtrl)
+ {
+ if (!kPrdt)
+ {
+ kPrdt = refCtrl;
+ kcout << "[set_prdt_struct] PRDT is set.";
+
+ return true;
+ }
+
+ kcout << "[set_prdt_struct] [WARNING] Tried to change PRDT.\n";
+ return false;
+ }
+
+ enum
+ {
+ k28BitRead = 0xC8,
+ k48BitRead = 0x25,
+ k28BitWrite = 0xCA,
+ k48BitWrite = 0x35,
+ };
+
+ const char* ata_read_28(ULong lba)
+ {
+ static char buffer[512];
+
+ UIntPtr* packet = (UIntPtr*)kPrdt.Leak()->PhysicalAddress();
+
+ packet[0] = k28BitRead;
+ packet[1] = (UIntPtr)&buffer;
+ packet[2] = lba;
+
+ rt_wait_for_io();
+
+ return buffer;
+ }
+
+ const char* ata_read_48(ULong lba)
+ {
+ static char buffer[512];
+
+ UIntPtr* packet = (UIntPtr*)kPrdt.Leak()->PhysicalAddress();
+
+ packet[0] = k48BitRead;
+ packet[1] = (UIntPtr)&buffer;
+ packet[4] = lba;
+
+ rt_wait_for_io();
+
+ return buffer;
+ }
+
+ Int32 ata_write_48(ULong lba, const char *text)
+ {
+ UIntPtr* packet = (UIntPtr*)kPrdt.Leak()->PhysicalAddress();
+
+ packet[0] = k48BitWrite;
+ packet[1] = (UIntPtr)&text;
+ packet[2] = lba;
+
+ rt_wait_for_io();
+
+ return packet[1] == 2 ? kATAError : 0;
+ }
+
+ Int32 ata_write_28(ULong lba, const char *text)
+ {
+ UIntPtr* packet = (UIntPtr*)kPrdt.Leak()->PhysicalAddress();
+
+ packet[0] = k28BitWrite;
+ packet[1] = (UIntPtr)&text;
+ packet[2] = lba;
+
+ rt_wait_for_io();
+
+ return packet[1] == 2 ? kATAError : 0;
+ }
+} // namespace hCore
diff --git a/Private/Source/Storage/NVME.cxx b/Private/Source/Storage/NVME.cxx
new file mode 100644
index 00000000..aa1d8ecc
--- /dev/null
+++ b/Private/Source/Storage/NVME.cxx
@@ -0,0 +1,18 @@
+/*
+ * ========================================================
+ *
+ * hCore
+ * Copyright 2024 Mahrouss Logic, all rights reserved.
+ *
+ * ========================================================
+ */
+
+#include <StorageKit/NVME.hpp>
+
+namespace hCore
+{
+ const char *NVMEDevice::Name() const
+ {
+ return ("NVMEDevice");
+ }
+} // namespace hCore
diff --git a/Private/Source/Storage/Storage.cxx b/Private/Source/Storage/Storage.cxx
new file mode 100644
index 00000000..6384479a
--- /dev/null
+++ b/Private/Source/Storage/Storage.cxx
@@ -0,0 +1,12 @@
+/*
+ * ========================================================
+ *
+ * hCore
+ * Copyright 2024 Mahrouss Logic, all rights reserved.
+ *
+ * ========================================================
+ */
+
+#include <StorageKit/Storage.hpp>
+
+const OSScsiPacket kCDRomPacketTemplate = { 0x43, 0, 1, 0, 0, 0, 0, 12, 0x40, 0, 0 };