From 40980a0c8e32a3cb650d1e5821a8ae5daa4628f4 Mon Sep 17 00:00:00 2001 From: Amlal Date: Wed, 30 Apr 2025 08:59:50 +0200 Subject: kernel: filesystem+vmem: don't be verbose on the allocator when we don't need it. details: - Reworked HeFS traversal algorithm, fixing last parts of HeFS regarding IND allocation. Signed-off-by: Amlal --- dev/boot/BootKit/BootKit.h | 76 ++++++++++++++++++++------------------- dev/boot/modules/SysChk/SysChk.cc | 2 +- 2 files changed, 40 insertions(+), 38 deletions(-) (limited to 'dev/boot') diff --git a/dev/boot/BootKit/BootKit.h b/dev/boot/BootKit/BootKit.h index d10ce0de..715f6426 100644 --- a/dev/boot/BootKit/BootKit.h +++ b/dev/boot/BootKit/BootKit.h @@ -225,16 +225,16 @@ class BDiskFormatFactory final { return true; #else - GPT_PARTITION_TABLE gpt_part{}; + GPT_PARTITION_TABLE* gpt_part = (GPT_PARTITION_TABLE*) RTL_ALLOCA(sizeof(GPT_PARTITION_TABLE)); fDiskDev.Leak().mBase = (kGPTPartitionTableLBA); fDiskDev.Leak().mSize = sizeof(GPT_PARTITION_TABLE); - fDiskDev.Read((Char*) &gpt_part, sizeof(GPT_PARTITION_TABLE)); + fDiskDev.Read((Char*) gpt_part, sizeof(GPT_PARTITION_TABLE)); BootTextWriter writer; - if (StrCmp(gpt_part.Signature, kMagicGPT) == 0) { + if (StrCmp(gpt_part->Signature, kMagicGPT) == 0) { writer.Write("BootZ: GPT Partition found.\r"); return true; } @@ -256,74 +256,76 @@ class BDiskFormatFactory final { template inline Boolean BDiskFormatFactory::Format(const Char* part_name) { #if defined(BOOTZ_EPM_SUPPORT) - EPM_PART_BLOCK epm_boot{}; + EPM_PART_BLOCK* epm_boot = (EPM_PART_BLOCK*) RTL_ALLOCA(sizeof(EPM_PART_BLOCK)); const auto kFsName = "HeFS"; const auto kBlockName = "OS (EPM)"; - epm_boot.FsVersion = 0; - epm_boot.LbaStart = sizeof(EPM_PART_BLOCK); - epm_boot.LbaEnd = fDiskDev.GetDiskSize() - 1; - epm_boot.SectorSz = BootDev::kSectorSize; - epm_boot.Kind = kEPMNeKernel; - epm_boot.NumBlocks = 1; + epm_boot->FsVersion = 0; + epm_boot->LbaStart = sizeof(EPM_PART_BLOCK); + epm_boot->LbaEnd = fDiskDev.GetDiskSize() - 1; + epm_boot->SectorSz = BootDev::kSectorSize; + epm_boot->Kind = kEPMNeKernel; + epm_boot->NumBlocks = 1; - epm_boot.Guid = kEPMNilGuid; + epm_boot->Guid = kEPMNilGuid; - CopyMem(epm_boot.Fs, reinterpret_cast(const_cast(kFsName)), StrLen(kFsName)); - CopyMem(epm_boot.Name, reinterpret_cast(const_cast(kBlockName)), + CopyMem(epm_boot->Fs, reinterpret_cast(const_cast(kFsName)), StrLen(kFsName)); + CopyMem(epm_boot->Name, reinterpret_cast(const_cast(kBlockName)), StrLen(kBlockName)); - CopyMem(epm_boot.Magic, reinterpret_cast(const_cast(kEPMMagic)), + CopyMem(epm_boot->Magic, reinterpret_cast(const_cast(kEPMMagic)), StrLen(kEPMMagic)); fDiskDev.Leak().mBase = kEPMBootBlockLba; // always always resies at zero block. fDiskDev.Leak().mSize = sizeof(EPM_PART_BLOCK); - fDiskDev.Write((Char*) &epm_boot, sizeof(EPM_PART_BLOCK)); + fDiskDev.Write((Char*) epm_boot, sizeof(EPM_PART_BLOCK)); BootTextWriter writer; writer.Write(L"BootZ: Drive is EPM formatted.\r"); -#elif defined(BOOTZ_VEPM_SUPPORT) +#elif defined(BOOTZ_GPT_SUPPORT) NE_UNUSED(part_name); - GPT_PARTITION_TABLE gpt_part{}; + GPT_PARTITION_TABLE* gpt_part = (GPT_PARTITION_TABLE*) RTL_ALLOCA(sizeof(GPT_PARTITION_TABLE)); - CopyMem(gpt_part.Signature, reinterpret_cast(const_cast(kMagicGPT)), + CopyMem(gpt_part->Signature, reinterpret_cast(const_cast(kMagicGPT)), StrLen(kMagicGPT)); - gpt_part.Revision = 0x00010000; - gpt_part.HeaderSize = sizeof(GPT_PARTITION_TABLE); + gpt_part->Revision = 0x00010000; + gpt_part->HeaderSize = sizeof(GPT_PARTITION_TABLE); - gpt_part.CRC32 = 0x00000000; + gpt_part->CRC32 = 0x00000000; - gpt_part.Reserved1 = 0x00000000; - gpt_part.LBAHeader = 0x00000000; - gpt_part.LBAAltHeader = 0x00000000; - gpt_part.FirstGPTEntry = 0x00000000; - gpt_part.LastGPTEntry = 0x00000000; + gpt_part->Reserved1 = 0x00000000; + gpt_part->LBAHeader = 0x00000000; + gpt_part->LBAAltHeader = 0x00000000; + gpt_part->FirstGPTEntry = 0x00000000; + gpt_part->LastGPTEntry = 0x00000000; - gpt_part.Guid.Data1 = 0x00000000; - gpt_part.Guid.Data2 = 0x0000; - gpt_part.Guid.Data3 = 0x0000; + gpt_part->Guid.Data1 = 0x00000000; + gpt_part->Guid.Data2 = 0x0000; + gpt_part->Guid.Data3 = 0x0000; - SetMem(gpt_part.Guid.Data4, 0, 8); + SetMem(gpt_part->Guid.Data4, 0, 8); - gpt_part.Revision = 0x00010000; + gpt_part->Revision = 0x00010000; - gpt_part.StartingLBA = 0x00000000; - gpt_part.NumPartitionEntries = 0x00000000; - gpt_part.SizeOfEntries = 0x00000000; - gpt_part.CRC32PartEntry = 0x00000000; + gpt_part->StartingLBA = 0x00000000; + gpt_part->NumPartitionEntries = 0x00000000; + gpt_part->SizeOfEntries = 0x00000000; + gpt_part->CRC32PartEntry = 0x00000000; - SetMem(gpt_part.Reserved2, 0, kSectorAlignGPT_PartTbl); + SetMem(gpt_part->Reserved2, 0, kSectorAlignGPT_PartTbl); fDiskDev.Leak().mBase = kGPTPartitionTableLBA; // always always resies at zero block. fDiskDev.Leak().mSize = sizeof(GPT_PARTITION_TABLE); - fDiskDev.Write((Char*) &gpt_part, sizeof(GPT_PARTITION_TABLE)); + fDiskDev.Write((Char*) gpt_part, sizeof(GPT_PARTITION_TABLE)); BootTextWriter writer; writer.Write(L"BootZ: Drive is GPT formatted.\r"); +#else + NE_UNUSED(part_name); #endif return YES; diff --git a/dev/boot/modules/SysChk/SysChk.cc b/dev/boot/modules/SysChk/SysChk.cc index c93ef83b..1c5255fb 100644 --- a/dev/boot/modules/SysChk/SysChk.cc +++ b/dev/boot/modules/SysChk/SysChk.cc @@ -24,7 +24,7 @@ // Makes the compiler shut up. #ifndef kMachineModel #define kMachineModel "OS" -#endif // !kMachineModel +#endif // !kMachineModel EXTERN_C Int32 SysChkModuleMain(Kernel::HEL::BootInfoHeader* handover) { fw_init_efi((EfiSystemTable*) handover->f_FirmwareCustomTables[1]); -- cgit v1.2.3