2 Library to add SMBIOS data records from HOB to SMBIOS table.
4 Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
6 This program and the accompanying materials are licensed and made available under
7 the terms and conditions of the BSD License which accompanies this distribution.
8 The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14 @par Specification Reference:
15 System Management BIOS (SMBIOS) Reference Specification v3.0.0
16 dated 2015-Feb-12 (DSP0134)
17 http://www.dmtf.org/sites/default/files/standards/documents/DSP0134_3.0.0.pdf
20 #include <IndustryStandard/SmBios.h>
21 #include <Library/UefiLib.h>
22 #include <Library/BaseLib.h>
23 #include <Library/BaseMemoryLib.h>
24 #include <Library/MemoryAllocationLib.h>
25 #include <Library/DebugLib.h>
26 #include <Library/HobLib.h>
27 #include <Library/UefiBootServicesTableLib.h>
28 #include <Protocol/Smbios.h>
32 Adds SMBIOS records to tables
34 @param[in] ImageHandle Image handle of this driver.
35 @param[in] SystemTable Global system service table.
37 @retval EFI_UNSUPPORTED - Could not locate SMBIOS protocol
38 @retval EFI_OUT_OF_RESOURCES - Failed to allocate memory for SMBIOS HOB type.
39 @retval EFI_SUCCESS - Successfully added SMBIOS records based on HOB.
43 DxeSmbiosDataHobLibConstructor (
44 IN EFI_HANDLE ImageHandle
,
45 IN EFI_SYSTEM_TABLE
*SystemTable
48 EFI_PEI_HOB_POINTERS Hob
;
49 EFI_SMBIOS_HANDLE SmbiosHandle
;
50 EFI_SMBIOS_PROTOCOL
*Smbios
;
57 DEBUG ((DEBUG_INFO
, "Adding SMBIOS records from HOB..\n"));
59 Status
= gBS
->LocateProtocol (&gEfiSmbiosProtocolGuid
, NULL
, (VOID
**)&Smbios
);
61 DEBUG ((DEBUG_WARN
, "Can't locate SMBIOS protocol\n"));
62 return EFI_UNSUPPORTED
;
66 /// Get SMBIOS HOB data (each hob contains one SMBIOS record)
68 for (Hob
.Raw
= GetHobList (); !END_OF_HOB_LIST(Hob
); Hob
.Raw
= GET_NEXT_HOB (Hob
)) {
69 if ((GET_HOB_TYPE (Hob
) == EFI_HOB_TYPE_GUID_EXTENSION
) && (CompareGuid (&Hob
.Guid
->Name
, &gIntelSmbiosDataHobGuid
))) {
70 RecordPtr
= GET_GUID_HOB_DATA (Hob
.Raw
);
73 /// Add generic SMBIOS HOB to SMBIOS table
75 DEBUG ((DEBUG_VERBOSE
, "Add SMBIOS record type: %x\n", ((EFI_SMBIOS_TABLE_HEADER
*) RecordPtr
)->Type
));
76 SmbiosHandle
= SMBIOS_HANDLE_PI_RESERVED
;
77 Status
= Smbios
->Add (Smbios
, NULL
, &SmbiosHandle
, (EFI_SMBIOS_TABLE_HEADER
*) RecordPtr
);
78 if (!EFI_ERROR (Status
)) {
83 DEBUG ((DEBUG_INFO
, "Found %d Records and added to SMBIOS table.\n", RecordCount
));