]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/Console/TerminalDxe/ComponentName.c
Add compiler hint of "GLOBAL_REMOVE_IF_UNREFERENCED" to prevent static unicode string...
[mirror_edk2.git] / MdeModulePkg / Universal / Console / TerminalDxe / ComponentName.c
CommitLineData
95276127 1/*++\r
2\r
3Copyright (c) 2006, Intel Corporation \r
4All rights reserved. This program and the accompanying materials \r
5are licensed and made available under the terms and conditions of the BSD License \r
6which accompanies this distribution. The full text of the license may be found at \r
7http://opensource.org/licenses/bsd-license.php \r
8 \r
9THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
10WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
11\r
12Module Name:\r
13\r
14 ComponentName.c\r
15\r
16Abstract:\r
17\r
18--*/\r
19\r
95276127 20#include "Terminal.h"\r
21\r
22//\r
23// EFI Component Name Protocol\r
24//\r
1307dcd7 25GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gTerminalComponentName = {\r
95276127 26 TerminalComponentNameGetDriverName,\r
27 TerminalComponentNameGetControllerName,\r
28 "eng"\r
1307dcd7 29};\r
5bca971e 30\r
31//\r
32// EFI Component Name 2 Protocol\r
33//\r
1307dcd7 34GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gTerminalComponentName2 = {\r
5bca971e 35 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) TerminalComponentNameGetDriverName,\r
36 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) TerminalComponentNameGetControllerName,\r
37 "en"\r
1307dcd7 38};\r
5bca971e 39\r
95276127 40\r
d1aeb0bd 41GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mTerminalDriverNameTable[] = {\r
95276127 42 {\r
5bca971e 43 "eng;en",\r
95276127 44 (CHAR16 *) L"Serial Terminal Driver"\r
45 },\r
46 {\r
47 NULL,\r
48 NULL\r
49 }\r
50};\r
51\r
5bca971e 52/**\r
53 Retrieves a Unicode string that is the user readable name of the driver.\r
54\r
55 This function retrieves the user readable name of a driver in the form of a\r
56 Unicode string. If the driver specified by This has a user readable name in\r
57 the language specified by Language, then a pointer to the driver name is\r
58 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
59 by This does not support the language specified by Language,\r
60 then EFI_UNSUPPORTED is returned.\r
61\r
62 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
63 EFI_COMPONENT_NAME_PROTOCOL instance.\r
64\r
65 @param Language[in] A pointer to a Null-terminated ASCII string\r
66 array indicating the language. This is the\r
67 language of the driver name that the caller is\r
68 requesting, and it must match one of the\r
69 languages specified in SupportedLanguages. The\r
70 number of languages supported by a driver is up\r
71 to the driver writer. Language is specified\r
72 in RFC 3066 or ISO 639-2 language code format.\r
73\r
74 @param DriverName[out] A pointer to the Unicode string to return.\r
75 This Unicode string is the name of the\r
76 driver specified by This in the language\r
77 specified by Language.\r
78\r
79 @retval EFI_SUCCESS The Unicode string for the Driver specified by\r
80 This and the language specified by Language was\r
81 returned in DriverName.\r
82\r
83 @retval EFI_INVALID_PARAMETER Language is NULL.\r
84\r
85 @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
86\r
87 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
88 the language specified by Language.\r
89\r
90**/\r
95276127 91EFI_STATUS\r
92EFIAPI\r
93TerminalComponentNameGetDriverName (\r
94 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
95 IN CHAR8 *Language,\r
96 OUT CHAR16 **DriverName\r
97 )\r
95276127 98{\r
5bca971e 99 return LookupUnicodeString2 (\r
100 Language,\r
101 This->SupportedLanguages,\r
102 mTerminalDriverNameTable,\r
103 DriverName,\r
104 (BOOLEAN)(This == &gTerminalComponentName)\r
105 );\r
95276127 106}\r
107\r
5bca971e 108/**\r
109 Retrieves a Unicode string that is the user readable name of the controller\r
110 that is being managed by a driver.\r
111\r
112 This function retrieves the user readable name of the controller specified by\r
113 ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
114 driver specified by This has a user readable name in the language specified by\r
115 Language, then a pointer to the controller name is returned in ControllerName,\r
116 and EFI_SUCCESS is returned. If the driver specified by This is not currently\r
117 managing the controller specified by ControllerHandle and ChildHandle,\r
118 then EFI_UNSUPPORTED is returned. If the driver specified by This does not\r
119 support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
120\r
121 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
122 EFI_COMPONENT_NAME_PROTOCOL instance.\r
123\r
124 @param ControllerHandle[in] The handle of a controller that the driver\r
125 specified by This is managing. This handle\r
126 specifies the controller whose name is to be\r
127 returned.\r
128\r
129 @param ChildHandle[in] The handle of the child controller to retrieve\r
130 the name of. This is an optional parameter that\r
131 may be NULL. It will be NULL for device\r
132 drivers. It will also be NULL for a bus drivers\r
133 that wish to retrieve the name of the bus\r
134 controller. It will not be NULL for a bus\r
135 driver that wishes to retrieve the name of a\r
136 child controller.\r
137\r
138 @param Language[in] A pointer to a Null-terminated ASCII string\r
139 array indicating the language. This is the\r
140 language of the driver name that the caller is\r
141 requesting, and it must match one of the\r
142 languages specified in SupportedLanguages. The\r
143 number of languages supported by a driver is up\r
144 to the driver writer. Language is specified in\r
145 RFC 3066 or ISO 639-2 language code format.\r
146\r
147 @param ControllerName[out] A pointer to the Unicode string to return.\r
148 This Unicode string is the name of the\r
149 controller specified by ControllerHandle and\r
150 ChildHandle in the language specified by\r
151 Language from the point of view of the driver\r
152 specified by This.\r
153\r
154 @retval EFI_SUCCESS The Unicode string for the user readable name in\r
155 the language specified by Language for the\r
156 driver specified by This was returned in\r
157 DriverName.\r
158\r
159 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.\r
160\r
161 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
162 EFI_HANDLE.\r
163\r
164 @retval EFI_INVALID_PARAMETER Language is NULL.\r
165\r
166 @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
167\r
168 @retval EFI_UNSUPPORTED The driver specified by This is not currently\r
169 managing the controller specified by\r
170 ControllerHandle and ChildHandle.\r
171\r
172 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
173 the language specified by Language.\r
174\r
175**/\r
95276127 176EFI_STATUS\r
177EFIAPI\r
178TerminalComponentNameGetControllerName (\r
179 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
180 IN EFI_HANDLE ControllerHandle,\r
181 IN EFI_HANDLE ChildHandle OPTIONAL,\r
182 IN CHAR8 *Language,\r
183 OUT CHAR16 **ControllerName\r
184 )\r
95276127 185{\r
186 EFI_STATUS Status;\r
187 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *SimpleTextOutput;\r
188 TERMINAL_DEV *TerminalDevice;\r
189\r
190 //\r
191 // Make sure this driver is currently managing ControllHandle\r
192 //\r
193 Status = EfiTestManagedDevice (\r
194 ControllerHandle,\r
195 gTerminalDriverBinding.DriverBindingHandle,\r
196 &gEfiSerialIoProtocolGuid\r
197 );\r
198 if (EFI_ERROR (Status)) {\r
199 return Status;\r
200 }\r
201\r
202 //\r
203 // This is a bus driver, so ChildHandle can not be NULL.\r
204 //\r
205 if (ChildHandle == NULL) {\r
206 return EFI_UNSUPPORTED;\r
207 }\r
208\r
209 Status = EfiTestChildHandle (\r
210 ControllerHandle,\r
211 ChildHandle,\r
212 &gEfiSerialIoProtocolGuid\r
213 );\r
214 if (EFI_ERROR (Status)) {\r
215 return Status;\r
216 }\r
217\r
218 //\r
219 // Get our context back\r
220 //\r
221 Status = gBS->OpenProtocol (\r
222 ChildHandle,\r
223 &gEfiSimpleTextOutProtocolGuid,\r
224 (VOID **) &SimpleTextOutput,\r
225 gTerminalDriverBinding.DriverBindingHandle,\r
226 ChildHandle,\r
227 EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
228 );\r
229 if (EFI_ERROR (Status)) {\r
230 return EFI_UNSUPPORTED;\r
231 }\r
232\r
233 TerminalDevice = TERMINAL_CON_OUT_DEV_FROM_THIS (SimpleTextOutput);\r
234\r
5bca971e 235 return LookupUnicodeString2 (\r
236 Language,\r
237 This->SupportedLanguages,\r
238 TerminalDevice->ControllerNameTable,\r
239 ControllerName,\r
240 (BOOLEAN)(This == &gTerminalComponentName)\r
241 );\r
95276127 242}\r