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