[edk2-devel] [PATCH v1 1/1] BoardModulePkg\Library\BiosIdLib: Support Standalone MM
Add Standalone Mm BiosIdLib and format code with Uncrustify. Cc: Eric Dong Cc: Nate DeSimone Signed-off-by: Lixia Huang --- Platform/Intel/BoardModulePkg/Library/BiosIdLib/BiosIdCommon.c| 96 Platform/Intel/BoardModulePkg/Library/BiosIdLib/DxeBiosIdLib.c| 111 +++--- Platform/Intel/BoardModulePkg/Library/BiosIdLib/PeiBiosIdLib.c| 118 +++- Platform/Intel/BoardModulePkg/Library/BiosIdLib/StandaloneMmBiosIdLib.c | 65 +++ Platform/Intel/BoardModulePkg/BoardModulePkg.dsc | 1 + Platform/Intel/BoardModulePkg/Library/BiosIdLib/DxeBiosIdLib.inf | 1 + Platform/Intel/BoardModulePkg/Library/BiosIdLib/PeiBiosIdLib.inf | 6 +- Platform/Intel/BoardModulePkg/Library/BiosIdLib/StandaloneMmBiosIdLib.inf | 42 +++ 8 files changed, 241 insertions(+), 199 deletions(-) diff --git a/Platform/Intel/BoardModulePkg/Library/BiosIdLib/BiosIdCommon.c b/Platform/Intel/BoardModulePkg/Library/BiosIdLib/BiosIdCommon.c new file mode 100644 index ..5735566bfe3a --- /dev/null +++ b/Platform/Intel/BoardModulePkg/Library/BiosIdLib/BiosIdCommon.c @@ -0,0 +1,96 @@ +/** @file + Boot service common BIOS ID library implementation. + + These functions in this file can be called during DXE and cannot be called during runtime + or in SMM which should use a RT or SMM library. + + +Copyright (c) 2023, Intel Corporation. All rights reserved. +SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include +#include + +/** + This function returns the BIOS Version & Release Date and Time by getting and converting BIOS ID. + + @param[out] BiosVersion The Bios Version out of the conversion. + @param[out] BiosReleaseDate The Bios Release Date out of the conversion. + @param[out] BiosReleaseTime The Bios Release Time out of the conversion. + + @retval EFI_SUCCESS BIOS Version & Release Date and Time have been got successfully. + @retval EFI_NOT_FOUND BIOS ID image is not found, and no parameter will be modified. + @retval EFI_INVALID_PARAMETER All the parameters are NULL. + +**/ +EFI_STATUS +EFIAPI +GetBiosVersionDateTime ( + OUT CHAR16 *BiosVersion OPTIONAL, + OUT CHAR16 *BiosReleaseDate OPTIONAL, + OUT CHAR16 *BiosReleaseTime OPTIONAL + ) +{ + EFI_STATUS Status; + BIOS_ID_IMAGE BiosIdImage; + + if ((BiosVersion == NULL) && (BiosReleaseDate == NULL) && (BiosReleaseTime == NULL)) { +return EFI_INVALID_PARAMETER; + } + + Status = GetBiosId (&BiosIdImage); + if (EFI_ERROR (Status)) { +return EFI_NOT_FOUND; + } + + if (BiosVersion != NULL) { +// +// Fill the BiosVersion data from the BIOS ID. +// +CopyMem (BiosVersion, &(BiosIdImage.BiosIdString), sizeof (BIOS_ID_STRING)); + } + + if (BiosReleaseDate != NULL) { +// +// Fill the build timestamp date from the BIOS ID in the "MM/DD/YY" format. +// +BiosReleaseDate[0] = BiosIdImage.BiosIdString.TimeStamp[2]; +BiosReleaseDate[1] = BiosIdImage.BiosIdString.TimeStamp[3]; +BiosReleaseDate[2] = (CHAR16)((UINT8)('/')); + +BiosReleaseDate[3] = BiosIdImage.BiosIdString.TimeStamp[4]; +BiosReleaseDate[4] = BiosIdImage.BiosIdString.TimeStamp[5]; +BiosReleaseDate[5] = (CHAR16)((UINT8)('/')); + +// +// Add 20 for SMBIOS table +// Current Linux kernel will misjudge 09 as year 0, so using 2009 for SMBIOS table +// +BiosReleaseDate[6] = '2'; +BiosReleaseDate[7] = '0'; +BiosReleaseDate[8] = BiosIdImage.BiosIdString.TimeStamp[0]; +BiosReleaseDate[9] = BiosIdImage.BiosIdString.TimeStamp[1]; + +BiosReleaseDate[10] = (CHAR16)((UINT8)('\0')); + } + + if (BiosReleaseTime != NULL) { +// +// Fill the build timestamp time from the BIOS ID in the "HH:MM" format. +// +BiosReleaseTime[0] = BiosIdImage.BiosIdString.TimeStamp[6]; +BiosReleaseTime[1] = BiosIdImage.BiosIdString.TimeStamp[7]; +BiosReleaseTime[2] = (CHAR16)((UINT8)(':')); + +BiosReleaseTime[3] = BiosIdImage.BiosIdString.TimeStamp[8]; +BiosReleaseTime[4] = BiosIdImage.BiosIdString.TimeStamp[9]; + +BiosReleaseTime[5] = (CHAR16)((UINT8)('\0')); + } + + return EFI_SUCCESS; +} diff --git a/Platform/Intel/BoardModulePkg/Library/BiosIdLib/DxeBiosIdLib.c b/Platform/Intel/BoardModulePkg/Library/BiosIdLib/DxeBiosIdLib.c index 3e614d9efc3e..6535bb36f6c9 100644 --- a/Platform/Intel/BoardModulePkg/Library/BiosIdLib/DxeBiosIdLib.c +++ b/Platform/Intel/BoardModulePkg/Library/BiosIdLib/DxeBiosIdLib.c @@ -5,7 +5,7 @@ or in SMM which should use a RT or SMM library. -Copyright (c) 2015 - 2019, Intel Corporation. All rights reserved. +Copyright (c) 2015 - 2023, Intel Corporation. All rights reserved. SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -15,7 +15,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include #include #include -#include #include #include #inclu
[edk2-devel] [PATCH v1 1/1] BoardModulePkg\Library\BiosIdLib: Support Standalone MM
Add Standalone Mm BiosIdLib. Also fix some EDKII Coding Style issue with uncrustify. Cc: Eric Dong Cc: Nate DeSimone Signed-off-by: Lixia Huang --- Platform/Intel/BoardModulePkg/Library/BiosIdLib/BiosIdCommon.c| 96 Platform/Intel/BoardModulePkg/Library/BiosIdLib/DxeBiosIdLib.c| 111 +++--- Platform/Intel/BoardModulePkg/Library/BiosIdLib/PeiBiosIdLib.c| 118 +++- Platform/Intel/BoardModulePkg/Library/BiosIdLib/StandaloneMmBiosIdLib.c | 65 +++ Platform/Intel/BoardModulePkg/BoardModulePkg.dsc | 1 + Platform/Intel/BoardModulePkg/Library/BiosIdLib/DxeBiosIdLib.inf | 6 +- Platform/Intel/BoardModulePkg/Library/BiosIdLib/PeiBiosIdLib.inf | 6 +- Platform/Intel/BoardModulePkg/Library/BiosIdLib/StandaloneMmBiosIdLib.inf | 42 +++ 8 files changed, 244 insertions(+), 201 deletions(-) diff --git a/Platform/Intel/BoardModulePkg/Library/BiosIdLib/BiosIdCommon.c b/Platform/Intel/BoardModulePkg/Library/BiosIdLib/BiosIdCommon.c new file mode 100644 index ..5735566bfe3a --- /dev/null +++ b/Platform/Intel/BoardModulePkg/Library/BiosIdLib/BiosIdCommon.c @@ -0,0 +1,96 @@ +/** @file + Boot service common BIOS ID library implementation. + + These functions in this file can be called during DXE and cannot be called during runtime + or in SMM which should use a RT or SMM library. + + +Copyright (c) 2023, Intel Corporation. All rights reserved. +SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include +#include + +/** + This function returns the BIOS Version & Release Date and Time by getting and converting BIOS ID. + + @param[out] BiosVersion The Bios Version out of the conversion. + @param[out] BiosReleaseDate The Bios Release Date out of the conversion. + @param[out] BiosReleaseTime The Bios Release Time out of the conversion. + + @retval EFI_SUCCESS BIOS Version & Release Date and Time have been got successfully. + @retval EFI_NOT_FOUND BIOS ID image is not found, and no parameter will be modified. + @retval EFI_INVALID_PARAMETER All the parameters are NULL. + +**/ +EFI_STATUS +EFIAPI +GetBiosVersionDateTime ( + OUT CHAR16 *BiosVersion OPTIONAL, + OUT CHAR16 *BiosReleaseDate OPTIONAL, + OUT CHAR16 *BiosReleaseTime OPTIONAL + ) +{ + EFI_STATUS Status; + BIOS_ID_IMAGE BiosIdImage; + + if ((BiosVersion == NULL) && (BiosReleaseDate == NULL) && (BiosReleaseTime == NULL)) { +return EFI_INVALID_PARAMETER; + } + + Status = GetBiosId (&BiosIdImage); + if (EFI_ERROR (Status)) { +return EFI_NOT_FOUND; + } + + if (BiosVersion != NULL) { +// +// Fill the BiosVersion data from the BIOS ID. +// +CopyMem (BiosVersion, &(BiosIdImage.BiosIdString), sizeof (BIOS_ID_STRING)); + } + + if (BiosReleaseDate != NULL) { +// +// Fill the build timestamp date from the BIOS ID in the "MM/DD/YY" format. +// +BiosReleaseDate[0] = BiosIdImage.BiosIdString.TimeStamp[2]; +BiosReleaseDate[1] = BiosIdImage.BiosIdString.TimeStamp[3]; +BiosReleaseDate[2] = (CHAR16)((UINT8)('/')); + +BiosReleaseDate[3] = BiosIdImage.BiosIdString.TimeStamp[4]; +BiosReleaseDate[4] = BiosIdImage.BiosIdString.TimeStamp[5]; +BiosReleaseDate[5] = (CHAR16)((UINT8)('/')); + +// +// Add 20 for SMBIOS table +// Current Linux kernel will misjudge 09 as year 0, so using 2009 for SMBIOS table +// +BiosReleaseDate[6] = '2'; +BiosReleaseDate[7] = '0'; +BiosReleaseDate[8] = BiosIdImage.BiosIdString.TimeStamp[0]; +BiosReleaseDate[9] = BiosIdImage.BiosIdString.TimeStamp[1]; + +BiosReleaseDate[10] = (CHAR16)((UINT8)('\0')); + } + + if (BiosReleaseTime != NULL) { +// +// Fill the build timestamp time from the BIOS ID in the "HH:MM" format. +// +BiosReleaseTime[0] = BiosIdImage.BiosIdString.TimeStamp[6]; +BiosReleaseTime[1] = BiosIdImage.BiosIdString.TimeStamp[7]; +BiosReleaseTime[2] = (CHAR16)((UINT8)(':')); + +BiosReleaseTime[3] = BiosIdImage.BiosIdString.TimeStamp[8]; +BiosReleaseTime[4] = BiosIdImage.BiosIdString.TimeStamp[9]; + +BiosReleaseTime[5] = (CHAR16)((UINT8)('\0')); + } + + return EFI_SUCCESS; +} diff --git a/Platform/Intel/BoardModulePkg/Library/BiosIdLib/DxeBiosIdLib.c b/Platform/Intel/BoardModulePkg/Library/BiosIdLib/DxeBiosIdLib.c index 3e614d9efc3e..6535bb36f6c9 100644 --- a/Platform/Intel/BoardModulePkg/Library/BiosIdLib/DxeBiosIdLib.c +++ b/Platform/Intel/BoardModulePkg/Library/BiosIdLib/DxeBiosIdLib.c @@ -5,7 +5,7 @@ or in SMM which should use a RT or SMM library. -Copyright (c) 2015 - 2019, Intel Corporation. All rights reserved. +Copyright (c) 2015 - 2023, Intel Corporation. All rights reserved. SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -15,7 +15,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include #include #include -#include #in
Re: [edk2-devel] [PATCH v1 1/1] BoardModulePkg\Library\BiosIdLib: Support Standalone MM
Hi Li, It looks like the standalone MM version of this library is missing the search for the BiosId file. I suspect the issue you ran into is that standalone MM only has support for 1 FV, and it is highly likely that the BiosId file is not in the standalone MM FV. This is understandable; however, it does highlight yet another deficiency in the architecture of standalone MM. Again, that is not your fault and is beyond the scope of this patch. Reviewed-by: Nate DeSimone > -Original Message- > From: Huang, Li-Xia > Sent: Monday, December 25, 2023 11:56 PM > To: devel@edk2.groups.io > Cc: Dong, Eric ; Desimone, Nathaniel L > > Subject: [PATCH v1 1/1] BoardModulePkg\Library\BiosIdLib: Support > Standalone MM > > Add Standalone Mm BiosIdLib and format code with Uncrustify. > > Cc: Eric Dong > Cc: Nate DeSimone > > Signed-off-by: Lixia Huang > --- > Platform/Intel/BoardModulePkg/Library/BiosIdLib/BiosIdCommon.c| > 96 > Platform/Intel/BoardModulePkg/Library/BiosIdLib/DxeBiosIdLib.c| > 111 > +++--- > Platform/Intel/BoardModulePkg/Library/BiosIdLib/PeiBiosIdLib.c| > 118 > +++- > Platform/Intel/BoardModulePkg/Library/BiosIdLib/StandaloneMmBiosIdLib.c > | 65 +++ > Platform/Intel/BoardModulePkg/BoardModulePkg.dsc | > 1 + > Platform/Intel/BoardModulePkg/Library/BiosIdLib/DxeBiosIdLib.inf | > 1 > + > Platform/Intel/BoardModulePkg/Library/BiosIdLib/PeiBiosIdLib.inf | > 6 > +- > > Platform/Intel/BoardModulePkg/Library/BiosIdLib/StandaloneMmBiosIdLib.i > nf | 42 +++ > 8 files changed, 241 insertions(+), 199 deletions(-) > > diff --git > a/Platform/Intel/BoardModulePkg/Library/BiosIdLib/BiosIdCommon.c > b/Platform/Intel/BoardModulePkg/Library/BiosIdLib/BiosIdCommon.c > new file mode 100644 > index ..5735566bfe3a > --- /dev/null > +++ b/Platform/Intel/BoardModulePkg/Library/BiosIdLib/BiosIdCommon.c > @@ -0,0 +1,96 @@ > +/** @file > + Boot service common BIOS ID library implementation. > + > + These functions in this file can be called during DXE and cannot be > + called during runtime or in SMM which should use a RT or SMM library. > + > + > +Copyright (c) 2023, Intel Corporation. All rights reserved. > +SPDX-License-Identifier: BSD-2-Clause-Patent > + > +**/ > + > +#include > +#include > +#include > +#include > + > +/** > + This function returns the BIOS Version & Release Date and Time by getting > and converting BIOS ID. > + > + @param[out] BiosVersion The Bios Version out of the conversion. > + @param[out] BiosReleaseDate The Bios Release Date out of the > conversion. > + @param[out] BiosReleaseTime The Bios Release Time out of the > conversion. > + > + @retval EFI_SUCCESS BIOS Version & Release Date and Time have > been got successfully. > + @retval EFI_NOT_FOUND BIOS ID image is not found, and no > parameter will be modified. > + @retval EFI_INVALID_PARAMETER All the parameters are NULL. > + > +**/ > +EFI_STATUS > +EFIAPI > +GetBiosVersionDateTime ( > + OUT CHAR16 *BiosVersion OPTIONAL, > + OUT CHAR16 *BiosReleaseDate OPTIONAL, > + OUT CHAR16 *BiosReleaseTime OPTIONAL > + ) > +{ > + EFI_STATUS Status; > + BIOS_ID_IMAGE BiosIdImage; > + > + if ((BiosVersion == NULL) && (BiosReleaseDate == NULL) && > (BiosReleaseTime == NULL)) { > +return EFI_INVALID_PARAMETER; > + } > + > + Status = GetBiosId (&BiosIdImage); > + if (EFI_ERROR (Status)) { > +return EFI_NOT_FOUND; > + } > + > + if (BiosVersion != NULL) { > +// > +// Fill the BiosVersion data from the BIOS ID. > +// > +CopyMem (BiosVersion, &(BiosIdImage.BiosIdString), sizeof > + (BIOS_ID_STRING)); } > + > + if (BiosReleaseDate != NULL) { > +// > +// Fill the build timestamp date from the BIOS ID in the "MM/DD/YY" > format. > +// > +BiosReleaseDate[0] = BiosIdImage.BiosIdString.TimeStamp[2]; > +BiosReleaseDate[1] = BiosIdImage.BiosIdString.TimeStamp[3]; > +BiosReleaseDate[2] = (CHAR16)((UINT8)('/')); > + > +BiosReleaseDate[3] = BiosIdImage.BiosIdString.TimeStamp[4]; > +BiosReleaseDate[4] = BiosIdImage.BiosIdString.TimeStamp[5]; > +BiosReleaseDate[5] = (CHAR16)((UINT8)('/')); > + > +// > +// Add 20 for SMBIOS table > +// Current Linux kernel will misjudge 09 as year 0, so using 2009 for > SMBIOS table > +// > +BiosReleaseDate[6] = '2'; > +BiosReleaseDate[7] = '0'; > +BiosReleaseDate[8] = BiosIdImage.BiosIdString.TimeStamp[0]; > +BiosReleaseDate[9] = BiosIdImage.BiosIdString.TimeStamp[1]; > + > +BiosReleaseDate[10] = (CHAR16)((UINT8)('\0')); } > + > + if (BiosReleaseTime != NULL) { > +// > +// Fill the build timestamp time from the BIOS ID in the "HH:MM" format. > +// > +BiosReleaseTime[0] = BiosIdImage.BiosIdString.TimeStamp[6]; > +BiosReleaseTime[1] = BiosIdImage.BiosIdString.TimeStamp[7]; >
Re: [edk2-devel] [PATCH v1 1/1] BoardModulePkg\Library\BiosIdLib: Support Standalone MM
Pushed as b46ecad > -Original Message- > From: Huang, Li-Xia > Sent: Monday, December 25, 2023 11:56 PM > To: devel@edk2.groups.io > Cc: Dong, Eric ; Desimone, Nathaniel L > > Subject: [PATCH v1 1/1] BoardModulePkg\Library\BiosIdLib: Support > Standalone MM > > Add Standalone Mm BiosIdLib and format code with Uncrustify. > > Cc: Eric Dong > Cc: Nate DeSimone > > Signed-off-by: Lixia Huang > --- > Platform/Intel/BoardModulePkg/Library/BiosIdLib/BiosIdCommon.c| > 96 > Platform/Intel/BoardModulePkg/Library/BiosIdLib/DxeBiosIdLib.c| > 111 > +++--- > Platform/Intel/BoardModulePkg/Library/BiosIdLib/PeiBiosIdLib.c| > 118 > +++- > Platform/Intel/BoardModulePkg/Library/BiosIdLib/StandaloneMmBiosIdLib.c > | 65 +++ > Platform/Intel/BoardModulePkg/BoardModulePkg.dsc | > 1 + > Platform/Intel/BoardModulePkg/Library/BiosIdLib/DxeBiosIdLib.inf | > 1 > + > Platform/Intel/BoardModulePkg/Library/BiosIdLib/PeiBiosIdLib.inf | > 6 > +- > > Platform/Intel/BoardModulePkg/Library/BiosIdLib/StandaloneMmBiosIdLib.i > nf | 42 +++ > 8 files changed, 241 insertions(+), 199 deletions(-) > > diff --git > a/Platform/Intel/BoardModulePkg/Library/BiosIdLib/BiosIdCommon.c > b/Platform/Intel/BoardModulePkg/Library/BiosIdLib/BiosIdCommon.c > new file mode 100644 > index ..5735566bfe3a > --- /dev/null > +++ b/Platform/Intel/BoardModulePkg/Library/BiosIdLib/BiosIdCommon.c > @@ -0,0 +1,96 @@ > +/** @file > + Boot service common BIOS ID library implementation. > + > + These functions in this file can be called during DXE and cannot be > + called during runtime or in SMM which should use a RT or SMM library. > + > + > +Copyright (c) 2023, Intel Corporation. All rights reserved. > +SPDX-License-Identifier: BSD-2-Clause-Patent > + > +**/ > + > +#include > +#include > +#include > +#include > + > +/** > + This function returns the BIOS Version & Release Date and Time by getting > and converting BIOS ID. > + > + @param[out] BiosVersion The Bios Version out of the conversion. > + @param[out] BiosReleaseDate The Bios Release Date out of the > conversion. > + @param[out] BiosReleaseTime The Bios Release Time out of the > conversion. > + > + @retval EFI_SUCCESS BIOS Version & Release Date and Time have > been got successfully. > + @retval EFI_NOT_FOUND BIOS ID image is not found, and no > parameter will be modified. > + @retval EFI_INVALID_PARAMETER All the parameters are NULL. > + > +**/ > +EFI_STATUS > +EFIAPI > +GetBiosVersionDateTime ( > + OUT CHAR16 *BiosVersion OPTIONAL, > + OUT CHAR16 *BiosReleaseDate OPTIONAL, > + OUT CHAR16 *BiosReleaseTime OPTIONAL > + ) > +{ > + EFI_STATUS Status; > + BIOS_ID_IMAGE BiosIdImage; > + > + if ((BiosVersion == NULL) && (BiosReleaseDate == NULL) && > (BiosReleaseTime == NULL)) { > +return EFI_INVALID_PARAMETER; > + } > + > + Status = GetBiosId (&BiosIdImage); > + if (EFI_ERROR (Status)) { > +return EFI_NOT_FOUND; > + } > + > + if (BiosVersion != NULL) { > +// > +// Fill the BiosVersion data from the BIOS ID. > +// > +CopyMem (BiosVersion, &(BiosIdImage.BiosIdString), sizeof > + (BIOS_ID_STRING)); } > + > + if (BiosReleaseDate != NULL) { > +// > +// Fill the build timestamp date from the BIOS ID in the "MM/DD/YY" > format. > +// > +BiosReleaseDate[0] = BiosIdImage.BiosIdString.TimeStamp[2]; > +BiosReleaseDate[1] = BiosIdImage.BiosIdString.TimeStamp[3]; > +BiosReleaseDate[2] = (CHAR16)((UINT8)('/')); > + > +BiosReleaseDate[3] = BiosIdImage.BiosIdString.TimeStamp[4]; > +BiosReleaseDate[4] = BiosIdImage.BiosIdString.TimeStamp[5]; > +BiosReleaseDate[5] = (CHAR16)((UINT8)('/')); > + > +// > +// Add 20 for SMBIOS table > +// Current Linux kernel will misjudge 09 as year 0, so using 2009 for > SMBIOS table > +// > +BiosReleaseDate[6] = '2'; > +BiosReleaseDate[7] = '0'; > +BiosReleaseDate[8] = BiosIdImage.BiosIdString.TimeStamp[0]; > +BiosReleaseDate[9] = BiosIdImage.BiosIdString.TimeStamp[1]; > + > +BiosReleaseDate[10] = (CHAR16)((UINT8)('\0')); } > + > + if (BiosReleaseTime != NULL) { > +// > +// Fill the build timestamp time from the BIOS ID in the "HH:MM" format. > +// > +BiosReleaseTime[0] = BiosIdImage.BiosIdString.TimeStamp[6]; > +BiosReleaseTime[1] = BiosIdImage.BiosIdString.TimeStamp[7]; > +BiosReleaseTime[2] = (CHAR16)((UINT8)(':')); > + > +BiosReleaseTime[3] = BiosIdImage.BiosIdString.TimeStamp[8]; > +BiosReleaseTime[4] = BiosIdImage.BiosIdString.TimeStamp[9]; > + > +BiosReleaseTime[5] = (CHAR16)((UINT8)('\0')); } > + > + return EFI_SUCCESS; > +} > diff --git a/Platform/Intel/BoardModulePkg/Library/BiosIdLib/DxeBiosIdLib.c > b/Platform/Intel/BoardModulePkg/Library/BiosIdLib/DxeBiosIdLib.c > index 3e614d9efc3e..6535bb36f6c9 1