]> git.proxmox.com Git - mirror_edk2.git/blob - IntelSiliconPkg/Library/DxeSmbiosDataHobLib/DxeSmbiosDataHobLib.c
IntelSiliconPkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / IntelSiliconPkg / Library / DxeSmbiosDataHobLib / DxeSmbiosDataHobLib.c
1 /** @file
2 Library to add SMBIOS data records from HOB to SMBIOS table.
3
4 Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
5
6 SPDX-License-Identifier: BSD-2-Clause-Patent
7
8 @par Specification Reference:
9 System Management BIOS (SMBIOS) Reference Specification v3.0.0
10 dated 2015-Feb-12 (DSP0134)
11 http://www.dmtf.org/sites/default/files/standards/documents/DSP0134_3.0.0.pdf
12
13 **/
14 #include <IndustryStandard/SmBios.h>
15 #include <Library/UefiLib.h>
16 #include <Library/BaseLib.h>
17 #include <Library/BaseMemoryLib.h>
18 #include <Library/MemoryAllocationLib.h>
19 #include <Library/DebugLib.h>
20 #include <Library/HobLib.h>
21 #include <Library/UefiBootServicesTableLib.h>
22 #include <Protocol/Smbios.h>
23
24
25 /**
26 Adds SMBIOS records to tables
27
28 @param[in] ImageHandle Image handle of this driver.
29 @param[in] SystemTable Global system service table.
30
31 @retval EFI_UNSUPPORTED - Could not locate SMBIOS protocol
32 @retval EFI_OUT_OF_RESOURCES - Failed to allocate memory for SMBIOS HOB type.
33 @retval EFI_SUCCESS - Successfully added SMBIOS records based on HOB.
34 **/
35 EFI_STATUS
36 EFIAPI
37 DxeSmbiosDataHobLibConstructor (
38 IN EFI_HANDLE ImageHandle,
39 IN EFI_SYSTEM_TABLE *SystemTable
40 )
41 {
42 EFI_PEI_HOB_POINTERS Hob;
43 EFI_SMBIOS_HANDLE SmbiosHandle;
44 EFI_SMBIOS_PROTOCOL *Smbios;
45 EFI_STATUS Status;
46 UINT8 *RecordPtr;
47 UINT16 RecordCount;
48
49 RecordCount = 0;
50
51 DEBUG ((DEBUG_INFO, "Adding SMBIOS records from HOB..\n"));
52
53 Status = gBS->LocateProtocol (&gEfiSmbiosProtocolGuid, NULL, (VOID **)&Smbios);
54 if (Smbios == NULL) {
55 DEBUG ((DEBUG_WARN, "Can't locate SMBIOS protocol\n"));
56 return EFI_UNSUPPORTED;
57 }
58
59 ///
60 /// Get SMBIOS HOB data (each hob contains one SMBIOS record)
61 ///
62 for (Hob.Raw = GetHobList (); !END_OF_HOB_LIST(Hob); Hob.Raw = GET_NEXT_HOB (Hob)) {
63 if ((GET_HOB_TYPE (Hob) == EFI_HOB_TYPE_GUID_EXTENSION) && (CompareGuid (&Hob.Guid->Name, &gIntelSmbiosDataHobGuid))) {
64 RecordPtr = GET_GUID_HOB_DATA (Hob.Raw);
65
66 ///
67 /// Add generic SMBIOS HOB to SMBIOS table
68 ///
69 DEBUG ((DEBUG_VERBOSE, "Add SMBIOS record type: %x\n", ((EFI_SMBIOS_TABLE_HEADER *) RecordPtr)->Type));
70 SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;
71 Status = Smbios->Add (Smbios, NULL, &SmbiosHandle, (EFI_SMBIOS_TABLE_HEADER *) RecordPtr);
72 if (!EFI_ERROR (Status)) {
73 RecordCount++;
74 }
75 }
76 }
77 DEBUG ((DEBUG_INFO, "Found %d Records and added to SMBIOS table.\n", RecordCount));
78
79 return EFI_SUCCESS;
80 }
81