summaryrefslogtreecommitdiffhomepage
path: root/Private/KernelKit/DriveManager.hpp
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/KernelKit/DriveManager.hpp
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/KernelKit/DriveManager.hpp')
-rw-r--r--Private/KernelKit/DriveManager.hpp87
1 files changed, 87 insertions, 0 deletions
diff --git a/Private/KernelKit/DriveManager.hpp b/Private/KernelKit/DriveManager.hpp
new file mode 100644
index 00000000..9951c9cf
--- /dev/null
+++ b/Private/KernelKit/DriveManager.hpp
@@ -0,0 +1,87 @@
+/*
+ * ========================================================
+ *
+ * hCore
+ * Copyright 2024 Mahrouss Logic, all rights reserved.
+ *
+ * ========================================================
+ */
+
+#pragma once
+
+#include <CompilerKit/Compiler.hpp>
+#include <NewKit/Defines.hpp>
+#include <NewKit/String.hpp>
+
+#include <KernelKit/Device.hpp>
+
+#define kDriveInvalidID -1
+#define kDriveNameLen 32
+
+namespace hCore
+{
+ enum
+ {
+ kInvalidDrive = -1,
+ kBlockDevice = 0xAD,
+ kMassStorage = 0xDA,
+ kFloppyDisc = 0xCD,
+ kOpticalDisc = 0xDC, // CD-ROM/DVD-ROM/Blu-Ray
+ kReadOnly = 0x10, // Read only drive
+ kXPMDrive = 0x11, // eXplicit Partition Map.
+ kXPTDrive = 0x12, // GPT w/ XPM partition.
+ kMBRDrive = 0x13, // IBM PC classic partition scheme
+ };
+
+ typedef Int64 DriveID;
+
+ // Mounted drive.
+ struct DriveTraits final
+ {
+ char fName[kDriveNameLen]; // /system, /boot...
+ Int32 fKind; // fMassStorage, fFloppy, fOpticalDisc.
+ DriveID fId; // Drive id.
+ Int32 fFlags; // fReadOnly, fXPMDrive, fXPTDrive
+
+ //! disk mount, unmount operations
+ void(*fMount)(void);
+ void(*fUnmount)(void);
+
+ bool(*fReady)(void); //! is drive ready?
+
+ //! for StorageKit.
+ struct
+ {
+ voidPtr fPacketContent; // packet body.
+ Char fPacketMime[32]; //! identify what we're sending.
+ SizeT fPacketSize; // packet size
+ } fPacket;
+ };
+
+#define kPacketBinary "file/x-binary"
+#define kPacketSource "file/x-source"
+#define kPacketASCII "file/x-ascii"
+#define kPacketZip "file/x-zip"
+
+ //! drive as a device.
+ typedef DeviceInterface<DriveTraits> Drive;
+ typedef Drive* DrivePtr;
+
+ class DriveSelector final
+ {
+ public:
+ explicit DriveSelector();
+ ~DriveSelector();
+
+ public:
+ HCORE_COPY_DEFAULT(DriveSelector);
+
+ DriveTraits& GetMounted();
+ bool Mount(DriveTraits* drive);
+ DriveTraits* Unmount();
+
+ private:
+ DriveTraits* fDrive;
+
+ };
+}