]> git.proxmox.com Git - mirror_edk2.git/blob - EdkModulePkg/Universal/Console/ConSplitter/Dxe/ComponentName.c
dc2a22f447a7bd7f1081ca7d6a9c4d1a1b8f3f13
[mirror_edk2.git] / EdkModulePkg / Universal / Console / ConSplitter / Dxe / 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 Functions
24 //
25 EFI_STATUS
26 EFIAPI
27 ConSplitterComponentNameGetDriverName (
28 IN EFI_COMPONENT_NAME_PROTOCOL *This,
29 IN CHAR8 *Language,
30 OUT CHAR16 **DriverName
31 );
32
33 EFI_STATUS
34 EFIAPI
35 ConSplitterConInComponentNameGetControllerName (
36 IN EFI_COMPONENT_NAME_PROTOCOL *This,
37 IN EFI_HANDLE ControllerHandle,
38 IN EFI_HANDLE ChildHandle OPTIONAL,
39 IN CHAR8 *Language,
40 OUT CHAR16 **ControllerName
41 );
42
43 EFI_STATUS
44 EFIAPI
45 ConSplitterSimplePointerComponentNameGetControllerName (
46 IN EFI_COMPONENT_NAME_PROTOCOL *This,
47 IN EFI_HANDLE ControllerHandle,
48 IN EFI_HANDLE ChildHandle OPTIONAL,
49 IN CHAR8 *Language,
50 OUT CHAR16 **ControllerName
51 );
52
53 EFI_STATUS
54 EFIAPI
55 ConSplitterConOutComponentNameGetControllerName (
56 IN EFI_COMPONENT_NAME_PROTOCOL *This,
57 IN EFI_HANDLE ControllerHandle,
58 IN EFI_HANDLE ChildHandle OPTIONAL,
59 IN CHAR8 *Language,
60 OUT CHAR16 **ControllerName
61 );
62
63 EFI_STATUS
64 EFIAPI
65 ConSplitterStdErrComponentNameGetControllerName (
66 IN EFI_COMPONENT_NAME_PROTOCOL *This,
67 IN EFI_HANDLE ControllerHandle,
68 IN EFI_HANDLE ChildHandle OPTIONAL,
69 IN CHAR8 *Language,
70 OUT CHAR16 **ControllerName
71 );
72
73 //
74 // EFI Component Name Protocol
75 //
76 EFI_COMPONENT_NAME_PROTOCOL gConSplitterConInComponentName = {
77 ConSplitterComponentNameGetDriverName,
78 ConSplitterConInComponentNameGetControllerName,
79 "eng"
80 };
81
82 EFI_COMPONENT_NAME_PROTOCOL gConSplitterSimplePointerComponentName = {
83 ConSplitterComponentNameGetDriverName,
84 ConSplitterSimplePointerComponentNameGetControllerName,
85 "eng"
86 };
87
88 EFI_COMPONENT_NAME_PROTOCOL gConSplitterConOutComponentName = {
89 ConSplitterComponentNameGetDriverName,
90 ConSplitterConOutComponentNameGetControllerName,
91 "eng"
92 };
93
94 EFI_COMPONENT_NAME_PROTOCOL gConSplitterStdErrComponentName = {
95 ConSplitterComponentNameGetDriverName,
96 ConSplitterStdErrComponentNameGetControllerName,
97 "eng"
98 };
99
100 static EFI_UNICODE_STRING_TABLE mConSplitterDriverNameTable[] = {
101 {
102 "eng",
103 (CHAR16 *) L"Console Splitter Driver"
104 },
105 {
106 NULL,
107 NULL
108 }
109 };
110
111 static EFI_UNICODE_STRING_TABLE mConSplitterConInControllerNameTable[] = {
112 {
113 "eng",
114 (CHAR16 *) L"Primary Console Input Device"
115 },
116 {
117 NULL,
118 NULL
119 }
120 };
121
122 static EFI_UNICODE_STRING_TABLE mConSplitterSimplePointerControllerNameTable[] = {
123 {
124 "eng",
125 (CHAR16 *) L"Primary Simple Pointer Device"
126 },
127 {
128 NULL,
129 NULL
130 }
131 };
132
133 static EFI_UNICODE_STRING_TABLE mConSplitterConOutControllerNameTable[] = {
134 {
135 "eng",
136 (CHAR16 *) L"Primary Console Output Device"
137 },
138 {
139 NULL,
140 NULL
141 }
142 };
143
144 static EFI_UNICODE_STRING_TABLE mConSplitterStdErrControllerNameTable[] = {
145 {
146 "eng",
147 (CHAR16 *) L"Primary Standard Error Device"
148 },
149 {
150 NULL,
151 NULL
152 }
153 };
154
155 EFI_STATUS
156 EFIAPI
157 ConSplitterComponentNameGetDriverName (
158 IN EFI_COMPONENT_NAME_PROTOCOL *This,
159 IN CHAR8 *Language,
160 OUT CHAR16 **DriverName
161 )
162 /*++
163
164 Routine Description:
165 Retrieves a Unicode string that is the user readable name of the EFI Driver.
166
167 Arguments:
168 This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
169 Language - A pointer to a three character ISO 639-2 language identifier.
170 This is the language of the driver name that that the caller
171 is requesting, and it must match one of the languages specified
172 in SupportedLanguages. The number of languages supported by a
173 driver is up to the driver writer.
174 DriverName - A pointer to the Unicode string to return. This Unicode string
175 is the name of the driver specified by This in the language
176 specified by Language.
177
178 Returns:
179 EFI_SUCCESS - The Unicode string for the Driver specified by This
180 and the language specified by Language was returned
181 in DriverName.
182 EFI_INVALID_PARAMETER - Language is NULL.
183 EFI_INVALID_PARAMETER - DriverName is NULL.
184 EFI_UNSUPPORTED - The driver specified by This does not support the
185 language specified by Language.
186
187 --*/
188 {
189 return LookupUnicodeString (
190 Language,
191 gConSplitterConInComponentName.SupportedLanguages,
192 mConSplitterDriverNameTable,
193 DriverName
194 );
195 }
196
197 EFI_STATUS
198 EFIAPI
199 ConSplitterConInComponentNameGetControllerName (
200 IN EFI_COMPONENT_NAME_PROTOCOL *This,
201 IN EFI_HANDLE ControllerHandle,
202 IN EFI_HANDLE ChildHandle OPTIONAL,
203 IN CHAR8 *Language,
204 OUT CHAR16 **ControllerName
205 )
206 /*++
207
208 Routine Description:
209 Retrieves a Unicode string that is the user readable name of the controller
210 that is being managed by an EFI Driver.
211
212 Arguments:
213 This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
214 ControllerHandle - The handle of a controller that the driver specified by
215 This is managing. This handle specifies the controller
216 whose name is to be returned.
217 ChildHandle - The handle of the child controller to retrieve the name
218 of. This is an optional parameter that may be NULL. It
219 will be NULL for device drivers. It will also be NULL
220 for a bus drivers that wish to retrieve the name of the
221 bus controller. It will not be NULL for a bus driver
222 that wishes to retrieve the name of a child controller.
223 Language - A pointer to a three character ISO 639-2 language
224 identifier. This is the language of the controller name
225 that that the caller is requesting, and it must match one
226 of the languages specified in SupportedLanguages. The
227 number of languages supported by a driver is up to the
228 driver writer.
229 ControllerName - A pointer to the Unicode string to return. This Unicode
230 string is the name of the controller specified by
231 ControllerHandle and ChildHandle in the language
232 specified by Language from the point of view of the
233 driver specified by This.
234
235 Returns:
236 EFI_SUCCESS - The Unicode string for the user readable name in the
237 language specified by Language for the driver
238 specified by This was returned in DriverName.
239 EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.
240 EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid
241 EFI_HANDLE.
242 EFI_INVALID_PARAMETER - Language is NULL.
243 EFI_INVALID_PARAMETER - ControllerName is NULL.
244 EFI_UNSUPPORTED - The driver specified by This is not currently
245 managing the controller specified by
246 ControllerHandle and ChildHandle.
247 EFI_UNSUPPORTED - The driver specified by This does not support the
248 language specified by Language.
249
250 --*/
251 {
252 EFI_STATUS Status;
253 EFI_SIMPLE_TEXT_IN_PROTOCOL *TextIn;
254 //
255 // here ChildHandle is not an Optional parameter.
256 //
257 if (ChildHandle == NULL) {
258 return EFI_UNSUPPORTED;
259 }
260
261 Status = gBS->OpenProtocol (
262 ControllerHandle,
263 &gEfiSimpleTextInProtocolGuid,
264 (VOID **) &TextIn,
265 NULL,
266 ControllerHandle,
267 EFI_OPEN_PROTOCOL_GET_PROTOCOL
268 );
269 if (EFI_ERROR (Status)) {
270 return EFI_UNSUPPORTED;
271 }
272
273 return LookupUnicodeString (
274 Language,
275 gConSplitterConInComponentName.SupportedLanguages,
276 mConSplitterConInControllerNameTable,
277 ControllerName
278 );
279 }
280
281 EFI_STATUS
282 EFIAPI
283 ConSplitterSimplePointerComponentNameGetControllerName (
284 IN EFI_COMPONENT_NAME_PROTOCOL *This,
285 IN EFI_HANDLE ControllerHandle,
286 IN EFI_HANDLE ChildHandle OPTIONAL,
287 IN CHAR8 *Language,
288 OUT CHAR16 **ControllerName
289 )
290 /*++
291
292 Routine Description:
293 Retrieves a Unicode string that is the user readable name of the controller
294 that is being managed by an EFI Driver.
295
296 Arguments:
297 This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
298 ControllerHandle - The handle of a controller that the driver specified by
299 This is managing. This handle specifies the controller
300 whose name is to be returned.
301 ChildHandle - The handle of the child controller to retrieve the name
302 of. This is an optional parameter that may be NULL. It
303 will be NULL for device drivers. It will also be NULL
304 for a bus drivers that wish to retrieve the name of the
305 bus controller. It will not be NULL for a bus driver
306 that wishes to retrieve the name of a child controller.
307 Language - A pointer to a three character ISO 639-2 language
308 identifier. This is the language of the controller name
309 that that the caller is requesting, and it must match one
310 of the languages specified in SupportedLanguages. The
311 number of languages supported by a driver is up to the
312 driver writer.
313 ControllerName - A pointer to the Unicode string to return. This Unicode
314 string is the name of the controller specified by
315 ControllerHandle and ChildHandle in the language
316 specified by Language from the point of view of the
317 driver specified by This.
318
319 Returns:
320 EFI_SUCCESS - The Unicode string for the user readable name in the
321 language specified by Language for the driver
322 specified by This was returned in DriverName.
323 EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.
324 EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid
325 EFI_HANDLE.
326 EFI_INVALID_PARAMETER - Language is NULL.
327 EFI_INVALID_PARAMETER - ControllerName is NULL.
328 EFI_UNSUPPORTED - The driver specified by This is not currently
329 managing the controller specified by
330 ControllerHandle and ChildHandle.
331 EFI_UNSUPPORTED - The driver specified by This does not support the
332 language specified by Language.
333
334 --*/
335 {
336 EFI_STATUS Status;
337 EFI_SIMPLE_POINTER_PROTOCOL *SimplePointer;
338 //
339 // here ChildHandle is not an Optional parameter.
340 //
341 if (ChildHandle == NULL) {
342 return EFI_UNSUPPORTED;
343 }
344
345 Status = gBS->OpenProtocol (
346 ControllerHandle,
347 &gEfiSimplePointerProtocolGuid,
348 (VOID **) &SimplePointer,
349 NULL,
350 ControllerHandle,
351 EFI_OPEN_PROTOCOL_GET_PROTOCOL
352 );
353 if (EFI_ERROR (Status)) {
354 return EFI_UNSUPPORTED;
355 }
356
357 return LookupUnicodeString (
358 Language,
359 gConSplitterSimplePointerComponentName.SupportedLanguages,
360 mConSplitterSimplePointerControllerNameTable,
361 ControllerName
362 );
363 }
364
365 EFI_STATUS
366 EFIAPI
367 ConSplitterConOutComponentNameGetControllerName (
368 IN EFI_COMPONENT_NAME_PROTOCOL *This,
369 IN EFI_HANDLE ControllerHandle,
370 IN EFI_HANDLE ChildHandle OPTIONAL,
371 IN CHAR8 *Language,
372 OUT CHAR16 **ControllerName
373 )
374 /*++
375
376 Routine Description:
377 Retrieves a Unicode string that is the user readable name of the controller
378 that is being managed by an EFI Driver.
379
380 Arguments:
381 This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
382 ControllerHandle - The handle of a controller that the driver specified by
383 This is managing. This handle specifies the controller
384 whose name is to be returned.
385 ChildHandle - The handle of the child controller to retrieve the name
386 of. This is an optional parameter that may be NULL. It
387 will be NULL for device drivers. It will also be NULL
388 for a bus drivers that wish to retrieve the name of the
389 bus controller. It will not be NULL for a bus driver
390 that wishes to retrieve the name of a child controller.
391 Language - A pointer to a three character ISO 639-2 language
392 identifier. This is the language of the controller name
393 that that the caller is requesting, and it must match one
394 of the languages specified in SupportedLanguages. The
395 number of languages supported by a driver is up to the
396 driver writer.
397 ControllerName - A pointer to the Unicode string to return. This Unicode
398 string is the name of the controller specified by
399 ControllerHandle and ChildHandle in the language
400 specified by Language from the point of view of the
401 driver specified by This.
402
403 Returns:
404 EFI_SUCCESS - The Unicode string for the user readable name in the
405 language specified by Language for the driver
406 specified by This was returned in DriverName.
407 EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.
408 EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid
409 EFI_HANDLE.
410 EFI_INVALID_PARAMETER - Language is NULL.
411 EFI_INVALID_PARAMETER - ControllerName is NULL.
412 EFI_UNSUPPORTED - The driver specified by This is not currently
413 managing the controller specified by
414 ControllerHandle and ChildHandle.
415 EFI_UNSUPPORTED - The driver specified by This does not support the
416 language specified by Language.
417
418 --*/
419 {
420 EFI_STATUS Status;
421 EFI_SIMPLE_TEXT_OUT_PROTOCOL *TextOut;
422 //
423 // here ChildHandle is not an Optional parameter.
424 //
425 if (ChildHandle == NULL) {
426 return EFI_UNSUPPORTED;
427 }
428
429 Status = gBS->OpenProtocol (
430 ControllerHandle,
431 &gEfiSimpleTextOutProtocolGuid,
432 (VOID **) &TextOut,
433 NULL,
434 ControllerHandle,
435 EFI_OPEN_PROTOCOL_GET_PROTOCOL
436 );
437 if (EFI_ERROR (Status)) {
438 return EFI_UNSUPPORTED;
439 }
440
441 return LookupUnicodeString (
442 Language,
443 gConSplitterConOutComponentName.SupportedLanguages,
444 mConSplitterConOutControllerNameTable,
445 ControllerName
446 );
447 }
448
449 EFI_STATUS
450 EFIAPI
451 ConSplitterStdErrComponentNameGetControllerName (
452 IN EFI_COMPONENT_NAME_PROTOCOL *This,
453 IN EFI_HANDLE ControllerHandle,
454 IN EFI_HANDLE ChildHandle OPTIONAL,
455 IN CHAR8 *Language,
456 OUT CHAR16 **ControllerName
457 )
458 /*++
459
460 Routine Description:
461 Retrieves a Unicode string that is the user readable name of the controller
462 that is being managed by an EFI Driver.
463
464 Arguments:
465 This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
466 ControllerHandle - The handle of a controller that the driver specified by
467 This is managing. This handle specifies the controller
468 whose name is to be returned.
469 ChildHandle - The handle of the child controller to retrieve the name
470 of. This is an optional parameter that may be NULL. It
471 will be NULL for device drivers. It will also be NULL
472 for a bus drivers that wish to retrieve the name of the
473 bus controller. It will not be NULL for a bus driver
474 that wishes to retrieve the name of a child controller.
475 Language - A pointer to a three character ISO 639-2 language
476 identifier. This is the language of the controller name
477 that that the caller is requesting, and it must match one
478 of the languages specified in SupportedLanguages. The
479 number of languages supported by a driver is up to the
480 driver writer.
481 ControllerName - A pointer to the Unicode string to return. This Unicode
482 string is the name of the controller specified by
483 ControllerHandle and ChildHandle in the language
484 specified by Language from the point of view of the
485 driver specified by This.
486
487 Returns:
488 EFI_SUCCESS - The Unicode string for the user readable name in the
489 language specified by Language for the driver
490 specified by This was returned in DriverName.
491 EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.
492 EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid
493 EFI_HANDLE.
494 EFI_INVALID_PARAMETER - Language is NULL.
495 EFI_INVALID_PARAMETER - ControllerName is NULL.
496 EFI_UNSUPPORTED - The driver specified by This is not currently
497 managing the controller specified by
498 ControllerHandle and ChildHandle.
499 EFI_UNSUPPORTED - The driver specified by This does not support the
500 language specified by Language.
501
502 --*/
503 {
504 EFI_STATUS Status;
505 EFI_SIMPLE_TEXT_OUT_PROTOCOL *ErrOut;
506 //
507 // here ChildHandle is not an Optional parameter.
508 //
509 if (ChildHandle == NULL) {
510 return EFI_UNSUPPORTED;
511 }
512
513 Status = gBS->OpenProtocol (
514 ControllerHandle,
515 &gEfiSimpleTextOutProtocolGuid,
516 (VOID **) &ErrOut,
517 NULL,
518 ControllerHandle,
519 EFI_OPEN_PROTOCOL_GET_PROTOCOL
520 );
521 if (EFI_ERROR (Status)) {
522 return EFI_UNSUPPORTED;
523 }
524
525 return LookupUnicodeString (
526 Language,
527 gConSplitterStdErrComponentName.SupportedLanguages,
528 mConSplitterStdErrControllerNameTable,
529 ControllerName
530 );
531 }