]> git.proxmox.com Git - mirror_edk2.git/blame - Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscSubclassDriverEntryPoint.c
Hash2 driver to [Components.IA32, Components.X64, Components.IPF] section.
[mirror_edk2.git] / Vlv2TbltDevicePkg / SmBiosMiscDxe / MiscSubclassDriverEntryPoint.c
CommitLineData
3cbfba02
DW
1/** @file\r
2\r
3Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>\r
4 \r\r
5 This program and the accompanying materials are licensed and made available under\r\r
6 the terms and conditions of the BSD License that accompanies this distribution. \r\r
7 The full text of the license may be found at \r\r
8 http://opensource.org/licenses/bsd-license.php. \r\r
9 \r\r
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r\r
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r\r
12 \r\r
13\r
14\r
15Module Name:\r
16\r
17 MiscSubclassDriverEntryPoint.c\r
18\r
19Abstract:\r
20\r
21 This driver parses the mMiscSubclassDataTable structure and reports\r
22 any generated data to the DataHub.\r
23\r
24\r
25**/\r
26\r
27\r
28#include "CommonHeader.h"\r
29\r
30#include "MiscSubclassDriver.h"\r
31#include <Protocol/HiiString.h>\r
32\r
33EFI_HII_HANDLE mHiiHandle;\r
34EFI_HII_STRING_PROTOCOL *mHiiString;\r
35\r
36\r
37EFI_STRING\r
38EFIAPI\r
39SmbiosMiscGetString (\r
40 IN EFI_STRING_ID StringId\r
41 ){\r
42\r
43 EFI_STATUS Status;\r
44 UINTN StringSize;\r
45 CHAR16 TempString;\r
46 EFI_STRING String;\r
47 String = NULL;\r
48\r
49 //\r
50 // Retrieve the size of the string in the string package for the BestLanguage\r
51 //\r
52 StringSize = 0;\r
53 Status = mHiiString->GetString (\r
54 mHiiString,\r
55 "en-US",\r
56 mHiiHandle,\r
57 StringId,\r
58 &TempString,\r
59 &StringSize,\r
60 NULL\r
61 );\r
62 //\r
63 // If GetString() returns EFI_SUCCESS for a zero size,\r
64 // then there are no supported languages registered for HiiHandle. If GetString()\r
65 // returns an error other than EFI_BUFFER_TOO_SMALL, then HiiHandle is not present\r
66 // in the HII Database\r
67 //\r
68 if (Status != EFI_BUFFER_TOO_SMALL) {\r
69 goto Error;\r
70 }\r
71\r
72 //\r
73 // Allocate a buffer for the return string\r
74 //\r
75 String = AllocateZeroPool (StringSize);\r
76 if (String == NULL) {\r
77 goto Error;\r
78 }\r
79\r
80 //\r
81 // Retrieve the string from the string package\r
82 //\r
83 Status = mHiiString->GetString (\r
84 mHiiString,\r
85 "en-US",\r
86 mHiiHandle,\r
87 StringId,\r
88 String,\r
89 &StringSize,\r
90 NULL\r
91 );\r
92 if (EFI_ERROR (Status)) {\r
93 //\r
94 // Free the buffer and return NULL if the supported languages can not be retrieved.\r
95 //\r
96 FreePool (String);\r
97 String = NULL;\r
98 }\r
99Error:\r
100\r
101 return String;\r
102}\r
103\r
104/**\r
105 Standard EFI driver point. This driver parses the mMiscSubclassDataTable\r
106 structure and reports any generated data to the DataHub.\r
107\r
108 @param ImageHandle - Handle for the image of this driver\r
109 @param SystemTable - Pointer to the EFI System Table\r
110\r
111 @retval EFI_SUCCESS - The data was successfully reported to the Data Hub.\r
112 @retval EFI_DEVICE_ERROR - Can not locate any protocols\r
113\r
114**/\r
115EFI_STATUS\r
116EFIAPI\r
117MiscSubclassDriverEntryPoint (\r
118 IN EFI_HANDLE ImageHandle,\r
119 IN EFI_SYSTEM_TABLE *SystemTable\r
120 )\r
121{\r
122 UINTN Index;\r
123 EFI_STATUS EfiStatus;\r
124 EFI_SMBIOS_PROTOCOL *Smbios;\r
125\r
126 //\r
127 // Retrieve the pointer to the UEFI HII String Protocol\r
128 //\r
129 EfiStatus = gBS->LocateProtocol (\r
130 &gEfiHiiStringProtocolGuid,\r
131 NULL,\r
132 (VOID **) &mHiiString\r
133 );\r
134 ASSERT_EFI_ERROR (EfiStatus);\r
135\r
136 EfiStatus = gBS->LocateProtocol(\r
137 &gEfiSmbiosProtocolGuid,\r
138 NULL,\r
139 (VOID**)&Smbios\r
140 );\r
141\r
142 if (EFI_ERROR(EfiStatus)) {\r
143 DEBUG((EFI_D_ERROR, "Could not locate SMBIOS protocol. %r\n", EfiStatus));\r
144 return EfiStatus;\r
145 }\r
146\r
147 mHiiHandle = HiiAddPackages (\r
148 &gEfiCallerIdGuid,\r
149 NULL,\r
150 MiscSubclassStrings,\r
151 NULL\r
152 );\r
153 ASSERT (mHiiHandle != NULL);\r
154\r
155 for (Index = 0; Index < mMiscSubclassDataTableEntries; ++Index) {\r
156 //\r
157 // If the entry have a function pointer, just log the data.\r
158 //\r
159 if (mMiscSubclassDataTable[Index].Function != NULL) {\r
160 EfiStatus = (*mMiscSubclassDataTable[Index].Function)(\r
161 mMiscSubclassDataTable[Index].RecordData,\r
162 Smbios\r
163 );\r
164\r
165 if (EFI_ERROR(EfiStatus)) {\r
166 DEBUG((EFI_D_ERROR, "Misc smbios store error. Index=%d, ReturnStatus=%r\n", Index, EfiStatus));\r
167 return EfiStatus;\r
168 }\r
169 }\r
170 }\r
171\r
172 return EfiStatus;\r
173}\r
174\r