summaryrefslogtreecommitdiffhomepage
path: root/dev/ZKAKit/src/NeFS+IO.cc
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/ZKAKit/src/NeFS+IO.cc
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/ZKAKit/src/NeFS+IO.cc')
-rw-r--r--dev/ZKAKit/src/NeFS+IO.cc101
1 files changed, 101 insertions, 0 deletions
diff --git a/dev/ZKAKit/src/NeFS+IO.cc b/dev/ZKAKit/src/NeFS+IO.cc
new file mode 100644
index 00000000..b55707f9
--- /dev/null
+++ b/dev/ZKAKit/src/NeFS+IO.cc
@@ -0,0 +1,101 @@
+/* -------------------------------------------
+
+ Copyright ZKA Web Services Co.
+
+------------------------------------------- */
+
+#include <KernelKit/DriveMgr.h>
+#include <KernelKit/FileMgr.h>
+
+/*************************************************************
+ *
+ * File: NeFS+IO.cc
+ * Purpose: Filesystem to mountpoint interface.
+ * Date: 3/26/24
+ *
+ * Copyright ZKA Web Services Co., all rights reserved.
+ *
+ *************************************************************/
+
+#ifdef __FSKIT_INCLUDES_NEFS__
+
+#include <FirmwareKit/EPM.h>
+
+/// Useful macros.
+
+#define NEFS_WRITE(DRV, TRAITS, MP) (MP->DRV()).fOutput(&TRAITS)
+#define NEFS_READ(DRV, TRAITS, MP) (MP->DRV()).fInput(&TRAITS)
+
+using namespace Kernel;
+
+/// @brief Read from newfs disk.
+/// @param Mnt mounted interface.
+/// @param DrvTrait drive info
+/// @param DrvIndex drive index.
+/// @return
+Int32 fs_newfs_read(MountpointInterface* Mnt, DriveTrait& DrvTrait, Int32 DrvIndex)
+{
+ if (!Mnt)
+ return -1;
+
+ DrvTrait.fPacket.fPacketGood = false;
+
+ switch (DrvIndex)
+ {
+ case kNeFSSubDriveA: {
+ NEFS_READ(A, DrvTrait.fPacket, Mnt);
+ break;
+ }
+ case kNeFSSubDriveB: {
+ NEFS_READ(B, DrvTrait.fPacket, Mnt);
+ break;
+ }
+ case kNeFSSubDriveC: {
+ NEFS_READ(C, DrvTrait.fPacket, Mnt);
+ break;
+ }
+ case kNeFSSubDriveD: {
+ NEFS_READ(D, DrvTrait.fPacket, Mnt);
+ break;
+ }
+ }
+
+ return DrvTrait.fPacket.fPacketGood;
+}
+
+/// @brief Write to newfs disk.
+/// @param Mnt mounted interface.
+/// @param DrvTrait drive info
+/// @param DrvIndex drive index.
+/// @return
+Int32 fs_newfs_write(MountpointInterface* Mnt, DriveTrait& DrvTrait, Int32 DrvIndex)
+{
+ if (!Mnt)
+ return -1;
+
+ DrvTrait.fPacket.fPacketGood = false;
+
+ switch (DrvIndex)
+ {
+ case kNeFSSubDriveA: {
+ NEFS_WRITE(A, DrvTrait.fPacket, Mnt);
+ break;
+ }
+ case kNeFSSubDriveB: {
+ NEFS_WRITE(B, DrvTrait.fPacket, Mnt);
+ break;
+ }
+ case kNeFSSubDriveC: {
+ NEFS_WRITE(C, DrvTrait.fPacket, Mnt);
+ break;
+ }
+ case kNeFSSubDriveD: {
+ NEFS_WRITE(D, DrvTrait.fPacket, Mnt);
+ break;
+ }
+ }
+
+ return DrvTrait.fPacket.fPacketGood;
+}
+
+#endif // ifdef __FSKIT_INCLUDES_NEFS__