[edk2-devel] [PATCH v3 1/1] [edk2-platforms]Tools\FitGen: Add extra parameter fixed FIT address
From: fanwang2intel Add "-T " parameter to provide fixed FIT address on flash region. When this parameter is set to a valid address in the input FD/FV file, tool will directly generate FIT on this address. It's users' responsibilities to reserve enough size for FIT table and option modules on the target location, otherwise, FIT Gen process will fail. Cc: Chen Christine Cc: Bob Feng Signed-off-by: fanwang2intel --- Silicon/Intel/Tools/FitGen/FitGen.c | 163 ++-- 1 file changed, 120 insertions(+), 43 deletions(-) diff --git a/Silicon/Intel/Tools/FitGen/FitGen.c b/Silicon/Intel/Tools/FitGen/FitGen.c index 290e688f6e4e..4de72ea4225e 100644 --- a/Silicon/Intel/Tools/FitGen/FitGen.c +++ b/Silicon/Intel/Tools/FitGen/FitGen.c @@ -345,6 +345,7 @@ Returns: "\t[-M ] [-M ...]|[-U ||] [-V ]\n" "\t[-O RecordType [-V ]] [-O ... [-V ...]]\n" "\t[-P RecordType [-V ]] [-P ... [-V ...]]\n" + "\t[-T ]\n" , UTILITY_NAME); printf (" Where:\n"); printf ("\t-D - It is FD file instead of FV file. (The tool will search FV file)\n"); @@ -388,6 +389,7 @@ Returns: printf ("\tWidth - The Width of the port.\n"); printf ("\tBit- The Bit Number of the port.\n"); printf ("\tIndex - The Index Number of the port.\n"); + printf ("\tFixedFitLocation - Fixed FIT location in flash address. FIT table will be generated at this location and Option Modules will be directly put right before it.\n"); printf ("\nUsage (view): %s [-view] InputFile -F \n", UTILITY_NAME); printf (" Where:\n"); printf ("\tInputFile - Name of the input file.\n"); @@ -445,6 +447,46 @@ CheckPath ( return TRUE; } +UINT32 +GetFixedFitLocation ( + IN INTN argc, + IN CHAR8 **argv + ) +/*++ + +Routine Description: + + Get fixed FIT location from argument + +Arguments: + + argc - Number of command line parameters. + argv - Array of pointers to parameter strings. + +Returns: + + FitLocation - The FIT location specified by Argument + 0 - Argument parse fail + +*/ +{ + UINT32 FitLocation; + INTNIndex; + + FitLocation = 0; + + for (Index = 0; Index + 1 < argc; Index ++) { + +if ((strcmp (argv[Index], "-T") == 0) || +(strcmp (argv[Index], "-t") == 0) ) { + FitLocation = xtoi (argv[Index + 1]); + break; +} + } + + return FitLocation; +} + STATUS ReadInputFile ( IN CHAR8*FileName, @@ -1909,10 +1951,11 @@ Returns: } VOID * -GetFreeSpaceFromFv ( +GetFreeSpaceForFit ( IN UINT8 *FvBuffer, IN UINT32FvSize, - IN UINT32FitEntryNumber + IN UINT32FitTableSize, + IN UINT32FixedFitLocation ) /*++ @@ -1922,9 +1965,10 @@ Routine Description: Arguments: - FvBuffer - FvRecovery binary buffer - FvSize - FvRecovery size - FitEntryNumber - The FIT entry number + FvBuffer - FvRecovery binary buffer + FvSize - FvRecovery size + FitTableSize - The FIT table size + FixedFitLocation - Fixed FIT location provided by argument Returns: @@ -1939,7 +1983,6 @@ Returns: UINT8 *OptionalModuleAddress; EFI_GUIDVTFGuid = EFI_FFS_VOLUME_TOP_FILE_GUID; UINT32 AlignedSize; - UINT32 FitTableSize; EFI_FIRMWARE_VOLUME_HEADER *FvHeader; EFI_FFS_FILE_HEADER *FileHeader; @@ -1966,45 +2009,62 @@ Returns: } } - // - // Get EFI_FFS_VOLUME_TOP_FILE_GUID location - // - FitTableOffset = NULL; + if (FixedFitLocation != 0) { +// +// Get Free space from fixed location +// +FitTableOffset = (UINT8 *) FLASH_TO_MEMORY (FixedFitLocation, FvBuffer, FvSize); + } else { +// +// Get Free Space from FvRecovery +// +FitTableOffset = NULL; - FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *)FvBuffer; - FvLength = FvHeader->FvLength; - FileHeader = (EFI_FFS_FILE_HEADER *)(FvBuffer + FvHeader->HeaderLength); - Offset = (UINTN)FileHeader - (UINTN)FvBuffer; +FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *)FvBuffer; +FvLength = FvHeader->FvLength; +FileHeader = (EFI_FFS_FILE_HEADER *)(FvBuffer + FvHeader->HeaderLength); +Offset = (UINTN)FileHeader - (UINTN)FvBuffer; - while (Offset < FvLength) { -FileLength = (*(UINT32 *)(FileHeader->Size)) & 0x00FF; -FileOccupiedSize = GETOCCUPIEDSIZE(FileLength, 8); -if ((CompareGuid (&(FileHeader->Name), &VTFGuid)) == 0) { - // find it - FitTableOffset = (UINT8 *)FileHeader; - break; +// +// Get EFI_FFS_VOLUME_TOP_FILE_GUID location +// +while (Offset < FvLength) { + FileLength = (*(UINT32 *)(FileHeader->Size)) & 0x00FF; + FileOccupiedSize = GETOCCUPIEDSIZE(FileLength, 8); + if ((CompareGuid (&(FileHeader->Name), &VTFGuid)) == 0) { +// find it +
[edk2-devel] [PATCH v2 1/1] Tools\FitGen: Add extra parameter fixed FIT address
From: fanwang2intel Add "-T " parameter to provide fixed FIT address on flash region. When this parameter is set to a valid address in the input FD/FV file, tool will directly generate FIT on this address. It's users' responsibilities to reserve enough size for FIT table and option modules on the target location, otherwise, FIT Gen process will fail. Cc: Chen Christine Cc: Bob Feng Signed-off-by: fanwang2intel --- Silicon/Intel/Tools/FitGen/FitGen.c | 163 ++-- 1 file changed, 120 insertions(+), 43 deletions(-) diff --git a/Silicon/Intel/Tools/FitGen/FitGen.c b/Silicon/Intel/Tools/FitGen/FitGen.c index 290e688f6e4e..4de72ea4225e 100644 --- a/Silicon/Intel/Tools/FitGen/FitGen.c +++ b/Silicon/Intel/Tools/FitGen/FitGen.c @@ -345,6 +345,7 @@ Returns: "\t[-M ] [-M ...]|[-U ||] [-V ]\n" "\t[-O RecordType [-V ]] [-O ... [-V ...]]\n" "\t[-P RecordType [-V ]] [-P ... [-V ...]]\n" + "\t[-T ]\n" , UTILITY_NAME); printf (" Where:\n"); printf ("\t-D - It is FD file instead of FV file. (The tool will search FV file)\n"); @@ -388,6 +389,7 @@ Returns: printf ("\tWidth - The Width of the port.\n"); printf ("\tBit- The Bit Number of the port.\n"); printf ("\tIndex - The Index Number of the port.\n"); + printf ("\tFixedFitLocation - Fixed FIT location in flash address. FIT table will be generated at this location and Option Modules will be directly put right before it.\n"); printf ("\nUsage (view): %s [-view] InputFile -F \n", UTILITY_NAME); printf (" Where:\n"); printf ("\tInputFile - Name of the input file.\n"); @@ -445,6 +447,46 @@ CheckPath ( return TRUE; } +UINT32 +GetFixedFitLocation ( + IN INTN argc, + IN CHAR8 **argv + ) +/*++ + +Routine Description: + + Get fixed FIT location from argument + +Arguments: + + argc - Number of command line parameters. + argv - Array of pointers to parameter strings. + +Returns: + + FitLocation - The FIT location specified by Argument + 0 - Argument parse fail + +*/ +{ + UINT32 FitLocation; + INTNIndex; + + FitLocation = 0; + + for (Index = 0; Index + 1 < argc; Index ++) { + +if ((strcmp (argv[Index], "-T") == 0) || +(strcmp (argv[Index], "-t") == 0) ) { + FitLocation = xtoi (argv[Index + 1]); + break; +} + } + + return FitLocation; +} + STATUS ReadInputFile ( IN CHAR8*FileName, @@ -1909,10 +1951,11 @@ Returns: } VOID * -GetFreeSpaceFromFv ( +GetFreeSpaceForFit ( IN UINT8 *FvBuffer, IN UINT32FvSize, - IN UINT32FitEntryNumber + IN UINT32FitTableSize, + IN UINT32FixedFitLocation ) /*++ @@ -1922,9 +1965,10 @@ Routine Description: Arguments: - FvBuffer - FvRecovery binary buffer - FvSize - FvRecovery size - FitEntryNumber - The FIT entry number + FvBuffer - FvRecovery binary buffer + FvSize - FvRecovery size + FitTableSize - The FIT table size + FixedFitLocation - Fixed FIT location provided by argument Returns: @@ -1939,7 +1983,6 @@ Returns: UINT8 *OptionalModuleAddress; EFI_GUIDVTFGuid = EFI_FFS_VOLUME_TOP_FILE_GUID; UINT32 AlignedSize; - UINT32 FitTableSize; EFI_FIRMWARE_VOLUME_HEADER *FvHeader; EFI_FFS_FILE_HEADER *FileHeader; @@ -1966,45 +2009,62 @@ Returns: } } - // - // Get EFI_FFS_VOLUME_TOP_FILE_GUID location - // - FitTableOffset = NULL; + if (FixedFitLocation != 0) { +// +// Get Free space from fixed location +// +FitTableOffset = (UINT8 *) FLASH_TO_MEMORY (FixedFitLocation, FvBuffer, FvSize); + } else { +// +// Get Free Space from FvRecovery +// +FitTableOffset = NULL; - FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *)FvBuffer; - FvLength = FvHeader->FvLength; - FileHeader = (EFI_FFS_FILE_HEADER *)(FvBuffer + FvHeader->HeaderLength); - Offset = (UINTN)FileHeader - (UINTN)FvBuffer; +FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *)FvBuffer; +FvLength = FvHeader->FvLength; +FileHeader = (EFI_FFS_FILE_HEADER *)(FvBuffer + FvHeader->HeaderLength); +Offset = (UINTN)FileHeader - (UINTN)FvBuffer; - while (Offset < FvLength) { -FileLength = (*(UINT32 *)(FileHeader->Size)) & 0x00FF; -FileOccupiedSize = GETOCCUPIEDSIZE(FileLength, 8); -if ((CompareGuid (&(FileHeader->Name), &VTFGuid)) == 0) { - // find it - FitTableOffset = (UINT8 *)FileHeader; - break; +// +// Get EFI_FFS_VOLUME_TOP_FILE_GUID location +// +while (Offset < FvLength) { + FileLength = (*(UINT32 *)(FileHeader->Size)) & 0x00FF; + FileOccupiedSize = GETOCCUPIEDSIZE(FileLength, 8); + if ((CompareGuid (&(FileHeader->Name), &VTFGuid)) == 0) { +// find it +
[edk2-devel] [PATCH v1 1/1] Tools\FitGen: Add extra parameter fixed FIT address
From: fanwang2intel Add "-T " parameter to provide fixed FIT address on flash region. When this parameter is set to a valid address in the input FD/FV file, tool will directly generate FIT on this address. It's users' responsibilities to reserve enough size for FIT table and option modules on the target location, otherwise, FIT Gen process will fail. Cc: Chen Christine Cc: Bob Feng Signed-off-by: fanwang2intel --- Silicon/Intel/Tools/FitGen/FitGen.c | 163 ++-- 1 file changed, 120 insertions(+), 43 deletions(-) diff --git a/Silicon/Intel/Tools/FitGen/FitGen.c b/Silicon/Intel/Tools/FitGen/FitGen.c index 290e688f6e4e..43f1cba25ec1 100644 --- a/Silicon/Intel/Tools/FitGen/FitGen.c +++ b/Silicon/Intel/Tools/FitGen/FitGen.c @@ -345,6 +345,7 @@ Returns: "\t[-M ] [-M ...]|[-U ||] [-V ]\n" "\t[-O RecordType [-V ]] [-O ... [-V ...]]\n" "\t[-P RecordType [-V ]] [-P ... [-V ...]]\n" + "\t[-T ]\n" , UTILITY_NAME); printf (" Where:\n"); printf ("\t-D - It is FD file instead of FV file. (The tool will search FV file)\n"); @@ -392,6 +393,7 @@ Returns: printf (" Where:\n"); printf ("\tInputFile - Name of the input file.\n"); printf ("\tFitTablePointerOffset - FIT table pointer offset from end of file. 0x%x as default.\n", DEFAULT_FIT_TABLE_POINTER_OFFSET); + printf ("\tFixedFitLocation - Fixed FIT location in flash address. FIT table will be generated at this location and Option Modules will be directly put right before it.\n"); printf ("\nTool return values:\n"); printf ("\tSTATUS_SUCCESS=%d, STATUS_WARNING=%d, STATUS_ERROR=%d\n", STATUS_SUCCESS, STATUS_WARNING, STATUS_ERROR); } @@ -445,6 +447,46 @@ CheckPath ( return TRUE; } +UINT32 +GetFixedFitLocation ( + IN INTN argc, + IN CHAR8 **argv + ) +/*++ + +Routine Description: + + Get fixed FIT location from argument + +Arguments: + + argc - Number of command line parameters. + argv - Array of pointers to parameter strings. + +Returns: + + FitLocation - The FIT location specified by Argument + 0 - Argument parse fail + +*/ +{ + UINT32 FitLocation; + INTNIndex; + + FitLocation = 0; + + for (Index = 0; Index + 1 < argc; Index ++) { + +if ((strcmp (argv[Index], "-T") == 0) || +(strcmp (argv[Index], "-t") == 0) ) { + FitLocation = xtoi (argv[Index + 1]); + break; +} + } + + return FitLocation; +} + STATUS ReadInputFile ( IN CHAR8*FileName, @@ -1909,10 +1951,11 @@ Returns: } VOID * -GetFreeSpaceFromFv ( +GetFreeSpaceForFit ( IN UINT8 *FvBuffer, IN UINT32FvSize, - IN UINT32FitEntryNumber + IN UINT32FitTableSize, + IN UINT32FixedFitLocation ) /*++ @@ -1922,9 +1965,10 @@ Routine Description: Arguments: - FvBuffer - FvRecovery binary buffer - FvSize - FvRecovery size - FitEntryNumber - The FIT entry number + FvBuffer - FvRecovery binary buffer + FvSize - FvRecovery size + FitTableSize - The FIT table size + FixedFitLocation - Fixed FIT location provided by argument Returns: @@ -1939,7 +1983,6 @@ Returns: UINT8 *OptionalModuleAddress; EFI_GUIDVTFGuid = EFI_FFS_VOLUME_TOP_FILE_GUID; UINT32 AlignedSize; - UINT32 FitTableSize; EFI_FIRMWARE_VOLUME_HEADER *FvHeader; EFI_FFS_FILE_HEADER *FileHeader; @@ -1966,45 +2009,62 @@ Returns: } } - // - // Get EFI_FFS_VOLUME_TOP_FILE_GUID location - // - FitTableOffset = NULL; + if (FixedFitLocation != 0) { +// +// Get Free space from fixed location +// +FitTableOffset = (UINT8 *) FLASH_TO_MEMORY (FixedFitLocation, FvBuffer, FvSize); + } else { +// +// Get Free Space from FvRecovery +// +FitTableOffset = NULL; - FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *)FvBuffer; - FvLength = FvHeader->FvLength; - FileHeader = (EFI_FFS_FILE_HEADER *)(FvBuffer + FvHeader->HeaderLength); - Offset = (UINTN)FileHeader - (UINTN)FvBuffer; +FvHeader = (EFI_FIRMWARE_VOLUME_HEADER *)FvBuffer; +FvLength = FvHeader->FvLength; +FileHeader = (EFI_FFS_FILE_HEADER *)(FvBuffer + FvHeader->HeaderLength); +Offset = (UINTN)FileHeader - (UINTN)FvBuffer; - while (Offset < FvLength) { -FileLength = (*(UINT32 *)(FileHeader->Size)) & 0x00FF; -FileOccupiedSize = GETOCCUPIEDSIZE(FileLength, 8); -if ((CompareGuid (&(FileHeader->Name), &VTFGuid)) == 0) { - // find it - FitTableOffset = (UINT8 *)FileHeader; - break; +// +// Get EFI_FFS_VOLUME_TOP_FILE_GUID location +// +while (Offset < FvLength) { + FileLength = (*(UINT32 *)(FileHeader->Size)) & 0x00FF; + FileOccupiedSize = GETOCCUPIEDSIZE(FileLength, 8); + if ((CompareGuid (&(FileHeader->Name), &VTFGuid)) == 0) { +