From a481180f3bcb979fecdced3851506bf572327fcf Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Sat, 24 Feb 2024 17:29:16 +0100 Subject: Kernel: Important commit, see below. - Rename EFIKit to FirmwareKit. - Reworked DriveManager, a mountpoint is a class which contains 4 disks at maximum, they act as virtual ones, their format doesn't matter. - Add KeHCFSRead, and KeHCFSWrite. Signed-off-by: Amlal El Mahrouss --- Private/KernelKit/DriveManager.hpp | 53 ++++++++++++++++++++++++++------------ Private/KernelKit/HError.hpp | 1 + 2 files changed, 38 insertions(+), 16 deletions(-) (limited to 'Private/KernelKit') diff --git a/Private/KernelKit/DriveManager.hpp b/Private/KernelKit/DriveManager.hpp index 8e6aaefd..d48b8aae 100644 --- a/Private/KernelKit/DriveManager.hpp +++ b/Private/KernelKit/DriveManager.hpp @@ -11,7 +11,9 @@ #define __DRIVE_MANAGER__ #include +#include #include +#include #include #include @@ -41,17 +43,15 @@ struct DriveTraits final { 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? + Handle fDriveHandle; //! for StorageKit. struct DrivePacket final { voidPtr fPacketContent; // packet body. Char fPacketMime[32]; //! identify what we're sending. SizeT fPacketSize; // packet size + UInt32 fPacketCRC32; // sanity crc, in case if good is set to false + Boolean fPacketGood; } fPacket; }; @@ -61,23 +61,44 @@ struct DriveTraits final { #define kPacketZip "file/x-zip" //! drive as a device. -typedef DeviceInterface Drive; -typedef Drive *DrivePtr; +typedef DeviceInterface DriveDevice; +typedef DriveDevice* DriveDevicePtr; -class DriveSelector final { +class Mountpoint final { public: - explicit DriveSelector(); - ~DriveSelector(); + explicit Mountpoint() = default; + ~Mountpoint() = default; - public: - HCORE_COPY_DEFAULT(DriveSelector); + HCORE_COPY_DEFAULT(Mountpoint); - DriveTraits &GetMounted(); - bool Mount(DriveTraits *drive); - DriveTraits *Unmount(); + public: + DriveDevicePtr A() { return mA; } + DriveDevicePtr B() { return mB; } + DriveDevicePtr C() { return mC; } + DriveDevicePtr D() { return mD; } + + DriveDevicePtr* GetAddressOf(int index) { + switch (index) { + case 0: + return &mA; + case 1: + return &mB; + case 2: + return &mC; + case 3: + return &mD; + default: { + GetLastError() = kErrorNoSuchDisk; + kcout << "Krnl\\Mountpoint: Check HError.\n"; + break; + } + } + + return nullptr; + } private: - DriveTraits *fDrive; + DriveDevicePtr mA, mB, mC, mD; }; } // namespace HCore diff --git a/Private/KernelKit/HError.hpp b/Private/KernelKit/HError.hpp index 247608f9..f050027f 100644 --- a/Private/KernelKit/HError.hpp +++ b/Private/KernelKit/HError.hpp @@ -27,6 +27,7 @@ inline constexpr HError kErrorThreadLocalStorage = 41; inline constexpr HError kErrorMath = 42; inline constexpr HError kErrorNoNetwork = 43; inline constexpr HError kErrorHeapOutOfMemory = 44; +inline constexpr HError kErrorNoSuchDisk = 45; Boolean ke_bug_check(void) noexcept; } // namespace HCore -- cgit v1.2.3