]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Bus/Usb/UsbMouseDxe/ComponentName.c
Add description to .inf files.
[mirror_edk2.git] / MdeModulePkg / Bus / Usb / UsbMouseDxe / ComponentName.c
1 /** @file
2
3 UEFI Component Name(2) protocol implementation for Usb Mouse driver.
4
5 Copyright (c) 2004 - 2008, Intel Corporation
6 All rights reserved. This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
10
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13
14 **/
15
16 #include "UsbMouse.h"
17 #include <Library/DebugLib.h>
18
19 //
20 // EFI Component Name Functions
21 //
22 /**
23 Retrieves a Unicode string that is the user readable name of the driver.
24
25 This function retrieves the user readable name of a driver in the form of a
26 Unicode string. If the driver specified by This has a user readable name in
27 the language specified by Language, then a pointer to the driver name is
28 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
29 by This does not support the language specified by Language,
30 then EFI_UNSUPPORTED is returned.
31
32 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
33 EFI_COMPONENT_NAME_PROTOCOL instance.
34
35 @param Language[in] A pointer to a Null-terminated ASCII string
36 array indicating the language. This is the
37 language of the driver name that the caller is
38 requesting, and it must match one of the
39 languages specified in SupportedLanguages. The
40 number of languages supported by a driver is up
41 to the driver writer. Language is specified
42 in RFC 3066 or ISO 639-2 language code format.
43
44 @param DriverName[out] A pointer to the Unicode string to return.
45 This Unicode string is the name of the
46 driver specified by This in the language
47 specified by Language.
48
49 @retval EFI_SUCCESS The Unicode string for the Driver specified by
50 This and the language specified by Language was
51 returned in DriverName.
52
53 @retval EFI_INVALID_PARAMETER Language is NULL.
54
55 @retval EFI_INVALID_PARAMETER DriverName is NULL.
56
57 @retval EFI_UNSUPPORTED The driver specified by This does not support
58 the language specified by Language.
59
60 **/
61 EFI_STATUS
62 EFIAPI
63 UsbMouseComponentNameGetDriverName (
64 IN EFI_COMPONENT_NAME_PROTOCOL *This,
65 IN CHAR8 *Language,
66 OUT CHAR16 **DriverName
67 );
68
69
70 /**
71 Retrieves a Unicode string that is the user readable name of the controller
72 that is being managed by a driver.
73
74 This function retrieves the user readable name of the controller specified by
75 ControllerHandle and ChildHandle in the form of a Unicode string. If the
76 driver specified by This has a user readable name in the language specified by
77 Language, then a pointer to the controller name is returned in ControllerName,
78 and EFI_SUCCESS is returned. If the driver specified by This is not currently
79 managing the controller specified by ControllerHandle and ChildHandle,
80 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
81 support the language specified by Language, then EFI_UNSUPPORTED is returned.
82
83 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
84 EFI_COMPONENT_NAME_PROTOCOL instance.
85
86 @param ControllerHandle[in] The handle of a controller that the driver
87 specified by This is managing. This handle
88 specifies the controller whose name is to be
89 returned.
90
91 @param ChildHandle[in] The handle of the child controller to retrieve
92 the name of. This is an optional parameter that
93 may be NULL. It will be NULL for device
94 drivers. It will also be NULL for a bus drivers
95 that wish to retrieve the name of the bus
96 controller. It will not be NULL for a bus
97 driver that wishes to retrieve the name of a
98 child controller.
99
100 @param Language[in] A pointer to a Null-terminated ASCII string
101 array indicating the language. This is the
102 language of the driver name that the caller is
103 requesting, and it must match one of the
104 languages specified in SupportedLanguages. The
105 number of languages supported by a driver is up
106 to the driver writer. Language is specified in
107 RFC 3066 or ISO 639-2 language code format.
108
109 @param ControllerName[out] A pointer to the Unicode string to return.
110 This Unicode string is the name of the
111 controller specified by ControllerHandle and
112 ChildHandle in the language specified by
113 Language from the point of view of the driver
114 specified by This.
115
116 @retval EFI_SUCCESS The Unicode string for the user readable name in
117 the language specified by Language for the
118 driver specified by This was returned in
119 DriverName.
120
121 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
122
123 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
124 EFI_HANDLE.
125
126 @retval EFI_INVALID_PARAMETER Language is NULL.
127
128 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
129
130 @retval EFI_UNSUPPORTED The driver specified by This is not currently
131 managing the controller specified by
132 ControllerHandle and ChildHandle.
133
134 @retval EFI_UNSUPPORTED The driver specified by This does not support
135 the language specified by Language.
136
137 **/
138 EFI_STATUS
139 EFIAPI
140 UsbMouseComponentNameGetControllerName (
141 IN EFI_COMPONENT_NAME_PROTOCOL *This,
142 IN EFI_HANDLE ControllerHandle,
143 IN EFI_HANDLE ChildHandle OPTIONAL,
144 IN CHAR8 *Language,
145 OUT CHAR16 **ControllerName
146 );
147
148
149 //
150 // EFI Component Name Protocol
151 //
152 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gUsbMouseComponentName = {
153 UsbMouseComponentNameGetDriverName,
154 UsbMouseComponentNameGetControllerName,
155 "eng"
156 };
157
158 //
159 // EFI Component Name 2 Protocol
160 //
161 GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gUsbMouseComponentName2 = {
162 (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) UsbMouseComponentNameGetDriverName,
163 (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) UsbMouseComponentNameGetControllerName,
164 "en"
165 };
166
167
168
169 GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mUsbMouseDriverNameTable[] = {
170 { "eng;en", L"Usb Mouse Driver" },
171 { NULL , NULL }
172 };
173
174
175 /**
176 Retrieves a Unicode string that is the user readable name of the driver.
177
178 This function retrieves the user readable name of a driver in the form of a
179 Unicode string. If the driver specified by This has a user readable name in
180 the language specified by Language, then a pointer to the driver name is
181 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
182 by This does not support the language specified by Language,
183 then EFI_UNSUPPORTED is returned.
184
185 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
186 EFI_COMPONENT_NAME_PROTOCOL instance.
187
188 @param Language[in] A pointer to a Null-terminated ASCII string
189 array indicating the language. This is the
190 language of the driver name that the caller is
191 requesting, and it must match one of the
192 languages specified in SupportedLanguages. The
193 number of languages supported by a driver is up
194 to the driver writer. Language is specified
195 in RFC 3066 or ISO 639-2 language code format.
196
197 @param DriverName[out] A pointer to the Unicode string to return.
198 This Unicode string is the name of the
199 driver specified by This in the language
200 specified by Language.
201
202 @retval EFI_SUCCESS The Unicode string for the Driver specified by
203 This and the language specified by Language was
204 returned in DriverName.
205
206 @retval EFI_INVALID_PARAMETER Language is NULL.
207
208 @retval EFI_INVALID_PARAMETER DriverName is NULL.
209
210 @retval EFI_UNSUPPORTED The driver specified by This does not support
211 the language specified by Language.
212
213 **/
214 EFI_STATUS
215 EFIAPI
216 UsbMouseComponentNameGetDriverName (
217 IN EFI_COMPONENT_NAME_PROTOCOL *This,
218 IN CHAR8 *Language,
219 OUT CHAR16 **DriverName
220 )
221 {
222 return LookupUnicodeString2 (
223 Language,
224 This->SupportedLanguages,
225 mUsbMouseDriverNameTable,
226 DriverName,
227 (BOOLEAN)(This == &gUsbMouseComponentName)
228 );
229 }
230
231 /**
232 Retrieves a Unicode string that is the user readable name of the controller
233 that is being managed by a driver.
234
235 This function retrieves the user readable name of the controller specified by
236 ControllerHandle and ChildHandle in the form of a Unicode string. If the
237 driver specified by This has a user readable name in the language specified by
238 Language, then a pointer to the controller name is returned in ControllerName,
239 and EFI_SUCCESS is returned. If the driver specified by This is not currently
240 managing the controller specified by ControllerHandle and ChildHandle,
241 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
242 support the language specified by Language, then EFI_UNSUPPORTED is returned.
243
244 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
245 EFI_COMPONENT_NAME_PROTOCOL instance.
246
247 @param ControllerHandle[in] The handle of a controller that the driver
248 specified by This is managing. This handle
249 specifies the controller whose name is to be
250 returned.
251
252 @param ChildHandle[in] The handle of the child controller to retrieve
253 the name of. This is an optional parameter that
254 may be NULL. It will be NULL for device
255 drivers. It will also be NULL for a bus drivers
256 that wish to retrieve the name of the bus
257 controller. It will not be NULL for a bus
258 driver that wishes to retrieve the name of a
259 child controller.
260
261 @param Language[in] A pointer to a Null-terminated ASCII string
262 array indicating the language. This is the
263 language of the driver name that the caller is
264 requesting, and it must match one of the
265 languages specified in SupportedLanguages. The
266 number of languages supported by a driver is up
267 to the driver writer. Language is specified in
268 RFC 3066 or ISO 639-2 language code format.
269
270 @param ControllerName[out] A pointer to the Unicode string to return.
271 This Unicode string is the name of the
272 controller specified by ControllerHandle and
273 ChildHandle in the language specified by
274 Language from the point of view of the driver
275 specified by This.
276
277 @retval EFI_SUCCESS The Unicode string for the user readable name in
278 the language specified by Language for the
279 driver specified by This was returned in
280 DriverName.
281
282 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
283
284 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
285 EFI_HANDLE.
286
287 @retval EFI_INVALID_PARAMETER Language is NULL.
288
289 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
290
291 @retval EFI_UNSUPPORTED The driver specified by This is not currently
292 managing the controller specified by
293 ControllerHandle and ChildHandle.
294
295 @retval EFI_UNSUPPORTED The driver specified by This does not support
296 the language specified by Language.
297
298 **/
299 EFI_STATUS
300 EFIAPI
301 UsbMouseComponentNameGetControllerName (
302 IN EFI_COMPONENT_NAME_PROTOCOL *This,
303 IN EFI_HANDLE ControllerHandle,
304 IN EFI_HANDLE ChildHandle OPTIONAL,
305 IN CHAR8 *Language,
306 OUT CHAR16 **ControllerName
307 )
308 {
309 EFI_STATUS Status;
310 USB_MOUSE_DEV *UsbMouseDev;
311 EFI_SIMPLE_POINTER_PROTOCOL *SimplePointerProtocol;
312 EFI_USB_IO_PROTOCOL *UsbIoProtocol;
313
314 //
315 // This is a device driver, so ChildHandle must be NULL.
316 //
317 if (ChildHandle != NULL) {
318 return EFI_UNSUPPORTED;
319 }
320
321 //
322 // Check Controller's handle
323 //
324 Status = gBS->OpenProtocol (
325 ControllerHandle,
326 &gEfiUsbIoProtocolGuid,
327 (VOID **) &UsbIoProtocol,
328 gUsbMouseDriverBinding.DriverBindingHandle,
329 ControllerHandle,
330 EFI_OPEN_PROTOCOL_BY_DRIVER
331 );
332 if (!EFI_ERROR (Status)) {
333 gBS->CloseProtocol (
334 ControllerHandle,
335 &gEfiUsbIoProtocolGuid,
336 gUsbMouseDriverBinding.DriverBindingHandle,
337 ControllerHandle
338 );
339
340 return EFI_UNSUPPORTED;
341 }
342
343 if (Status != EFI_ALREADY_STARTED) {
344 return EFI_UNSUPPORTED;
345 }
346 //
347 // Get the device context
348 //
349 Status = gBS->OpenProtocol (
350 ControllerHandle,
351 &gEfiSimplePointerProtocolGuid,
352 (VOID **) &SimplePointerProtocol,
353 gUsbMouseDriverBinding.DriverBindingHandle,
354 ControllerHandle,
355 EFI_OPEN_PROTOCOL_GET_PROTOCOL
356 );
357
358 if (EFI_ERROR (Status)) {
359 return Status;
360 }
361
362 UsbMouseDev = USB_MOUSE_DEV_FROM_MOUSE_PROTOCOL (SimplePointerProtocol);
363
364 return LookupUnicodeString2 (
365 Language,
366 This->SupportedLanguages,
367 UsbMouseDev->ControllerNameTable,
368 ControllerName,
369 (BOOLEAN)(This == &gUsbMouseComponentName)
370 );
371
372 }