| 1 | /** @file\r |
| 2 | \r |
| 3 | Copyright (c) 2006 - 2007, Intel Corporation \r |
| 4 | \r |
| 5 | All rights reserved. This program and the accompanying materials\r |
| 6 | are licensed and made available under the terms and conditions\r |
| 7 | of the BSD License which accompanies this distribution. The\r |
| 8 | full text of the license may be found at\r |
| 9 | http://opensource.org/licenses/bsd-license.php\r |
| 10 | \r |
| 11 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r |
| 12 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r |
| 13 | \r |
| 14 | Module Name:\r |
| 15 | \r |
| 16 | ComponentName.c\r |
| 17 | \r |
| 18 | Abstract:\r |
| 19 | \r |
| 20 | \r |
| 21 | **/\r |
| 22 | \r |
| 23 | #include "Ehci.h"\r |
| 24 | \r |
| 25 | //\r |
| 26 | // EFI Component Name Functions\r |
| 27 | //\r |
| 28 | /**\r |
| 29 | Retrieves a Unicode string that is the user readable name of the driver.\r |
| 30 | \r |
| 31 | This function retrieves the user readable name of a driver in the form of a\r |
| 32 | Unicode string. If the driver specified by This has a user readable name in\r |
| 33 | the language specified by Language, then a pointer to the driver name is\r |
| 34 | returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r |
| 35 | by This does not support the language specified by Language,\r |
| 36 | then EFI_UNSUPPORTED is returned.\r |
| 37 | \r |
| 38 | @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r |
| 39 | EFI_COMPONENT_NAME_PROTOCOL instance.\r |
| 40 | \r |
| 41 | @param Language[in] A pointer to a Null-terminated ASCII string\r |
| 42 | array indicating the language. This is the\r |
| 43 | language of the driver name that the caller is\r |
| 44 | requesting, and it must match one of the\r |
| 45 | languages specified in SupportedLanguages. The\r |
| 46 | number of languages supported by a driver is up\r |
| 47 | to the driver writer. Language is specified\r |
| 48 | in RFC 3066 or ISO 639-2 language code format.\r |
| 49 | \r |
| 50 | @param DriverName[out] A pointer to the Unicode string to return.\r |
| 51 | This Unicode string is the name of the\r |
| 52 | driver specified by This in the language\r |
| 53 | specified by Language.\r |
| 54 | \r |
| 55 | @retval EFI_SUCCESS The Unicode string for the Driver specified by\r |
| 56 | This and the language specified by Language was\r |
| 57 | returned in DriverName.\r |
| 58 | \r |
| 59 | @retval EFI_INVALID_PARAMETER Language is NULL.\r |
| 60 | \r |
| 61 | @retval EFI_INVALID_PARAMETER DriverName is NULL.\r |
| 62 | \r |
| 63 | @retval EFI_UNSUPPORTED The driver specified by This does not support\r |
| 64 | the language specified by Language.\r |
| 65 | \r |
| 66 | **/\r |
| 67 | EFI_STATUS\r |
| 68 | EFIAPI\r |
| 69 | EhciComponentNameGetDriverName (\r |
| 70 | IN EFI_COMPONENT_NAME_PROTOCOL *This,\r |
| 71 | IN CHAR8 *Language,\r |
| 72 | OUT CHAR16 **DriverName\r |
| 73 | );\r |
| 74 | \r |
| 75 | \r |
| 76 | /**\r |
| 77 | Retrieves a Unicode string that is the user readable name of the controller\r |
| 78 | that is being managed by a driver.\r |
| 79 | \r |
| 80 | This function retrieves the user readable name of the controller specified by\r |
| 81 | ControllerHandle and ChildHandle in the form of a Unicode string. If the\r |
| 82 | driver specified by This has a user readable name in the language specified by\r |
| 83 | Language, then a pointer to the controller name is returned in ControllerName,\r |
| 84 | and EFI_SUCCESS is returned. If the driver specified by This is not currently\r |
| 85 | managing the controller specified by ControllerHandle and ChildHandle,\r |
| 86 | then EFI_UNSUPPORTED is returned. If the driver specified by This does not\r |
| 87 | support the language specified by Language, then EFI_UNSUPPORTED is returned.\r |
| 88 | \r |
| 89 | @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r |
| 90 | EFI_COMPONENT_NAME_PROTOCOL instance.\r |
| 91 | \r |
| 92 | @param ControllerHandle[in] The handle of a controller that the driver\r |
| 93 | specified by This is managing. This handle\r |
| 94 | specifies the controller whose name is to be\r |
| 95 | returned.\r |
| 96 | \r |
| 97 | @param ChildHandle[in] The handle of the child controller to retrieve\r |
| 98 | the name of. This is an optional parameter that\r |
| 99 | may be NULL. It will be NULL for device\r |
| 100 | drivers. It will also be NULL for a bus drivers\r |
| 101 | that wish to retrieve the name of the bus\r |
| 102 | controller. It will not be NULL for a bus\r |
| 103 | driver that wishes to retrieve the name of a\r |
| 104 | child controller.\r |
| 105 | \r |
| 106 | @param Language[in] A pointer to a Null-terminated ASCII string\r |
| 107 | array indicating the language. This is the\r |
| 108 | language of the driver name that the caller is\r |
| 109 | requesting, and it must match one of the\r |
| 110 | languages specified in SupportedLanguages. The\r |
| 111 | number of languages supported by a driver is up\r |
| 112 | to the driver writer. Language is specified in\r |
| 113 | RFC 3066 or ISO 639-2 language code format.\r |
| 114 | \r |
| 115 | @param ControllerName[out] A pointer to the Unicode string to return.\r |
| 116 | This Unicode string is the name of the\r |
| 117 | controller specified by ControllerHandle and\r |
| 118 | ChildHandle in the language specified by\r |
| 119 | Language from the point of view of the driver\r |
| 120 | specified by This.\r |
| 121 | \r |
| 122 | @retval EFI_SUCCESS The Unicode string for the user readable name in\r |
| 123 | the language specified by Language for the\r |
| 124 | driver specified by This was returned in\r |
| 125 | DriverName.\r |
| 126 | \r |
| 127 | @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.\r |
| 128 | \r |
| 129 | @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r |
| 130 | EFI_HANDLE.\r |
| 131 | \r |
| 132 | @retval EFI_INVALID_PARAMETER Language is NULL.\r |
| 133 | \r |
| 134 | @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r |
| 135 | \r |
| 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 |
| 139 | \r |
| 140 | @retval EFI_UNSUPPORTED The driver specified by This does not support\r |
| 141 | the language specified by Language.\r |
| 142 | \r |
| 143 | **/\r |
| 144 | EFI_STATUS\r |
| 145 | EFIAPI\r |
| 146 | EhciComponentNameGetControllerName (\r |
| 147 | IN EFI_COMPONENT_NAME_PROTOCOL *This,\r |
| 148 | IN EFI_HANDLE ControllerHandle,\r |
| 149 | IN EFI_HANDLE ChildHandle OPTIONAL,\r |
| 150 | IN CHAR8 *Language,\r |
| 151 | OUT CHAR16 **ControllerName\r |
| 152 | );\r |
| 153 | \r |
| 154 | \r |
| 155 | //\r |
| 156 | // EFI Component Name Protocol\r |
| 157 | //\r |
| 158 | EFI_COMPONENT_NAME_PROTOCOL gEhciComponentName = {\r |
| 159 | EhciComponentNameGetDriverName,\r |
| 160 | EhciComponentNameGetControllerName,\r |
| 161 | "eng"\r |
| 162 | };\r |
| 163 | \r |
| 164 | //\r |
| 165 | // EFI Component Name 2 Protocol\r |
| 166 | //\r |
| 167 | EFI_COMPONENT_NAME2_PROTOCOL gEhciComponentName2 = {\r |
| 168 | (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) EhciComponentNameGetDriverName,\r |
| 169 | (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) EhciComponentNameGetControllerName,\r |
| 170 | "en"\r |
| 171 | };\r |
| 172 | \r |
| 173 | \r |
| 174 | static EFI_UNICODE_STRING_TABLE mEhciDriverNameTable[] = {\r |
| 175 | { "eng;en", L"Usb Ehci Driver" },\r |
| 176 | { NULL , NULL }\r |
| 177 | };\r |
| 178 | \r |
| 179 | /**\r |
| 180 | Retrieves a Unicode string that is the user readable name of the driver.\r |
| 181 | \r |
| 182 | This function retrieves the user readable name of a driver in the form of a\r |
| 183 | Unicode string. If the driver specified by This has a user readable name in\r |
| 184 | the language specified by Language, then a pointer to the driver name is\r |
| 185 | returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r |
| 186 | by This does not support the language specified by Language,\r |
| 187 | then EFI_UNSUPPORTED is returned.\r |
| 188 | \r |
| 189 | @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r |
| 190 | EFI_COMPONENT_NAME_PROTOCOL instance.\r |
| 191 | \r |
| 192 | @param Language[in] A pointer to a Null-terminated ASCII string\r |
| 193 | array indicating the language. This is the\r |
| 194 | language of the driver name that the caller is\r |
| 195 | requesting, and it must match one of the\r |
| 196 | languages specified in SupportedLanguages. The\r |
| 197 | number of languages supported by a driver is up\r |
| 198 | to the driver writer. Language is specified\r |
| 199 | in RFC 3066 or ISO 639-2 language code format.\r |
| 200 | \r |
| 201 | @param DriverName[out] A pointer to the Unicode string to return.\r |
| 202 | This Unicode string is the name of the\r |
| 203 | driver specified by This in the language\r |
| 204 | specified by Language.\r |
| 205 | \r |
| 206 | @retval EFI_SUCCESS The Unicode string for the Driver specified by\r |
| 207 | This and the language specified by Language was\r |
| 208 | returned in DriverName.\r |
| 209 | \r |
| 210 | @retval EFI_INVALID_PARAMETER Language is NULL.\r |
| 211 | \r |
| 212 | @retval EFI_INVALID_PARAMETER DriverName is NULL.\r |
| 213 | \r |
| 214 | @retval EFI_UNSUPPORTED The driver specified by This does not support\r |
| 215 | the language specified by Language.\r |
| 216 | \r |
| 217 | **/\r |
| 218 | EFI_STATUS\r |
| 219 | EFIAPI\r |
| 220 | EhciComponentNameGetDriverName (\r |
| 221 | IN EFI_COMPONENT_NAME_PROTOCOL *This,\r |
| 222 | IN CHAR8 *Language,\r |
| 223 | OUT CHAR16 **DriverName\r |
| 224 | )\r |
| 225 | {\r |
| 226 | return LookupUnicodeString2 (\r |
| 227 | Language,\r |
| 228 | This->SupportedLanguages,\r |
| 229 | mEhciDriverNameTable,\r |
| 230 | DriverName,\r |
| 231 | (BOOLEAN)(This == &gEhciComponentName)\r |
| 232 | );\r |
| 233 | }\r |
| 234 | \r |
| 235 | /**\r |
| 236 | Retrieves a Unicode string that is the user readable name of the controller\r |
| 237 | that is being managed by a driver.\r |
| 238 | \r |
| 239 | This function retrieves the user readable name of the controller specified by\r |
| 240 | ControllerHandle and ChildHandle in the form of a Unicode string. If the\r |
| 241 | driver specified by This has a user readable name in the language specified by\r |
| 242 | Language, then a pointer to the controller name is returned in ControllerName,\r |
| 243 | and EFI_SUCCESS is returned. If the driver specified by This is not currently\r |
| 244 | managing the controller specified by ControllerHandle and ChildHandle,\r |
| 245 | then EFI_UNSUPPORTED is returned. If the driver specified by This does not\r |
| 246 | support the language specified by Language, then EFI_UNSUPPORTED is returned.\r |
| 247 | \r |
| 248 | @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r |
| 249 | EFI_COMPONENT_NAME_PROTOCOL instance.\r |
| 250 | \r |
| 251 | @param ControllerHandle[in] The handle of a controller that the driver\r |
| 252 | specified by This is managing. This handle\r |
| 253 | specifies the controller whose name is to be\r |
| 254 | returned.\r |
| 255 | \r |
| 256 | @param ChildHandle[in] The handle of the child controller to retrieve\r |
| 257 | the name of. This is an optional parameter that\r |
| 258 | may be NULL. It will be NULL for device\r |
| 259 | drivers. It will also be NULL for a bus drivers\r |
| 260 | that wish to retrieve the name of the bus\r |
| 261 | controller. It will not be NULL for a bus\r |
| 262 | driver that wishes to retrieve the name of a\r |
| 263 | child controller.\r |
| 264 | \r |
| 265 | @param Language[in] A pointer to a Null-terminated ASCII string\r |
| 266 | array indicating the language. This is the\r |
| 267 | language of the driver name that the caller is\r |
| 268 | requesting, and it must match one of the\r |
| 269 | languages specified in SupportedLanguages. The\r |
| 270 | number of languages supported by a driver is up\r |
| 271 | to the driver writer. Language is specified in\r |
| 272 | RFC 3066 or ISO 639-2 language code format.\r |
| 273 | \r |
| 274 | @param ControllerName[out] A pointer to the Unicode string to return.\r |
| 275 | This Unicode string is the name of the\r |
| 276 | controller specified by ControllerHandle and\r |
| 277 | ChildHandle in the language specified by\r |
| 278 | Language from the point of view of the driver\r |
| 279 | specified by This.\r |
| 280 | \r |
| 281 | @retval EFI_SUCCESS The Unicode string for the user readable name in\r |
| 282 | the language specified by Language for the\r |
| 283 | driver specified by This was returned in\r |
| 284 | DriverName.\r |
| 285 | \r |
| 286 | @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.\r |
| 287 | \r |
| 288 | @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r |
| 289 | EFI_HANDLE.\r |
| 290 | \r |
| 291 | @retval EFI_INVALID_PARAMETER Language is NULL.\r |
| 292 | \r |
| 293 | @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r |
| 294 | \r |
| 295 | @retval EFI_UNSUPPORTED The driver specified by This is not currently\r |
| 296 | managing the controller specified by\r |
| 297 | ControllerHandle and ChildHandle.\r |
| 298 | \r |
| 299 | @retval EFI_UNSUPPORTED The driver specified by This does not support\r |
| 300 | the language specified by Language.\r |
| 301 | \r |
| 302 | **/\r |
| 303 | EFI_STATUS\r |
| 304 | EFIAPI\r |
| 305 | EhciComponentNameGetControllerName (\r |
| 306 | IN EFI_COMPONENT_NAME_PROTOCOL *This,\r |
| 307 | IN EFI_HANDLE ControllerHandle,\r |
| 308 | IN EFI_HANDLE ChildHandle OPTIONAL,\r |
| 309 | IN CHAR8 *Language,\r |
| 310 | OUT CHAR16 **ControllerName\r |
| 311 | )\r |
| 312 | {\r |
| 313 | EFI_STATUS Status;\r |
| 314 | USB2_HC_DEV *EhciDev;\r |
| 315 | EFI_USB2_HC_PROTOCOL *Usb2Hc;\r |
| 316 | \r |
| 317 | //\r |
| 318 | // This is a device driver, so ChildHandle must be NULL.\r |
| 319 | //\r |
| 320 | if (ChildHandle != NULL) {\r |
| 321 | return EFI_UNSUPPORTED;\r |
| 322 | }\r |
| 323 | //\r |
| 324 | // Make sure this driver is currently managing ControllerHandle\r |
| 325 | //\r |
| 326 | Status = EfiTestManagedDevice (\r |
| 327 | ControllerHandle,\r |
| 328 | gEhciDriverBinding.DriverBindingHandle,\r |
| 329 | &gEfiPciIoProtocolGuid\r |
| 330 | );\r |
| 331 | if (EFI_ERROR (Status)) {\r |
| 332 | return Status;\r |
| 333 | }\r |
| 334 | //\r |
| 335 | // Get the device context\r |
| 336 | //\r |
| 337 | Status = gBS->OpenProtocol (\r |
| 338 | ControllerHandle,\r |
| 339 | &gEfiUsb2HcProtocolGuid,\r |
| 340 | (VOID **) &Usb2Hc,\r |
| 341 | gEhciDriverBinding.DriverBindingHandle,\r |
| 342 | ControllerHandle,\r |
| 343 | EFI_OPEN_PROTOCOL_GET_PROTOCOL\r |
| 344 | );\r |
| 345 | if (EFI_ERROR (Status)) {\r |
| 346 | return Status;\r |
| 347 | }\r |
| 348 | \r |
| 349 | EhciDev = EHC_FROM_THIS (Usb2Hc);\r |
| 350 | \r |
| 351 | return LookupUnicodeString2 (\r |
| 352 | Language,\r |
| 353 | This->SupportedLanguages,\r |
| 354 | EhciDev->ControllerNameTable,\r |
| 355 | ControllerName,\r |
| 356 | (BOOLEAN)(This == &gEhciComponentName)\r |
| 357 | );\r |
| 358 | \r |
| 359 | }\r |