From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.136, mailfrom: shenglei.zhang@intel.com) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by groups.io with SMTP; Thu, 30 May 2019 23:36:09 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 May 2019 23:36:08 -0700 X-ExtLoop1: 1 Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by orsmga003.jf.intel.com with ESMTP; 30 May 2019 23:36:08 -0700 Received: from fmsmsx157.amr.corp.intel.com (10.18.116.73) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.408.0; Thu, 30 May 2019 23:36:08 -0700 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by FMSMSX157.amr.corp.intel.com (10.18.116.73) with Microsoft SMTP Server (TLS) id 14.3.408.0; Thu, 30 May 2019 23:36:05 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.134]) by SHSMSX104.ccr.corp.intel.com ([169.254.5.137]) with mapi id 14.03.0415.000; Fri, 31 May 2019 14:36:03 +0800 From: "Zhang, Shenglei" To: "Kinney, Michael D" , "devel@edk2.groups.io" Subject: Re: [edk2-devel] [PATCH] BaseTools/GenBiosId: Add a new tool GenBiosId Thread-Topic: [edk2-devel] [PATCH] BaseTools/GenBiosId: Add a new tool GenBiosId Thread-Index: AQHVFPU123sdQoA6xk2oZkLumeTB4aaAwBDggAQIQtA= Date: Fri, 31 May 2019 06:36:02 +0000 Message-ID: References: <20190528013218.40580-1-shenglei.zhang@intel.com> In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Return-Path: shenglei.zhang@intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable > -----Original Message----- > From: Kinney, Michael D > Sent: Wednesday, May 29, 2019 12:49 AM > To: devel@edk2.groups.io; Zhang, Shenglei ; > Kinney, Michael D > Subject: RE: [edk2-devel] [PATCH] BaseTools/GenBiosId: Add a new tool > GenBiosId >=20 > Could this tools be ported to Python using the python > struct module to access C structures? >=20 > The implementation may be much simpler if python was > used for command line parsing. And this capability > could also be provided as a python module to support > direct access from pre/post build steps implemented in > python. >=20 I think it's feasible to using the python structure to substitute C struct= ure. I'll investigate on it. Best Regards, Shenglei > Thanks, >=20 > Mike >=20 > > -----Original Message----- > > From: devel@edk2.groups.io > > [mailto:devel@edk2.groups.io] On Behalf Of Zhang, > > Shenglei > > Sent: Monday, May 27, 2019 6:32 PM > > To: devel@edk2.groups.io > > Subject: [edk2-devel] [PATCH] BaseTools/GenBiosId: Add > > a new tool GenBiosId > > > > GenBiosId is a tool to generate the BIOS ID binary file > > which uses > > the data from the configuration file. > > https://bugzilla.tianocore.org/show_bug.cgi?id=3D1846 > > > > Signed-off-by: Shenglei Zhang > > > > --- > > BaseTools/Source/C/GenBiosId/GenBiosId.c | 627 > > +++++++++++++++++++++++ > > BaseTools/Source/C/GNUmakefile | 3 +- > > BaseTools/Source/C/GenBiosId/BiosId.env | 27 + > > BaseTools/Source/C/GenBiosId/GNUmakefile | 14 + > > BaseTools/Source/C/GenBiosId/GenBiosId.h | 105 ++++ > > BaseTools/Source/C/GenBiosId/Makefile | 14 + > > BaseTools/Source/C/Makefile | 3 +- > > 7 files changed, 791 insertions(+), 2 deletions(-) > > create mode 100644 > > BaseTools/Source/C/GenBiosId/GenBiosId.c > > create mode 100644 > > BaseTools/Source/C/GenBiosId/BiosId.env > > create mode 100644 > > BaseTools/Source/C/GenBiosId/GNUmakefile > > create mode 100644 > > BaseTools/Source/C/GenBiosId/GenBiosId.h > > create mode 100644 > > BaseTools/Source/C/GenBiosId/Makefile > > > > diff --git a/BaseTools/Source/C/GenBiosId/GenBiosId.c > > b/BaseTools/Source/C/GenBiosId/GenBiosId.c > > new file mode 100644 > > index 000000000000..21d71d4ebd51 > > --- /dev/null > > +++ b/BaseTools/Source/C/GenBiosId/GenBiosId.c > > @@ -0,0 +1,627 @@ > > +/** @file > > +This tool generates the BIOS ID binary file using the > > data from the configuration file. > > + > > +Copyright (c) 2015 - 2019, Intel Corporation. All > > rights reserved.
> > +SPDX-License-Identifier: BSD-2-Clause-Patent > > + > > +**/ > > + > > +#include "GenBiosId.h" > > + > > +CHAR8 InputFileName[FILE_NAME_SIZE]; > > +CHAR8 OutputFileName[FILE_NAME_SIZE]; > > +CHAR8 OutputBatchFileName[FILE_NAME_SIZE]; > > + > > +FILE *InputFile; > > +FILE *OutputFile; > > +FILE *OutputBatchFile; > > + > > +BIOS_ID_IMAGE BiosIdImage =3D { > > + { '$', 'I', 'B', 'I', 'O', 'S', 'I', '$' }, > > + { > > + { ATOU (' '), ATOU (' '), ATOU (' '), ATOU (' '), > > ATOU (' '), ATOU (' '), ATOU (' ') }, > > + ATOU (' '), > > + ATOU ('.'), > > + { ATOU (' '), ATOU (' '), ATOU (' ') }, > > + ATOU ('.'), > > + { ATOU ('0'), ATOU ('0'), ATOU ('0'), ATOU ('0') > > }, > > + ATOU ('.'), > > + ATOU (' '), > > + { ATOU ('0'), ATOU ('0') }, > > + ATOU ('.'), > > + { ATOU ('0'), ATOU ('0'), ATOU ('0'), ATOU ('0'), > > ATOU ('0'), > > + ATOU ('0'), ATOU ('0'), ATOU ('0'), ATOU ('0'), > > ATOU ('0') }, > > + ATOU ('\0') > > + } > > +}; > > + > > +VOID > > +PrintBanner ( > > + VOID > > + ) > > +/*++ > > + > > +Routine Description: > > + > > +Arguments: > > + > > +Returns: > > + > > +--*/ > > +{ > > + printf ("\n"); > > + printf ("GenBiosId utility, version: v1.0 05/27/2018 > > \n"); > > + printf ("Copyright (c) 2019, Intel Corporation. All > > rights reserved. \n"); > > + printf ("\n"); > > +} > > + > > +VOID > > +PrintUsage ( > > + VOID > > + ) > > +/*++ > > + > > +Routine Description: > > + > > +Arguments: > > + > > +Returns: > > + > > +--*/ > > +{ > > + printf ("Usage:\n"); > > + printf ("GenBiosId -i ConfigFile -o OutputFile [-ob > > OutputBatchFile] \n"); > > + printf ("\n"); > > +} > > + > > +CHAR8 * > > +StripLeadingWhiteSpace ( > > + IN CHAR8 *StrInput > > + ) > > +/*++ > > + > > +Routine Description: > > + > > + Strip the leading whitespoace off the given ASCII > > string. > > + > > +Arguments: > > + > > + StrInput - the ASCII string that should be > > processed. > > + > > +Returns: > > + > > + A pointer to the first non-whitespace character in > > the given string, > > + or NULL if the string was all whitespace. > > + > > +--*/ > > +{ > > + if (StrInput =3D=3D NULL) { > > + return NULL; > > + } > > + > > + while (*StrInput !=3D 0) { > > + if ((*StrInput =3D=3D ' ') || (*StrInput =3D=3D '\t') || > > (*StrInput =3D=3D '\n')) { > > + ++StrInput; > > + } else { > > + return StrInput; > > + } > > + } > > + > > + return NULL; > > +} > > + > > +VOID > > +ConvertToUnicode ( > > + IN CHAR8 *StrAscii, > > + OUT CHAR16 *StrUnicode > > + ) > > +/*++ > > + > > +Routine Description: > > + > > + Convert the given ASCII string to Unicode without > > appending terminating 0x0000. > > + > > +Arguments: > > + > > + StrAscii - the source ASCII string, null- > > terminated. > > + > > + StrUnicode - the resulted Unicode string will be > > put here, without the terminating 0x0000. > > + > > +Returns: > > + > > +--*/ > > +{ > > + if ((StrAscii =3D=3D NULL) || (StrUnicode =3D=3D NULL)) { > > + return; > > + } > > + > > + while (*StrAscii !=3D 0) { > > + *StrUnicode =3D ATOU (*StrAscii); > > + ++StrAscii; > > + ++StrUnicode; > > + } > > +} > > + > > +VOID > > +FillTimeStamp ( > > + OUT CHAR16 *StrTimeStampUnicode > > + ) > > +/*++ > > + > > +Routine Description: > > + The function generates the current timestamp in > > "YYMMDDHHMM" format > > + and puts it into the Unicode string supplied, > > without the null-terminator. > > + > > +Arguments: > > + > > + StrTimeStampUnicode - The Unicode string which is > > filled on return with the current timestamp. > > + > > +Returns: > > + > > +--*/ > > +{ > > + struct tm *Time; > > + time_t CurTime; > > + CHAR8 StrTime[11]; > > + > > + // > > + // Fetch the current time based on UTC timezone > > + // > > + time (&CurTime); > > + Time =3D gmtime (&CurTime); > > + > > + if (NULL =3D=3D Time) { > > + return; > > + } > > + > > + sprintf ( > > + StrTime, > > + "%02d%02d%02d%02d%02d", > > + (Time->tm_year + 1900) % 100, // Year is 1900- > > based, need only 2 digits. > > + Time->tm_mon + 1, // Month is zero > > based. > > + Time->tm_mday, > > + Time->tm_hour, > > + Time->tm_min > > + ); > > + > > + ConvertToUnicode (StrTime, StrTimeStampUnicode); > > +} > > + > > +VOID > > +ConvertToAscii ( > > + IN CHAR16 *StrUnicode, > > + OUT CHAR8 *StrAscii > > + ) > > +/*++ > > + > > +Routine Description: > > + > > + Convert the given Unicode string to ASCII with > > appending terminating 0x00. > > + > > +Arguments: > > + > > + StrUnicode - the source Unicode string, null- > > terminated. > > + > > + StrAscii - the resulted ASCII string will be put > > here, with the terminating 0x00. > > + > > +Returns: > > + > > +--*/ > > +{ > > + if ((StrUnicode =3D=3D NULL) || (StrAscii =3D=3D NULL)) { > > + return; > > + } > > + > > + while (*StrUnicode !=3D 0) { > > + *StrAscii =3D UTOA (*StrUnicode); > > + ++StrUnicode; > > + ++StrAscii; > > + } > > + *StrAscii =3D 0; > > +} > > + > > +VOID > > +PrintUnicodeString ( > > + IN CHAR16 *StrUnicode > > + ) > > +/*++ > > + > > +Routine Description: > > + > > + Print the given Unicode string. > > + > > +Arguments: > > + > > + StrUnicode - the null-terminated Unicode string to > > print. > > + > > +Returns: > > + > > +--*/ > > +{ > > + if (StrUnicode =3D=3D NULL) { > > + return; > > + } > > + > > + while (*StrUnicode !=3D 0) { > > + putchar ((CHAR8)(*StrUnicode)); > > + ++StrUnicode; > > + } > > +} > > + > > +EFI_STATUS > > +ParseInputFile ( > > + VOID > > + ) > > +/*++ > > + > > +Routine Description: > > + > > + Parse the BIOS ID definition file and fill the BIOS > > ID structure, including timestamp. > > + > > +Arguments: > > + > > +Returns: > > + > > + EFI_SUCCESS - The input file was parsed > > successfully. > > + > > + EFI_INVALID_PARAMETER - The input file has incorrect > > format. > > + > > +--*/ > > +{ > > + CHAR8 StrLine[MAX_LINE_SIZE]; > > + CHAR8 StrFieldName[MAX_LINE_SIZE]; > > + CHAR8 StrFieldValue[MAX_LINE_SIZE]; > > + CHAR8 *Str; > > + UINT16 FieldsSet; > > + CHAR8 FormatString[MAX_FORMAT_STRING_SIZE]; > > + > > + FieldsSet =3D 0; > > + Str =3D NULL; > > + > > + // > > + // Generate the format string for sscanf() function. > > + // > > + sprintf (FormatString, "%%%us =3D %%%us", (unsigned > > int) sizeof (StrFieldName) - 1, (unsigned int) sizeof > > (StrFieldValue) - 1); > > + > > + while (fgets (StrLine, sizeof (StrLine) - 1, > > InputFile) !=3D NULL) { > > + Str =3D StripLeadingWhiteSpace (StrLine); > > + > > + // > > + // Check for whitespace string. > > + // > > + if (Str =3D=3D NULL) { > > + continue; > > + } > > + > > + // > > + // Check for comment string. > > + // > > + if (*Str =3D=3D '#') { > > + continue; > > + } > > + > > + if (sscanf (Str, FormatString, StrFieldName, > > StrFieldValue) !=3D 2) { > > + continue; > > + } > > + > > + if (strcmp (StrFieldName, NAME_BOARD_ID) =3D=3D 0) { > > + if (strlen (StrFieldValue) =3D=3D CHARS_BOARD_ID) { > > + ConvertToUnicode (StrFieldValue, > > BiosIdImage.BiosIdString.BoardId); > > + FieldsSet |=3D FIELD_BOARD_ID; > > + } else { > > + printf ("Error: value of %s should have > > exactly %d chars\n", NAME_BOARD_ID, CHARS_BOARD_ID); > > + return EFI_INVALID_PARAMETER; > > + } > > + } > > + > > + if (strcmp (StrFieldName, NAME_BOARD_REV) =3D=3D 0) { > > + if (strlen (StrFieldValue) =3D=3D CHARS_BOARD_REV) { > > + ConvertToUnicode (StrFieldValue, > > &(BiosIdImage.BiosIdString.BoardRev)); > > + FieldsSet |=3D FIELD_BOARD_REV; > > + } else { > > + printf ("Error: value of %s should have > > exactly %d chars\n", NAME_BOARD_REV, CHARS_BOARD_REV); > > + return EFI_INVALID_PARAMETER; > > + } > > + } > > + > > + if (strcmp (StrFieldName, NAME_BOARD_EXT) =3D=3D 0) { > > + if (strlen (StrFieldValue) =3D=3D CHARS_BOARD_EXT) { > > + ConvertToUnicode (StrFieldValue, > > BiosIdImage.BiosIdString.BoardExt); > > + FieldsSet |=3D FIELD_BOARD_EXT; > > + } else { > > + printf ("Error: value of %s should have > > exactly %d chars\n", NAME_BOARD_EXT, CHARS_BOARD_EXT); > > + return EFI_INVALID_PARAMETER; > > + } > > + } > > + > > + if (strcmp (StrFieldName, NAME_BUILD_TYPE) =3D=3D 0) { > > + if (strlen (StrFieldValue) =3D=3D CHARS_BUILD_TYPE) > > { > > + if ((strcmp (StrFieldValue, "D") =3D=3D 0) || > > + (strcmp (StrFieldValue, "A") =3D=3D 0) || > > + (strcmp (StrFieldValue, "B") =3D=3D 0) || > > + (strcmp (StrFieldValue, "P") =3D=3D 0)) { > > + ConvertToUnicode (StrFieldValue, > > &(BiosIdImage.BiosIdString.BuildType)); > > + FieldsSet |=3D FIELD_BUILD_TYPE; > > + } else { > > + printf ("Error: value of %s should be one of > > %s, %s, %s or %s\n", NAME_BUILD_TYPE, "D", "A", "B", > > "P"); > > + return EFI_INVALID_PARAMETER; > > + } > > + } else { > > + printf ("Error: value of %s should have > > exactly %d chars\n", NAME_BUILD_TYPE, > > CHARS_BUILD_TYPE); > > + return EFI_INVALID_PARAMETER; > > + } > > + } > > + > > + if (strcmp (StrFieldName, NAME_VERSION_MAJOR) =3D=3D > > 0) { > > + if (strlen (StrFieldValue) =3D=3D > > CHARS_VERSION_MAJOR) { > > + ConvertToUnicode (StrFieldValue, > > BiosIdImage.BiosIdString.VersionMajor); > > + FieldsSet |=3D FIELD_VERSION_MAJOR; > > + } else { > > + printf ("Error: value of %s should have > > exactly %d chars\n", NAME_VERSION_MAJOR, > > CHARS_VERSION_MAJOR); > > + return EFI_INVALID_PARAMETER; > > + } > > + } > > + > > + if (strcmp (StrFieldName, NAME_VERSION_MINOR) =3D=3D > > 0) { > > + if (strlen (StrFieldValue) =3D=3D > > CHARS_VERSION_MINOR) { > > + ConvertToUnicode (StrFieldValue, > > BiosIdImage.BiosIdString.VersionMinor); > > + FieldsSet |=3D FIELD_VERSION_MINOR; > > + } else { > > + printf ("Error: value of %s should have > > exactly %d chars\n", NAME_VERSION_MINOR, > > CHARS_VERSION_MINOR); > > + return EFI_INVALID_PARAMETER; > > + } > > + } > > + > > + if (strcmp (StrFieldName, NAME_DATE) =3D=3D 0) { > > + if (strlen (StrFieldValue) =3D=3D CHARS_DATE) { > > + ConvertToUnicode (StrFieldValue, > > BiosIdImage.BiosIdString.TimeStamp); > > + FieldsSet |=3D FIELD_DATE; > > + } else { > > + printf ("Error: value of %s should have > > exactly %d chars\n", NAME_DATE, CHARS_DATE); > > + return EFI_INVALID_PARAMETER; > > + } > > + } > > + > > + if (strcmp (StrFieldName, NAME_TIME) =3D=3D 0) { > > + if (strlen (StrFieldValue) =3D=3D CHARS_TIME) { > > + ConvertToUnicode (StrFieldValue, > > &(BiosIdImage.BiosIdString.TimeStamp[CHARS_DATE])); > > + FieldsSet |=3D FIELD_TIME; > > + } else { > > + printf ("Error: value of %s should have > > exactly %d chars\n", NAME_TIME, CHARS_TIME); > > + return EFI_INVALID_PARAMETER; > > + } > > + } > > + > > + } > > + > > + if ((FieldsSet & (FIELD_DATE | FIELD_TIME)) !=3D > > (FIELD_DATE | FIELD_TIME)) { > > + // > > + // Fill the timestamp. > > + // > > + FillTimeStamp > > (BiosIdImage.BiosIdString.TimeStamp); > > + FieldsSet |=3D (FIELD_DATE | FIELD_TIME); > > + } > > + > > + // > > + // Exit if not all fields were supplied. > > + // > > + if ((FieldsSet & FIELD_ALL) !=3D FIELD_ALL) { > > + return EFI_INVALID_PARAMETER; > > + } > > + > > + return EFI_SUCCESS; > > +} > > + > > +EFI_STATUS > > +WriteOutputFile ( > > + VOID > > + ) > > +/*++ > > + > > +Routine Description: > > + > > + Write the BIOS ID structure to the output file. > > + > > +Arguments: > > + > > +Returns: > > + > > + EFI_SUCCESS - The output file was created > > successfully. > > + > > + EFI_DEVICE_ERROR - There was a file write error. > > + > > +--*/ > > +{ > > + if (fwrite (&BiosIdImage, sizeof (BIOS_ID_IMAGE), 1, > > OutputFile) !=3D 1) { > > + return EFI_DEVICE_ERROR; > > + } > > + > > + return EFI_SUCCESS; > > +} > > + > > +EFI_STATUS > > +WriteOutputBatchFile ( > > + VOID > > + ) > > +/*++ > > + > > +Routine Description: > > + > > + Write "SET BIOS_ID=3D" and BIOS ID string to the batch > > file. > > + > > +Arguments: > > + > > +Returns: > > + > > + EFI_SUCCESS - The output batch file was > > created successfully. > > + > > + EFI_DEVICE_ERROR - There was a file write error. > > + > > +--*/ > > +{ > > +#ifndef __GNUC__ > > + CHAR8 BatchFileContent[MAX_LINE_SIZE] =3D "SET > > BIOS_ID=3D"; > > +#else > > + CHAR8 BatchFileContent[MAX_LINE_SIZE] =3D "export > > BIOS_ID=3D"; > > +#endif > > + > > + CHAR8 BiosIdString[sizeof (BIOS_ID_STRING)]; > > + > > + ConvertToAscii ((CHAR16 *) > > (&(BiosIdImage.BiosIdString)), BiosIdString); > > + strcat (BatchFileContent, BiosIdString); > > + > > + if (fwrite (BatchFileContent, strlen > > (BatchFileContent), 1, OutputBatchFile) !=3D 1) { > > + return EFI_DEVICE_ERROR; > > + } > > + > > + return EFI_SUCCESS; > > +} > > + > > +int > > +main ( > > + IN int argc, > > + IN CHAR8 *argv[] > > + ) > > +/*++ > > + > > +Routine Description: > > + > > +Arguments: > > + > > + argc - Number of command-line arguments. > > + > > + argv - Array of command-line arguments. > > + > > +Returns: > > + > > + 0 - The operation completed successfully. > > + > > + -1 - An error occurred. > > + > > +--*/ > > +{ > > + int Status; > > + > > + Status =3D 0; > > + > > + PrintBanner (); > > + > > + if ((argc !=3D 5) && (argc !=3D 7)) { > > + PrintUsage (); > > + Status =3D -1; > > + goto Done; > > + } > > + > > + if (strcmp (argv[1], "-i") =3D=3D 0) { > > + if (strlen (argv[2])> sizeof (InputFileName) - 1) > > { > > + printf ("The InputFileName %s is too long \n", > > argv[2]); > > + Status =3D -1; > > + goto Done; > > + } > > + strncpy (InputFileName, argv[2], sizeof > > (InputFileName) - 1); > > + InputFileName[sizeof (InputFileName) - 1] =3D 0; > > + } else { > > + PrintUsage (); > > + Status =3D -1; > > + goto Done; > > + } > > + > > + if (strcmp (argv[3], "-o") =3D=3D 0) { > > + if (strlen (argv[4])> sizeof (OutputFileName) - 1) > > { > > + printf ("OutputFileName %s is too long \n", > > argv[4]); > > + Status =3D -1; > > + goto Done; > > + } > > + strncpy (OutputFileName, argv[4], sizeof > > (OutputFileName) - 1); > > + OutputFileName[sizeof (OutputFileName) - 1] =3D 0; > > + } else { > > + PrintUsage (); > > + Status =3D -1; > > + goto Done; > > + } > > + > > + if (argc =3D=3D 7) { > > + if (strcmp (argv[5], "-ob") =3D=3D 0) { > > + if (strlen (argv[6])> sizeof > > (OutputBatchFileName) - 1) { > > + printf ("The OutputBatchFileName %s is too > > long \n", argv[6]); > > + Status =3D -1; > > + goto Done; > > + } > > + strncpy (OutputBatchFileName, argv[6], sizeof > > (OutputBatchFileName) - 1); > > + OutputBatchFileName[sizeof (OutputBatchFileName) > > - 1] =3D 0; > > + } else { > > + PrintUsage (); > > + Status =3D -1; > > + goto Done; > > + } > > + } > > + > > + InputFile =3D NULL; > > + OutputFile =3D NULL; > > + OutputBatchFile =3D NULL; > > + > > + InputFile =3D fopen (InputFileName, "r"); > > + if (InputFile =3D=3D NULL) { > > + printf ("Error opening input file: %s\n", > > InputFileName); > > + Status =3D -1; > > + goto Done; > > + } > > + > > + OutputFile =3D fopen (OutputFileName, "wb"); > > + if (OutputFile =3D=3D NULL) { > > + printf ("Error creating output file: %s\n", > > OutputFileName); > > + Status =3D -1; > > + goto Done; > > + } > > + > > + if (argc =3D=3D 7) { > > + OutputBatchFile =3D fopen (OutputBatchFileName, > > "wb"); > > + if (OutputBatchFile =3D=3D NULL) { > > + printf ("Error creating output batch file: > > %s\n", OutputBatchFileName); > > + Status =3D -1; > > + goto Done; > > + } > > + } > > + > > + if (ParseInputFile () !=3D EFI_SUCCESS) { > > + printf ("Invalid config file format: %s\n", > > InputFileName); > > + Status =3D -1; > > + goto Done; > > + } > > + > > + if (WriteOutputFile () !=3D EFI_SUCCESS) { > > + printf ("Can't write output file: %s\n", > > OutputFileName); > > + Status =3D -1; > > + goto Done; > > + } > > + > > + if (argc =3D=3D 7) { > > + if (WriteOutputBatchFile () !=3D EFI_SUCCESS) { > > + printf ("Can't write output batch file: %s\n", > > OutputBatchFileName); > > + Status =3D -1; > > + goto Done; > > + } > > + } > > + > > + printf ("BIOS ID created: "); > > + PrintUnicodeString ((CHAR16 > > *)(&(BiosIdImage.BiosIdString))); > > + printf ("\n"); > > + printf ("BIOS ID binary file created: %s\n", > > OutputFileName); > > + > > +Done: > > + > > + if (InputFile !=3D NULL) { > > + fclose (InputFile); > > + } > > + > > + if (OutputFile !=3D NULL) { > > + fclose (OutputFile); > > + } > > + > > + if (OutputBatchFile !=3D NULL) { > > + fclose (OutputBatchFile); > > + } > > + > > + return Status; > > +} > > + > > diff --git a/BaseTools/Source/C/GNUmakefile > > b/BaseTools/Source/C/GNUmakefile > > index 37bcce519c7e..9dbf1a4b06db 100644 > > --- a/BaseTools/Source/C/GNUmakefile > > +++ b/BaseTools/Source/C/GNUmakefile > > @@ -1,7 +1,7 @@ > > ## @file > > # GNU/Linux makefile for C tools build. > > # > > -# Copyright (c) 2007 - 2017, Intel Corporation. All > > rights reserved.
> > +# Copyright (c) 2007 - 2019, Intel Corporation. All > > rights reserved.
> > # > > # SPDX-License-Identifier: BSD-2-Clause-Patent > > # > > @@ -47,6 +47,7 @@ VFRAUTOGEN =3D VfrCompile/VfrLexer.h > > APPLICATIONS =3D \ > > BrotliCompress \ > > VfrCompile \ > > + GenBiosId \ > > EfiRom \ > > GenFfs \ > > GenFv \ > > diff --git a/BaseTools/Source/C/GenBiosId/BiosId.env > > b/BaseTools/Source/C/GenBiosId/BiosId.env > > new file mode 100644 > > index 000000000000..de54273107bd > > --- /dev/null > > +++ b/BaseTools/Source/C/GenBiosId/BiosId.env > > @@ -0,0 +1,27 @@ > > +## @file > > +# This file is used to define the BIOS ID parameters > > of the build. > > +# This file is processed by GenBiosId. > > +# Here, it is just a template and can be customized > > by user. > > +# > > +# BIOS ID string format: > > +# > > $(BOARD_ID)$(BOARD_REV).$(BOARD_EXT).$(VERSION_MAJOR).$ > > (BUILD_TYPE)$(VERSION_MINOR).YYMMDDHHMM > > +# All fields must have a fixed length. YYMMDDHHMM is > > UTC time. > > +# Example: "OVMF.000.0008.D03.1501301017" > > +# > > +# If DATE is specified for YYMMDD and TIME is > > specified for HHMM like below, > > +# GenBiosId will use the value of DATE and TIME to > > fill YYMMDDHHMM, > > +# otherwise GenBiosId will fill YYMMDDHHMM with > > current UTC time of the build machine. > > +# DATE =3D 150130 > > +# TIME =3D 1017 > > +# > > +# Copyright (c) 2015 - 2019, Intel Corporation. All > > rights reserved.
> > +# SPDX-License-Identifier: BSD-2-Clause-Patent > > +# > > +## > > + > > +BOARD_ID =3D OVMF > > +BOARD_REV =3D 1 > > +BOARD_EXT =3D 000 > > +BUILD_TYPE =3D D > > +VERSION_MAJOR =3D 0008 > > +VERSION_MINOR =3D 03 > > diff --git a/BaseTools/Source/C/GenBiosId/GNUmakefile > > b/BaseTools/Source/C/GenBiosId/GNUmakefile > > new file mode 100644 > > index 000000000000..90a918c13f96 > > --- /dev/null > > +++ b/BaseTools/Source/C/GenBiosId/GNUmakefile > > @@ -0,0 +1,14 @@ > > +## @file > > +# makefile for building the GenBiosId utility. > > +# > > +# Copyright (c) 2015 - 2019, Intel Corporation. All > > rights reserved.
> > +# SPDX-License-Identifier: BSD-2-Clause-Patent > > +# > > +## > > +MAKEROOT ?=3D .. > > + > > +APPNAME =3D GenBiosId > > + > > +OBJECTS =3D GenBiosId.o > > + > > +include $(MAKEROOT)/Makefiles/app.makefile > > diff --git a/BaseTools/Source/C/GenBiosId/GenBiosId.h > > b/BaseTools/Source/C/GenBiosId/GenBiosId.h > > new file mode 100644 > > index 000000000000..660fba77e90b > > --- /dev/null > > +++ b/BaseTools/Source/C/GenBiosId/GenBiosId.h > > @@ -0,0 +1,105 @@ > > +/** @file > > +Definitions for the GenBiosId tool. > > + > > +Copyright (c) 2015 - 2019, Intel Corporation. All > > rights reserved.
> > +SPDX-License-Identifier: BSD-2-Clause-Patent > > + > > +**/ > > + > > +#ifndef _GEN_BIOS_ID_ > > +#define _GEN_BIOS_ID_ > > + > > +#include > > +#include > > +#include > > +#include > > +#include > > + > > +#define FILE_NAME_SIZE 256 > > +#define MAX_LINE_SIZE 256 > > +#define MAX_FORMAT_STRING_SIZE 64 > > + > > +#define ATOU(a) (CHAR16) ((UINT8) (a)) > > +#define UTOA(a) (CHAR8) ((UINT16) (a)) > > + > > +// > > +// BIOS ID field names. > > +// > > +#define NAME_BOARD_ID "BOARD_ID" > > +#define NAME_BOARD_REV "BOARD_REV" > > +#define NAME_BOARD_EXT "BOARD_EXT" > > +#define NAME_BUILD_TYPE "BUILD_TYPE" > > +#define NAME_VERSION_MAJOR "VERSION_MAJOR" > > +#define NAME_VERSION_MINOR "VERSION_MINOR" > > +#define NAME_DATE "DATE" > > +#define NAME_TIME "TIME" > > + > > +// > > +// Number of ASCII characters in each field > > +// > > +#define CHARS_BOARD_ID 7 > > +#define CHARS_BOARD_REV 1 > > +#define CHARS_BOARD_EXT 3 > > +#define CHARS_BUILD_TYPE 1 > > +#define CHARS_VERSION_MAJOR 4 > > +#define CHARS_VERSION_MINOR 2 > > +#define CHARS_DATE 6 > > +#define CHARS_TIME 4 > > + > > +#define FIELD_BOARD_ID 0x0001 > > +#define FIELD_BOARD_REV 0x0002 > > +#define FIELD_BOARD_EXT 0x0004 > > +#define FIELD_BUILD_TYPE 0x0008 > > +#define FIELD_VERSION_MAJOR 0x0010 > > +#define FIELD_VERSION_MINOR 0x0020 > > +#define FIELD_DATE 0x0040 > > +#define FIELD_TIME 0x0080 > > + > > +#define FIELD_ALL ( \ > > + FIELD_BOARD_ID | \ > > + FIELD_BOARD_REV | \ > > + FIELD_BOARD_EXT | \ > > + FIELD_BUILD_TYPE | \ > > + FIELD_VERSION_MAJOR | \ > > + FIELD_VERSION_MINOR | \ > > + FIELD_DATE | \ > > + FIELD_TIME) > > + > > +// > > +// BIOS ID string format: > > +// > > +// > > $(BOARD_ID)$(BOARD_REV).$(BOARD_EXT).$(VERSION_MAJOR).$ > > (BUILD_TYPE)$(VERSION_MINOR).YYMMDDHHMM > > +// > > +// Example: "TRFTCRB1.000.0008.D03.1501301017" > > +// > > +// The format should be same as platform BIOS ID > > definition > > +// > > +#pragma pack(1) > > + > > +typedef struct { > > + CHAR16 BoardId[7]; // "TRFTCRB" > > + CHAR16 BoardRev; // "1" > > + CHAR16 Dot1; // "." > > + CHAR16 BoardExt[3]; // "000" > > + CHAR16 Dot2; // "." > > + CHAR16 VersionMajor[4]; // "0008" > > + CHAR16 Dot3; // "." > > + CHAR16 BuildType; // "D" > > + CHAR16 VersionMinor[2]; // "03" > > + CHAR16 Dot4; // "." > > + CHAR16 TimeStamp[10]; // "YYMMDDHHMM" > > + CHAR16 NullTerminator; // 0x0000 > > +} BIOS_ID_STRING; > > + > > +// > > +// A signature precedes the BIOS ID string in the FV > > to enable search by external tools. > > +// > > +typedef struct { > > + UINT8 Signature[8]; // "$IBIOSI$" > > + BIOS_ID_STRING BiosIdString; // > > "TRFTCRB1.000.0008.D03.1501301017" > > +} BIOS_ID_IMAGE; > > + > > +#pragma pack() > > + > > + > > +#endif // _GEN_BIOS_ID_ > > diff --git a/BaseTools/Source/C/GenBiosId/Makefile > > b/BaseTools/Source/C/GenBiosId/Makefile > > new file mode 100644 > > index 000000000000..967a1809b635 > > --- /dev/null > > +++ b/BaseTools/Source/C/GenBiosId/Makefile > > @@ -0,0 +1,14 @@ > > +## @file > > +# makefile for building the GenBiosId utility. > > +# > > +# Copyright (c) 2015 - 2019, Intel Corporation. All > > rights reserved.
> > +# SPDX-License-Identifier: BSD-2-Clause-Patent > > +# > > +!INCLUDE ..\Makefiles\ms.common > > + > > +APPNAME =3D GenBiosId > > + > > +OBJECTS =3D GenBiosId.obj > > + > > +!INCLUDE ..\Makefiles\ms.app > > + > > diff --git a/BaseTools/Source/C/Makefile > > b/BaseTools/Source/C/Makefile > > index 217fc2b91d7b..748565bba9ff 100644 > > --- a/BaseTools/Source/C/Makefile > > +++ b/BaseTools/Source/C/Makefile > > @@ -1,7 +1,7 @@ > > ## @file > > # Windows makefile for C tools build. > > # > > -# Copyright (c) 2009 - 2018, Intel Corporation. All > > rights reserved.
> > +# Copyright (c) 2009 - 2019, Intel Corporation. All > > rights reserved.
> > # SPDX-License-Identifier: BSD-2-Clause-Patent > > # > > HOST_ARCH =3D IA32 > > @@ -12,6 +12,7 @@ LIBRARIES =3D Common > > APPLICATIONS =3D \ > > VfrCompile \ > > BrotliCompress \ > > + GenBiosId \ > > EfiRom \ > > GenCrc32 \ > > GenFfs \ > > -- > > 2.18.0.windows.1 > > > > > >=20