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