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