]> git.proxmox.com Git - mirror_edk2.git/blame - Nt32Pkg/WinNtSerialIoDxe/ComponentName.c
Nt32Pkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / Nt32Pkg / WinNtSerialIoDxe / ComponentName.c
CommitLineData
6ae81428 1/**@file\r
5f44f5b9 2\r
8f2a5f80 3Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
9d2eedba 4SPDX-License-Identifier: BSD-2-Clause-Patent\r
5f44f5b9 5\r
6Module Name:\r
7\r
8 ComponentName.c\r
9\r
10Abstract:\r
11\r
6ae81428 12**/\r
5f44f5b9 13\r
14#include "WinNtSerialIo.h"\r
15\r
16//\r
17// EFI Component Name Functions\r
18//\r
04369cd8 19/**\r
20 Retrieves a Unicode string that is the user readable name of the driver.\r
21\r
22 This function retrieves the user readable name of a driver in the form of a\r
23 Unicode string. If the driver specified by This has a user readable name in\r
24 the language specified by Language, then a pointer to the driver name is\r
25 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
26 by This does not support the language specified by Language,\r
27 then EFI_UNSUPPORTED is returned.\r
28\r
29 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
30 EFI_COMPONENT_NAME_PROTOCOL instance.\r
31\r
32 @param Language[in] A pointer to a Null-terminated ASCII string\r
33 array indicating the language. This is the\r
34 language of the driver name that the caller is\r
35 requesting, and it must match one of the\r
36 languages specified in SupportedLanguages. The\r
37 number of languages supported by a driver is up\r
38 to the driver writer. Language is specified\r
44c40247 39 in RFC 4646 or ISO 639-2 language code format.\r
04369cd8 40\r
41 @param DriverName[out] A pointer to the Unicode string to return.\r
42 This Unicode string is the name of the\r
43 driver specified by This in the language\r
44 specified by Language.\r
45\r
46 @retval EFI_SUCCESS The Unicode string for the Driver specified by\r
47 This and the language specified by Language was\r
48 returned in DriverName.\r
49\r
50 @retval EFI_INVALID_PARAMETER Language is NULL.\r
51\r
52 @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
53\r
54 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
55 the language specified by Language.\r
56\r
57**/\r
5f44f5b9 58EFI_STATUS\r
59EFIAPI\r
60WinNtSerialIoComponentNameGetDriverName (\r
61 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
62 IN CHAR8 *Language,\r
63 OUT CHAR16 **DriverName\r
64 );\r
65\r
04369cd8 66\r
67/**\r
68 Retrieves a Unicode string that is the user readable name of the controller\r
69 that is being managed by a driver.\r
70\r
71 This function retrieves the user readable name of the controller specified by\r
72 ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
73 driver specified by This has a user readable name in the language specified by\r
74 Language, then a pointer to the controller name is returned in ControllerName,\r
75 and EFI_SUCCESS is returned. If the driver specified by This is not currently\r
76 managing the controller specified by ControllerHandle and ChildHandle,\r
77 then EFI_UNSUPPORTED is returned. If the driver specified by This does not\r
78 support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
79\r
80 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
81 EFI_COMPONENT_NAME_PROTOCOL instance.\r
82\r
83 @param ControllerHandle[in] The handle of a controller that the driver\r
84 specified by This is managing. This handle\r
85 specifies the controller whose name is to be\r
86 returned.\r
87\r
88 @param ChildHandle[in] The handle of the child controller to retrieve\r
89 the name of. This is an optional parameter that\r
90 may be NULL. It will be NULL for device\r
91 drivers. It will also be NULL for a bus drivers\r
92 that wish to retrieve the name of the bus\r
93 controller. It will not be NULL for a bus\r
94 driver that wishes to retrieve the name of a\r
95 child controller.\r
96\r
97 @param Language[in] A pointer to a Null-terminated ASCII string\r
98 array indicating the language. This is the\r
99 language of the driver name that the caller is\r
100 requesting, and it must match one of the\r
101 languages specified in SupportedLanguages. The\r
102 number of languages supported by a driver is up\r
103 to the driver writer. Language is specified in\r
44c40247 104 RFC 4646 or ISO 639-2 language code format.\r
04369cd8 105\r
106 @param ControllerName[out] A pointer to the Unicode string to return.\r
107 This Unicode string is the name of the\r
108 controller specified by ControllerHandle and\r
109 ChildHandle in the language specified by\r
110 Language from the point of view of the driver\r
111 specified by This.\r
112\r
113 @retval EFI_SUCCESS The Unicode string for the user readable name in\r
114 the language specified by Language for the\r
115 driver specified by This was returned in\r
116 DriverName.\r
117\r
118 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.\r
119\r
120 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
121 EFI_HANDLE.\r
122\r
123 @retval EFI_INVALID_PARAMETER Language is NULL.\r
124\r
125 @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
126\r
127 @retval EFI_UNSUPPORTED The driver specified by This is not currently\r
128 managing the controller specified by\r
129 ControllerHandle and ChildHandle.\r
130\r
131 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
132 the language specified by Language.\r
133\r
134**/\r
5f44f5b9 135EFI_STATUS\r
136EFIAPI\r
137WinNtSerialIoComponentNameGetControllerName (\r
138 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
139 IN EFI_HANDLE ControllerHandle,\r
140 IN EFI_HANDLE ChildHandle OPTIONAL,\r
141 IN CHAR8 *Language,\r
142 OUT CHAR16 **ControllerName\r
143 );\r
144\r
04369cd8 145\r
5f44f5b9 146//\r
147// EFI Component Name Protocol\r
148//\r
1307dcd7 149GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gWinNtSerialIoComponentName = {\r
5f44f5b9 150 WinNtSerialIoComponentNameGetDriverName,\r
151 WinNtSerialIoComponentNameGetControllerName,\r
152 "eng"\r
1307dcd7 153};\r
04369cd8 154\r
155//\r
156// EFI Component Name 2 Protocol\r
157//\r
1307dcd7 158GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gWinNtSerialIoComponentName2 = {\r
04369cd8 159 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) WinNtSerialIoComponentNameGetDriverName,\r
160 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) WinNtSerialIoComponentNameGetControllerName,\r
161 "en"\r
1307dcd7 162};\r
04369cd8 163\r
5f44f5b9 164\r
d1aeb0bd 165GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mWinNtSerialIoDriverNameTable[] = {\r
04369cd8 166 { "eng;en", L"Windows Serial I/O Driver" },\r
5f44f5b9 167 { NULL , NULL }\r
168};\r
169\r
04369cd8 170/**\r
171 Retrieves a Unicode string that is the user readable name of the driver.\r
172\r
173 This function retrieves the user readable name of a driver in the form of a\r
174 Unicode string. If the driver specified by This has a user readable name in\r
175 the language specified by Language, then a pointer to the driver name is\r
176 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
177 by This does not support the language specified by Language,\r
178 then EFI_UNSUPPORTED is returned.\r
179\r
180 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
181 EFI_COMPONENT_NAME_PROTOCOL instance.\r
182\r
183 @param Language[in] A pointer to a Null-terminated ASCII string\r
184 array indicating the language. This is the\r
185 language of the driver name that the caller is\r
186 requesting, and it must match one of the\r
187 languages specified in SupportedLanguages. The\r
188 number of languages supported by a driver is up\r
189 to the driver writer. Language is specified\r
44c40247 190 in RFC 4646 or ISO 639-2 language code format.\r
04369cd8 191\r
192 @param DriverName[out] A pointer to the Unicode string to return.\r
193 This Unicode string is the name of the\r
194 driver specified by This in the language\r
195 specified by Language.\r
196\r
197 @retval EFI_SUCCESS The Unicode string for the Driver specified by\r
198 This and the language specified by Language was\r
199 returned in DriverName.\r
200\r
201 @retval EFI_INVALID_PARAMETER Language is NULL.\r
202\r
203 @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
204\r
205 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
206 the language specified by Language.\r
207\r
208**/\r
5f44f5b9 209EFI_STATUS\r
210EFIAPI\r
211WinNtSerialIoComponentNameGetDriverName (\r
212 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
213 IN CHAR8 *Language,\r
214 OUT CHAR16 **DriverName\r
215 )\r
5f44f5b9 216{\r
04369cd8 217 return LookupUnicodeString2 (\r
218 Language,\r
219 This->SupportedLanguages,\r
220 mWinNtSerialIoDriverNameTable,\r
221 DriverName,\r
222 (BOOLEAN)(This == &gWinNtSerialIoComponentName)\r
223 );\r
5f44f5b9 224}\r
225\r
04369cd8 226/**\r
227 Retrieves a Unicode string that is the user readable name of the controller\r
228 that is being managed by a driver.\r
229\r
230 This function retrieves the user readable name of the controller specified by\r
231 ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
232 driver specified by This has a user readable name in the language specified by\r
233 Language, then a pointer to the controller name is returned in ControllerName,\r
234 and EFI_SUCCESS is returned. If the driver specified by This is not currently\r
235 managing the controller specified by ControllerHandle and ChildHandle,\r
236 then EFI_UNSUPPORTED is returned. If the driver specified by This does not\r
237 support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
238\r
239 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
240 EFI_COMPONENT_NAME_PROTOCOL instance.\r
241\r
242 @param ControllerHandle[in] The handle of a controller that the driver\r
243 specified by This is managing. This handle\r
244 specifies the controller whose name is to be\r
245 returned.\r
246\r
247 @param ChildHandle[in] The handle of the child controller to retrieve\r
248 the name of. This is an optional parameter that\r
249 may be NULL. It will be NULL for device\r
250 drivers. It will also be NULL for a bus drivers\r
251 that wish to retrieve the name of the bus\r
252 controller. It will not be NULL for a bus\r
253 driver that wishes to retrieve the name of a\r
254 child controller.\r
255\r
256 @param Language[in] A pointer to a Null-terminated ASCII string\r
257 array indicating the language. This is the\r
258 language of the driver name that the caller is\r
259 requesting, and it must match one of the\r
260 languages specified in SupportedLanguages. The\r
261 number of languages supported by a driver is up\r
262 to the driver writer. Language is specified in\r
44c40247 263 RFC 4646 or ISO 639-2 language code format.\r
04369cd8 264\r
265 @param ControllerName[out] A pointer to the Unicode string to return.\r
266 This Unicode string is the name of the\r
267 controller specified by ControllerHandle and\r
268 ChildHandle in the language specified by\r
269 Language from the point of view of the driver\r
270 specified by This.\r
271\r
272 @retval EFI_SUCCESS The Unicode string for the user readable name in\r
273 the language specified by Language for the\r
274 driver specified by This was returned in\r
275 DriverName.\r
276\r
277 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.\r
278\r
279 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
280 EFI_HANDLE.\r
281\r
282 @retval EFI_INVALID_PARAMETER Language is NULL.\r
283\r
284 @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
285\r
286 @retval EFI_UNSUPPORTED The driver specified by This is not currently\r
287 managing the controller specified by\r
288 ControllerHandle and ChildHandle.\r
289\r
290 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
291 the language specified by Language.\r
292\r
293**/\r
5f44f5b9 294EFI_STATUS\r
295EFIAPI\r
296WinNtSerialIoComponentNameGetControllerName (\r
297 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
298 IN EFI_HANDLE ControllerHandle,\r
299 IN EFI_HANDLE ChildHandle OPTIONAL,\r
300 IN CHAR8 *Language,\r
301 OUT CHAR16 **ControllerName\r
302 )\r
5f44f5b9 303{\r
304 EFI_STATUS Status;\r
305 EFI_SERIAL_IO_PROTOCOL *SerialIo;\r
306 WIN_NT_SERIAL_IO_PRIVATE_DATA *Private;\r
307\r
308 //\r
309 // Make sure this driver is currently managing ControllHandle\r
310 //\r
311 Status = EfiTestManagedDevice (\r
312 ControllerHandle,\r
313 gWinNtSerialIoDriverBinding.DriverBindingHandle,\r
314 &gEfiWinNtIoProtocolGuid\r
315 );\r
316 if (EFI_ERROR (Status)) {\r
317 return Status;\r
318 }\r
319\r
320 //\r
321 // This is a bus driver, so ChildHandle must not be NULL.\r
322 //\r
323 if (ChildHandle == NULL) {\r
324 return EFI_UNSUPPORTED;\r
325 }\r
326\r
327 Status = EfiTestChildHandle (\r
328 ControllerHandle,\r
329 ChildHandle,\r
330 &gEfiWinNtIoProtocolGuid\r
331 );\r
332 if (EFI_ERROR (Status)) {\r
333 return Status;\r
334 }\r
335\r
336 //\r
337 // Get our context back\r
338 //\r
339 Status = gBS->OpenProtocol (\r
340 ChildHandle,\r
341 &gEfiSerialIoProtocolGuid,\r
63941829 342 (VOID **) &SerialIo,\r
5f44f5b9 343 gWinNtSerialIoDriverBinding.DriverBindingHandle,\r
344 ChildHandle,\r
345 EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
346 );\r
347 if (EFI_ERROR (Status)) {\r
348 return EFI_UNSUPPORTED;\r
349 }\r
350\r
351 Private = WIN_NT_SERIAL_IO_PRIVATE_DATA_FROM_THIS (SerialIo);\r
352\r
04369cd8 353 return LookupUnicodeString2 (\r
354 Language,\r
355 This->SupportedLanguages,\r
356 Private->ControllerNameTable,\r
357 ControllerName,\r
358 (BOOLEAN)(This == &gWinNtSerialIoComponentName)\r
359 );\r
5f44f5b9 360}\r