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