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