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