X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=BaseTools%2FSource%2FC%2FGenVtf%2FGenVtf.c;h=60df34906eb804cab97ff26cddf6289787a92371;hb=1be2ed90a20618d71ddf34b8a07d038da0b36854;hp=2e417bf563d261c53a357ab29b63b53bfaee61b4;hpb=a709adfaf0bebbaf3d989f56b500e3985687d0e3;p=mirror_edk2.git diff --git a/BaseTools/Source/C/GenVtf/GenVtf.c b/BaseTools/Source/C/GenVtf/GenVtf.c index 2e417bf563..60df34906e 100644 --- a/BaseTools/Source/C/GenVtf/GenVtf.c +++ b/BaseTools/Source/C/GenVtf/GenVtf.c @@ -1,6 +1,6 @@ /** -Copyright (c) 1999-2008 Intel Corporation. All rights reserved +Copyright (c) 1999 - 2014, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -105,44 +105,51 @@ ConvertVersionInfo ( /*++ Routine Description: - This function converts GUID string to GUID + This function split version to major version and minor version Arguments: Str - String representing in form XX.XX - MajorVer - The major vertion - MinorVer - The minor vertion + MajorVer - The major version + MinorVer - The minor version Returns: - EFI_SUCCESS - The fuction completed successfully. + EFI_SUCCESS - The function completed successfully. --*/ { - CHAR8 StrPtr[40]; - CHAR8 *Token; - UINTN Length; + CHAR8 TemStr[5] = "0000"; unsigned Major; unsigned Minor; + UINTN Length; Major = 0; Minor = 0; - memset (StrPtr, 0, 40); - Token = strtok (Str, "."); - while (Token != NULL) { - strcat (StrPtr, Token); - Token = strtok (NULL, "."); + if (strstr (Str, ".") != NULL) { + sscanf ( + Str, + "%02x.%02x", + &Major, + &Minor + ); + } else { + Length = strlen(Str); + if (Length < 4) { + strncpy (TemStr + 4 - Length, Str, Length); + } else { + strncpy (TemStr, Str + Length - 4, 4); + } + + sscanf ( + TemStr, + "%02x%02x", + &Major, + &Minor + ); } - Length = strlen (StrPtr); - sscanf ( - StrPtr, - "%01x%02x", - &Major, - &Minor - ); - *MajorVer = (UINT8) Major; *MinorVer = (UINT8) Minor; return EFI_SUCCESS; @@ -342,7 +349,6 @@ Returns: VtfInfo->LocationType = SECOND_VTF; } else { VtfInfo->LocationType = NONE; - Warning(UTILITY_NAME, 0, 0001, "Unknown location for component.", VtfInfo->CompName); } } else if (strnicmp (*TokenStr, "COMP_TYPE", 9) == 0) { TokenStr++; @@ -1064,7 +1070,7 @@ Returns: CHAR8 Buff5[10]; CHAR8 Token[50]; - Fp = fopen (VtfInfo->CompSymName, "rb"); + Fp = fopen (LongFilePath (VtfInfo->CompSymName), "rb"); if (Fp == NULL) { Error (NULL, 0, 0001, "Error opening file", VtfInfo->CompSymName); @@ -1135,7 +1141,6 @@ Returns: EFI_STATUS Status; UINT64 CompStartAddress; UINT64 FileSize; - UINT64 NumByteRead; UINT64 NumAdjustByte; UINT8 *Buffer; FILE *Fp; @@ -1147,7 +1152,7 @@ Returns: return EFI_SUCCESS; } - Fp = fopen (VtfInfo->CompBinName, "rb"); + Fp = fopen (LongFilePath (VtfInfo->CompBinName), "rb"); if (Fp == NULL) { Error (NULL, 0, 0001, "Error opening file", VtfInfo->CompBinName); @@ -1183,7 +1188,7 @@ Returns: // // Read first 64 bytes of PAL header and use it to find version info // - NumByteRead = fread (Buffer, sizeof (UINT8), SIZE_OF_PAL_HEADER, Fp); + fread (Buffer, sizeof (UINT8), SIZE_OF_PAL_HEADER, Fp); // // PAL header contains the version info. Currently, we will use the header @@ -1194,7 +1199,7 @@ Returns: } } - NumByteRead = fread (Buffer, sizeof (UINT8), (UINTN) FileSize, Fp); + fread (Buffer, sizeof (UINT8), (UINTN) FileSize, Fp); fclose (Fp); // @@ -1323,12 +1328,11 @@ Returns: UINT64 AbsAddress; UINTN RelativeAddress; UINT64 FileSize; - UINT64 NumByteRead; UINT8 *Buffer; FILE *Fp; FIT_TABLE *PalFitPtr; - Fp = fopen (VtfInfo->CompBinName, "rb"); + Fp = fopen (LongFilePath (VtfInfo->CompBinName), "rb"); if (Fp == NULL) { Error (NULL, 0, 0001, "Error opening file", VtfInfo->CompBinName); @@ -1361,7 +1365,7 @@ Returns: // // Read, Get version Info and discard the PAL header. // - NumByteRead = fread (Buffer, sizeof (UINT8), SIZE_OF_PAL_HEADER, Fp); + fread (Buffer, sizeof (UINT8), SIZE_OF_PAL_HEADER, Fp); // // Extract the version info from header of PAL_A. Once done, discrad this buffer @@ -1373,7 +1377,7 @@ Returns: // // Read PAL_A file in a buffer // - NumByteRead = fread (Buffer, sizeof (UINT8), (UINTN) FileSize, Fp); + fread (Buffer, sizeof (UINT8), (UINTN) FileSize, Fp); fclose (Fp); PalStartAddress = Fv1EndAddress - (SIZE_TO_OFFSET_PAL_A_END + FileSize); @@ -1547,7 +1551,7 @@ Returns: VtfBuffer = (VOID *) RelativeAddress; } - Fp = fopen (FileName, "wb"); + Fp = fopen (LongFilePath (FileName), "wb"); if (Fp == NULL) { Error (NULL, 0, 0001, "Error opening file", FileName); return EFI_ABORTED; @@ -1753,14 +1757,13 @@ Returns: UINT8 *Buffer; UINT8 *LocalVtfBuffer; UINTN FileSize; - UINTN NumByteRead; FILE *Fp; if (!strcmp (FileName, "")) { return EFI_INVALID_PARAMETER; } - Fp = fopen (FileName, "rb"); + Fp = fopen (LongFilePath (FileName), "rb"); if (Fp == NULL) { Error (NULL, 0, 0001, "Error opening file", FileName); @@ -1778,7 +1781,7 @@ Returns: return EFI_OUT_OF_RESOURCES; } - NumByteRead = fread (Buffer, sizeof (UINT8), FileSize, Fp); + fread (Buffer, sizeof (UINT8), FileSize, Fp); LocalVtfBuffer = (UINT8 *) Vtf1EndBuffer - SIZE_IA32_RESET_VECT; memcpy (LocalVtfBuffer, Buffer, FileSize); @@ -2115,7 +2118,6 @@ Returns: FILE *Fp; UINT64 *StartAddressPtr; UINTN FirstFwVSize; - UINTN NumByte; StartAddressPtr = malloc (sizeof (UINT64)); if (StartAddressPtr == NULL) { @@ -2123,7 +2125,7 @@ Returns: } *StartAddressPtr = StartAddress; - Fp = fopen (OutFileName1, "rb"); + Fp = fopen (LongFilePath (OutFileName1), "rb"); if (Fp == NULL) { Error (NULL, 0, 0001, "Error opening file", OutFileName1); @@ -2135,7 +2137,7 @@ Returns: FirstFwVSize = _filelength (fileno (Fp)); fseek (Fp, (long) (FirstFwVSize - (UINTN) (SIZE_IA32_RESET_VECT + SIZE_SALE_ENTRY_POINT)), SEEK_SET); - NumByte = fwrite ((VOID *) StartAddressPtr, sizeof (UINT64), 1, Fp); + fwrite ((VOID *) StartAddressPtr, sizeof (UINT64), 1, Fp); if (Fp) { fclose (Fp); @@ -2181,12 +2183,12 @@ Returns: { FILE *SourceFile; FILE *DestFile; - CHAR8 Buffer[_MAX_PATH]; - CHAR8 Type[_MAX_PATH]; - CHAR8 Address[_MAX_PATH]; - CHAR8 Section[_MAX_PATH]; - CHAR8 Token[_MAX_PATH]; - CHAR8 BaseToken[_MAX_PATH]; + CHAR8 Buffer[MAX_LONG_FILE_PATH]; + CHAR8 Type[MAX_LONG_FILE_PATH]; + CHAR8 Address[MAX_LONG_FILE_PATH]; + CHAR8 Section[MAX_LONG_FILE_PATH]; + CHAR8 Token[MAX_LONG_FILE_PATH]; + CHAR8 BaseToken[MAX_LONG_FILE_PATH]; UINT64 TokenAddress; long StartLocation; @@ -2200,7 +2202,7 @@ Returns: // // Open the source file // - SourceFile = fopen (SourceFileName, "r"); + SourceFile = fopen (LongFilePath (SourceFileName), "r"); if (SourceFile == NULL) { // @@ -2219,7 +2221,7 @@ Returns: // // Open the destination file // - DestFile = fopen (DestFileName, "a+"); + DestFile = fopen (LongFilePath (DestFileName), "a+"); if (DestFile == NULL) { fclose (SourceFile); Error (NULL, 0, 0001, "Error opening file", DestFileName); @@ -2250,7 +2252,7 @@ Returns: // // Read the first line // - if (fgets (Buffer, _MAX_PATH, SourceFile) == NULL) { + if (fgets (Buffer, MAX_LONG_FILE_PATH, SourceFile) == NULL) { Buffer[0] = 0; } @@ -2377,7 +2379,7 @@ Returns: --*/ { - fprintf (stdout, "%s Version %d.%d\n", UTILITY_NAME, UTILITY_MAJOR_VERSION, UTILITY_MINOR_VERSION); + fprintf (stdout, "%s Version %d.%d %s \n", UTILITY_NAME, UTILITY_MAJOR_VERSION, UTILITY_MINOR_VERSION, __BUILD_VERSION); } VOID @@ -2408,7 +2410,7 @@ Returns: // // Copyright declaration // - fprintf (stdout, "Copyright (c) 2007 - 2009, Intel Corporation. All rights reserved.\n\n"); + fprintf (stdout, "Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.\n\n"); // // Details Option // @@ -2544,7 +2546,7 @@ Returns: // Get the input VTF file name // VtfFileName = argv[Index+1]; - VtfFP = fopen(VtfFileName, "rb"); + VtfFP = fopen (LongFilePath (VtfFileName), "rb"); if (VtfFP == NULL) { Error (NULL, 0, 0001, "Error opening file", VtfFileName); goto ERROR;