]> git.proxmox.com Git - mirror_edk2.git/blame - UnixPkg/MiscSubClassPlatformDxe/MiscSubclassDriverEntryPoint.c
Enable TPM measurement lib to measure all PE image from a FV unmeasured by TcgPei
[mirror_edk2.git] / UnixPkg / MiscSubClassPlatformDxe / MiscSubclassDriverEntryPoint.c
CommitLineData
804405e7 1/*++\r
2\r
3e570e6e 3Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
f9b8ab56 4This program and the accompanying materials\r
804405e7 5are licensed and made available under the terms and conditions of the BSD License\r
6which accompanies this distribution. The full text of the license may be found at\r
7http://opensource.org/licenses/bsd-license.php\r
8\r
9THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
10WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
11\r
12Module Name:\r
13\r
14 MiscSubclassDriverEntryPoint.c\r
15\r
16Abstract:\r
17\r
18 This driver parses the mMiscSubclassDataTable structure and reports\r
19 any generated data to the DataHub.\r
20\r
21--*/\r
22\r
23#include "MiscSubClassDriver.h"\r
24\r
aaa2cc19 25EFI_HII_HANDLE mHiiHandle;\r
804405e7 26\r
aaa2cc19 27/**\r
28 This is the standard EFI driver point that detects whether there is a\r
29 MemoryConfigurationData Variable and, if so, reports memory configuration info\r
30 to the DataHub.\r
804405e7 31\r
aaa2cc19 32 @param ImageHandle Handle for the image of this driver\r
33 @param SystemTable Pointer to the EFI System Table\r
804405e7 34\r
aaa2cc19 35 @return EFI_SUCCESS if the data is successfully reported\r
36 @return EFI_NOT_FOUND if the HOB list could not be located.\r
804405e7 37\r
aaa2cc19 38**/\r
39EFI_STATUS\r
40LogMemorySmbiosRecord (\r
41 VOID\r
42 )\r
804405e7 43{\r
aaa2cc19 44 EFI_STATUS Status;\r
45 UINT64 TotalMemorySize;\r
46 UINT8 NumSlots;\r
47 SMBIOS_TABLE_TYPE19 *Type19Record;\r
48 EFI_SMBIOS_HANDLE MemArrayMappedAddrSmbiosHandle;\r
49 EFI_SMBIOS_PROTOCOL *Smbios;\r
50 CHAR16 *UnixMemString;\r
51\r
52 Status = gBS->LocateProtocol (&gEfiSmbiosProtocolGuid, NULL, (VOID**)&Smbios);\r
53 ASSERT_EFI_ERROR (Status);\r
54 \r
55 NumSlots = 1;\r
804405e7 56\r
57 //\r
aaa2cc19 58 // Process Memory String in form size!size ...\r
59 // So 64!64 is 128 MB\r
804405e7 60 //\r
aaa2cc19 61 UnixMemString = PcdGetPtr (PcdUnixMemorySize);\r
62 for (TotalMemorySize = 0; *UnixMemString != '\0';) {\r
63 TotalMemorySize += StrDecimalToUint64 (UnixMemString);\r
64 while (*UnixMemString != '\0') {\r
65 if (*UnixMemString == '!') {\r
66 UnixMemString++; \r
67 break;\r
68 }\r
69 UnixMemString++;\r
70 }\r
804405e7 71 }\r
aaa2cc19 72\r
73 //\r
74 // Convert Total Memory Size to based on KiloByte\r
804405e7 75 //\r
aaa2cc19 76 TotalMemorySize = LShiftU64 (TotalMemorySize, 20);\r
804405e7 77 //\r
aaa2cc19 78 // Generate Memory Array Mapped Address info\r
79 //\r
3e570e6e 80 Type19Record = AllocateZeroPool(sizeof (SMBIOS_TABLE_TYPE19) + 2);\r
aaa2cc19 81 Type19Record->Hdr.Type = EFI_SMBIOS_TYPE_MEMORY_ARRAY_MAPPED_ADDRESS;\r
82 Type19Record->Hdr.Length = sizeof(SMBIOS_TABLE_TYPE19);\r
83 Type19Record->Hdr.Handle = 0;\r
84 Type19Record->StartingAddress = 0;\r
85 Type19Record->EndingAddress = (UINT32)RShiftU64(TotalMemorySize, 10) - 1;\r
86 Type19Record->MemoryArrayHandle = 0;\r
87 Type19Record->PartitionWidth = (UINT8)(NumSlots); \r
804405e7 88\r
89 //\r
aaa2cc19 90 // Generate Memory Array Mapped Address info (TYPE 19)\r
804405e7 91 //\r
a762a877
SZ
92 Status = AddSmbiosRecord (Smbios, &MemArrayMappedAddrSmbiosHandle, (EFI_SMBIOS_TABLE_HEADER*) Type19Record);\r
93\r
aaa2cc19 94 FreePool(Type19Record);\r
95 ASSERT_EFI_ERROR (Status);\r
804405e7 96\r
aaa2cc19 97 return Status;\r
804405e7 98}\r
99\r
100\r
101EFI_STATUS\r
102EFIAPI\r
103MiscSubclassDriverEntryPoint (\r
104 IN EFI_HANDLE ImageHandle,\r
105 IN EFI_SYSTEM_TABLE *SystemTable\r
106 )\r
107/*++\r
108Description:\r
109\r
110 Standard EFI driver point. This driver parses the mMiscSubclassDataTable\r
111 structure and reports any generated data to the DataHub.\r
112\r
113Arguments:\r
114\r
115 ImageHandle\r
116 Handle for the image of this driver\r
117\r
118 SystemTable\r
119 Pointer to the EFI System Table\r
120\r
121Returns:\r
122\r
123 EFI_SUCCESS\r
124 The data was successfully reported to the Data Hub.\r
125\r
126--*/\r
127{\r
aaa2cc19 128 UINTN Index;\r
129 EFI_STATUS EfiStatus;\r
130 EFI_SMBIOS_PROTOCOL *Smbios; \r
804405e7 131\r
aaa2cc19 132 EfiStatus = gBS->LocateProtocol(&gEfiSmbiosProtocolGuid, NULL, (VOID**)&Smbios);\r
804405e7 133\r
aaa2cc19 134 if (EFI_ERROR(EfiStatus)) {\r
135 DEBUG((EFI_D_ERROR, "Could not locate SMBIOS protocol. %r\n", EfiStatus));\r
804405e7 136 return EfiStatus;\r
804405e7 137 }\r
138\r
aaa2cc19 139 mHiiHandle = HiiAddPackages (\r
140 &gEfiCallerIdGuid,\r
141 NULL,\r
142 MiscSubclassStrings,\r
143 NULL\r
144 );\r
145 ASSERT (mHiiHandle != NULL);\r
cb7d01c0 146\r
804405e7 147 for (Index = 0; Index < mMiscSubclassDataTableEntries; ++Index) {\r
148 //\r
aaa2cc19 149 // If the entry have a function pointer, just log the data.\r
804405e7 150 //\r
aaa2cc19 151 if (mMiscSubclassDataTable[Index].Function != NULL) {\r
152 EfiStatus = (*mMiscSubclassDataTable[Index].Function)(\r
804405e7 153 mMiscSubclassDataTable[Index].RecordData,\r
aaa2cc19 154 Smbios\r
804405e7 155 );\r
804405e7 156\r
aaa2cc19 157 if (EFI_ERROR(EfiStatus)) {\r
158 DEBUG((EFI_D_ERROR, "Misc smbios store error. Index=%d, ReturnStatus=%r\n", Index, EfiStatus));\r
159 return EfiStatus;\r
804405e7 160 }\r
804405e7 161 }\r
162 }\r
163\r
804405e7 164 //\r
aaa2cc19 165 // Log Memory SMBIOS Record\r
804405e7 166 //\r
aaa2cc19 167 EfiStatus = LogMemorySmbiosRecord();\r
168 return EfiStatus;\r
804405e7 169}\r
a762a877
SZ
170\r
171/**\r
172 Add an SMBIOS record.\r
173\r
174 @param Smbios The EFI_SMBIOS_PROTOCOL instance.\r
175 @param SmbiosHandle A unique handle will be assigned to the SMBIOS record.\r
176 @param Record The data for the fixed portion of the SMBIOS record. The format of the record is\r
177 determined by EFI_SMBIOS_TABLE_HEADER.Type. The size of the formatted area is defined \r
178 by EFI_SMBIOS_TABLE_HEADER.Length and either followed by a double-null (0x0000) or \r
179 a set of null terminated strings and a null.\r
180\r
181 @retval EFI_SUCCESS Record was added.\r
182 @retval EFI_OUT_OF_RESOURCES Record was not added due to lack of system resources.\r
183\r
184**/\r
185EFI_STATUS\r
186AddSmbiosRecord (\r
187 IN EFI_SMBIOS_PROTOCOL *Smbios,\r
188 OUT EFI_SMBIOS_HANDLE *SmbiosHandle,\r
189 IN EFI_SMBIOS_TABLE_HEADER *Record\r
190 )\r
191{\r
192 *SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;\r
193 return Smbios->Add (\r
194 Smbios,\r
195 NULL,\r
196 SmbiosHandle,\r
197 Record\r
198 );\r
199}\r
200\r