diff options
| author | Amlal El Mahrouss <amlal@el-mahrouss-logic.com> | 2024-04-06 22:28:21 +0200 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal@el-mahrouss-logic.com> | 2024-04-06 22:28:59 +0200 |
| commit | 256e54f04323215a6b4e964e3955c606563c2dae (patch) | |
| tree | 7720038b93b7a6e99cb750249a2667b857209d51 /Private | |
| parent | e2fd9a88d6b9def2fdebbc974001ae0778c26622 (diff) | |
NewOS: Pre-release R1, see below.
NewFS: Add FindFork, improve CreateFork, still working on NewFS support.
DriveManager: Fix ke_drv_input and ke_drv_output, drv_std_ calls,
throws an error when no specifying any drive backends.
Signed-off-by: Amlal El Mahrouss <amlal@el-mahrouss-logic.com>
Diffstat (limited to 'Private')
| -rw-r--r-- | Private/FSKit/NewFS.hxx | 8 | ||||
| -rw-r--r-- | Private/Source/DriveManager.cxx | 13 | ||||
| -rw-r--r-- | Private/Source/FS/NewFS.cxx | 183 | ||||
| -rw-r--r-- | Private/Source/ThreadLocalStorage.cxx | 6 |
4 files changed, 132 insertions, 78 deletions
diff --git a/Private/FSKit/NewFS.hxx b/Private/FSKit/NewFS.hxx index 04e68cc6..3d5071c5 100644 --- a/Private/FSKit/NewFS.hxx +++ b/Private/FSKit/NewFS.hxx @@ -188,7 +188,11 @@ class NewFSParser final { /// @return the fork _Output NewFork* CreateFork(_Input NewCatalog* catalog, _Input NewFork& theFork); - virtual _Output NewFork* FindFork(_Input NewCatalog* catalog, _Input const Char* name) = 0; + /// @brief Find fork inside New filesystem. + /// @param catalog the catalog. + /// @param name the fork name. + /// @return the fork. + _Output NewFork* FindFork(_Input NewCatalog* catalog, _Input const Char* name); virtual _Output Void RemoveFork(_Input NewFork* fork) = 0; @@ -228,7 +232,7 @@ class NewFSParser final { /// @brief Make a EPM+NewFS drive out of the disk. /// @param drive The drive to write on. /// @return If it was sucessful, see DbgLastError(). - virtual bool Format(_Input _Output DriveTrait* drive) = 0; + bool Format(_Input _Output DriveTrait* drive); public: Int32 fDriveIndex{ kNewFSSubDriveA }; diff --git a/Private/Source/DriveManager.cxx b/Private/Source/DriveManager.cxx index b468ebae..45b3c09a 100644 --- a/Private/Source/DriveManager.cxx +++ b/Private/Source/DriveManager.cxx @@ -7,6 +7,7 @@ #include <KernelKit/DebugOutput.hpp> #include <KernelKit/DriveManager.hxx> #include <Builtins/ATA/Defines.hxx> +#include <Builtins/AHCI/Defines.hxx> /// @file DriveManager.cxx /// @brief Kernel drive manager. @@ -25,10 +26,10 @@ Void ke_drv_input(DriveTrait::DrivePacket* pckt) { pckt->fPacketGood = false; -#ifndef __AHCI__ - drv_std_read(pckt->fLba, kATAIO, kATAMaster, (Char*)pckt->fPacketContent, 1, pckt->fPacketSize); -#else +#ifdef __AHCI__ drv_std_read(pckt->fLba, (Char*)pckt->fPacketContent, 1, pckt->fPacketSize); +#elif defined(__ATA_PIO__) || defined(__ATA_DMA__) + drv_std_read(pckt->fLba, kATAIO, kATAMaster, (Char*)pckt->fPacketContent, 1, pckt->fPacketSize); #endif @@ -45,10 +46,10 @@ Void ke_drv_output(DriveTrait::DrivePacket* pckt) { pckt->fPacketGood = false; -#ifndef __AHCI__ - drv_std_write(pckt->fLba, kATAIO, kATAMaster, (Char*)pckt->fPacketContent, 1, pckt->fPacketSize); -#else +#ifdef __AHCI__ drv_std_write(pckt->fLba,(Char*)pckt->fPacketContent, 1, pckt->fPacketSize); +#elif defined(__ATA_PIO__) || defined(__ATA_DMA__) + drv_std_write(pckt->fLba, kATAIO, kATAMaster, (Char*)pckt->fPacketContent, 1, pckt->fPacketSize); #endif pckt->fPacketGood = true; diff --git a/Private/Source/FS/NewFS.cxx b/Private/Source/FS/NewFS.cxx index f497c2af..3c33f441 100644 --- a/Private/Source/FS/NewFS.cxx +++ b/Private/Source/FS/NewFS.cxx @@ -11,9 +11,9 @@ using namespace NewOS; -STATIC Lba ke_find_fork(SizeT sz); -STATIC Lba ke_find_catalog(SizeT sz); -STATIC Lba ke_find_data(SizeT sz); +STATIC Lba ke_find_free_fork(SizeT sz); +STATIC Lba ke_find_free_catalog(SizeT sz); +STATIC Lba ke_find_free_data(SizeT sz); STATIC MountpointInterface sMountpointInterface; @@ -21,72 +21,121 @@ STATIC MountpointInterface sMountpointInterface; /// @param catalog it's catalog /// @param theFork the fork itself. /// @return the fork -_Output NewFork* NewFSParser::CreateFork(_Input NewCatalog* catalog, _Input NewFork& theFork) -{ - if (catalog && - theFork.Name[0] != 0 && - theFork.DataSize > 0) { - Lba whereFork = 0; - - theFork.DataOffset = ke_find_fork(theFork.DataSize); - theFork.Flags |= kNewFSFlagCreated; - - if (catalog->FirstFork == 0) { - catalog->FirstFork = whereFork; - } else { - if (catalog->LastFork == 0) { - theFork.PreviousSibling = catalog->FirstFork; - } - } - - if (catalog->LastFork == 0) { - catalog->LastFork = whereFork; - } else { - theFork.PreviousSibling = catalog->LastFork; - } - - if (!sMountpointInterface.GetAddressOf(this->fDriveIndex) || - !*sMountpointInterface.GetAddressOf(this->fDriveIndex)) - return nullptr; - - auto drv = *sMountpointInterface.GetAddressOf(this->fDriveIndex); - - drv->fPacket.fLba = whereFork; - drv->fPacket.fPacketSize = theFork.DataSize; - drv->fPacket.fPacketContent = (VoidPtr)&theFork; - - rt_copy_memory((VoidPtr)"fs/newfs-packet", drv->fPacket.fPacketMime, 16); - - if (auto res = fs_newfs_write(&sMountpointInterface, *drv, this->fDriveIndex); - res) { - switch (res) - { - case 1: - DbgLastError() = kErrorDiskReadOnly; - break; - case 2: - DbgLastError() = kErrorDiskIsFull; - break; - DbgLastError() = kErrorNoSuchDisk; - break; - - default: - break; - } - return nullptr; - } - - /// Also update catalog. - this->WriteCatalog(catalog, nullptr); - - return &theFork; +_Output NewFork* NewFSParser::CreateFork(_Input NewCatalog* catalog, + _Input NewFork& theFork) { + if (catalog && theFork.Name[0] != 0 && theFork.DataSize > 0) { + Lba whereFork = 0; + + theFork.DataOffset = ke_find_free_fork(theFork.DataSize); + theFork.Flags |= kNewFSFlagCreated; + + if (catalog->FirstFork == 0) { + catalog->FirstFork = whereFork; + } else { + if (catalog->LastFork == 0) { + theFork.PreviousSibling = catalog->FirstFork; + } } - return nullptr; + if (catalog->LastFork == 0) { + catalog->LastFork = whereFork; + } else { + theFork.PreviousSibling = catalog->LastFork; + } + + if (!sMountpointInterface.GetAddressOf(this->fDriveIndex) || + !*sMountpointInterface.GetAddressOf(this->fDriveIndex)) + return nullptr; + + auto drv = *sMountpointInterface.GetAddressOf(this->fDriveIndex); + + drv->fPacket.fLba = whereFork; + drv->fPacket.fPacketSize = theFork.DataSize; + drv->fPacket.fPacketContent = (VoidPtr)&theFork; + + rt_copy_memory((VoidPtr) "fs/newfs-packet", drv->fPacket.fPacketMime, 16); + + if (auto res = + fs_newfs_write(&sMountpointInterface, *drv, this->fDriveIndex); + res) { + switch (res) { + case 1: + DbgLastError() = kErrorDiskReadOnly; + break; + case 2: + DbgLastError() = kErrorDiskIsFull; + break; + DbgLastError() = kErrorNoSuchDisk; + break; + + default: + break; + } + return nullptr; + } + + /// Also update catalog. + this->WriteCatalog(catalog, nullptr); + + return &theFork; + } + + return nullptr; +} + +/// @brief Find fork inside New filesystem. +/// @param catalog the catalog. +/// @param name the fork name. +/// @return the fork. +_Output NewFork* NewFSParser::FindFork(_Input NewCatalog* catalog, + _Input const Char* name) { + auto drv = *sMountpointInterface.GetAddressOf(this->fDriveIndex); + NewFork* theFork = nullptr; + Lba lba = catalog->FirstFork; + + while (lba != 0) { + drv->fPacket.fLba = lba; + drv->fPacket.fPacketSize = sizeof(NewFork); + drv->fPacket.fPacketContent = (VoidPtr)theFork; + + rt_copy_memory((VoidPtr) "fs/newfs-packet", drv->fPacket.fPacketMime, 16); + + if (auto res = + fs_newfs_read(&sMountpointInterface, *drv, this->fDriveIndex); + res) { + switch (res) { + case 1: + DbgLastError() = kErrorDiskReadOnly; + break; + case 2: + DbgLastError() = kErrorDiskIsFull; + break; + DbgLastError() = kErrorNoSuchDisk; + break; + + default: + break; + } + return nullptr; + } + + if (StringBuilder::Equals(theFork->Name, name)) { + break; + } + + lba = theFork->NextSibling; + } + + return theFork; } -STATIC Lba ke_find_fork(SizeT sz) {} -STATIC Lba ke_find_catalog(SizeT sz) {} -STATIC Lba ke_find_data(SizeT sz) {} +/// @brief Make a EPM+NewFS drive out of the disk. +/// @param drive The drive to write on. +/// @return If it was sucessful, see DbgLastError(). +bool NewFSParser::Format(_Input _Output DriveTrait* drive) { return false; } + +STATIC Lba ke_find_free_fork(SizeT sz) { return 0; } +STATIC Lba ke_find_free_catalog(SizeT sz) { return 0; } +STATIC Lba ke_find_free_data(SizeT sz) { return 0; } -#endif // ifdef __FSKIT_NEWFS__
\ No newline at end of file +#endif // ifdef __FSKIT_NEWFS__
\ No newline at end of file diff --git a/Private/Source/ThreadLocalStorage.cxx b/Private/Source/ThreadLocalStorage.cxx index 2bc0e298..d3e31a1c 100644 --- a/Private/Source/ThreadLocalStorage.cxx +++ b/Private/Source/ThreadLocalStorage.cxx @@ -20,7 +20,7 @@ using namespace NewOS; /** - * Check for cookie inside TIB. + * @brief Check for cookie inside TIB. * @param tib the TIB to check. * @return if the cookie is enabled. */ @@ -38,8 +38,8 @@ Boolean tls_check_tib(ThreadInformationBlock* tib) { } /** - * System call implementation of the TLS check. - * @param ptr + * @brief System call implementation of the TLS check. + * @param stackPtr The call frame. * @return */ EXTERN_C Void tls_check_syscall_impl(NewOS::HAL::StackFramePtr stackPtr) noexcept { |
