]> git.proxmox.com Git - mirror_edk2.git/blame - SecurityPkg/Tcg/Opal/OpalPasswordDxe/ComponentName.c
SecurityPkg OpalPassword: Add solution without SMM device code
[mirror_edk2.git] / SecurityPkg / Tcg / Opal / OpalPasswordDxe / ComponentName.c
CommitLineData
a06875e1
ED
1/** @file\r
2 UEFI Component Name(2) protocol implementation for Opal driver.\r
3\r
4Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>\r
5This program and the accompanying materials\r
6are licensed and made available under the terms and conditions of the BSD License\r
7which accompanies this distribution. The full text of the license may be found at\r
8http://opensource.org/licenses/bsd-license.php\r
9\r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13**/\r
14\r
15#include "OpalDriver.h"\r
16\r
17//\r
18// EFI Component Name Protocol\r
19//\r
20GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gOpalComponentName = {\r
21 OpalEfiDriverComponentNameGetDriverName,\r
22 OpalEfiDriverComponentNameGetControllerName,\r
23 "eng"\r
24};\r
25\r
26//\r
27// EFI Component Name 2 Protocol\r
28//\r
29GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gOpalComponentName2 = {\r
30 OpalEfiDriverComponentName2GetDriverName,\r
31 OpalEfiDriverComponentName2GetControllerName,\r
32 "en"\r
33};\r
34\r
35\r
36/// The name of the driver in all the languages we support.\r
37GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mOpalDriverNameTable[] = {\r
38 { LANGUAGE_RFC_3066_ENGLISH, (CHAR16*)EFI_DRIVER_NAME_UNICODE },\r
39 { LANGUAGE_ISO_639_2_ENGLISH, (CHAR16*)EFI_DRIVER_NAME_UNICODE },\r
40 { 0, 0 }\r
41};\r
42\r
43/**\r
44 Retrieves a Unicode string that is the user readable name of the driver.\r
45\r
46 This function retrieves the user readable name of a driver in the form of a\r
47 Unicode string. If the driver specified by This has a user readable name in\r
48 the language specified by Language, then a pointer to the driver name is\r
49 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
50 by This does not support the language specified by Language,\r
51 then EFI_UNSUPPORTED is returned.\r
52\r
53 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
54 EFI_COMPONENT_NAME_PROTOCOL instance.\r
55\r
56 @param Language[in] A pointer to a Null-terminated ASCII string\r
57 array indicating the language. This is the\r
58 language of the driver name that the caller is\r
59 requesting, and it must match one of the\r
60 languages specified in SupportedLanguages. The\r
61 number of languages supported by a driver is up\r
62 to the driver writer. Language is specified\r
63 in RFC 4646 or ISO 639-2 language code format.\r
64\r
65 @param DriverName[out] A pointer to the Unicode string to return.\r
66 This Unicode string is the name of the\r
67 driver specified by This in the language\r
68 specified by Language.\r
69\r
70 @retval EFI_SUCCESS The Unicode string for the Driver specified by\r
71 This and the language specified by Language was\r
72 returned in DriverName.\r
73\r
74 @retval EFI_INVALID_PARAMETER Language is NULL.\r
75\r
76 @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
77\r
78 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
79 the language specified by Language.\r
80\r
81**/\r
82EFI_STATUS\r
83EFIAPI\r
84OpalEfiDriverComponentNameGetDriverName(\r
85 EFI_COMPONENT_NAME_PROTOCOL* This,\r
86 CHAR8* Language,\r
87 CHAR16** DriverName\r
88 )\r
89{\r
90 return LookupUnicodeString2(\r
91 Language,\r
92 This->SupportedLanguages,\r
93 mOpalDriverNameTable,\r
94 DriverName,\r
95 TRUE\r
96 );\r
97}\r
98\r
99/**\r
100 Retrieves a Unicode string that is the user readable name of the driver.\r
101\r
102 This function retrieves the user readable name of a driver in the form of a\r
103 Unicode string. If the driver specified by This has a user readable name in\r
104 the language specified by Language, then a pointer to the driver name is\r
105 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
106 by This does not support the language specified by Language,\r
107 then EFI_UNSUPPORTED is returned.\r
108\r
109 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
110 EFI_COMPONENT_NAME_PROTOCOL instance.\r
111\r
112 @param Language[in] A pointer to a Null-terminated ASCII string\r
113 array indicating the language. This is the\r
114 language of the driver name that the caller is\r
115 requesting, and it must match one of the\r
116 languages specified in SupportedLanguages. The\r
117 number of languages supported by a driver is up\r
118 to the driver writer. Language is specified\r
119 in RFC 4646 or ISO 639-2 language code format.\r
120\r
121 @param DriverName[out] A pointer to the Unicode string to return.\r
122 This Unicode string is the name of the\r
123 driver specified by This in the language\r
124 specified by Language.\r
125\r
126 @retval EFI_SUCCESS The Unicode string for the Driver specified by\r
127 This and the language specified by Language was\r
128 returned in DriverName.\r
129\r
130 @retval EFI_INVALID_PARAMETER Language is NULL.\r
131\r
132 @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
133\r
134 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
135 the language specified by Language.\r
136\r
137**/\r
138EFI_STATUS\r
139EFIAPI\r
140OpalEfiDriverComponentName2GetDriverName(\r
141 EFI_COMPONENT_NAME2_PROTOCOL* This,\r
142 CHAR8* Language,\r
143 CHAR16** DriverName\r
144 )\r
145{\r
146 return LookupUnicodeString2(\r
147 Language,\r
148 This->SupportedLanguages,\r
149 mOpalDriverNameTable,\r
150 DriverName,\r
151 FALSE\r
152 );\r
153}\r
154\r
155/**\r
156 Retrieves a Unicode string that is the user readable name of the controller\r
157 that is being managed by a driver.\r
158\r
159 This function retrieves the user readable name of the controller specified by\r
160 ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
161 driver specified by This has a user readable name in the language specified by\r
162 Language, then a pointer to the controller name is returned in ControllerName,\r
163 and EFI_SUCCESS is returned. If the driver specified by This is not currently\r
164 managing the controller specified by ControllerHandle and ChildHandle,\r
165 then EFI_UNSUPPORTED is returned. If the driver specified by This does not\r
166 support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
167\r
168 @param ControllerHandle[in] The handle of a controller that the driver\r
169 specified by This is managing. This handle\r
170 specifies the controller whose name is to be\r
171 returned.\r
172\r
173 @param ChildHandle[in] The handle of the child controller to retrieve\r
174 the name of. This is an optional parameter that\r
175 may be NULL. It will be NULL for device\r
176 drivers. It will also be NULL for a bus drivers\r
177 that wish to retrieve the name of the bus\r
178 controller. It will not be NULL for a bus\r
179 driver that wishes to retrieve the name of a\r
180 child controller.\r
181\r
182\r
183 @param Language[in] A pointer to a Null-terminated ASCII string\r
184 array indicating the language. This is the\r
185 language of the driver name that the caller is\r
186 requesting, and it must match one of the\r
187 languages specified in SupportedLanguages. The\r
188 number of languages supported by a driver is up\r
189 to the driver writer. Language is specified in\r
190 RFC 4646 or ISO 639-2 language code format.\r
191\r
192 @param ControllerName[out] A pointer to the Unicode string to return.\r
193 This Unicode string is the name of the\r
194 controller specified by ControllerHandle and\r
195 ChildHandle in the language specified by\r
196 Language from the point of view of the driver\r
197 specified by This.\r
198\r
199 @retval EFI_SUCCESS The Unicode string for the user readable name in\r
200 the language specified by Language for the\r
201 driver specified by This was returned in\r
202 DriverName.\r
203\r
204 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
205\r
206 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
207 EFI_HANDLE.\r
208\r
209 @retval EFI_INVALID_PARAMETER Language is NULL.\r
210\r
211 @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
212\r
213 @retval EFI_UNSUPPORTED The driver specified by This is not currently\r
214 managing the controller specified by\r
215 ControllerHandle and ChildHandle.\r
216\r
217 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
218 the language specified by Language.\r
219\r
220**/\r
221EFI_STATUS\r
222GetControllerName(\r
223 EFI_HANDLE ControllerHandle,\r
224 EFI_HANDLE ChildHandle,\r
225 CHAR8* Language,\r
226 CHAR16** ControllerName\r
227 )\r
228{\r
229 if (Language == NULL || ControllerName == NULL || ControllerHandle == NULL) {\r
230 return EFI_INVALID_PARAMETER;\r
231 }\r
232\r
233 // don't support any controller or children names\r
234 return EFI_UNSUPPORTED;\r
235}\r
236\r
237/**\r
238 Retrieves a Unicode string that is the user readable name of the controller\r
239 that is being managed by a driver.\r
240\r
241 This function retrieves the user readable name of the controller specified by\r
242 ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
243 driver specified by This has a user readable name in the language specified by\r
244 Language, then a pointer to the controller name is returned in ControllerName,\r
245 and EFI_SUCCESS is returned. If the driver specified by This is not currently\r
246 managing the controller specified by ControllerHandle and ChildHandle,\r
247 then EFI_UNSUPPORTED is returned. If the driver specified by This does not\r
248 support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
249\r
250 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
251 EFI_COMPONENT_NAME_PROTOCOL instance.\r
252\r
253 @param ControllerHandle[in] The handle of a controller that the driver\r
254 specified by This is managing. This handle\r
255 specifies the controller whose name is to be\r
256 returned.\r
257\r
258 @param ChildHandle[in] The handle of the child controller to retrieve\r
259 the name of. This is an optional parameter that\r
260 may be NULL. It will be NULL for device\r
261 drivers. It will also be NULL for a bus drivers\r
262 that wish to retrieve the name of the bus\r
263 controller. It will not be NULL for a bus\r
264 driver that wishes to retrieve the name of a\r
265 child controller.\r
266\r
267 @param Language[in] A pointer to a Null-terminated ASCII string\r
268 array indicating the language. This is the\r
269 language of the driver name that the caller is\r
270 requesting, and it must match one of the\r
271 languages specified in SupportedLanguages. The\r
272 number of languages supported by a driver is up\r
273 to the driver writer. Language is specified in\r
274 RFC 4646 or ISO 639-2 language code format.\r
275\r
276 @param ControllerName[out] A pointer to the Unicode string to return.\r
277 This Unicode string is the name of the\r
278 controller specified by ControllerHandle and\r
279 ChildHandle in the language specified by\r
280 Language from the point of view of the driver\r
281 specified by This.\r
282\r
283 @retval EFI_SUCCESS The Unicode string for the user readable name in\r
284 the language specified by Language for the\r
285 driver specified by This was returned in\r
286 DriverName.\r
287\r
288 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
289\r
290 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
291 EFI_HANDLE.\r
292\r
293 @retval EFI_INVALID_PARAMETER Language is NULL.\r
294\r
295 @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
296\r
297 @retval EFI_UNSUPPORTED The driver specified by This is not currently\r
298 managing the controller specified by\r
299 ControllerHandle and ChildHandle.\r
300\r
301 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
302 the language specified by Language.\r
303\r
304**/\r
305EFI_STATUS\r
306EFIAPI\r
307OpalEfiDriverComponentNameGetControllerName(\r
308 EFI_COMPONENT_NAME_PROTOCOL* This,\r
309 EFI_HANDLE ControllerHandle,\r
310 EFI_HANDLE ChildHandle,\r
311 CHAR8* Language,\r
312 CHAR16** ControllerName\r
313 )\r
314{\r
315 return (GetControllerName( ControllerHandle, ChildHandle, Language, ControllerName));\r
316}\r
317\r
318/**\r
319 Retrieves a Unicode string that is the user readable name of the controller\r
320 that is being managed by a driver.\r
321\r
322 This function retrieves the user readable name of the controller specified by\r
323 ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
324 driver specified by This has a user readable name in the language specified by\r
325 Language, then a pointer to the controller name is returned in ControllerName,\r
326 and EFI_SUCCESS is returned. If the driver specified by This is not currently\r
327 managing the controller specified by ControllerHandle and ChildHandle,\r
328 then EFI_UNSUPPORTED is returned. If the driver specified by This does not\r
329 support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
330\r
331 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
332 EFI_COMPONENT_NAME_PROTOCOL instance.\r
333\r
334 @param ControllerHandle[in] The handle of a controller that the driver\r
335 specified by This is managing. This handle\r
336 specifies the controller whose name is to be\r
337 returned.\r
338\r
339 @param ChildHandle[in] The handle of the child controller to retrieve\r
340 the name of. This is an optional parameter that\r
341 may be NULL. It will be NULL for device\r
342 drivers. It will also be NULL for a bus drivers\r
343 that wish to retrieve the name of the bus\r
344 controller. It will not be NULL for a bus\r
345 driver that wishes to retrieve the name of a\r
346 child controller.\r
347\r
348 @param Language[in] A pointer to a Null-terminated ASCII string\r
349 array indicating the language. This is the\r
350 language of the driver name that the caller is\r
351 requesting, and it must match one of the\r
352 languages specified in SupportedLanguages. The\r
353 number of languages supported by a driver is up\r
354 to the driver writer. Language is specified in\r
355 RFC 4646 or ISO 639-2 language code format.\r
356\r
357 @param ControllerName[out] A pointer to the Unicode string to return.\r
358 This Unicode string is the name of the\r
359 controller specified by ControllerHandle and\r
360 ChildHandle in the language specified by\r
361 Language from the point of view of the driver\r
362 specified by This.\r
363\r
364 @retval EFI_SUCCESS The Unicode string for the user readable name in\r
365 the language specified by Language for the\r
366 driver specified by This was returned in\r
367 DriverName.\r
368\r
369 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
370\r
371 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
372 EFI_HANDLE.\r
373\r
374 @retval EFI_INVALID_PARAMETER Language is NULL.\r
375\r
376 @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
377\r
378 @retval EFI_UNSUPPORTED The driver specified by This is not currently\r
379 managing the controller specified by\r
380 ControllerHandle and ChildHandle.\r
381\r
382 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
383 the language specified by Language.\r
384\r
385**/\r
386EFI_STATUS\r
387EFIAPI\r
388OpalEfiDriverComponentName2GetControllerName(\r
389 EFI_COMPONENT_NAME2_PROTOCOL* This,\r
390 EFI_HANDLE ControllerHandle,\r
391 EFI_HANDLE ChildHandle,\r
392 CHAR8* Language,\r
393 CHAR16** ControllerName\r
394 )\r
395{\r
396 return (GetControllerName(ControllerHandle, ChildHandle, Language, ControllerName));\r
397}\r
398\r