]> git.proxmox.com Git - mirror_edk2.git/blame - Vlv2TbltDevicePkg/SmBiosMiscDxe/MiscSubclassDriverEntryPoint.c
MdeModulePkg/CapsuleApp: Center bitmap at bottom of screen
[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
3cbfba02
DW
29#include "MiscSubclassDriver.h"\r
30#include <Protocol/HiiString.h>\r
6f2ef18e
TH
31#include <Guid/PlatformInfo.h>\r
32\r
3cbfba02
DW
33\r
34EFI_HII_HANDLE mHiiHandle;\r
35EFI_HII_STRING_PROTOCOL *mHiiString;\r
6f2ef18e 36EFI_PLATFORM_INFO_HOB *mPlatformInfo=NULL;\r
3cbfba02
DW
37\r
38EFI_STRING\r
39EFIAPI\r
40SmbiosMiscGetString (\r
41 IN EFI_STRING_ID StringId\r
42 ){\r
43\r
44 EFI_STATUS Status;\r
45 UINTN StringSize;\r
46 CHAR16 TempString;\r
47 EFI_STRING String;\r
48 String = NULL;\r
49\r
50 //\r
51 // Retrieve the size of the string in the string package for the BestLanguage\r
52 //\r
53 StringSize = 0;\r
54 Status = mHiiString->GetString (\r
55 mHiiString,\r
56 "en-US",\r
57 mHiiHandle,\r
58 StringId,\r
59 &TempString,\r
60 &StringSize,\r
61 NULL\r
62 );\r
63 //\r
64 // If GetString() returns EFI_SUCCESS for a zero size,\r
65 // then there are no supported languages registered for HiiHandle. If GetString()\r
66 // returns an error other than EFI_BUFFER_TOO_SMALL, then HiiHandle is not present\r
67 // in the HII Database\r
68 //\r
69 if (Status != EFI_BUFFER_TOO_SMALL) {\r
70 goto Error;\r
71 }\r
72\r
73 //\r
74 // Allocate a buffer for the return string\r
75 //\r
76 String = AllocateZeroPool (StringSize);\r
77 if (String == NULL) {\r
78 goto Error;\r
79 }\r
80\r
81 //\r
82 // Retrieve the string from the string package\r
83 //\r
84 Status = mHiiString->GetString (\r
85 mHiiString,\r
86 "en-US",\r
87 mHiiHandle,\r
88 StringId,\r
89 String,\r
90 &StringSize,\r
91 NULL\r
92 );\r
93 if (EFI_ERROR (Status)) {\r
94 //\r
95 // Free the buffer and return NULL if the supported languages can not be retrieved.\r
96 //\r
97 FreePool (String);\r
98 String = NULL;\r
99 }\r
100Error:\r
101\r
102 return String;\r
103}\r
104\r
105/**\r
106 Standard EFI driver point. This driver parses the mMiscSubclassDataTable\r
107 structure and reports any generated data to the DataHub.\r
108\r
109 @param ImageHandle - Handle for the image of this driver\r
110 @param SystemTable - Pointer to the EFI System Table\r
111\r
112 @retval EFI_SUCCESS - The data was successfully reported to the Data Hub.\r
113 @retval EFI_DEVICE_ERROR - Can not locate any protocols\r
114\r
115**/\r
116EFI_STATUS\r
117EFIAPI\r
118MiscSubclassDriverEntryPoint (\r
119 IN EFI_HANDLE ImageHandle,\r
120 IN EFI_SYSTEM_TABLE *SystemTable\r
121 )\r
122{\r
123 UINTN Index;\r
124 EFI_STATUS EfiStatus;\r
125 EFI_SMBIOS_PROTOCOL *Smbios;\r
6f2ef18e 126 EFI_PEI_HOB_POINTERS GuidHob;\r
3cbfba02 127\r
6f2ef18e
TH
128\r
129\r
130 GuidHob.Raw = GetHobList ();\r
131 if (GuidHob.Raw != NULL) {\r
132 if ((GuidHob.Raw = GetNextGuidHob (&gEfiPlatformInfoGuid, GuidHob.Raw)) != NULL) {\r
133 mPlatformInfo = GET_GUID_HOB_DATA (GuidHob.Guid);\r
134 }\r
135 }\r
136 \r
137 DEBUG ((EFI_D_ERROR, "PlatformInfoHob->BoardId [0x%x]\n", mPlatformInfo->BoardId));\r
138 \r
3cbfba02
DW
139 //\r
140 // Retrieve the pointer to the UEFI HII String Protocol\r
141 //\r
142 EfiStatus = gBS->LocateProtocol (\r
143 &gEfiHiiStringProtocolGuid,\r
144 NULL,\r
145 (VOID **) &mHiiString\r
146 );\r
147 ASSERT_EFI_ERROR (EfiStatus);\r
148\r
149 EfiStatus = gBS->LocateProtocol(\r
150 &gEfiSmbiosProtocolGuid,\r
151 NULL,\r
152 (VOID**)&Smbios\r
153 );\r
154\r
155 if (EFI_ERROR(EfiStatus)) {\r
156 DEBUG((EFI_D_ERROR, "Could not locate SMBIOS protocol. %r\n", EfiStatus));\r
157 return EfiStatus;\r
158 }\r
159\r
160 mHiiHandle = HiiAddPackages (\r
161 &gEfiCallerIdGuid,\r
162 NULL,\r
163 MiscSubclassStrings,\r
164 NULL\r
165 );\r
166 ASSERT (mHiiHandle != NULL);\r
167\r
168 for (Index = 0; Index < mMiscSubclassDataTableEntries; ++Index) {\r
169 //\r
170 // If the entry have a function pointer, just log the data.\r
171 //\r
172 if (mMiscSubclassDataTable[Index].Function != NULL) {\r
173 EfiStatus = (*mMiscSubclassDataTable[Index].Function)(\r
174 mMiscSubclassDataTable[Index].RecordData,\r
175 Smbios\r
176 );\r
177\r
178 if (EFI_ERROR(EfiStatus)) {\r
179 DEBUG((EFI_D_ERROR, "Misc smbios store error. Index=%d, ReturnStatus=%r\n", Index, EfiStatus));\r
180 return EfiStatus;\r
181 }\r
182 }\r
183 }\r
184\r
185 return EfiStatus;\r
186}\r
187\r