From 595a52436c86b4cdc37f26d9562cd55ccdb1a4ec Mon Sep 17 00:00:00 2001 From: Amlal Date: Fri, 17 Jan 2025 21:53:27 +0100 Subject: META: Tweaks and patches applied to mostly the kernel. Signed-off-by: Amlal --- dev/Boot/amd64-desktop.make | 2 +- dev/Boot/src/HEL/AMD64/BootATA.cc | 4 +- dev/Hints/CompilerHint.h | 2 +- dev/Kernel/FSKit/NeFS.h | 47 ++++++++++---------- dev/Kernel/FirmwareKit/EFI/EFI.h | 28 ++++++------ dev/Kernel/HALKit/AMD64/Storage/ATA-PIO.cc | 4 +- dev/Kernel/HALKit/AMD64/Storage/SATA-DMA.cc | 2 +- dev/Kernel/HALKit/ARM64/Storage/MFlash+IO.cc | 6 +-- dev/Kernel/KernelKit/DriveMgr.h | 14 +++--- dev/Kernel/KernelKit/HardwareThreadScheduler.h | 2 +- dev/Kernel/KernelKit/IPEFDylibObject.h | 2 +- dev/Kernel/KernelKit/LoaderInterface.h | 6 +-- dev/Kernel/KernelKit/PCI/DMA.h | 2 +- dev/Kernel/KernelKit/UserProcessScheduler.h | 2 +- dev/Kernel/NewKit/Macros.h | 2 +- dev/Kernel/src/DriveMgr.cc | 60 +++++--------------------- dev/Kernel/src/FS/NeFS.cc | 58 +++++++++++-------------- 17 files changed, 98 insertions(+), 145 deletions(-) (limited to 'dev') diff --git a/dev/Boot/amd64-desktop.make b/dev/Boot/amd64-desktop.make index 9d7eea25..49326c8b 100644 --- a/dev/Boot/amd64-desktop.make +++ b/dev/Boot/amd64-desktop.make @@ -31,7 +31,7 @@ IMG_2=epm-master-2.img EMU_FLAGS=-net none -smp 4 -m 8G -M q35 \ -bios $(BIOS) -drive \ file=fat:rw:src/Root/,index=2,format=raw \ - -serial stdio + -d int LD_FLAGS=-e Main --subsystem=10 diff --git a/dev/Boot/src/HEL/AMD64/BootATA.cc b/dev/Boot/src/HEL/AMD64/BootATA.cc index 2f6eed2a..e9cbfe67 100644 --- a/dev/Boot/src/HEL/AMD64/BootATA.cc +++ b/dev/Boot/src/HEL/AMD64/BootATA.cc @@ -124,7 +124,7 @@ Void boot_ata_read(UInt64 Lba, UInt16 IO, UInt8 Master, CharacterTypeUTF8* Buf, rt_out8(IO + ATA_REG_SEC_COUNT0, ((Size + SectorSz) / SectorSz)); - rt_out8(IO + ATA_REG_LBA0, (Lba)&0xFF); + rt_out8(IO + ATA_REG_LBA0, (Lba) & 0xFF); rt_out8(IO + ATA_REG_LBA1, (Lba) >> 8); rt_out8(IO + ATA_REG_LBA2, (Lba) >> 16); rt_out8(IO + ATA_REG_LBA3, (Lba) >> 24); @@ -154,7 +154,7 @@ Void boot_ata_write(UInt64 Lba, UInt16 IO, UInt8 Master, CharacterTypeUTF8* Buf, rt_out8(IO + ATA_REG_SEC_COUNT0, ((Size + (SectorSz)) / SectorSz)); - rt_out8(IO + ATA_REG_LBA0, (Lba)&0xFF); + rt_out8(IO + ATA_REG_LBA0, (Lba) & 0xFF); rt_out8(IO + ATA_REG_LBA1, (Lba) >> 8); rt_out8(IO + ATA_REG_LBA2, (Lba) >> 16); rt_out8(IO + ATA_REG_LBA3, (Lba) >> 24); diff --git a/dev/Hints/CompilerHint.h b/dev/Hints/CompilerHint.h index b134cc6f..decdf900 100644 --- a/dev/Hints/CompilerHint.h +++ b/dev/Hints/CompilerHint.h @@ -7,7 +7,7 @@ #ifndef HINTKIT_HINT_H #define HINTKIT_HINT_H -#ifdef __TK__ +#ifdef __LIBCOMPILER__ #pragma compiler(hint_manifest) #endif diff --git a/dev/Kernel/FSKit/NeFS.h b/dev/Kernel/FSKit/NeFS.h index 5d0d7582..4593c8e5 100644 --- a/dev/Kernel/FSKit/NeFS.h +++ b/dev/Kernel/FSKit/NeFS.h @@ -265,61 +265,60 @@ namespace Kernel ZKA_COPY_DEFAULT(NeFileSystemParser); public: - /// @brief Creates a new fork inside the New filesystem partition. + /// @brief Creates a new fork inside the NeFS partition. /// @param catalog it's catalog /// @param theFork the fork itself. /// @return the fork - _Output BOOL CreateFork(_Input NFS_CATALOG_STRUCT* catalog, - _Input NFS_FORK_STRUCT& theFork); + _Output BOOL CreateFork(_Input NFS_FORK_STRUCT& in); /// @brief Find fork inside New filesystem. /// @param catalog the catalog. /// @param name the fork name. /// @return the fork. _Output NFS_FORK_STRUCT* FindFork(_Input NFS_CATALOG_STRUCT* catalog, - _Input const Char* name, - Boolean dataOrRsrc); + _Input const Char* name, + Boolean data); _Output Void RemoveFork(_Input NFS_FORK_STRUCT* fork); _Output Void CloseFork(_Input NFS_FORK_STRUCT* fork); - _Output NFS_CATALOG_STRUCT* FindCatalog(_Input const Char* catalogName, Lba& outLba, Bool searchHidden = YES, Bool local_search = NO); + _Output NFS_CATALOG_STRUCT* FindCatalog(_Input const Char* catalog_name, Lba& ou_lba, Bool search_hidden = YES, Bool local_search = NO); _Output NFS_CATALOG_STRUCT* GetCatalog(_Input const Char* name); - _Output NFS_CATALOG_STRUCT* CreateCatalog(_Input const Char* name, + _Output NFS_CATALOG_STRUCT* CreateCatalog(_Input const Char* name, _Input const Int32& flags, _Input const Int32& kind); _Output NFS_CATALOG_STRUCT* CreateCatalog(_Input const Char* name); - Bool WriteCatalog(_Input _Output NFS_CATALOG_STRUCT* catalog, - _Input Bool isRsrcFork, - _Input VoidPtr data, - _Input SizeT sizeOfData, - _Input const Char* forkName); + _Output Bool WriteCatalog(_Input _Output NFS_CATALOG_STRUCT* catalog, + _Input Bool rsrc, + _Input VoidPtr data, + _Input SizeT sz, + _Input const Char* name); - VoidPtr ReadCatalog(_Input _Output NFS_CATALOG_STRUCT* catalog, - _Input Bool isRsrcFork, - _Input SizeT dataSz, - _Input const Char* forkName); + _Output VoidPtr ReadCatalog(_Input _Output NFS_CATALOG_STRUCT* catalog, + _Input Bool isRsrcFork, + _Input SizeT dataSz, + _Input const Char* forkName); - bool Seek(_Input _Output NFS_CATALOG_STRUCT* catalog, SizeT off); + _Output Bool Seek(_Input _Output NFS_CATALOG_STRUCT* catalog, SizeT off); - SizeT Tell(_Input _Output NFS_CATALOG_STRUCT* catalog); + _Output SizeT Tell(_Input _Output NFS_CATALOG_STRUCT* catalog); - bool RemoveCatalog(_Input const Char* catalog); + _Output Bool RemoveCatalog(_Input const Char* catalog); - bool CloseCatalog(_InOut NFS_CATALOG_STRUCT* catalog); + _Output Bool CloseCatalog(_InOut NFS_CATALOG_STRUCT* catalog); /// @brief Make a EPM+NeFS drive out of the disk. /// @param drive The drive to write on. /// @return If it was sucessful, see err_local_get(). - bool Format(_Input _Output DriveTrait* drive, _Input const Lba endLba, _Input const Int32 flags, const Char* part_name); + _Output Bool Format(_Input _Output DriveTrait* drive, _Input const Lba endLba, _Input const Int32 flags, const Char* part_name); public: - Int32 mDriveIndex{kNeFSSubDriveA}; + UInt32 mDriveIndex{kNeFSSubDriveA}; }; /// @@ -364,7 +363,7 @@ namespace Kernel if (!parser) return NO; - delete parser->CreateCatalog("/etc/xml/", 0, kNeFSCatalogKindDir); + delete parser->CreateCatalog("/etc/xml/", 0, kNeFSCatalogKindDir); mNode = parser->CreateCatalog(mStamp); if (!mNode) @@ -420,7 +419,7 @@ namespace Kernel new_fork.DataSize = rt_string_len(xml_data); new_fork.Kind = kNeFSRsrcForkKind; - if (!parser->CreateFork(mNode, new_fork)) + if (!parser->CreateFork(new_fork)) return NO; kcout << "XML Commited: " << xml_data << "\r\nTo Journal Fork: " << journal_name << endl; diff --git a/dev/Kernel/FirmwareKit/EFI/EFI.h b/dev/Kernel/FirmwareKit/EFI/EFI.h index 091ae940..dcfb97dd 100644 --- a/dev/Kernel/FirmwareKit/EFI/EFI.h +++ b/dev/Kernel/FirmwareKit/EFI/EFI.h @@ -52,7 +52,7 @@ typedef Char16 EfiChar16Type; /// Self is like NT's Win32 HANDLE type. typedef struct EfiHandle { -} * EfiHandlePtr; +}* EfiHandlePtr; /* UEFI uses wide characters by default. */ typedef WideChar EfiCharType; @@ -582,15 +582,15 @@ typedef struct typedef EfiStatusType(EFI_API* EfiInputReadKey)( IN EfiSimpleTextInputProtocol* This, - OUT EfiInputKey* Key); + OUT EfiInputKey* Key); typedef EfiStatusType(EFI_API* EfiInputReset)( IN EfiSimpleTextInputProtocol* This, IN Boolean ExtendedChk); typedef EfiStatusType(EFI_API* EfiWaitForEvent)( - IN UInt32 NumberOfEvents, - IN VoidPtr Event, + IN UInt32 NumberOfEvents, + IN VoidPtr Event, OUT UInt32* Index); typedef struct EfiSimpleTextInputProtocol @@ -632,7 +632,7 @@ typedef struct EfiSystemTable { EfiGUID VendorGUID; VoidPtr VendorTable; - } * ConfigurationTable; + }* ConfigurationTable; } EfiSystemTable; #define kEfiOk 0 @@ -864,11 +864,11 @@ typedef struct _EfiProcessorInformation typedef EfiStatusType EFI_API (*EfiMpServicesGetNumberOfProcessors)( IN struct _EfiMpServicesProtocol* Self, - OUT UInt32* NumberOfProcessors, - OUT UInt32* NumberOfEnabledProcessors); + OUT UInt32* NumberOfProcessors, + OUT UInt32* NumberOfEnabledProcessors); typedef EfiStatusType EFI_API (*EfiMpServicesGetProcessorInfo)( - IN struct _EfiMpServicesProtocol* Self, + IN struct _EfiMpServicesProtocol* Self, IN UInt32* ProcessorNumber, OUT struct _EfiProcessorInformation* NumberOfEnabledProcessors); @@ -881,8 +881,8 @@ typedef EfiStatusType EFI_API (*EfiMpServicesStartupAllAPS)( IN Boolean SingleThread, IN VoidPtr WaitEvent OPTIONAL, // EFI_EVENT first, but unused here. IN UInt32 TimeoutInMicroSeconds, - IN Void* ProcedureArgument OPTIONAL, - OUT UInt32** FailedCpuList OPTIONAL); + IN Void* ProcedureArgument OPTIONAL, + OUT UInt32** FailedCpuList OPTIONAL); typedef EfiStatusType EFI_API (*EfiMpServicesSwitchBSP)( IN struct _EfiMpServicesProtocol* Self, @@ -895,18 +895,18 @@ typedef EfiStatusType EFI_API (*EfiMpServicesStartupThisAP)( IN UInt32 ProcessorNumber, IN VoidPtr WaitEvent OPTIONAL, IN UInt32 TimeoutInMicroseconds, - IN Void* ProcedureArgument OPTIONAL, - OUT Boolean* Finished OPTIONAL); + IN Void* ProcedureArgument OPTIONAL, + OUT Boolean* Finished OPTIONAL); typedef EfiStatusType EFI_API (*EfiMpServicesDisableThisAP)( IN struct _EfiMpServicesProtocol* Self, IN UInt32 ProcessorNumber, IN Boolean EnableAP, - IN UInt32* HealthFlag OPTIONAL); + IN UInt32* HealthFlag OPTIONAL); typedef EfiStatusType EFI_API (*EfiMpServicesWhoAmI)( IN struct _EfiMpServicesProtocol* Self, - OUT UInt32* ProcessorNumber); + OUT UInt32* ProcessorNumber); typedef struct _EfiMpServicesProtocol { diff --git a/dev/Kernel/HALKit/AMD64/Storage/ATA-PIO.cc b/dev/Kernel/HALKit/AMD64/Storage/ATA-PIO.cc index abee0649..c446cf9f 100644 --- a/dev/Kernel/HALKit/AMD64/Storage/ATA-PIO.cc +++ b/dev/Kernel/HALKit/AMD64/Storage/ATA-PIO.cc @@ -121,7 +121,7 @@ Void drv_std_read(UInt64 Lba, UInt16 IO, UInt8 Master, Char* Buf, SizeT SectorSz rt_out8(IO + ATA_REG_SEC_COUNT0, ((Size + SectorSz) / SectorSz)); - rt_out8(IO + ATA_REG_LBA0, (Lba)&0xFF); + rt_out8(IO + ATA_REG_LBA0, (Lba) & 0xFF); rt_out8(IO + ATA_REG_LBA1, (Lba) >> 8); rt_out8(IO + ATA_REG_LBA2, (Lba) >> 16); rt_out8(IO + ATA_REG_LBA3, (Lba) >> 24); @@ -153,7 +153,7 @@ Void drv_std_write(UInt64 Lba, UInt16 IO, UInt8 Master, Char* Buf, SizeT SectorS rt_out8(IO + ATA_REG_SEC_COUNT0, ((Size + (SectorSz)) / SectorSz)); - rt_out8(IO + ATA_REG_LBA0, (Lba)&0xFF); + rt_out8(IO + ATA_REG_LBA0, (Lba) & 0xFF); rt_out8(IO + ATA_REG_LBA1, (Lba) >> 8); rt_out8(IO + ATA_REG_LBA2, (Lba) >> 16); rt_out8(IO + ATA_REG_LBA3, (Lba) >> 24); diff --git a/dev/Kernel/HALKit/AMD64/Storage/SATA-DMA.cc b/dev/Kernel/HALKit/AMD64/Storage/SATA-DMA.cc index 8336dbd0..ef761416 100644 --- a/dev/Kernel/HALKit/AMD64/Storage/SATA-DMA.cc +++ b/dev/Kernel/HALKit/AMD64/Storage/SATA-DMA.cc @@ -47,7 +47,7 @@ enum }; STATIC Kernel::PCI::Device kPCIDevice; -STATIC HbaMem* kSATAPort = nullptr; +STATIC HbaMem* kSATAPort = nullptr; STATIC Kernel::SizeT kSATAPortIdx = 0UL; STATIC Kernel::Lba kCurrentDiskSectorCount = 0UL; diff --git a/dev/Kernel/HALKit/ARM64/Storage/MFlash+IO.cc b/dev/Kernel/HALKit/ARM64/Storage/MFlash+IO.cc index d01ee13c..5be94409 100644 --- a/dev/Kernel/HALKit/ARM64/Storage/MFlash+IO.cc +++ b/dev/Kernel/HALKit/ARM64/Storage/MFlash+IO.cc @@ -22,9 +22,9 @@ namespace Kernel constexpr auto kFlashBridgeMagic = "FLSH"; constexpr auto kFlashBridgeRevision = 1; - STATIC BOOL kFlashEnabled = NO; - STATIC SizeT kFlashSize[kMaxFlashSlots] = {}; - STATIC SizeT kFlashSectorSz[kMaxFlashSlots] = {}; + STATIC BOOL kFlashEnabled = NO; + STATIC SizeT kFlashSize[kMaxFlashSlots] = {}; + STATIC SizeT kFlashSectorSz[kMaxFlashSlots] = {}; STATIC IMBCIHost* kFlashMetaPackets[kMaxFlashSlots] = {}; STATIC IMBCIHost* kFlashDataPackets[kMaxFlashSlots] = {}; diff --git a/dev/Kernel/KernelKit/DriveMgr.h b/dev/Kernel/KernelKit/DriveMgr.h index d2765840..c1e42ba3 100644 --- a/dev/Kernel/KernelKit/DriveMgr.h +++ b/dev/Kernel/KernelKit/DriveMgr.h @@ -51,11 +51,9 @@ namespace Kernel { Char fName[kDriveNameLen]; // /System, /Boot, //./Devices/USB... Int32 fKind; // fMassStorage, fFloppy, fOpticalDisc. - Int32 fFlags; // fReadOnly, fXPMDrive, fXPTDrive - UInt64 fLbaEnd{0}; - UInt64 fLbaStart{0}; - UInt64 fSectorSz{512}; - /// @brief Packet drive (StorageKit compilant.) + Int32 fFlags; // fReadOnly, fEPMDrive... + + /// @brief Packet drive (StorageKit compilant.) struct DrivePacket final { VoidPtr fPacketContent{nullptr}; //! packet body. @@ -64,9 +62,11 @@ namespace Kernel UInt32 fPacketCRC32{0UL}; //! sanity crc, in case if good is set to false Boolean fPacketGood{YES}; Lba fPacketLba{0UL}; + SizeT fSectorSz{512}; Boolean fPacketReadOnly{NO}; - DriveTrait* fPacketDrive{nullptr}; - } fPacket; + } fPacket; + + Lba fLbaStart{0}, fLbaEnd{0}; Void (*fInput)(DrivePacket* packet_ptr); Void (*fOutput)(DrivePacket* packet_ptr); diff --git a/dev/Kernel/KernelKit/HardwareThreadScheduler.h b/dev/Kernel/KernelKit/HardwareThreadScheduler.h index 90ccd0d0..db4063bd 100644 --- a/dev/Kernel/KernelKit/HardwareThreadScheduler.h +++ b/dev/Kernel/KernelKit/HardwareThreadScheduler.h @@ -105,7 +105,7 @@ namespace Kernel public: Ref operator[](const SizeT& idx); bool operator!() noexcept; - operator bool() noexcept; + operator bool() noexcept; const Bool IsUser() override { diff --git a/dev/Kernel/KernelKit/IPEFDylibObject.h b/dev/Kernel/KernelKit/IPEFDylibObject.h index 1450ee89..a679c17d 100644 --- a/dev/Kernel/KernelKit/IPEFDylibObject.h +++ b/dev/Kernel/KernelKit/IPEFDylibObject.h @@ -100,7 +100,7 @@ namespace Kernel typedef IPEFDylibObject* IDylibRef; EXTERN_C IDylibRef rtl_init_dylib(UserProcess& header); - EXTERN_C Void rtl_fini_dylib(UserProcess& header, IDylibRef lib, Bool* successful); + EXTERN_C Void rtl_fini_dylib(UserProcess& header, IDylibRef lib, Bool* successful); } // namespace Kernel #endif /* ifndef __KERNELKIT_SHARED_OBJECT_H__ */ diff --git a/dev/Kernel/KernelKit/LoaderInterface.h b/dev/Kernel/KernelKit/LoaderInterface.h index e9bd7d7d..25cceac9 100644 --- a/dev/Kernel/KernelKit/LoaderInterface.h +++ b/dev/Kernel/KernelKit/LoaderInterface.h @@ -25,9 +25,9 @@ namespace Kernel public: virtual _Output ErrorOr GetBlob() = 0; - virtual _Output const Char* AsString() = 0; - virtual _Output const Char* MIME() = 0; - virtual _Output const Char* Path() = 0; + virtual _Output const Char* AsString() = 0; + virtual _Output const Char* MIME() = 0; + virtual _Output const Char* Path() = 0; virtual _Output ErrorOr FindStart() = 0; virtual _Output VoidPtr FindSymbol(_Input const Char* name, _Input Int32 kind) = 0; }; diff --git a/dev/Kernel/KernelKit/PCI/DMA.h b/dev/Kernel/KernelKit/PCI/DMA.h index c3978bec..bfe335ce 100644 --- a/dev/Kernel/KernelKit/PCI/DMA.h +++ b/dev/Kernel/KernelKit/PCI/DMA.h @@ -52,7 +52,7 @@ namespace Kernel T* Get(const UIntPtr off = 0); public: - operator bool(); + operator bool(); bool operator!(); public: diff --git a/dev/Kernel/KernelKit/UserProcessScheduler.h b/dev/Kernel/KernelKit/UserProcessScheduler.h index 060426c7..cc947ec1 100644 --- a/dev/Kernel/KernelKit/UserProcessScheduler.h +++ b/dev/Kernel/KernelKit/UserProcessScheduler.h @@ -288,7 +288,7 @@ namespace Kernel ZKA_COPY_DEFAULT(UserProcessScheduler) - operator bool(); + operator bool(); bool operator!(); public: diff --git a/dev/Kernel/NewKit/Macros.h b/dev/Kernel/NewKit/Macros.h index 528a2689..c38abae2 100644 --- a/dev/Kernel/NewKit/Macros.h +++ b/dev/Kernel/NewKit/Macros.h @@ -11,7 +11,7 @@ #endif #ifndef kib_cast -#define kib_cast(X) (Kernel::UInt64)((X)*1024) +#define kib_cast(X) (Kernel::UInt64)((X) * 1024) #endif #ifndef MIB diff --git a/dev/Kernel/src/DriveMgr.cc b/dev/Kernel/src/DriveMgr.cc index 09702351..cccfebfe 100644 --- a/dev/Kernel/src/DriveMgr.cc +++ b/dev/Kernel/src/DriveMgr.cc @@ -29,30 +29,15 @@ namespace Kernel /// @return Void io_drv_input(DriveTrait::DrivePacket* pckt) { - if (!pckt || !pckt->fPacketDrive) + if (!pckt) { return; } - if (!StringBuilder::Equals("fs/detect-packet", pckt->fPacketMime) && - pckt->fPacketDrive->fLbaStart > 0 && pckt->fPacketDrive->fLbaEnd > 0) - { - if (pckt->fPacketLba > pckt->fPacketDrive->fLbaEnd) - { - pckt->fPacketGood = NO; - return; - } - else if (pckt->fPacketLba < pckt->fPacketDrive->fLbaStart) - { - pckt->fPacketGood = NO; - return; - } - } - #ifdef __AHCI__ - drv_std_read(pckt->fPacketLba, (Char*)pckt->fPacketContent, pckt->fPacketDrive->fSectorSz, pckt->fPacketSize); + drv_std_read(pckt->fPacketLba, (Char*)pckt->fPacketContent, pckt->fSectorSz, pckt->fPacketSize); #elif defined(__ATA_PIO__) || defined(__ATA_DMA__) - drv_std_read(pckt->fPacketLba, kATAIO, kATAMaster, (Char*)pckt->fPacketContent, pckt->fPacketDrive->fSectorSz, pckt->fPacketSize); + drv_std_read(pckt->fPacketLba, kATAIO, kATAMaster, (Char*)pckt->fPacketContent, pckt->fSectorSz, pckt->fPacketSize); #endif } @@ -61,7 +46,7 @@ namespace Kernel /// @return Void io_drv_output(DriveTrait::DrivePacket* pckt) { - if (!pckt || !pckt->fPacketDrive) + if (!pckt) { return; } @@ -72,25 +57,10 @@ namespace Kernel return; } - if (!StringBuilder::Equals("fs/detect-packet", pckt->fPacketMime) && - pckt->fPacketDrive->fLbaStart > 0 && pckt->fPacketDrive->fLbaEnd > 0) - { - if (pckt->fPacketLba > pckt->fPacketDrive->fLbaEnd) - { - pckt->fPacketGood = NO; - return; - } - else if (pckt->fPacketLba < pckt->fPacketDrive->fLbaStart) - { - pckt->fPacketGood = NO; - return; - } - } - #ifdef __AHCI__ - drv_std_write(pckt->fPacketLba, (Char*)pckt->fPacketContent, pckt->fPacketDrive->fSectorSz, pckt->fPacketSize); + drv_std_write(pckt->fPacketLba, (Char*)pckt->fPacketContent, pckt->fSectorSz, pckt->fPacketSize); #elif defined(__ATA_PIO__) || defined(__ATA_DMA__) - drv_std_write(pckt->fPacketLba, kATAIO, kATAMaster, (Char*)pckt->fPacketContent, pckt->fPacketDrive->fSectorSz, pckt->fPacketSize); + drv_std_write(pckt->fPacketLba, kATAIO, kATAMaster, (Char*)pckt->fPacketContent, pckt->fSectorSz, pckt->fPacketSize); #endif } @@ -104,7 +74,7 @@ namespace Kernel return; } -#if defined( __ATA_PIO__ ) || defined( __ATA_DMA__ ) +#if defined(__ATA_PIO__) || defined(__ATA_DMA__) kATAMaster = 0; kATAIO = 0; #endif @@ -168,7 +138,6 @@ namespace Kernel /// @brief Unimplemented drive function. /// @param pckt the packet to read. - /// @return Void io_drv_unimplemented(DriveTrait::DrivePacket* pckt) noexcept { ZKA_UNUSED(pckt); @@ -200,15 +169,6 @@ namespace Kernel { EPM_PART_BLOCK block_struct; - trait.fPacket.fPacketDrive = &trait; - -#ifdef __ATA_PIO__ - trait.fSectorSz = kATASectorSize; -#elif defined(__AHCI__) - trait.fSectorSz = kAHCISectorSize; -#else - trait.fSectorSz = 512; -#endif trait.fPacket.fPacketLba = kEPMBootBlockLba; trait.fPacket.fPacketSize = sizeof(EPM_PART_BLOCK); trait.fPacket.fPacketContent = &block_struct; @@ -227,11 +187,11 @@ namespace Kernel kcout << "Formatted Disk is EPM (Mass Storage)\r"; - trait.fSectorSz = block_struct.SectorSz; + trait.fPacket.fSectorSz = block_struct.SectorSz; trait.fLbaEnd = block_struct.LbaEnd; trait.fLbaStart = block_struct.LbaStart; - if (trait.fSectorSz == 0) + if (trait.fPacket.fSectorSz == 0) { ke_panic(RUNTIME_CHECK_FAILED, "Invalid EPM partition!"); } @@ -244,7 +204,7 @@ namespace Kernel kcout << "Scheme Found: " << block_struct.Name << endl; if (block_struct.Name[0] == 0) - kcout << "Disk partition is unknown (Read Only)\r"; + kcout << "Disk partition is empty (Read Only)\r"; } rt_copy_memory((VoidPtr) "*/*", trait.fPacket.fPacketMime, diff --git a/dev/Kernel/src/FS/NeFS.cc b/dev/Kernel/src/FS/NeFS.cc index 0dad44f8..531c852e 100644 --- a/dev/Kernel/src/FS/NeFS.cc +++ b/dev/Kernel/src/FS/NeFS.cc @@ -60,45 +60,41 @@ STATIC MountpointInterface kMountpoint; /// @param the_fork the fork itself. /// @return the fork /***********************************************************************************/ -_Output BOOL NeFileSystemParser::CreateFork(_Input NFS_CATALOG_STRUCT* catalog, - _Input NFS_FORK_STRUCT& the_fork) +_Output BOOL NeFileSystemParser::CreateFork(_Input NFS_FORK_STRUCT& the_fork) { - if (catalog && the_fork.ForkName[0] != 0 && - the_fork.DataSize > 0) + if (the_fork.ForkName[0] != 0 && + the_fork.CatalogName[0] != 0 && + the_fork.DataSize > 0) { - Lba lba = (the_fork.Kind == kNeFSDataForkKind) ? catalog->DataFork - : catalog->ResourceFork; + auto catalog = this->GetCatalog(the_fork.CatalogName); - kcout << "Fork lba: " << hex_number(lba) << endl; + if (!catalog) + return NO; + + Lba lba = catalog->DataFork; + + kcout << "Fork LBA: " << hex_number(lba) << endl; if (lba < kNeFSCatalogStartAddress) return NO; auto drv = kMountpoint.A(); - /// special treatment. - rt_copy_memory((VoidPtr) "fs/nefs-packet", drv.fPacket.fPacketMime, - rt_string_len("fs/nefs-packet")); - - NFS_FORK_STRUCT curFork{0}; - NFS_FORK_STRUCT prevFork{0}; Lba lbaOfPreviousFork = lba; + NFS_FORK_STRUCT prevFork; + /// do not check for anything. Loop until we get what we want, that is a free fork zone. - while (YES) + while (drv.fPacket.fPacketGood) { - drv.fPacket.fPacketLba = lba; + NFS_FORK_STRUCT curFork; + + drv.fPacket.fPacketLba = lba; drv.fPacket.fPacketSize = sizeof(NFS_FORK_STRUCT); drv.fPacket.fPacketContent = &curFork; drv.fInput(&drv.fPacket); - if (curFork.NextSibling > kBadAddress) - { - kcout << "Bad fork: " << hex_number(curFork.NextSibling) << endl; - return NO; - } - kcout << "Next fork: " << hex_number(curFork.NextSibling) << endl; if (curFork.Flags & kNeFSFlagCreated) @@ -107,8 +103,8 @@ _Output BOOL NeFileSystemParser::CreateFork(_Input NFS_CATALOG_STRUCT* catalog, /// sanity check. if (StringBuilder::Equals(curFork.ForkName, the_fork.ForkName) && - StringBuilder::Equals(curFork.CatalogName, catalog->Name)) - return NO; + StringBuilder::Equals(curFork.CatalogName, the_fork.CatalogName)) + break; kcout << "Next fork: " << hex_number(curFork.NextSibling) << endl; @@ -137,18 +133,17 @@ _Output BOOL NeFileSystemParser::CreateFork(_Input NFS_CATALOG_STRUCT* catalog, } } - constexpr auto kForkPadding = - 4; /// this value gives us space for the data offset. - the_fork.Flags |= kNeFSFlagCreated; the_fork.DataOffset = lba - sizeof(NFS_FORK_STRUCT); the_fork.PreviousSibling = lbaOfPreviousFork; - the_fork.NextSibling = (the_fork.DataOffset - the_fork.DataSize - sizeof(NFS_FORK_STRUCT)) * kForkPadding; + the_fork.NextSibling = (the_fork.DataOffset - the_fork.DataSize - sizeof(NFS_FORK_STRUCT)); drv.fPacket.fPacketLba = lba; drv.fPacket.fPacketSize = sizeof(NFS_FORK_STRUCT); drv.fPacket.fPacketContent = &the_fork; + kcout << "Writing fork...\r"; + drv.fOutput(&drv.fPacket); /// log what we have now. @@ -170,8 +165,8 @@ _Output BOOL NeFileSystemParser::CreateFork(_Input NFS_CATALOG_STRUCT* catalog, /// @return the fork. /***********************************************************************************/ _Output NFS_FORK_STRUCT* NeFileSystemParser::FindFork(_Input NFS_CATALOG_STRUCT* catalog, - _Input const Char* name, - Boolean isDataFork) + _Input const Char* name, + Boolean isDataFork) { auto drive = kMountpoint.A(); NFS_FORK_STRUCT* the_fork = nullptr; @@ -236,7 +231,7 @@ _Output NFS_CATALOG_STRUCT* NeFileSystemParser::CreateCatalog(_Input const Char* /// @param kind the catalog kind. /// @return catalog pointer. /***********************************************************************************/ -_Output NFS_CATALOG_STRUCT* NeFileSystemParser::CreateCatalog(_Input const Char* name, +_Output NFS_CATALOG_STRUCT* NeFileSystemParser::CreateCatalog(_Input const Char* name, _Input const Int32& flags, _Input const Int32& kind) { @@ -939,7 +934,7 @@ Boolean NeFileSystemParser::RemoveCatalog(_Input const Char* catalog_name) VoidPtr NeFileSystemParser::ReadCatalog(_Input _Output NFS_CATALOG_STRUCT* catalog, _Input Bool is_rsrc_fork, _Input SizeT dataSz, - _Input const Char* forkName) + _Input const Char* forkName) { if (!catalog) { @@ -1037,7 +1032,6 @@ namespace Kernel::NeFS kcout << "Creating A:\r"; kMountpoint.A() = io_construct_main_drive(); - kMountpoint.A().fPacket.fPacketDrive = &kMountpoint.A(); kcout << "Creating A: [ OK ]\r"; -- cgit v1.2.3