]>
Commit | Line | Data |
---|---|---|
09f72ae8 | 1 | /** @file\r |
67b8a9ce | 2 | UEFI Component Name(2) protocol implementation for USB Mouse Absolute Pointer Driver.\r |
09f72ae8 | 3 | \r |
284ee2e8 | 4 | Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>\r |
9d510e61 | 5 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
09f72ae8 | 6 | \r |
09f72ae8 | 7 | **/\r |
8 | \r | |
67b8a9ce | 9 | #include "UsbMouseAbsolutePointer.h"\r |
09f72ae8 | 10 | \r |
11 | //\r | |
12 | // EFI Component Name Protocol\r | |
13 | //\r | |
14 | GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gUsbMouseAbsolutePointerComponentName = {\r | |
15 | UsbMouseAbsolutePointerComponentNameGetDriverName,\r | |
16 | UsbMouseAbsolutePointerComponentNameGetControllerName,\r | |
17 | "eng"\r | |
18 | };\r | |
19 | \r | |
20 | //\r | |
21 | // EFI Component Name 2 Protocol\r | |
22 | //\r | |
1436aea4 MK |
23 | GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gUsbMouseAbsolutePointerComponentName2 = {\r |
24 | (EFI_COMPONENT_NAME2_GET_DRIVER_NAME)UsbMouseAbsolutePointerComponentNameGetDriverName,\r | |
25 | (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)UsbMouseAbsolutePointerComponentNameGetControllerName,\r | |
09f72ae8 | 26 | "en"\r |
27 | };\r | |
28 | \r | |
1436aea4 | 29 | GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mUsbMouseAbsolutePointerDriverNameTable[] = {\r |
67b8a9ce | 30 | { "eng;en", L"Usb Mouse Absolute Pointer Driver" },\r |
1436aea4 | 31 | { NULL, NULL }\r |
09f72ae8 | 32 | };\r |
33 | \r | |
09f72ae8 | 34 | /**\r |
35 | Retrieves a Unicode string that is the user readable name of the driver.\r | |
36 | \r | |
37 | This function retrieves the user readable name of a driver in the form of a\r | |
38 | Unicode string. If the driver specified by This has a user readable name in\r | |
39 | the language specified by Language, then a pointer to the driver name is\r | |
40 | returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r | |
41 | by This does not support the language specified by Language,\r | |
42 | then EFI_UNSUPPORTED is returned.\r | |
43 | \r | |
67b8a9ce | 44 | @param This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r |
09f72ae8 | 45 | EFI_COMPONENT_NAME_PROTOCOL instance.\r |
67b8a9ce | 46 | @param Language A pointer to a Null-terminated ASCII string\r |
09f72ae8 | 47 | array indicating the language. This is the\r |
48 | language of the driver name that the caller is\r | |
49 | requesting, and it must match one of the\r | |
50 | languages specified in SupportedLanguages. The\r | |
51 | number of languages supported by a driver is up\r | |
52 | to the driver writer. Language is specified\r | |
0254efc0 | 53 | in RFC 4646 or ISO 639-2 language code format.\r |
67b8a9ce | 54 | @param DriverName A pointer to the Unicode string to return.\r |
09f72ae8 | 55 | This Unicode string is the name of the\r |
56 | driver specified by This in the language\r | |
57 | specified by Language.\r | |
58 | \r | |
59 | @retval EFI_SUCCESS The Unicode string for the Driver specified by\r | |
60 | This and the language specified by Language was\r | |
61 | returned in DriverName.\r | |
09f72ae8 | 62 | @retval EFI_INVALID_PARAMETER Language is NULL.\r |
09f72ae8 | 63 | @retval EFI_INVALID_PARAMETER DriverName is NULL.\r |
09f72ae8 | 64 | @retval EFI_UNSUPPORTED The driver specified by This does not support\r |
65 | the language specified by Language.\r | |
66 | \r | |
67 | **/\r | |
68 | EFI_STATUS\r | |
69 | EFIAPI\r | |
70 | UsbMouseAbsolutePointerComponentNameGetDriverName (\r | |
71 | IN EFI_COMPONENT_NAME_PROTOCOL *This,\r | |
72 | IN CHAR8 *Language,\r | |
73 | OUT CHAR16 **DriverName\r | |
74 | )\r | |
75 | {\r | |
76 | return LookupUnicodeString2 (\r | |
77 | Language,\r | |
78 | This->SupportedLanguages,\r | |
79 | mUsbMouseAbsolutePointerDriverNameTable,\r | |
80 | DriverName,\r | |
81 | (BOOLEAN)(This == &gUsbMouseAbsolutePointerComponentName)\r | |
82 | );\r | |
83 | }\r | |
84 | \r | |
85 | /**\r | |
86 | Retrieves a Unicode string that is the user readable name of the controller\r | |
87 | that is being managed by a driver.\r | |
88 | \r | |
89 | This function retrieves the user readable name of the controller specified by\r | |
90 | ControllerHandle and ChildHandle in the form of a Unicode string. If the\r | |
91 | driver specified by This has a user readable name in the language specified by\r | |
92 | Language, then a pointer to the controller name is returned in ControllerName,\r | |
93 | and EFI_SUCCESS is returned. If the driver specified by This is not currently\r | |
94 | managing the controller specified by ControllerHandle and ChildHandle,\r | |
95 | then EFI_UNSUPPORTED is returned. If the driver specified by This does not\r | |
96 | support the language specified by Language, then EFI_UNSUPPORTED is returned.\r | |
97 | \r | |
67b8a9ce | 98 | @param This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r |
09f72ae8 | 99 | EFI_COMPONENT_NAME_PROTOCOL instance.\r |
67b8a9ce | 100 | @param ControllerHandle The handle of a controller that the driver\r |
09f72ae8 | 101 | specified by This is managing. This handle\r |
102 | specifies the controller whose name is to be\r | |
103 | returned.\r | |
67b8a9ce | 104 | @param ChildHandle The handle of the child controller to retrieve\r |
09f72ae8 | 105 | the name of. This is an optional parameter that\r |
106 | may be NULL. It will be NULL for device\r | |
107 | drivers. It will also be NULL for a bus drivers\r | |
108 | that wish to retrieve the name of the bus\r | |
109 | controller. It will not be NULL for a bus\r | |
110 | driver that wishes to retrieve the name of a\r | |
111 | child controller.\r | |
67b8a9ce | 112 | @param Language A pointer to a Null-terminated ASCII string\r |
09f72ae8 | 113 | array indicating the language. This is the\r |
114 | language of the driver name that the caller is\r | |
115 | requesting, and it must match one of the\r | |
116 | languages specified in SupportedLanguages. The\r | |
117 | number of languages supported by a driver is up\r | |
118 | to the driver writer. Language is specified in\r | |
0254efc0 | 119 | RFC 4646 or ISO 639-2 language code format.\r |
67b8a9ce | 120 | @param ControllerName A pointer to the Unicode string to return.\r |
09f72ae8 | 121 | This Unicode string is the name of the\r |
122 | controller specified by ControllerHandle and\r | |
123 | ChildHandle in the language specified by\r | |
124 | Language from the point of view of the driver\r | |
125 | specified by This.\r | |
126 | \r | |
127 | @retval EFI_SUCCESS The Unicode string for the user readable name in\r | |
128 | the language specified by Language for the\r | |
129 | driver specified by This was returned in\r | |
130 | DriverName.\r | |
284ee2e8 | 131 | @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r |
09f72ae8 | 132 | @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r |
133 | EFI_HANDLE.\r | |
09f72ae8 | 134 | @retval EFI_INVALID_PARAMETER Language is NULL.\r |
09f72ae8 | 135 | @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r |
09f72ae8 | 136 | @retval EFI_UNSUPPORTED The driver specified by This is not currently\r |
137 | managing the controller specified by\r | |
138 | ControllerHandle and ChildHandle.\r | |
09f72ae8 | 139 | @retval EFI_UNSUPPORTED The driver specified by This does not support\r |
140 | the language specified by Language.\r | |
141 | \r | |
142 | **/\r | |
143 | EFI_STATUS\r | |
144 | EFIAPI\r | |
145 | UsbMouseAbsolutePointerComponentNameGetControllerName (\r | |
1436aea4 MK |
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 | |
09f72ae8 | 151 | )\r |
152 | {\r | |
1436aea4 MK |
153 | EFI_STATUS Status;\r |
154 | USB_MOUSE_ABSOLUTE_POINTER_DEV *UsbMouseAbsolutePointerDev;\r | |
155 | EFI_ABSOLUTE_POINTER_PROTOCOL *AbsolutePointerProtocol;\r | |
156 | EFI_USB_IO_PROTOCOL *UsbIoProtocol;\r | |
09f72ae8 | 157 | \r |
158 | //\r | |
159 | // This is a device driver, so ChildHandle must be NULL.\r | |
160 | //\r | |
161 | if (ChildHandle != NULL) {\r | |
162 | return EFI_UNSUPPORTED;\r | |
163 | }\r | |
164 | \r | |
165 | //\r | |
166 | // Check Controller's handle\r | |
167 | //\r | |
168 | Status = gBS->OpenProtocol (\r | |
169 | ControllerHandle,\r | |
170 | &gEfiUsbIoProtocolGuid,\r | |
1436aea4 | 171 | (VOID **)&UsbIoProtocol,\r |
09f72ae8 | 172 | gUsbMouseAbsolutePointerDriverBinding.DriverBindingHandle,\r |
173 | ControllerHandle,\r | |
174 | EFI_OPEN_PROTOCOL_BY_DRIVER\r | |
175 | );\r | |
176 | if (!EFI_ERROR (Status)) {\r | |
177 | gBS->CloseProtocol (\r | |
67b8a9ce | 178 | ControllerHandle,\r |
179 | &gEfiUsbIoProtocolGuid,\r | |
180 | gUsbMouseAbsolutePointerDriverBinding.DriverBindingHandle,\r | |
181 | ControllerHandle\r | |
182 | );\r | |
09f72ae8 | 183 | \r |
184 | return EFI_UNSUPPORTED;\r | |
185 | }\r | |
186 | \r | |
187 | if (Status != EFI_ALREADY_STARTED) {\r | |
188 | return EFI_UNSUPPORTED;\r | |
189 | }\r | |
1436aea4 | 190 | \r |
09f72ae8 | 191 | //\r |
192 | // Get the device context\r | |
193 | //\r | |
194 | Status = gBS->OpenProtocol (\r | |
195 | ControllerHandle,\r | |
1436aea4 MK |
196 | &gEfiAbsolutePointerProtocolGuid,\r |
197 | (VOID **)&AbsolutePointerProtocol,\r | |
09f72ae8 | 198 | gUsbMouseAbsolutePointerDriverBinding.DriverBindingHandle,\r |
199 | ControllerHandle,\r | |
200 | EFI_OPEN_PROTOCOL_GET_PROTOCOL\r | |
201 | );\r | |
202 | \r | |
203 | if (EFI_ERROR (Status)) {\r | |
204 | return Status;\r | |
205 | }\r | |
206 | \r | |
207 | UsbMouseAbsolutePointerDev = USB_MOUSE_ABSOLUTE_POINTER_DEV_FROM_MOUSE_PROTOCOL (AbsolutePointerProtocol);\r | |
208 | \r | |
209 | return LookupUnicodeString2 (\r | |
210 | Language,\r | |
211 | This->SupportedLanguages,\r | |
212 | UsbMouseAbsolutePointerDev->ControllerNameTable,\r | |
213 | ControllerName,\r | |
214 | (BOOLEAN)(This == &gUsbMouseAbsolutePointerComponentName)\r | |
215 | );\r | |
09f72ae8 | 216 | }\r |