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