summaryrefslogtreecommitdiffhomepage
path: root/Source/Storage
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Storage')
-rw-r--r--Source/Storage/ATA.cxx99
-rw-r--r--Source/Storage/NVME.cxx18
-rw-r--r--Source/Storage/Storage.cxx12
3 files changed, 129 insertions, 0 deletions
diff --git a/Source/Storage/ATA.cxx b/Source/Storage/ATA.cxx
new file mode 100644
index 00000000..5a53d78d
--- /dev/null
+++ b/Source/Storage/ATA.cxx
@@ -0,0 +1,99 @@
+/*
+ * ========================================================
+ *
+ * hCore
+ * Copyright 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/Source/Storage/NVME.cxx b/Source/Storage/NVME.cxx
new file mode 100644
index 00000000..20fbd84d
--- /dev/null
+++ b/Source/Storage/NVME.cxx
@@ -0,0 +1,18 @@
+/*
+ * ========================================================
+ *
+ * hCore
+ * Copyright Mahrouss Logic, all rights reserved.
+ *
+ * ========================================================
+ */
+
+#include <StorageKit/NVME.hpp>
+
+namespace hCore
+{
+ const char *NVMEDevice::Name() const
+ {
+ return ("NVMEDevice");
+ }
+} // namespace hCore
diff --git a/Source/Storage/Storage.cxx b/Source/Storage/Storage.cxx
new file mode 100644
index 00000000..f6732599
--- /dev/null
+++ b/Source/Storage/Storage.cxx
@@ -0,0 +1,12 @@
+/*
+ * ========================================================
+ *
+ * hCore
+ * Copyright Mahrouss Logic, all rights reserved.
+ *
+ * ========================================================
+ */
+
+#include <StorageKit/Storage.hpp>
+
+const OSScsiPacket kCDRomPacketTemplate = { 0x43, 0, 1, 0, 0, 0, 0, 12, 0x40, 0, 0 };