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/Source/DriveManager.cxx | 45 +------------------------------ Private/Source/KernelMain.cxx | 2 +- Private/Source/NewFS+IO.cxx | 59 +++++++++++++++++++++++++++++++++++++++-- 3 files changed, 59 insertions(+), 47 deletions(-) (limited to 'Private/Source') diff --git a/Private/Source/DriveManager.cxx b/Private/Source/DriveManager.cxx index 371758b1..27f6cc42 100644 --- a/Private/Source/DriveManager.cxx +++ b/Private/Source/DriveManager.cxx @@ -10,47 +10,4 @@ #include #include -namespace HCore { -DriveSelector::DriveSelector() : fDrive(nullptr) {} - -DriveSelector::~DriveSelector() { - if (fDrive) { - this->Unmount(); - } -} - -DriveTraits &DriveSelector::GetMounted() { - MUST_PASS(fDrive != nullptr); - return *fDrive; -} - -bool DriveSelector::Mount(DriveTraits *drive) { - if (drive && drive->fReady()) { - if (fDrive != nullptr) { - this->Unmount(); - } - - fDrive = drive; - fDrive->fMount(); - - kcout << "Mount: " << fDrive->fName << "\n"; - - return true; - } - - return false; -} - -DriveTraits *DriveSelector::Unmount() { - if (!fDrive) return nullptr; - - DriveTraits *drivePointer = fDrive; - - fDrive->fUnmount(); - fDrive = nullptr; - - kcout << "Unmount: " << fDrive->fName << "\n"; - - return drivePointer; -} -} // namespace HCore +namespace HCore {} // namespace HCore diff --git a/Private/Source/KernelMain.cxx b/Private/Source/KernelMain.cxx index e641c7e9..1b2698c4 100644 --- a/Private/Source/KernelMain.cxx +++ b/Private/Source/KernelMain.cxx @@ -8,7 +8,7 @@ */ #include -#include +#include #include #include #include diff --git a/Private/Source/NewFS+IO.cxx b/Private/Source/NewFS+IO.cxx index 681b198a..2e6559c5 100644 --- a/Private/Source/NewFS+IO.cxx +++ b/Private/Source/NewFS+IO.cxx @@ -18,8 +18,63 @@ #ifdef __FSKIT_NEWFS__ -/// @brief This implements NewFS with Device Abstraction in mind. +#include -/// BUGS: 0 +/// Useful macros. + +#define NEWFS_WRITE(DRV, TRAITS, MP) (*MP->DRV()) << TRAITS +#define NEWFS_READ(DRV, TRAITS, MP) (*MP->DRV()) >> TRAITS + +using namespace HCore; + +Int32 KeHCFSRead(Mountpoint* Mnt, DriveTraits& DrvTraits, Int32 DrvIndex) { + if (!Mnt) return -1; + + switch (DrvIndex) { + case 0: { + NEWFS_READ(A, DrvTraits, Mnt); + break; + } + case 1: { + NEWFS_READ(B, DrvTraits, Mnt); + break; + } + case 2: { + NEWFS_READ(C, DrvTraits, Mnt); + break; + } + case 3: { + NEWFS_READ(D, DrvTraits, Mnt); + break; + } + } + + return DrvTraits.fPacket.fPacketGood; +} + +Int32 KeHCFSWrite(Mountpoint* Mnt, DriveTraits& DrvTraits, Int32 DrvIndex) { + if (!Mnt) return -1; + + switch (DrvIndex) { + case 0: { + NEWFS_WRITE(A, DrvTraits, Mnt); + break; + } + case 1: { + NEWFS_WRITE(B, DrvTraits, Mnt); + break; + } + case 2: { + NEWFS_WRITE(C, DrvTraits, Mnt); + break; + } + case 3: { + NEWFS_WRITE(D, DrvTraits, Mnt); + break; + } + } + + return DrvTraits.fPacket.fPacketGood; +} #endif // ifdef __FSKIT_NEWFS__ -- cgit v1.2.3