From 33e44574e6fb4c571a370d5ebdfdf1cdb6735763 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Sun, 31 Mar 2024 21:06:50 +0200 Subject: FirmwareKit: Update EPM specs and implementation. Signed-off-by: Amlal El Mahrouss --- Private/FirmwareKit/EPM.hxx | 17 ++++++++++------- Private/NewBoot/Source/HEL/AMD64/BootEPM.cxx | 16 ++++++++-------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/Private/FirmwareKit/EPM.hxx b/Private/FirmwareKit/EPM.hxx index 7dab6edc..b26c722b 100644 --- a/Private/FirmwareKit/EPM.hxx +++ b/Private/FirmwareKit/EPM.hxx @@ -37,7 +37,7 @@ struct PACKED BootBlock { NewOS::Int32 Version; NewOS::Int64 NumBlocks; NewOS::Int64 SectorSz; - NewOS::Int64 SectorStart; + NewOS::Int64 LbaStart; }; /** @@ -46,12 +46,12 @@ struct PACKED BootBlock { */ struct PACKED PartitionBlock { NewOS::Char Name[kEPMNameLength]; - NewOS::Int32 Magic; - NewOS::Int64 SectorEnd; + NewOS::Int32 Version; + NewOS::Int64 LbaEnd; NewOS::Int64 SectorSz; - NewOS::Int64 SectorStart; + NewOS::Int64 LbaStart; NewOS::Int16 Kind; - NewOS::Int32 Version; + NewOS::Int32 FsVersion; NewOS::Char Fs[kEPMFilesystemLength]; /* NewFS, HCFS... */ }; @@ -100,8 +100,11 @@ typedef struct PartitionBlock PartitionBlockType; #define kEPMMagic kEPMMagicError #endif -/// partition must start after this address. -#define kEPMStartPartitionBlk 34 +///! @brief partition must start after this address. +#define kEPMStartPartitionBlk 0 + +///! @brief Current EPM revision (2) +#define kEPMRevision 2 /// END SPECS diff --git a/Private/NewBoot/Source/HEL/AMD64/BootEPM.cxx b/Private/NewBoot/Source/HEL/AMD64/BootEPM.cxx index 52c6a001..9a858a68 100644 --- a/Private/NewBoot/Source/HEL/AMD64/BootEPM.cxx +++ b/Private/NewBoot/Source/HEL/AMD64/BootEPM.cxx @@ -43,7 +43,7 @@ EXTERN_C Boolean boot_write_epm_partition(const Char* namePart, SizeT namePartLe BootBlockType* bootBlock = (BootBlockType*)buf; - bootBlock->Version = kEPMNewOS; + bootBlock->Version = kEPMRevision; bootBlock->NumBlocks = 2; for (SizeT i = 0; i < kEPMNameLength; i++) { @@ -54,7 +54,7 @@ EXTERN_C Boolean boot_write_epm_partition(const Char* namePart, SizeT namePartLe bootBlock->Name[i] = namePart[i]; } - bootBlock->SectorStart = + bootBlock->LbaStart = sizeof(BootBlockType) + (sizeof(PartitionBlockType) * kEPMMaxBlks); bootBlock->SectorSz = kATASectorSize; @@ -70,7 +70,7 @@ EXTERN_C Boolean boot_write_epm_partition(const Char* namePart, SizeT namePartLe partBlock->Fs[i] = fsName[i]; } - partBlock->Magic = kEPMNewOS; + partBlock->Version = kEPMNewOS; char* partName = "System HD"; int partNameLength = 10; @@ -80,10 +80,10 @@ EXTERN_C Boolean boot_write_epm_partition(const Char* namePart, SizeT namePartLe } partBlock->SectorSz = kATASectorSize; - partBlock->SectorStart = kEPMStartPartitionBlk + kSwapSize; + partBlock->LbaStart = kEPMStartPartitionBlk + kSwapSize; partBlock->Version = kNewFSVersionInteger; partBlock->Kind = kNewFSPartitionTypeStandard; - partBlock->SectorEnd = 0; /// grows on the disk. + partBlock->LbaEnd = 0UL; ///! grows on the disk. PartitionBlock* swapBlock = (PartitionBlock*)(buf + sizeof(BootBlock) + sizeof(PartitionBlock)); @@ -91,7 +91,7 @@ EXTERN_C Boolean boot_write_epm_partition(const Char* namePart, SizeT namePartLe swapBlock->Fs[i] = fsName[i]; } - swapBlock->Magic = kEPMNewOS; + swapBlock->Version = kEPMNewOS; partName = "Swap HD"; partNameLength = 8; @@ -101,10 +101,10 @@ EXTERN_C Boolean boot_write_epm_partition(const Char* namePart, SizeT namePartLe } swapBlock->SectorSz = kATASectorSize; - swapBlock->SectorStart = kEPMStartPartitionBlk; + swapBlock->LbaStart = kEPMStartPartitionBlk; swapBlock->Version = kNewFSVersionInteger; swapBlock->Kind = kNewFSPartitionTypePage; - swapBlock->SectorEnd = kSwapSize; /// 4 MIB swap partition. + swapBlock->LbaEnd = kSwapSize; /// 4 MIB swap partition. ataInterface->Write(buf, 1); -- cgit v1.2.3