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