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