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