]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/Console/TerminalDxe/ComponentName.c
9048326f5a5e5812df8c1b248cdd16a9b26a462e
[mirror_edk2.git] / MdeModulePkg / Universal / Console / TerminalDxe / 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 //
22 // Include common header file for this module.
23 //
24 #include "CommonHeader.h"
25
26 #include "Terminal.h"
27
28 //
29 // EFI Component Name Protocol
30 //
31 EFI_COMPONENT_NAME_PROTOCOL gTerminalComponentName = {
32 TerminalComponentNameGetDriverName,
33 TerminalComponentNameGetControllerName,
34 "eng"
35 };
36
37 static EFI_UNICODE_STRING_TABLE mTerminalDriverNameTable[] = {
38 {
39 "eng",
40 (CHAR16 *) L"Serial Terminal Driver"
41 },
42 {
43 NULL,
44 NULL
45 }
46 };
47
48 EFI_STATUS
49 EFIAPI
50 TerminalComponentNameGetDriverName (
51 IN EFI_COMPONENT_NAME_PROTOCOL *This,
52 IN CHAR8 *Language,
53 OUT CHAR16 **DriverName
54 )
55 /*++
56
57 Routine Description:
58 Retrieves a Unicode string that is the user readable name of the EFI Driver.
59
60 Arguments:
61 This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
62 Language - A pointer to a three character ISO 639-2 language identifier.
63 This is the language of the driver name that that the caller
64 is requesting, and it must match one of the languages specified
65 in SupportedLanguages. The number of languages supported by a
66 driver is up to the driver writer.
67 DriverName - A pointer to the Unicode string to return. This Unicode string
68 is the name of the driver specified by This in the language
69 specified by Language.
70
71 Returns:
72 EFI_SUCCESS - The Unicode string for the Driver specified by This
73 and the language specified by Language was returned
74 in DriverName.
75 EFI_INVALID_PARAMETER - Language is NULL.
76 EFI_INVALID_PARAMETER - DriverName is NULL.
77 EFI_UNSUPPORTED - The driver specified by This does not support the
78 language specified by Language.
79
80 --*/
81 {
82 return LookupUnicodeString (
83 Language,
84 gTerminalComponentName.SupportedLanguages,
85 mTerminalDriverNameTable,
86 DriverName
87 );
88 }
89
90 EFI_STATUS
91 EFIAPI
92 TerminalComponentNameGetControllerName (
93 IN EFI_COMPONENT_NAME_PROTOCOL *This,
94 IN EFI_HANDLE ControllerHandle,
95 IN EFI_HANDLE ChildHandle OPTIONAL,
96 IN CHAR8 *Language,
97 OUT CHAR16 **ControllerName
98 )
99 /*++
100
101 Routine Description:
102 Retrieves a Unicode string that is the user readable name of the controller
103 that is being managed by an EFI Driver.
104
105 Arguments:
106 This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
107 ControllerHandle - The handle of a controller that the driver specified by
108 This is managing. This handle specifies the controller
109 whose name is to be returned.
110 ChildHandle - The handle of the child controller to retrieve the name
111 of. This is an optional parameter that may be NULL. It
112 will be NULL for device drivers. It will also be NULL
113 for a bus drivers that wish to retrieve the name of the
114 bus controller. It will not be NULL for a bus driver
115 that wishes to retrieve the name of a child controller.
116 Language - A pointer to a three character ISO 639-2 language
117 identifier. This is the language of the controller name
118 that that the caller is requesting, and it must match one
119 of the languages specified in SupportedLanguages. The
120 number of languages supported by a driver is up to the
121 driver writer.
122 ControllerName - A pointer to the Unicode string to return. This Unicode
123 string is the name of the controller specified by
124 ControllerHandle and ChildHandle in the language
125 specified by Language from the point of view of the
126 driver specified by This.
127
128 Returns:
129 EFI_SUCCESS - The Unicode string for the user readable name in the
130 language specified by Language for the driver
131 specified by This was returned in DriverName.
132 EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.
133 EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid
134 EFI_HANDLE.
135 EFI_INVALID_PARAMETER - Language is NULL.
136 EFI_INVALID_PARAMETER - ControllerName is NULL.
137 EFI_UNSUPPORTED - The driver specified by This is not currently
138 managing the controller specified by
139 ControllerHandle and ChildHandle.
140 EFI_UNSUPPORTED - The driver specified by This does not support the
141 language specified by Language.
142
143 --*/
144 {
145 EFI_STATUS Status;
146 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *SimpleTextOutput;
147 TERMINAL_DEV *TerminalDevice;
148
149 //
150 // Make sure this driver is currently managing ControllHandle
151 //
152 Status = EfiTestManagedDevice (
153 ControllerHandle,
154 gTerminalDriverBinding.DriverBindingHandle,
155 &gEfiSerialIoProtocolGuid
156 );
157 if (EFI_ERROR (Status)) {
158 return Status;
159 }
160
161 //
162 // This is a bus driver, so ChildHandle can not be NULL.
163 //
164 if (ChildHandle == NULL) {
165 return EFI_UNSUPPORTED;
166 }
167
168 Status = EfiTestChildHandle (
169 ControllerHandle,
170 ChildHandle,
171 &gEfiSerialIoProtocolGuid
172 );
173 if (EFI_ERROR (Status)) {
174 return Status;
175 }
176
177 //
178 // Get our context back
179 //
180 Status = gBS->OpenProtocol (
181 ChildHandle,
182 &gEfiSimpleTextOutProtocolGuid,
183 (VOID **) &SimpleTextOutput,
184 gTerminalDriverBinding.DriverBindingHandle,
185 ChildHandle,
186 EFI_OPEN_PROTOCOL_GET_PROTOCOL
187 );
188 if (EFI_ERROR (Status)) {
189 return EFI_UNSUPPORTED;
190 }
191
192 TerminalDevice = TERMINAL_CON_OUT_DEV_FROM_THIS (SimpleTextOutput);
193
194 return LookupUnicodeString (
195 Language,
196 gTerminalComponentName.SupportedLanguages,
197 TerminalDevice->ControllerNameTable,
198 ControllerName
199 );
200 }