]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/Console/ConSplitterDxe/ComponentName.c
Add compiler hint of "GLOBAL_REMOVE_IF_UNREFERENCED" to prevent static unicode string...
[mirror_edk2.git] / MdeModulePkg / Universal / Console / ConSplitterDxe / ComponentName.c
1 /*++
2
3 Copyright (c) 2006, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
8
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11
12 Module Name:
13
14 ComponentName.c
15
16 Abstract:
17
18 --*/
19
20 #include "ConSplitter.h"
21
22 //
23 // EFI Component Name Protocol
24 //
25 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gConSplitterConInComponentName = {
26 ConSplitterComponentNameGetDriverName,
27 ConSplitterConInComponentNameGetControllerName,
28 "eng"
29 };
30
31 //
32 // EFI Component Name 2 Protocol
33 //
34 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gConSplitterConInComponentName2 = {
35 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) ConSplitterComponentNameGetDriverName,
36 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) ConSplitterConInComponentNameGetControllerName,
37 "en"
38 };
39
40
41 //
42 // EFI Component Name Protocol
43 //
44 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gConSplitterSimplePointerComponentName = {
45 ConSplitterComponentNameGetDriverName,
46 ConSplitterSimplePointerComponentNameGetControllerName,
47 "eng"
48 };
49
50 //
51 // EFI Component Name 2 Protocol
52 //
53 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gConSplitterSimplePointerComponentName2 = {
54 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) ConSplitterComponentNameGetDriverName,
55 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) ConSplitterSimplePointerComponentNameGetControllerName,
56 "en"
57 };
58
59
60 //
61 // EFI Component Name Protocol
62 //
63 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gConSplitterConOutComponentName = {
64 ConSplitterComponentNameGetDriverName,
65 ConSplitterConOutComponentNameGetControllerName,
66 "eng"
67 };
68
69 //
70 // EFI Component Name 2 Protocol
71 //
72 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gConSplitterConOutComponentName2 = {
73 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) ConSplitterComponentNameGetDriverName,
74 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) ConSplitterConOutComponentNameGetControllerName,
75 "en"
76 };
77
78
79 //
80 // EFI Component Name Protocol
81 //
82 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gConSplitterStdErrComponentName = {
83 ConSplitterComponentNameGetDriverName,
84 ConSplitterStdErrComponentNameGetControllerName,
85 "eng"
86 };
87
88 //
89 // EFI Component Name 2 Protocol
90 //
91 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gConSplitterStdErrComponentName2 = {
92 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) ConSplitterComponentNameGetDriverName,
93 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) ConSplitterStdErrComponentNameGetControllerName,
94 "en"
95 };
96
97
98 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mConSplitterDriverNameTable[] = {
99 {
100 "eng;en",
101 (CHAR16 *) L"Console Splitter Driver"
102 },
103 {
104 NULL,
105 NULL
106 }
107 };
108
109 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mConSplitterConInControllerNameTable[] = {
110 {
111 "eng;en",
112 (CHAR16 *) L"Primary Console Input Device"
113 },
114 {
115 NULL,
116 NULL
117 }
118 };
119
120 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mConSplitterSimplePointerControllerNameTable[] = {
121 {
122 "eng;en",
123 (CHAR16 *) L"Primary Simple Pointer Device"
124 },
125 {
126 NULL,
127 NULL
128 }
129 };
130
131 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mConSplitterConOutControllerNameTable[] = {
132 {
133 "eng;en",
134 (CHAR16 *) L"Primary Console Output Device"
135 },
136 {
137 NULL,
138 NULL
139 }
140 };
141
142 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mConSplitterStdErrControllerNameTable[] = {
143 {
144 "eng;en",
145 (CHAR16 *) L"Primary Standard Error Device"
146 },
147 {
148 NULL,
149 NULL
150 }
151 };
152
153 /**
154 Retrieves a Unicode string that is the user readable name of the driver.
155
156 This function retrieves the user readable name of a driver in the form of a
157 Unicode string. If the driver specified by This has a user readable name in
158 the language specified by Language, then a pointer to the driver name is
159 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
160 by This does not support the language specified by Language,
161 then EFI_UNSUPPORTED is returned.
162
163 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
164 EFI_COMPONENT_NAME_PROTOCOL instance.
165
166 @param Language[in] A pointer to a Null-terminated ASCII string
167 array indicating the language. This is the
168 language of the driver name that the caller is
169 requesting, and it must match one of the
170 languages specified in SupportedLanguages. The
171 number of languages supported by a driver is up
172 to the driver writer. Language is specified
173 in RFC 3066 or ISO 639-2 language code format.
174
175 @param DriverName[out] A pointer to the Unicode string to return.
176 This Unicode string is the name of the
177 driver specified by This in the language
178 specified by Language.
179
180 @retval EFI_SUCCESS The Unicode string for the Driver specified by
181 This and the language specified by Language was
182 returned in DriverName.
183
184 @retval EFI_INVALID_PARAMETER Language is NULL.
185
186 @retval EFI_INVALID_PARAMETER DriverName is NULL.
187
188 @retval EFI_UNSUPPORTED The driver specified by This does not support
189 the language specified by Language.
190
191 **/
192 EFI_STATUS
193 EFIAPI
194 ConSplitterComponentNameGetDriverName (
195 IN EFI_COMPONENT_NAME_PROTOCOL *This,
196 IN CHAR8 *Language,
197 OUT CHAR16 **DriverName
198 )
199 {
200 return LookupUnicodeString2 (
201 Language,
202 This->SupportedLanguages,
203 mConSplitterDriverNameTable,
204 DriverName,
205 (BOOLEAN)(This == &gConSplitterConInComponentName)
206 );
207 }
208
209 /**
210 Retrieves a Unicode string that is the user readable name of the controller
211 that is being managed by a driver.
212
213 This function retrieves the user readable name of the controller specified by
214 ControllerHandle and ChildHandle in the form of a Unicode string. If the
215 driver specified by This has a user readable name in the language specified by
216 Language, then a pointer to the controller name is returned in ControllerName,
217 and EFI_SUCCESS is returned. If the driver specified by This is not currently
218 managing the controller specified by ControllerHandle and ChildHandle,
219 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
220 support the language specified by Language, then EFI_UNSUPPORTED is returned.
221
222 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
223 EFI_COMPONENT_NAME_PROTOCOL instance.
224
225 @param ControllerHandle[in] The handle of a controller that the driver
226 specified by This is managing. This handle
227 specifies the controller whose name is to be
228 returned.
229
230 @param ChildHandle[in] The handle of the child controller to retrieve
231 the name of. This is an optional parameter that
232 may be NULL. It will be NULL for device
233 drivers. It will also be NULL for a bus drivers
234 that wish to retrieve the name of the bus
235 controller. It will not be NULL for a bus
236 driver that wishes to retrieve the name of a
237 child controller.
238
239 @param Language[in] A pointer to a Null-terminated ASCII string
240 array indicating the language. This is the
241 language of the driver name that the caller is
242 requesting, and it must match one of the
243 languages specified in SupportedLanguages. The
244 number of languages supported by a driver is up
245 to the driver writer. Language is specified in
246 RFC 3066 or ISO 639-2 language code format.
247
248 @param ControllerName[out] A pointer to the Unicode string to return.
249 This Unicode string is the name of the
250 controller specified by ControllerHandle and
251 ChildHandle in the language specified by
252 Language from the point of view of the driver
253 specified by This.
254
255 @retval EFI_SUCCESS The Unicode string for the user readable name in
256 the language specified by Language for the
257 driver specified by This was returned in
258 DriverName.
259
260 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
261
262 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
263 EFI_HANDLE.
264
265 @retval EFI_INVALID_PARAMETER Language is NULL.
266
267 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
268
269 @retval EFI_UNSUPPORTED The driver specified by This is not currently
270 managing the controller specified by
271 ControllerHandle and ChildHandle.
272
273 @retval EFI_UNSUPPORTED The driver specified by This does not support
274 the language specified by Language.
275
276 **/
277 EFI_STATUS
278 EFIAPI
279 ConSplitterConInComponentNameGetControllerName (
280 IN EFI_COMPONENT_NAME_PROTOCOL *This,
281 IN EFI_HANDLE ControllerHandle,
282 IN EFI_HANDLE ChildHandle OPTIONAL,
283 IN CHAR8 *Language,
284 OUT CHAR16 **ControllerName
285 )
286 {
287 EFI_STATUS Status;
288 EFI_SIMPLE_TEXT_INPUT_PROTOCOL *TextIn;
289 //
290 // here ChildHandle is not an Optional parameter.
291 //
292 if (ChildHandle == NULL) {
293 return EFI_UNSUPPORTED;
294 }
295
296 Status = gBS->OpenProtocol (
297 ControllerHandle,
298 &gEfiSimpleTextInProtocolGuid,
299 (VOID **) &TextIn,
300 NULL,
301 ControllerHandle,
302 EFI_OPEN_PROTOCOL_GET_PROTOCOL
303 );
304 if (EFI_ERROR (Status)) {
305 return EFI_UNSUPPORTED;
306 }
307
308 return LookupUnicodeString2 (
309 Language,
310 This->SupportedLanguages,
311 mConSplitterConInControllerNameTable,
312 ControllerName,
313 (BOOLEAN)(This == &gConSplitterConInComponentName)
314 );
315 }
316
317 /**
318 Retrieves a Unicode string that is the user readable name of the controller
319 that is being managed by a driver.
320
321 This function retrieves the user readable name of the controller specified by
322 ControllerHandle and ChildHandle in the form of a Unicode string. If the
323 driver specified by This has a user readable name in the language specified by
324 Language, then a pointer to the controller name is returned in ControllerName,
325 and EFI_SUCCESS is returned. If the driver specified by This is not currently
326 managing the controller specified by ControllerHandle and ChildHandle,
327 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
328 support the language specified by Language, then EFI_UNSUPPORTED is returned.
329
330 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
331 EFI_COMPONENT_NAME_PROTOCOL instance.
332
333 @param ControllerHandle[in] The handle of a controller that the driver
334 specified by This is managing. This handle
335 specifies the controller whose name is to be
336 returned.
337
338 @param ChildHandle[in] The handle of the child controller to retrieve
339 the name of. This is an optional parameter that
340 may be NULL. It will be NULL for device
341 drivers. It will also be NULL for a bus drivers
342 that wish to retrieve the name of the bus
343 controller. It will not be NULL for a bus
344 driver that wishes to retrieve the name of a
345 child controller.
346
347 @param Language[in] A pointer to a Null-terminated ASCII string
348 array indicating the language. This is the
349 language of the driver name that the caller is
350 requesting, and it must match one of the
351 languages specified in SupportedLanguages. The
352 number of languages supported by a driver is up
353 to the driver writer. Language is specified in
354 RFC 3066 or ISO 639-2 language code format.
355
356 @param ControllerName[out] A pointer to the Unicode string to return.
357 This Unicode string is the name of the
358 controller specified by ControllerHandle and
359 ChildHandle in the language specified by
360 Language from the point of view of the driver
361 specified by This.
362
363 @retval EFI_SUCCESS The Unicode string for the user readable name in
364 the language specified by Language for the
365 driver specified by This was returned in
366 DriverName.
367
368 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
369
370 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
371 EFI_HANDLE.
372
373 @retval EFI_INVALID_PARAMETER Language is NULL.
374
375 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
376
377 @retval EFI_UNSUPPORTED The driver specified by This is not currently
378 managing the controller specified by
379 ControllerHandle and ChildHandle.
380
381 @retval EFI_UNSUPPORTED The driver specified by This does not support
382 the language specified by Language.
383
384 **/
385 EFI_STATUS
386 EFIAPI
387 ConSplitterSimplePointerComponentNameGetControllerName (
388 IN EFI_COMPONENT_NAME_PROTOCOL *This,
389 IN EFI_HANDLE ControllerHandle,
390 IN EFI_HANDLE ChildHandle OPTIONAL,
391 IN CHAR8 *Language,
392 OUT CHAR16 **ControllerName
393 )
394 {
395 EFI_STATUS Status;
396 EFI_SIMPLE_POINTER_PROTOCOL *SimplePointer;
397 //
398 // here ChildHandle is not an Optional parameter.
399 //
400 if (ChildHandle == NULL) {
401 return EFI_UNSUPPORTED;
402 }
403
404 Status = gBS->OpenProtocol (
405 ControllerHandle,
406 &gEfiSimplePointerProtocolGuid,
407 (VOID **) &SimplePointer,
408 NULL,
409 ControllerHandle,
410 EFI_OPEN_PROTOCOL_GET_PROTOCOL
411 );
412 if (EFI_ERROR (Status)) {
413 return EFI_UNSUPPORTED;
414 }
415
416 return LookupUnicodeString2 (
417 Language,
418 This->SupportedLanguages,
419 mConSplitterSimplePointerControllerNameTable,
420 ControllerName,
421 (BOOLEAN)(This == &gConSplitterSimplePointerComponentName)
422 );
423 }
424
425 /**
426 Retrieves a Unicode string that is the user readable name of the controller
427 that is being managed by a driver.
428
429 This function retrieves the user readable name of the controller specified by
430 ControllerHandle and ChildHandle in the form of a Unicode string. If the
431 driver specified by This has a user readable name in the language specified by
432 Language, then a pointer to the controller name is returned in ControllerName,
433 and EFI_SUCCESS is returned. If the driver specified by This is not currently
434 managing the controller specified by ControllerHandle and ChildHandle,
435 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
436 support the language specified by Language, then EFI_UNSUPPORTED is returned.
437
438 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
439 EFI_COMPONENT_NAME_PROTOCOL instance.
440
441 @param ControllerHandle[in] The handle of a controller that the driver
442 specified by This is managing. This handle
443 specifies the controller whose name is to be
444 returned.
445
446 @param ChildHandle[in] The handle of the child controller to retrieve
447 the name of. This is an optional parameter that
448 may be NULL. It will be NULL for device
449 drivers. It will also be NULL for a bus drivers
450 that wish to retrieve the name of the bus
451 controller. It will not be NULL for a bus
452 driver that wishes to retrieve the name of a
453 child controller.
454
455 @param Language[in] A pointer to a Null-terminated ASCII string
456 array indicating the language. This is the
457 language of the driver name that the caller is
458 requesting, and it must match one of the
459 languages specified in SupportedLanguages. The
460 number of languages supported by a driver is up
461 to the driver writer. Language is specified in
462 RFC 3066 or ISO 639-2 language code format.
463
464 @param ControllerName[out] A pointer to the Unicode string to return.
465 This Unicode string is the name of the
466 controller specified by ControllerHandle and
467 ChildHandle in the language specified by
468 Language from the point of view of the driver
469 specified by This.
470
471 @retval EFI_SUCCESS The Unicode string for the user readable name in
472 the language specified by Language for the
473 driver specified by This was returned in
474 DriverName.
475
476 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
477
478 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
479 EFI_HANDLE.
480
481 @retval EFI_INVALID_PARAMETER Language is NULL.
482
483 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
484
485 @retval EFI_UNSUPPORTED The driver specified by This is not currently
486 managing the controller specified by
487 ControllerHandle and ChildHandle.
488
489 @retval EFI_UNSUPPORTED The driver specified by This does not support
490 the language specified by Language.
491
492 **/
493 EFI_STATUS
494 EFIAPI
495 ConSplitterConOutComponentNameGetControllerName (
496 IN EFI_COMPONENT_NAME_PROTOCOL *This,
497 IN EFI_HANDLE ControllerHandle,
498 IN EFI_HANDLE ChildHandle OPTIONAL,
499 IN CHAR8 *Language,
500 OUT CHAR16 **ControllerName
501 )
502 {
503 EFI_STATUS Status;
504 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *TextOut;
505 //
506 // here ChildHandle is not an Optional parameter.
507 //
508 if (ChildHandle == NULL) {
509 return EFI_UNSUPPORTED;
510 }
511
512 Status = gBS->OpenProtocol (
513 ControllerHandle,
514 &gEfiSimpleTextOutProtocolGuid,
515 (VOID **) &TextOut,
516 NULL,
517 ControllerHandle,
518 EFI_OPEN_PROTOCOL_GET_PROTOCOL
519 );
520 if (EFI_ERROR (Status)) {
521 return EFI_UNSUPPORTED;
522 }
523
524 return LookupUnicodeString2 (
525 Language,
526 This->SupportedLanguages,
527 mConSplitterConOutControllerNameTable,
528 ControllerName,
529 (BOOLEAN)(This == &gConSplitterConOutComponentName)
530 );
531 }
532
533 /**
534 Retrieves a Unicode string that is the user readable name of the controller
535 that is being managed by a driver.
536
537 This function retrieves the user readable name of the controller specified by
538 ControllerHandle and ChildHandle in the form of a Unicode string. If the
539 driver specified by This has a user readable name in the language specified by
540 Language, then a pointer to the controller name is returned in ControllerName,
541 and EFI_SUCCESS is returned. If the driver specified by This is not currently
542 managing the controller specified by ControllerHandle and ChildHandle,
543 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
544 support the language specified by Language, then EFI_UNSUPPORTED is returned.
545
546 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
547 EFI_COMPONENT_NAME_PROTOCOL instance.
548
549 @param ControllerHandle[in] The handle of a controller that the driver
550 specified by This is managing. This handle
551 specifies the controller whose name is to be
552 returned.
553
554 @param ChildHandle[in] The handle of the child controller to retrieve
555 the name of. This is an optional parameter that
556 may be NULL. It will be NULL for device
557 drivers. It will also be NULL for a bus drivers
558 that wish to retrieve the name of the bus
559 controller. It will not be NULL for a bus
560 driver that wishes to retrieve the name of a
561 child controller.
562
563 @param Language[in] A pointer to a Null-terminated ASCII string
564 array indicating the language. This is the
565 language of the driver name that the caller is
566 requesting, and it must match one of the
567 languages specified in SupportedLanguages. The
568 number of languages supported by a driver is up
569 to the driver writer. Language is specified in
570 RFC 3066 or ISO 639-2 language code format.
571
572 @param ControllerName[out] A pointer to the Unicode string to return.
573 This Unicode string is the name of the
574 controller specified by ControllerHandle and
575 ChildHandle in the language specified by
576 Language from the point of view of the driver
577 specified by This.
578
579 @retval EFI_SUCCESS The Unicode string for the user readable name in
580 the language specified by Language for the
581 driver specified by This was returned in
582 DriverName.
583
584 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
585
586 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
587 EFI_HANDLE.
588
589 @retval EFI_INVALID_PARAMETER Language is NULL.
590
591 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
592
593 @retval EFI_UNSUPPORTED The driver specified by This is not currently
594 managing the controller specified by
595 ControllerHandle and ChildHandle.
596
597 @retval EFI_UNSUPPORTED The driver specified by This does not support
598 the language specified by Language.
599
600 **/
601 EFI_STATUS
602 EFIAPI
603 ConSplitterStdErrComponentNameGetControllerName (
604 IN EFI_COMPONENT_NAME_PROTOCOL *This,
605 IN EFI_HANDLE ControllerHandle,
606 IN EFI_HANDLE ChildHandle OPTIONAL,
607 IN CHAR8 *Language,
608 OUT CHAR16 **ControllerName
609 )
610 {
611 EFI_STATUS Status;
612 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *ErrOut;
613 //
614 // here ChildHandle is not an Optional parameter.
615 //
616 if (ChildHandle == NULL) {
617 return EFI_UNSUPPORTED;
618 }
619
620 Status = gBS->OpenProtocol (
621 ControllerHandle,
622 &gEfiSimpleTextOutProtocolGuid,
623 (VOID **) &ErrOut,
624 NULL,
625 ControllerHandle,
626 EFI_OPEN_PROTOCOL_GET_PROTOCOL
627 );
628 if (EFI_ERROR (Status)) {
629 return EFI_UNSUPPORTED;
630 }
631
632 return LookupUnicodeString2 (
633 Language,
634 This->SupportedLanguages,
635 mConSplitterStdErrControllerNameTable,
636 ControllerName,
637 (BOOLEAN)(This == &gConSplitterStdErrComponentName)
638 );
639 }