summaryrefslogtreecommitdiffhomepage
path: root/Private/Source
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@el-mahrouss-logic.com>2024-04-03 09:20:28 +0200
committerAmlal El Mahrouss <amlal@el-mahrouss-logic.com>2024-04-03 09:20:28 +0200
commit3facc32b746a44b0e3a91cbe1897127194396d1b (patch)
tree0725ebbf35a18e6933596ea5c765ac81adf7834f /Private/Source
parentefc6b5d169d2b6eaabe7384141cec6054ae622a0 (diff)
MHR-3: See main changes below.
Kernel: Improve Disk interfaces regarding the struct they're using (all of them are using MountpountInterface now) SystemLib: Start adding PowerPC code to the SystemLib to be cross compiled as a PEF FAT binary. Kernel: Adding new builtins to support a wide range of hardware. Signed-off-by: Amlal El Mahrouss <amlal@el-mahrouss-logic.com>
Diffstat (limited to 'Private/Source')
-rw-r--r--Private/Source/DriveManager.cxx15
-rw-r--r--Private/Source/NewFS+IO.cxx20
-rw-r--r--Private/Source/Storage/AHCIDeviceInterface.cxx4
-rw-r--r--Private/Source/Storage/ATADeviceInterface.cxx68
-rw-r--r--Private/Source/Storage/SCSIDeviceInterface.cxx (renamed from Private/Source/Storage/StorageBase.cxx)4
5 files changed, 97 insertions, 14 deletions
diff --git a/Private/Source/DriveManager.cxx b/Private/Source/DriveManager.cxx
index 41a623c9..f79fcdf5 100644
--- a/Private/Source/DriveManager.cxx
+++ b/Private/Source/DriveManager.cxx
@@ -53,6 +53,21 @@ Void ke_drv_check_disk(DriveTrait::DrivePacket* pckt) {
pckt->fPacketGood = false;
}
+/// @brief Gets the drive kind (ATA, SCSI, AHCI...)
+/// @param
+/// @return
+#ifdef __ATA_PIO__
+const Char* ke_drive_kind(Void) { return "ATA-PIO"; }
+#endif
+
+#ifdef __ATA_DMA__
+const Char* ke_drive_kind(Void) { return "ATA-DMA"; }
+#endif
+
+#ifdef __AHCI__
+const Char* ke_drive_kind(Void) { return "AHCO"; }
+#endif
+
/// @brief Unimplemented drive.
/// @param pckt
/// @return
diff --git a/Private/Source/NewFS+IO.cxx b/Private/Source/NewFS+IO.cxx
index 8264f7fa..63db9b1a 100644
--- a/Private/Source/NewFS+IO.cxx
+++ b/Private/Source/NewFS+IO.cxx
@@ -24,8 +24,8 @@
/// Useful macros.
-#define NEWFS_WRITE(DRV, TRAITS, MP) (*MP->DRV()) << TRAITS
-#define NEWFS_READ(DRV, TRAITS, MP) (*MP->DRV()) >> TRAITS
+#define NEWFS_WRITE(DRV, TRAITS, MP) (*MP->DRV()).fOutput(&TRAITS)
+#define NEWFS_READ(DRV, TRAITS, MP) (*MP->DRV()).fInput(&TRAITS)
using namespace NewOS;
@@ -41,19 +41,19 @@ Int32 fs_newfs_read_raw(MountpointInterface* Mnt, DriveTrait& DrvTrait, Int32 Dr
switch (DrvIndex) {
case kHCFSSubDriveA: {
- NEWFS_READ(A, DrvTrait, Mnt);
+ NEWFS_READ(A, DrvTrait.fPacket, Mnt);
break;
}
case kHCFSSubDriveB: {
- NEWFS_READ(B, DrvTrait, Mnt);
+ NEWFS_READ(B, DrvTrait.fPacket, Mnt);
break;
}
case kHCFSSubDriveC: {
- NEWFS_READ(C, DrvTrait, Mnt);
+ NEWFS_READ(C, DrvTrait.fPacket, Mnt);
break;
}
case kHCFSSubDriveD: {
- NEWFS_READ(D, DrvTrait, Mnt);
+ NEWFS_READ(D, DrvTrait.fPacket, Mnt);
break;
}
}
@@ -73,19 +73,19 @@ Int32 fs_newfs_write_raw(MountpointInterface* Mnt, DriveTrait& DrvTrait, Int32 D
switch (DrvIndex) {
case kHCFSSubDriveA: {
- NEWFS_WRITE(A, DrvTrait, Mnt);
+ NEWFS_WRITE(A, DrvTrait.fPacket, Mnt);
break;
}
case kHCFSSubDriveB: {
- NEWFS_WRITE(B, DrvTrait, Mnt);
+ NEWFS_WRITE(B, DrvTrait.fPacket, Mnt);
break;
}
case kHCFSSubDriveC: {
- NEWFS_WRITE(C, DrvTrait, Mnt);
+ NEWFS_WRITE(C, DrvTrait.fPacket, Mnt);
break;
}
case kHCFSSubDriveD: {
- NEWFS_WRITE(D, DrvTrait, Mnt);
+ NEWFS_WRITE(D, DrvTrait.fPacket, Mnt);
break;
}
}
diff --git a/Private/Source/Storage/AHCIDeviceInterface.cxx b/Private/Source/Storage/AHCIDeviceInterface.cxx
index c6a4a4be..c7a99cb0 100644
--- a/Private/Source/Storage/AHCIDeviceInterface.cxx
+++ b/Private/Source/Storage/AHCIDeviceInterface.cxx
@@ -12,8 +12,8 @@ using namespace NewOS;
/// @param Out Disk output
/// @param In Disk input
/// @param Cleanup Disk cleanup.
-AHCIDeviceInterface::AHCIDeviceInterface(void (*Out)(AHCIPacket outpacket),
- void (*In)(AHCIPacket inpacket), void (*Cleanup)(void))
+AHCIDeviceInterface::AHCIDeviceInterface(void (*Out)(MountpointInterface* outpacket),
+ void (*In)(MountpointInterface* inpacket), void (*Cleanup)(void))
: DeviceInterface(Out, In), fCleanup(Cleanup) {}
/// @brief Class desctructor
diff --git a/Private/Source/Storage/ATADeviceInterface.cxx b/Private/Source/Storage/ATADeviceInterface.cxx
new file mode 100644
index 00000000..89f11f5d
--- /dev/null
+++ b/Private/Source/Storage/ATADeviceInterface.cxx
@@ -0,0 +1,68 @@
+/* -------------------------------------------
+
+ Copyright Mahrouss Logic
+
+------------------------------------------- */
+
+#include <StorageKit/ATA.hpp>
+
+using namespace NewOS;
+
+/// @brief Class constructor
+/// @param Out Disk output
+/// @param In Disk input
+/// @param Cleanup Disk cleanup.
+ATADeviceInterface::ATADeviceInterface(
+ void (*Out)(MountpointInterface* outpacket),
+ void (*In)(MountpointInterface* inpacket), void (*Cleanup)(void))
+ : DeviceInterface(Out, In), fCleanup(Cleanup) {}
+
+/// @brief Class desctructor
+ATADeviceInterface::~ATADeviceInterface() {
+ MUST_PASS(fCleanup);
+ if (fCleanup) fCleanup();
+}
+
+/// @brief Returns the name of the device interface.
+/// @return it's name as a string.
+const char* ATADeviceInterface::Name() const { return "ATADeviceInterface"; }
+
+/// @brief Output operator.
+/// @param Data
+/// @return
+ATADeviceInterface& ATADeviceInterface::operator<<(MountpointInterface* Data) {
+ if (!Data) return *this;
+
+ for (SizeT driveCount = 0; driveCount < kDriveManagerCount; ++driveCount) {
+ auto interface = Data->GetAddressOf(driveCount);
+ if ((*interface) && rt_string_cmp((*interface)->fDriveKind(), "ATA-", 5) == 0) {
+ continue;
+ } else if ((*interface) &&
+ rt_string_cmp((*interface)->fDriveKind(), "ATA-", 5) != 0) {
+ return *this;
+ }
+ }
+
+ return (ATADeviceInterface&)DeviceInterface<MountpointInterface*>::operator<<(
+ Data);
+}
+
+/// @brief Input operator.
+/// @param Data
+/// @return
+ATADeviceInterface& ATADeviceInterface::operator>>(MountpointInterface* Data) {
+ if (!Data) return *this;
+
+ for (SizeT driveCount = 0; driveCount < kDriveManagerCount; ++driveCount) {
+ auto interface = Data->GetAddressOf(driveCount);
+ if ((*interface) && rt_string_cmp((*interface)->fDriveKind(), "ATA-", 5) == 0) {
+ continue;
+ } else if ((*interface) &&
+ rt_string_cmp((*interface)->fDriveKind(), "ATA-", 5) != 0) {
+ return *this;
+ }
+ }
+
+ return (ATADeviceInterface&)DeviceInterface<MountpointInterface*>::operator>>(
+ Data);
+} \ No newline at end of file
diff --git a/Private/Source/Storage/StorageBase.cxx b/Private/Source/Storage/SCSIDeviceInterface.cxx
index bba4be1f..7625a279 100644
--- a/Private/Source/Storage/StorageBase.cxx
+++ b/Private/Source/Storage/SCSIDeviceInterface.cxx
@@ -4,8 +4,8 @@
------------------------------------------- */
-#include <StorageKit/Storage.hpp>
+#include <StorageKit/SCSI.hxx>
///! @brief ATAPI SCSI packet.
-const SKScsiPacket kCDRomPacketTemplate = {0x43, 0, 1, 0, 0, 0,
+const scsi_packet_type kCDRomPacketTemplate = {0x43, 0, 1, 0, 0, 0,
0, 12, 0x40, 0, 0};