From 2bfd90f959c94165c1e3b597992932e6dcb59669 Mon Sep 17 00:00:00 2001 From: lzeng14 Date: Mon, 21 Nov 2011 09:32:09 +0000 Subject: [PATCH] According to PI errata 0000654 and 000811, we need use 0xFFFE to instead of 0 for EFI_SMBIOS_PROTOCOL.Add() SmbiosHandle parameter to assign a unique handle to the SMBIOS record, and for EFI_SMBIOS_PROTOCOL.GetNext() SmbiosHandle parameter to get the first matched SMBIOS handle or indicate no more SMBIOS record. Signed-off-by: lzeng14 Reviewed-by: li-elvin git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12754 6f19259b-4bc3-4df7-8a09-765794883524 --- EmulatorPkg/CpuRuntimeDxe/Cpu.c | 2 +- .../MiscBaseBoardManufacturerFunction.c | 10 +---- .../MiscBiosVendorFunction.c | 8 +--- .../MiscBootInformationFunction.c | 11 ++---- .../MiscChassisManufacturerFunction.c | 10 +---- ...MiscNumberOfInstallableLanguagesFunction.c | 11 ++---- .../MiscOemStringFunction.c | 11 ++---- ...cPortInternalConnectorDesignatorFunction.c | 11 ++---- .../MiscResetCapabilitiesFunction.c | 11 ++---- .../MiscSubClassDriver.h | 28 +++++++++----- .../MiscSubclassDriverEntryPoint.c | 37 +++++++++++++++++-- .../MiscSystemLanguageStringFunction.c | 11 ++---- .../MiscSystemManufacturerFunction.c | 11 ++---- .../MiscSystemOptionStringFunction.c | 10 +---- .../MiscSystemSlotDesignationFunction.c | 11 ++---- 15 files changed, 85 insertions(+), 108 deletions(-) diff --git a/EmulatorPkg/CpuRuntimeDxe/Cpu.c b/EmulatorPkg/CpuRuntimeDxe/Cpu.c index 10d86f8e9c..07d6420807 100644 --- a/EmulatorPkg/CpuRuntimeDxe/Cpu.c +++ b/EmulatorPkg/CpuRuntimeDxe/Cpu.c @@ -217,7 +217,7 @@ LogSmbiosData ( EFI_STATUS Status; EFI_SMBIOS_HANDLE SmbiosHandle; - SmbiosHandle = 0; + SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED; Status = Smbios->Add ( Smbios, NULL, diff --git a/EmulatorPkg/MiscSubClassPlatformDxe/MiscBaseBoardManufacturerFunction.c b/EmulatorPkg/MiscSubClassPlatformDxe/MiscBaseBoardManufacturerFunction.c index ce217fa263..562f716fd4 100644 --- a/EmulatorPkg/MiscSubClassPlatformDxe/MiscBaseBoardManufacturerFunction.c +++ b/EmulatorPkg/MiscSubClassPlatformDxe/MiscBaseBoardManufacturerFunction.c @@ -2,7 +2,7 @@ BaseBoard manufacturer information boot time changes. SMBIOS type 2. - Copyright (c) 2009, Intel Corporation. All rights reserved.
+ Copyright (c) 2009 - 2011, 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 @@ -154,13 +154,7 @@ MISC_SMBIOS_TABLE_FUNCTION(MiscBaseBoardManufacturer) // // Now we have got the full smbios record, call smbios protocol to add this record. // - SmbiosHandle = 0; - Status = Smbios-> Add( - Smbios, - NULL, - &SmbiosHandle, - (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord - ); + Status = AddSmbiosRecord (Smbios, &SmbiosHandle, (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord); FreePool(SmbiosRecord); return Status; diff --git a/EmulatorPkg/MiscSubClassPlatformDxe/MiscBiosVendorFunction.c b/EmulatorPkg/MiscSubClassPlatformDxe/MiscBiosVendorFunction.c index 7fdd47f599..39cb889f62 100644 --- a/EmulatorPkg/MiscSubClassPlatformDxe/MiscBiosVendorFunction.c +++ b/EmulatorPkg/MiscSubClassPlatformDxe/MiscBiosVendorFunction.c @@ -189,13 +189,7 @@ MISC_SMBIOS_TABLE_FUNCTION(MiscBiosVendor) // // Now we have got the full smbios record, call smbios protocol to add this record. // - SmbiosHandle = 0; - Status = Smbios-> Add( - Smbios, - NULL, - &SmbiosHandle, - (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord - ); + Status = AddSmbiosRecord (Smbios, &SmbiosHandle, (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord); FreePool(SmbiosRecord); return Status; diff --git a/EmulatorPkg/MiscSubClassPlatformDxe/MiscBootInformationFunction.c b/EmulatorPkg/MiscSubClassPlatformDxe/MiscBootInformationFunction.c index 98d6181501..8e58e61031 100644 --- a/EmulatorPkg/MiscSubClassPlatformDxe/MiscBootInformationFunction.c +++ b/EmulatorPkg/MiscSubClassPlatformDxe/MiscBootInformationFunction.c @@ -2,7 +2,7 @@ boot information boot time changes. SMBIOS type 32. - Copyright (c) 2009, Intel Corporation. All rights reserved.
+ Copyright (c) 2009 - 2011, 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 @@ -61,13 +61,8 @@ MISC_SMBIOS_TABLE_FUNCTION(BootInformationStatus) // // Now we have got the full smbios record, call smbios protocol to add this record. // - SmbiosHandle = 0; - Status = Smbios-> Add( - Smbios, - NULL, - &SmbiosHandle, - (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord - ); + Status = AddSmbiosRecord (Smbios, &SmbiosHandle, (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord); + FreePool(SmbiosRecord); return Status; } diff --git a/EmulatorPkg/MiscSubClassPlatformDxe/MiscChassisManufacturerFunction.c b/EmulatorPkg/MiscSubClassPlatformDxe/MiscChassisManufacturerFunction.c index 8e57fd5022..0df651e693 100644 --- a/EmulatorPkg/MiscSubClassPlatformDxe/MiscChassisManufacturerFunction.c +++ b/EmulatorPkg/MiscSubClassPlatformDxe/MiscChassisManufacturerFunction.c @@ -2,7 +2,7 @@ Chassis manufacturer information boot time changes. SMBIOS type 3. - Copyright (c) 2009, Intel Corporation. All rights reserved.
+ Copyright (c) 2009 - 2011, 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 @@ -124,13 +124,7 @@ MISC_SMBIOS_TABLE_FUNCTION(MiscChassisManufacturer) // // Now we have got the full smbios record, call smbios protocol to add this record. // - SmbiosHandle = 0; - Status = Smbios-> Add( - Smbios, - NULL, - &SmbiosHandle, - (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord - ); + Status = AddSmbiosRecord (Smbios, &SmbiosHandle, (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord); FreePool(SmbiosRecord); return Status; diff --git a/EmulatorPkg/MiscSubClassPlatformDxe/MiscNumberOfInstallableLanguagesFunction.c b/EmulatorPkg/MiscSubClassPlatformDxe/MiscNumberOfInstallableLanguagesFunction.c index 3c3a5f3ed7..988e0c6029 100644 --- a/EmulatorPkg/MiscSubClassPlatformDxe/MiscNumberOfInstallableLanguagesFunction.c +++ b/EmulatorPkg/MiscSubClassPlatformDxe/MiscNumberOfInstallableLanguagesFunction.c @@ -2,7 +2,7 @@ This driver parses the mSmbiosMiscDataTable structure and reports any generated data. - Copyright (c) 2009, Intel Corporation. All rights reserved.
+ Copyright (c) 2009 - 2011, 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 @@ -226,13 +226,8 @@ MISC_SMBIOS_TABLE_FUNCTION(NumberOfInstallableLanguages) // // Now we have got the full smbios record, call smbios protocol to add this record. // - SmbiosHandle = 0; - Status = Smbios-> Add( - Smbios, - NULL, - &SmbiosHandle, - (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord - ); + Status = AddSmbiosRecord (Smbios, &SmbiosHandle, (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord); + FreePool(SmbiosRecord); return Status; } diff --git a/EmulatorPkg/MiscSubClassPlatformDxe/MiscOemStringFunction.c b/EmulatorPkg/MiscSubClassPlatformDxe/MiscOemStringFunction.c index f3291828c3..a879283a9c 100644 --- a/EmulatorPkg/MiscSubClassPlatformDxe/MiscOemStringFunction.c +++ b/EmulatorPkg/MiscSubClassPlatformDxe/MiscOemStringFunction.c @@ -2,7 +2,7 @@ boot information boot time changes. SMBIOS type 11. - Copyright (c) 2009, Intel Corporation. All rights reserved.
+ Copyright (c) 2009 - 2011, 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 @@ -68,13 +68,8 @@ MISC_SMBIOS_TABLE_FUNCTION(OemString) // // Now we have got the full smbios record, call smbios protocol to add this record. // - SmbiosHandle = 0; - Status = Smbios-> Add( - Smbios, - NULL, - &SmbiosHandle, - (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord - ); + Status = AddSmbiosRecord (Smbios, &SmbiosHandle, (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord); + FreePool(SmbiosRecord); return Status; } diff --git a/EmulatorPkg/MiscSubClassPlatformDxe/MiscPortInternalConnectorDesignatorFunction.c b/EmulatorPkg/MiscSubClassPlatformDxe/MiscPortInternalConnectorDesignatorFunction.c index e137887803..3242fe342e 100644 --- a/EmulatorPkg/MiscSubClassPlatformDxe/MiscPortInternalConnectorDesignatorFunction.c +++ b/EmulatorPkg/MiscSubClassPlatformDxe/MiscPortInternalConnectorDesignatorFunction.c @@ -1,6 +1,6 @@ /*++ -Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2011, 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 @@ -161,13 +161,8 @@ Returns: // // Now we have got the full smbios record, call smbios protocol to add this record. // - SmbiosHandle = 0; - Status = Smbios-> Add( - Smbios, - NULL, - &SmbiosHandle, - (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord - ); + Status = AddSmbiosRecord (Smbios, &SmbiosHandle, (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord); + FreePool(SmbiosRecord); return Status; } diff --git a/EmulatorPkg/MiscSubClassPlatformDxe/MiscResetCapabilitiesFunction.c b/EmulatorPkg/MiscSubClassPlatformDxe/MiscResetCapabilitiesFunction.c index 33a43a3e64..d7678d3758 100644 --- a/EmulatorPkg/MiscSubClassPlatformDxe/MiscResetCapabilitiesFunction.c +++ b/EmulatorPkg/MiscSubClassPlatformDxe/MiscResetCapabilitiesFunction.c @@ -2,7 +2,7 @@ ResetCapabilities. SMBIOS type 23. - Copyright (c) 2009, Intel Corporation. All rights reserved.
+ Copyright (c) 2009 - 2011, 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 @@ -63,13 +63,8 @@ MISC_SMBIOS_TABLE_FUNCTION(MiscResetCapabilities) // // Now we have got the full smbios record, call smbios protocol to add this record. // - SmbiosHandle = 0; - Status = Smbios-> Add( - Smbios, - NULL, - &SmbiosHandle, - (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord - ); + Status = AddSmbiosRecord (Smbios, &SmbiosHandle, (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord); + FreePool(SmbiosRecord); return Status; } diff --git a/EmulatorPkg/MiscSubClassPlatformDxe/MiscSubClassDriver.h b/EmulatorPkg/MiscSubClassPlatformDxe/MiscSubClassDriver.h index 7e5be7ea80..c7749f3f17 100644 --- a/EmulatorPkg/MiscSubClassPlatformDxe/MiscSubClassDriver.h +++ b/EmulatorPkg/MiscSubClassPlatformDxe/MiscSubClassDriver.h @@ -1,6 +1,6 @@ /*++ -Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2011, 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 @@ -106,17 +106,27 @@ extern UINTN mMiscSubclassDataTableEntries; extern UINT8 MiscSubclassStrings[]; extern EFI_HII_HANDLE mHiiHandle; -// -// Prototypes -// +/** + Add an SMBIOS record. + + @param Smbios The EFI_SMBIOS_PROTOCOL instance. + @param SmbiosHandle A unique handle will be assigned to the SMBIOS record. + @param Record The data for the fixed portion of the SMBIOS record. The format of the record is + determined by EFI_SMBIOS_TABLE_HEADER.Type. The size of the formatted area is defined + by EFI_SMBIOS_TABLE_HEADER.Length and either followed by a double-null (0x0000) or + a set of null terminated strings and a null. + + @retval EFI_SUCCESS Record was added. + @retval EFI_OUT_OF_RESOURCES Record was not added due to lack of system resources. + +**/ EFI_STATUS -EFIAPI -MiscSubclassDriverEntryPoint ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable +AddSmbiosRecord ( + IN EFI_SMBIOS_PROTOCOL *Smbios, + OUT EFI_SMBIOS_HANDLE *SmbiosHandle, + IN EFI_SMBIOS_TABLE_HEADER *Record ); - #endif /* _MISC_SUBCLASS_DRIVER_H */ /* eof - MiscSubclassDriver.h */ diff --git a/EmulatorPkg/MiscSubClassPlatformDxe/MiscSubclassDriverEntryPoint.c b/EmulatorPkg/MiscSubClassPlatformDxe/MiscSubclassDriverEntryPoint.c index 88a99a2108..fc2275cc7a 100644 --- a/EmulatorPkg/MiscSubClassPlatformDxe/MiscSubclassDriverEntryPoint.c +++ b/EmulatorPkg/MiscSubClassPlatformDxe/MiscSubclassDriverEntryPoint.c @@ -1,6 +1,6 @@ /*++ -Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2011, 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 @@ -90,8 +90,8 @@ LogMemorySmbiosRecord ( // // Generate Memory Array Mapped Address info (TYPE 19) // - MemArrayMappedAddrSmbiosHandle = 0; - Status = Smbios->Add (Smbios, NULL, &MemArrayMappedAddrSmbiosHandle, (EFI_SMBIOS_TABLE_HEADER*) Type19Record); + Status = AddSmbiosRecord (Smbios, &MemArrayMappedAddrSmbiosHandle, (EFI_SMBIOS_TABLE_HEADER*) Type19Record); + FreePool(Type19Record); ASSERT_EFI_ERROR (Status); @@ -168,3 +168,34 @@ Returns: EfiStatus = LogMemorySmbiosRecord(); return EfiStatus; } + +/** + Add an SMBIOS record. + + @param Smbios The EFI_SMBIOS_PROTOCOL instance. + @param SmbiosHandle A unique handle will be assigned to the SMBIOS record. + @param Record The data for the fixed portion of the SMBIOS record. The format of the record is + determined by EFI_SMBIOS_TABLE_HEADER.Type. The size of the formatted area is defined + by EFI_SMBIOS_TABLE_HEADER.Length and either followed by a double-null (0x0000) or + a set of null terminated strings and a null. + + @retval EFI_SUCCESS Record was added. + @retval EFI_OUT_OF_RESOURCES Record was not added due to lack of system resources. + +**/ +EFI_STATUS +AddSmbiosRecord ( + IN EFI_SMBIOS_PROTOCOL *Smbios, + OUT EFI_SMBIOS_HANDLE *SmbiosHandle, + IN EFI_SMBIOS_TABLE_HEADER *Record + ) +{ + *SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED; + return Smbios->Add ( + Smbios, + NULL, + SmbiosHandle, + Record + ); +} + diff --git a/EmulatorPkg/MiscSubClassPlatformDxe/MiscSystemLanguageStringFunction.c b/EmulatorPkg/MiscSubClassPlatformDxe/MiscSystemLanguageStringFunction.c index db15a252da..96a3577828 100644 --- a/EmulatorPkg/MiscSubClassPlatformDxe/MiscSystemLanguageStringFunction.c +++ b/EmulatorPkg/MiscSubClassPlatformDxe/MiscSystemLanguageStringFunction.c @@ -2,7 +2,7 @@ ResetCapabilities. SMBIOS type 23. - Copyright (c) 2009, Intel Corporation. All rights reserved.
+ Copyright (c) 2009 - 2011, 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 @@ -72,13 +72,8 @@ MISC_SMBIOS_TABLE_FUNCTION(SystemLanguageString) // // Now we have got the full smbios record, call smbios protocol to add this record. // - SmbiosHandle = 0; - Status = Smbios-> Add( - Smbios, - NULL, - &SmbiosHandle, - (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord - ); + Status = AddSmbiosRecord (Smbios, &SmbiosHandle, (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord); + FreePool(SmbiosRecord); return Status; } diff --git a/EmulatorPkg/MiscSubClassPlatformDxe/MiscSystemManufacturerFunction.c b/EmulatorPkg/MiscSubClassPlatformDxe/MiscSystemManufacturerFunction.c index 670f379f56..317922ffe1 100644 --- a/EmulatorPkg/MiscSubClassPlatformDxe/MiscSystemManufacturerFunction.c +++ b/EmulatorPkg/MiscSubClassPlatformDxe/MiscSystemManufacturerFunction.c @@ -1,6 +1,6 @@ /*++ -Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2011, 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 @@ -126,13 +126,8 @@ MISC_SMBIOS_TABLE_FUNCTION(MiscSystemManufacturer) // // Now we have got the full smbios record, call smbios protocol to add this record. // - SmbiosHandle = 0; - Status = Smbios-> Add( - Smbios, - NULL, - &SmbiosHandle, - (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord - ); + Status = AddSmbiosRecord (Smbios, &SmbiosHandle, (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord); + FreePool(SmbiosRecord); return Status; } diff --git a/EmulatorPkg/MiscSubClassPlatformDxe/MiscSystemOptionStringFunction.c b/EmulatorPkg/MiscSubClassPlatformDxe/MiscSystemOptionStringFunction.c index 348a33ec82..734e90dff6 100644 --- a/EmulatorPkg/MiscSubClassPlatformDxe/MiscSystemOptionStringFunction.c +++ b/EmulatorPkg/MiscSubClassPlatformDxe/MiscSystemOptionStringFunction.c @@ -2,7 +2,7 @@ BIOS system option string boot time changes. SMBIOS type 12. - Copyright (c) 2009, Intel Corporation. All rights reserved.
+ Copyright (c) 2009 - 2011, 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 @@ -70,13 +70,7 @@ MISC_SMBIOS_TABLE_FUNCTION(SystemOptionString) // // Now we have got the full smbios record, call smbios protocol to add this record. // - SmbiosHandle = 0; - Status = Smbios-> Add( - Smbios, - NULL, - &SmbiosHandle, - (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord - ); + Status = AddSmbiosRecord (Smbios, &SmbiosHandle, (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord); FreePool(SmbiosRecord); return Status; diff --git a/EmulatorPkg/MiscSubClassPlatformDxe/MiscSystemSlotDesignationFunction.c b/EmulatorPkg/MiscSubClassPlatformDxe/MiscSystemSlotDesignationFunction.c index 3ed0fa74ca..3c64a11e69 100644 --- a/EmulatorPkg/MiscSubClassPlatformDxe/MiscSystemSlotDesignationFunction.c +++ b/EmulatorPkg/MiscSubClassPlatformDxe/MiscSystemSlotDesignationFunction.c @@ -2,7 +2,7 @@ BIOS system slot designator information boot time changes. SMBIOS type 9. - Copyright (c) 2009, Intel Corporation. All rights reserved.
+ Copyright (c) 2009 - 2011, 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 @@ -85,13 +85,8 @@ MISC_SMBIOS_TABLE_FUNCTION(MiscSystemSlotDesignation) // // Now we have got the full smbios record, call smbios protocol to add this record. // - SmbiosHandle = 0; - Status = Smbios-> Add( - Smbios, - NULL, - &SmbiosHandle, - (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord - ); + Status = AddSmbiosRecord (Smbios, &SmbiosHandle, (EFI_SMBIOS_TABLE_HEADER *) SmbiosRecord); + FreePool(SmbiosRecord); return Status; } -- 2.39.2