]>
Commit | Line | Data |
---|---|---|
913cb9dc | 1 | /** @file\r |
ab6495ea | 2 | UEFI Component Name(2) protocol implementation for UHCI driver.\r |
913cb9dc | 3 | \r |
284ee2e8 | 4 | Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>\r |
cd5ebaa0 | 5 | This program and the accompanying materials\r |
913cb9dc | 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 | |
913cb9dc | 13 | **/\r |
14 | \r | |
16829953 | 15 | #include "Uhci.h"\r |
913cb9dc | 16 | \r |
f527bce3 | 17 | \r |
913cb9dc | 18 | //\r |
19 | // EFI Component Name Protocol\r | |
20 | //\r | |
aa79b0b3 | 21 | \r |
1307dcd7 | 22 | GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gUhciComponentName = {\r |
913cb9dc | 23 | UhciComponentNameGetDriverName,\r |
24 | UhciComponentNameGetControllerName,\r | |
25 | "eng"\r | |
1307dcd7 | 26 | };\r |
f527bce3 | 27 | \r |
28 | //\r | |
29 | // EFI Component Name 2 Protocol\r | |
30 | //\r | |
1307dcd7 | 31 | GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gUhciComponentName2 = {\r |
f527bce3 | 32 | (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) UhciComponentNameGetDriverName,\r |
33 | (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) UhciComponentNameGetControllerName,\r | |
34 | "en"\r | |
1307dcd7 | 35 | };\r |
f527bce3 | 36 | \r |
913cb9dc | 37 | \r |
d1aeb0bd | 38 | GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mUhciDriverNameTable[] = {\r |
f527bce3 | 39 | { "eng;en", L"Usb Uhci Driver" },\r |
913cb9dc | 40 | { NULL, NULL }\r |
41 | };\r | |
42 | \r | |
aa79b0b3 | 43 | \r |
44 | //\r | |
45 | // EFI Component Name Functions\r | |
46 | //\r | |
47 | \r | |
f527bce3 | 48 | /**\r |
49 | Retrieves a Unicode string that is the user readable name of the driver.\r | |
50 | \r | |
51 | This function retrieves the user readable name of a driver in the form of a\r | |
52 | Unicode string. If the driver specified by This has a user readable name in\r | |
53 | the language specified by Language, then a pointer to the driver name is\r | |
54 | returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r | |
55 | by This does not support the language specified by Language,\r | |
56 | then EFI_UNSUPPORTED is returned.\r | |
57 | \r | |
58 | @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r | |
59 | EFI_COMPONENT_NAME_PROTOCOL instance.\r | |
60 | \r | |
61 | @param Language[in] A pointer to a Null-terminated ASCII string\r | |
62 | array indicating the language. This is the\r | |
63 | language of the driver name that the caller is\r | |
64 | requesting, and it must match one of the\r | |
65 | languages specified in SupportedLanguages. The\r | |
66 | number of languages supported by a driver is up\r | |
67 | to the driver writer. Language is specified\r | |
0254efc0 | 68 | in RFC 4646 or ISO 639-2 language code format.\r |
f527bce3 | 69 | \r |
70 | @param DriverName[out] A pointer to the Unicode string to return.\r | |
71 | This Unicode string is the name of the\r | |
72 | driver specified by This in the language\r | |
73 | specified by Language.\r | |
74 | \r | |
75 | @retval EFI_SUCCESS The Unicode string for the Driver specified by\r | |
76 | This and the language specified by Language was\r | |
77 | returned in DriverName.\r | |
78 | \r | |
79 | @retval EFI_INVALID_PARAMETER Language is NULL.\r | |
80 | \r | |
81 | @retval EFI_INVALID_PARAMETER DriverName is NULL.\r | |
82 | \r | |
83 | @retval EFI_UNSUPPORTED The driver specified by This does not support\r | |
84 | the language specified by Language.\r | |
85 | \r | |
86 | **/\r | |
913cb9dc | 87 | EFI_STATUS\r |
88 | EFIAPI\r | |
89 | UhciComponentNameGetDriverName (\r | |
f527bce3 | 90 | IN EFI_COMPONENT_NAME_PROTOCOL *This,\r |
91 | IN CHAR8 *Language,\r | |
92 | OUT CHAR16 **DriverName\r | |
913cb9dc | 93 | )\r |
913cb9dc | 94 | {\r |
f527bce3 | 95 | return LookupUnicodeString2 (\r |
96 | Language,\r | |
97 | This->SupportedLanguages,\r | |
98 | mUhciDriverNameTable,\r | |
99 | DriverName,\r | |
100 | (BOOLEAN)(This == &gUhciComponentName)\r | |
101 | );\r | |
913cb9dc | 102 | }\r |
103 | \r | |
f527bce3 | 104 | /**\r |
105 | Retrieves a Unicode string that is the user readable name of the controller\r | |
106 | that is being managed by a driver.\r | |
107 | \r | |
108 | This function retrieves the user readable name of the controller specified by\r | |
109 | ControllerHandle and ChildHandle in the form of a Unicode string. If the\r | |
110 | driver specified by This has a user readable name in the language specified by\r | |
111 | Language, then a pointer to the controller name is returned in ControllerName,\r | |
112 | and EFI_SUCCESS is returned. If the driver specified by This is not currently\r | |
113 | managing the controller specified by ControllerHandle and ChildHandle,\r | |
114 | then EFI_UNSUPPORTED is returned. If the driver specified by This does not\r | |
115 | support the language specified by Language, then EFI_UNSUPPORTED is returned.\r | |
116 | \r | |
117 | @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r | |
118 | EFI_COMPONENT_NAME_PROTOCOL instance.\r | |
119 | \r | |
120 | @param ControllerHandle[in] The handle of a controller that the driver\r | |
121 | specified by This is managing. This handle\r | |
122 | specifies the controller whose name is to be\r | |
123 | returned.\r | |
124 | \r | |
125 | @param ChildHandle[in] The handle of the child controller to retrieve\r | |
126 | the name of. This is an optional parameter that\r | |
127 | may be NULL. It will be NULL for device\r | |
128 | drivers. It will also be NULL for a bus drivers\r | |
129 | that wish to retrieve the name of the bus\r | |
130 | controller. It will not be NULL for a bus\r | |
131 | driver that wishes to retrieve the name of a\r | |
132 | child controller.\r | |
133 | \r | |
134 | @param Language[in] A pointer to a Null-terminated ASCII string\r | |
135 | array indicating the language. This is the\r | |
136 | language of the driver name that the caller is\r | |
137 | requesting, and it must match one of the\r | |
138 | languages specified in SupportedLanguages. The\r | |
139 | number of languages supported by a driver is up\r | |
140 | to the driver writer. Language is specified in\r | |
0254efc0 | 141 | RFC 4646 or ISO 639-2 language code format.\r |
f527bce3 | 142 | \r |
143 | @param ControllerName[out] A pointer to the Unicode string to return.\r | |
144 | This Unicode string is the name of the\r | |
145 | controller specified by ControllerHandle and\r | |
146 | ChildHandle in the language specified by\r | |
147 | Language from the point of view of the driver\r | |
148 | specified by This.\r | |
149 | \r | |
150 | @retval EFI_SUCCESS The Unicode string for the user readable name in\r | |
151 | the language specified by Language for the\r | |
152 | driver specified by This was returned in\r | |
153 | DriverName.\r | |
154 | \r | |
284ee2e8 | 155 | @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r |
f527bce3 | 156 | \r |
157 | @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r | |
158 | EFI_HANDLE.\r | |
159 | \r | |
160 | @retval EFI_INVALID_PARAMETER Language is NULL.\r | |
161 | \r | |
162 | @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r | |
163 | \r | |
164 | @retval EFI_UNSUPPORTED The driver specified by This is not currently\r | |
165 | managing the controller specified by\r | |
166 | ControllerHandle and ChildHandle.\r | |
167 | \r | |
168 | @retval EFI_UNSUPPORTED The driver specified by This does not support\r | |
169 | the language specified by Language.\r | |
170 | \r | |
171 | **/\r | |
913cb9dc | 172 | EFI_STATUS\r |
173 | EFIAPI\r | |
174 | UhciComponentNameGetControllerName (\r | |
f527bce3 | 175 | IN EFI_COMPONENT_NAME_PROTOCOL *This,\r |
176 | IN EFI_HANDLE ControllerHandle,\r | |
177 | IN EFI_HANDLE ChildHandle OPTIONAL,\r | |
178 | IN CHAR8 *Language,\r | |
179 | OUT CHAR16 **ControllerName\r | |
913cb9dc | 180 | )\r |
913cb9dc | 181 | {\r |
ea5632e5 | 182 | EFI_STATUS Status;\r |
183 | USB_HC_DEV *UhciDev;\r | |
184 | EFI_USB2_HC_PROTOCOL *Usb2Hc;\r | |
913cb9dc | 185 | \r |
186 | //\r | |
187 | // This is a device driver, so ChildHandle must be NULL.\r | |
188 | //\r | |
189 | if (ChildHandle != NULL) {\r | |
190 | return EFI_UNSUPPORTED;\r | |
191 | }\r | |
192 | \r | |
193 | //\r | |
194 | // Make sure this driver is currently managing ControllerHandle\r | |
195 | //\r | |
196 | Status = EfiTestManagedDevice (\r | |
197 | ControllerHandle,\r | |
198 | gUhciDriverBinding.DriverBindingHandle,\r | |
199 | &gEfiPciIoProtocolGuid\r | |
200 | );\r | |
201 | if (EFI_ERROR (Status)) {\r | |
202 | return Status;\r | |
203 | }\r | |
204 | \r | |
205 | //\r | |
206 | // Get the device context\r | |
207 | //\r | |
208 | Status = gBS->OpenProtocol (\r | |
209 | ControllerHandle,\r | |
ea5632e5 | 210 | &gEfiUsb2HcProtocolGuid,\r |
211 | (VOID **) &Usb2Hc,\r | |
913cb9dc | 212 | gUhciDriverBinding.DriverBindingHandle,\r |
213 | ControllerHandle,\r | |
214 | EFI_OPEN_PROTOCOL_GET_PROTOCOL\r | |
215 | );\r | |
216 | \r | |
217 | if (EFI_ERROR (Status)) {\r | |
218 | return Status;\r | |
219 | }\r | |
220 | \r | |
ea5632e5 | 221 | UhciDev = UHC_FROM_USB2_HC_PROTO (Usb2Hc);\r |
913cb9dc | 222 | \r |
f527bce3 | 223 | return LookupUnicodeString2 (\r |
224 | Language,\r | |
225 | This->SupportedLanguages,\r | |
226 | UhciDev->CtrlNameTable,\r | |
227 | ControllerName,\r | |
228 | (BOOLEAN)(This == &gUhciComponentName)\r | |
229 | );\r | |
913cb9dc | 230 | \r |
231 | }\r |