From f527bce3d07ff80c7fff9684b2c7cdc02805c32e Mon Sep 17 00:00:00 2001 From: qhuang8 Date: Sun, 30 Sep 2007 02:42:47 +0000 Subject: [PATCH] Update to support to produce Component Name and & Component Name 2 protocol based on Feature flag PcdComponentNameDisable & PcdComponentName2Disable. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@4000 6f19259b-4bc3-4df7-8a09-765794883524 --- .../Bus/Pci/AtapiPassThruDxe/AtapiPassThru.c | 5 +- .../Bus/Pci/AtapiPassThruDxe/AtapiPassThru.h | 114 +++++- .../Bus/Pci/AtapiPassThruDxe/ComponentName.c | 191 +++++---- MdeModulePkg/Bus/Pci/EhciDxe/ComponentName.c | 361 +++++++++++++----- MdeModulePkg/Bus/Pci/EhciDxe/Ehci.c | 18 +- MdeModulePkg/Bus/Pci/EhciDxe/Ehci.h | 5 +- MdeModulePkg/Bus/Pci/UhciDxe/ComponentName.c | 361 +++++++++++++----- MdeModulePkg/Bus/Pci/UhciDxe/Uhci.c | 18 +- MdeModulePkg/Bus/Pci/UhciDxe/Uhci.h | 5 +- 9 files changed, 787 insertions(+), 291 deletions(-) diff --git a/MdeModulePkg/Bus/Pci/AtapiPassThruDxe/AtapiPassThru.c b/MdeModulePkg/Bus/Pci/AtapiPassThruDxe/AtapiPassThru.c index b6dceeb83a..fc0b8efbbc 100644 --- a/MdeModulePkg/Bus/Pci/AtapiPassThruDxe/AtapiPassThru.c +++ b/MdeModulePkg/Bus/Pci/AtapiPassThruDxe/AtapiPassThru.c @@ -2393,14 +2393,13 @@ InitializeAtapiPassThru( // // Install driver model protocol(s). // - Status = EfiLibInstallAllDriverProtocols ( + Status = EfiLibInstallDriverBindingComponentName2 ( ImageHandle, SystemTable, &gAtapiScsiPassThruDriverBinding, ImageHandle, &gAtapiScsiPassThruComponentName, - NULL, - NULL + &gAtapiScsiPassThruComponentName2 ); ASSERT_EFI_ERROR (Status); diff --git a/MdeModulePkg/Bus/Pci/AtapiPassThruDxe/AtapiPassThru.h b/MdeModulePkg/Bus/Pci/AtapiPassThruDxe/AtapiPassThru.h index 0cb169786a..ac1db971d7 100644 --- a/MdeModulePkg/Bus/Pci/AtapiPassThruDxe/AtapiPassThru.h +++ b/MdeModulePkg/Bus/Pci/AtapiPassThruDxe/AtapiPassThru.h @@ -131,8 +131,9 @@ typedef struct { // // Global Variables // -extern EFI_DRIVER_BINDING_PROTOCOL gAtapiScsiPassThruDriverBinding; -extern EFI_COMPONENT_NAME_PROTOCOL gAtapiScsiPassThruComponentName; +extern EFI_DRIVER_BINDING_PROTOCOL gAtapiScsiPassThruDriverBinding; +extern EFI_COMPONENT_NAME_PROTOCOL gAtapiScsiPassThruComponentName; +extern EFI_COMPONENT_NAME2_PROTOCOL gAtapiScsiPassThruComponentName2; // // ATAPI Command op code @@ -301,6 +302,45 @@ AtapiScsiPassThruDriverBindingStop ( // // EFI Component Name Functions // +/** + Retrieves a Unicode string that is the user readable name of the driver. + + This function retrieves the user readable name of a driver in the form of a + Unicode string. If the driver specified by This has a user readable name in + the language specified by Language, then a pointer to the driver name is + returned in DriverName, and EFI_SUCCESS is returned. If the driver specified + by This does not support the language specified by Language, + then EFI_UNSUPPORTED is returned. + + @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or + EFI_COMPONENT_NAME_PROTOCOL instance. + + @param Language[in] A pointer to a Null-terminated ASCII string + array indicating the language. This is the + language of the driver name that the caller is + requesting, and it must match one of the + languages specified in SupportedLanguages. The + number of languages supported by a driver is up + to the driver writer. Language is specified + in RFC 3066 or ISO 639-2 language code format. + + @param DriverName[out] A pointer to the Unicode string to return. + This Unicode string is the name of the + driver specified by This in the language + specified by Language. + + @retval EFI_SUCCESS The Unicode string for the Driver specified by + This and the language specified by Language was + returned in DriverName. + + @retval EFI_INVALID_PARAMETER Language is NULL. + + @retval EFI_INVALID_PARAMETER DriverName is NULL. + + @retval EFI_UNSUPPORTED The driver specified by This does not support + the language specified by Language. + +**/ EFI_STATUS EFIAPI AtapiScsiPassThruComponentNameGetDriverName ( @@ -309,6 +349,75 @@ AtapiScsiPassThruComponentNameGetDriverName ( OUT CHAR16 **DriverName ); + +/** + Retrieves a Unicode string that is the user readable name of the controller + that is being managed by a driver. + + This function retrieves the user readable name of the controller specified by + ControllerHandle and ChildHandle in the form of a Unicode string. If the + driver specified by This has a user readable name in the language specified by + Language, then a pointer to the controller name is returned in ControllerName, + and EFI_SUCCESS is returned. If the driver specified by This is not currently + managing the controller specified by ControllerHandle and ChildHandle, + then EFI_UNSUPPORTED is returned. If the driver specified by This does not + support the language specified by Language, then EFI_UNSUPPORTED is returned. + + @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or + EFI_COMPONENT_NAME_PROTOCOL instance. + + @param ControllerHandle[in] The handle of a controller that the driver + specified by This is managing. This handle + specifies the controller whose name is to be + returned. + + @param ChildHandle[in] The handle of the child controller to retrieve + the name of. This is an optional parameter that + may be NULL. It will be NULL for device + drivers. It will also be NULL for a bus drivers + that wish to retrieve the name of the bus + controller. It will not be NULL for a bus + driver that wishes to retrieve the name of a + child controller. + + @param Language[in] A pointer to a Null-terminated ASCII string + array indicating the language. This is the + language of the driver name that the caller is + requesting, and it must match one of the + languages specified in SupportedLanguages. The + number of languages supported by a driver is up + to the driver writer. Language is specified in + RFC 3066 or ISO 639-2 language code format. + + @param ControllerName[out] A pointer to the Unicode string to return. + This Unicode string is the name of the + controller specified by ControllerHandle and + ChildHandle in the language specified by + Language from the point of view of the driver + specified by This. + + @retval EFI_SUCCESS The Unicode string for the user readable name in + the language specified by Language for the + driver specified by This was returned in + DriverName. + + @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE. + + @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid + EFI_HANDLE. + + @retval EFI_INVALID_PARAMETER Language is NULL. + + @retval EFI_INVALID_PARAMETER ControllerName is NULL. + + @retval EFI_UNSUPPORTED The driver specified by This is not currently + managing the controller specified by + ControllerHandle and ChildHandle. + + @retval EFI_UNSUPPORTED The driver specified by This does not support + the language specified by Language. + +**/ EFI_STATUS EFIAPI AtapiScsiPassThruComponentNameGetControllerName ( @@ -319,6 +428,7 @@ AtapiScsiPassThruComponentNameGetControllerName ( OUT CHAR16 **ControllerName ); + /** AtapiScsiPassThruDriverEntryPoint diff --git a/MdeModulePkg/Bus/Pci/AtapiPassThruDxe/ComponentName.c b/MdeModulePkg/Bus/Pci/AtapiPassThruDxe/ComponentName.c index 1731571069..940b037bf2 100644 --- a/MdeModulePkg/Bus/Pci/AtapiPassThruDxe/ComponentName.c +++ b/MdeModulePkg/Bus/Pci/AtapiPassThruDxe/ComponentName.c @@ -13,40 +13,67 @@ **/ #include "AtapiPassThru.h" -/// -/// EFI Component Name Protocol -/// -EFI_COMPONENT_NAME_PROTOCOL gAtapiScsiPassThruComponentName = { +// +// EFI Component Name Protocol +// +EFI_COMPONENT_NAME_PROTOCOL gAtapiScsiPassThruComponentName = { AtapiScsiPassThruComponentNameGetDriverName, AtapiScsiPassThruComponentNameGetControllerName, "eng" -}; + }; + +// +// EFI Component Name 2 Protocol +// +EFI_COMPONENT_NAME2_PROTOCOL gAtapiScsiPassThruComponentName2 = { + (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) AtapiScsiPassThruComponentNameGetDriverName, + (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) AtapiScsiPassThruComponentNameGetControllerName, + "en" + }; + static EFI_UNICODE_STRING_TABLE mAtapiScsiPassThruDriverNameTable[] = { - { "eng", (CHAR16 *) L"ATAPI SCSI Pass Thru Driver" }, + { "eng;en", (CHAR16 *) L"ATAPI SCSI Pass Thru Driver" }, { NULL , NULL } }; /** - Retrieves a Unicode string that is the user readable name of the EFI Driver. - - @param This A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance. - @param Language A pointer to a three character ISO 639-2 language identifier. - This is the language of the driver name that that the caller - is requesting, and it must match one of the languages specified - in SupportedLanguages. The number of languages supported by a - driver is up to the driver writer. - @param DriverName A pointer to the Unicode string to return. This Unicode string - is the name of the driver specified by This in the language - specified by Language. - - @retval EFI_SUCCESS The Unicode string for the Driver specified by This - and the language specified by Language was returned - in DriverName. - @retval EFI_INVALID_PARAMETER Language is NULL. - @retval EFI_INVALID_PARAMETER DriverName is NULL. - @retval EFI_UNSUPPORTED The driver specified by This does not support the - language specified by Language. + Retrieves a Unicode string that is the user readable name of the driver. + + This function retrieves the user readable name of a driver in the form of a + Unicode string. If the driver specified by This has a user readable name in + the language specified by Language, then a pointer to the driver name is + returned in DriverName, and EFI_SUCCESS is returned. If the driver specified + by This does not support the language specified by Language, + then EFI_UNSUPPORTED is returned. + + @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or + EFI_COMPONENT_NAME_PROTOCOL instance. + + @param Language[in] A pointer to a Null-terminated ASCII string + array indicating the language. This is the + language of the driver name that the caller is + requesting, and it must match one of the + languages specified in SupportedLanguages. The + number of languages supported by a driver is up + to the driver writer. Language is specified + in RFC 3066 or ISO 639-2 language code format. + + @param DriverName[out] A pointer to the Unicode string to return. + This Unicode string is the name of the + driver specified by This in the language + specified by Language. + + @retval EFI_SUCCESS The Unicode string for the Driver specified by + This and the language specified by Language was + returned in DriverName. + + @retval EFI_INVALID_PARAMETER Language is NULL. + + @retval EFI_INVALID_PARAMETER DriverName is NULL. + + @retval EFI_UNSUPPORTED The driver specified by This does not support + the language specified by Language. **/ EFI_STATUS @@ -57,53 +84,81 @@ AtapiScsiPassThruComponentNameGetDriverName ( OUT CHAR16 **DriverName ) { - return LookupUnicodeString ( - Language, - gAtapiScsiPassThruComponentName.SupportedLanguages, - mAtapiScsiPassThruDriverNameTable, - DriverName - ); + return LookupUnicodeString2 ( + Language, + This->SupportedLanguages, + mAtapiScsiPassThruDriverNameTable, + DriverName, + (BOOLEAN)(This == &gAtapiScsiPassThruComponentName) + ); } /** Retrieves a Unicode string that is the user readable name of the controller - that is being managed by an EFI Driver. - - @param This A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance. - @param ControllerHandle The handle of a controller that the driver specified by - This is managing. This handle specifies the controller - whose name is to be returned. - @param ChildHandle The handle of the child controller to retrieve the name - of. This is an optional parameter that may be NULL. It - will be NULL for device drivers. It will also be NULL - for a bus drivers that wish to retrieve the name of the - bus controller. It will not be NULL for a bus driver - that wishes to retrieve the name of a child controller. - @param Language A pointer to a three character ISO 639-2 language - identifier. This is the language of the controller name - that that the caller is requesting, and it must match one - of the languages specified in SupportedLanguages. The - number of languages supported by a driver is up to the - driver writer. - @param ControllerName A pointer to the Unicode string to return. This Unicode - string is the name of the controller specified by - ControllerHandle and ChildHandle in the language - specified by Language from the point of view of the - driver specified by This. - - @retval EFI_SUCCESS The Unicode string for the user readable name in the - language specified by Language for the driver - specified by This was returned in DriverName. - @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE. - @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid - EFI_HANDLE. - @retval EFI_INVALID_PARAMETER Language is NULL. - @retval EFI_INVALID_PARAMETER ControllerName is NULL. - @retval EFI_UNSUPPORTED The driver specified by This is not currently - managing the controller specified by - ControllerHandle and ChildHandle. - @retval EFI_UNSUPPORTED The driver specified by This does not support the - language specified by Language. + that is being managed by a driver. + + This function retrieves the user readable name of the controller specified by + ControllerHandle and ChildHandle in the form of a Unicode string. If the + driver specified by This has a user readable name in the language specified by + Language, then a pointer to the controller name is returned in ControllerName, + and EFI_SUCCESS is returned. If the driver specified by This is not currently + managing the controller specified by ControllerHandle and ChildHandle, + then EFI_UNSUPPORTED is returned. If the driver specified by This does not + support the language specified by Language, then EFI_UNSUPPORTED is returned. + + @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or + EFI_COMPONENT_NAME_PROTOCOL instance. + + @param ControllerHandle[in] The handle of a controller that the driver + specified by This is managing. This handle + specifies the controller whose name is to be + returned. + + @param ChildHandle[in] The handle of the child controller to retrieve + the name of. This is an optional parameter that + may be NULL. It will be NULL for device + drivers. It will also be NULL for a bus drivers + that wish to retrieve the name of the bus + controller. It will not be NULL for a bus + driver that wishes to retrieve the name of a + child controller. + + @param Language[in] A pointer to a Null-terminated ASCII string + array indicating the language. This is the + language of the driver name that the caller is + requesting, and it must match one of the + languages specified in SupportedLanguages. The + number of languages supported by a driver is up + to the driver writer. Language is specified in + RFC 3066 or ISO 639-2 language code format. + + @param ControllerName[out] A pointer to the Unicode string to return. + This Unicode string is the name of the + controller specified by ControllerHandle and + ChildHandle in the language specified by + Language from the point of view of the driver + specified by This. + + @retval EFI_SUCCESS The Unicode string for the user readable name in + the language specified by Language for the + driver specified by This was returned in + DriverName. + + @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE. + + @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid + EFI_HANDLE. + + @retval EFI_INVALID_PARAMETER Language is NULL. + + @retval EFI_INVALID_PARAMETER ControllerName is NULL. + + @retval EFI_UNSUPPORTED The driver specified by This is not currently + managing the controller specified by + ControllerHandle and ChildHandle. + + @retval EFI_UNSUPPORTED The driver specified by This does not support + the language specified by Language. **/ EFI_STATUS diff --git a/MdeModulePkg/Bus/Pci/EhciDxe/ComponentName.c b/MdeModulePkg/Bus/Pci/EhciDxe/ComponentName.c index 86029036f8..8d533bbf91 100644 --- a/MdeModulePkg/Bus/Pci/EhciDxe/ComponentName.c +++ b/MdeModulePkg/Bus/Pci/EhciDxe/ComponentName.c @@ -25,134 +25,290 @@ Abstract: // // EFI Component Name Functions // +/** + Retrieves a Unicode string that is the user readable name of the driver. + + This function retrieves the user readable name of a driver in the form of a + Unicode string. If the driver specified by This has a user readable name in + the language specified by Language, then a pointer to the driver name is + returned in DriverName, and EFI_SUCCESS is returned. If the driver specified + by This does not support the language specified by Language, + then EFI_UNSUPPORTED is returned. + + @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or + EFI_COMPONENT_NAME_PROTOCOL instance. + + @param Language[in] A pointer to a Null-terminated ASCII string + array indicating the language. This is the + language of the driver name that the caller is + requesting, and it must match one of the + languages specified in SupportedLanguages. The + number of languages supported by a driver is up + to the driver writer. Language is specified + in RFC 3066 or ISO 639-2 language code format. + + @param DriverName[out] A pointer to the Unicode string to return. + This Unicode string is the name of the + driver specified by This in the language + specified by Language. + + @retval EFI_SUCCESS The Unicode string for the Driver specified by + This and the language specified by Language was + returned in DriverName. + + @retval EFI_INVALID_PARAMETER Language is NULL. + + @retval EFI_INVALID_PARAMETER DriverName is NULL. + + @retval EFI_UNSUPPORTED The driver specified by This does not support + the language specified by Language. + +**/ EFI_STATUS EFIAPI EhciComponentNameGetDriverName ( - IN EFI_COMPONENT_NAME_PROTOCOL *This, - IN CHAR8 *Language, - OUT CHAR16 **DriverName + IN EFI_COMPONENT_NAME_PROTOCOL *This, + IN CHAR8 *Language, + OUT CHAR16 **DriverName ); + +/** + Retrieves a Unicode string that is the user readable name of the controller + that is being managed by a driver. + + This function retrieves the user readable name of the controller specified by + ControllerHandle and ChildHandle in the form of a Unicode string. If the + driver specified by This has a user readable name in the language specified by + Language, then a pointer to the controller name is returned in ControllerName, + and EFI_SUCCESS is returned. If the driver specified by This is not currently + managing the controller specified by ControllerHandle and ChildHandle, + then EFI_UNSUPPORTED is returned. If the driver specified by This does not + support the language specified by Language, then EFI_UNSUPPORTED is returned. + + @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or + EFI_COMPONENT_NAME_PROTOCOL instance. + + @param ControllerHandle[in] The handle of a controller that the driver + specified by This is managing. This handle + specifies the controller whose name is to be + returned. + + @param ChildHandle[in] The handle of the child controller to retrieve + the name of. This is an optional parameter that + may be NULL. It will be NULL for device + drivers. It will also be NULL for a bus drivers + that wish to retrieve the name of the bus + controller. It will not be NULL for a bus + driver that wishes to retrieve the name of a + child controller. + + @param Language[in] A pointer to a Null-terminated ASCII string + array indicating the language. This is the + language of the driver name that the caller is + requesting, and it must match one of the + languages specified in SupportedLanguages. The + number of languages supported by a driver is up + to the driver writer. Language is specified in + RFC 3066 or ISO 639-2 language code format. + + @param ControllerName[out] A pointer to the Unicode string to return. + This Unicode string is the name of the + controller specified by ControllerHandle and + ChildHandle in the language specified by + Language from the point of view of the driver + specified by This. + + @retval EFI_SUCCESS The Unicode string for the user readable name in + the language specified by Language for the + driver specified by This was returned in + DriverName. + + @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE. + + @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid + EFI_HANDLE. + + @retval EFI_INVALID_PARAMETER Language is NULL. + + @retval EFI_INVALID_PARAMETER ControllerName is NULL. + + @retval EFI_UNSUPPORTED The driver specified by This is not currently + managing the controller specified by + ControllerHandle and ChildHandle. + + @retval EFI_UNSUPPORTED The driver specified by This does not support + the language specified by Language. + +**/ EFI_STATUS EFIAPI EhciComponentNameGetControllerName ( - IN EFI_COMPONENT_NAME_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN EFI_HANDLE ChildHandle, OPTIONAL - IN CHAR8 *Language, - OUT CHAR16 **ControllerName + IN EFI_COMPONENT_NAME_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN EFI_HANDLE ChildHandle OPTIONAL, + IN CHAR8 *Language, + OUT CHAR16 **ControllerName ); + // // EFI Component Name Protocol // -EFI_COMPONENT_NAME_PROTOCOL gEhciComponentName = { +EFI_COMPONENT_NAME_PROTOCOL gEhciComponentName = { EhciComponentNameGetDriverName, EhciComponentNameGetControllerName, "eng" -}; + }; + +// +// EFI Component Name 2 Protocol +// +EFI_COMPONENT_NAME2_PROTOCOL gEhciComponentName2 = { + (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) EhciComponentNameGetDriverName, + (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) EhciComponentNameGetControllerName, + "en" + }; + static EFI_UNICODE_STRING_TABLE mEhciDriverNameTable[] = { - { "eng", L"Usb Ehci Driver" }, + { "eng;en", L"Usb Ehci Driver" }, { NULL , NULL } }; +/** + Retrieves a Unicode string that is the user readable name of the driver. + + This function retrieves the user readable name of a driver in the form of a + Unicode string. If the driver specified by This has a user readable name in + the language specified by Language, then a pointer to the driver name is + returned in DriverName, and EFI_SUCCESS is returned. If the driver specified + by This does not support the language specified by Language, + then EFI_UNSUPPORTED is returned. + + @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or + EFI_COMPONENT_NAME_PROTOCOL instance. + + @param Language[in] A pointer to a Null-terminated ASCII string + array indicating the language. This is the + language of the driver name that the caller is + requesting, and it must match one of the + languages specified in SupportedLanguages. The + number of languages supported by a driver is up + to the driver writer. Language is specified + in RFC 3066 or ISO 639-2 language code format. + + @param DriverName[out] A pointer to the Unicode string to return. + This Unicode string is the name of the + driver specified by This in the language + specified by Language. + + @retval EFI_SUCCESS The Unicode string for the Driver specified by + This and the language specified by Language was + returned in DriverName. + + @retval EFI_INVALID_PARAMETER Language is NULL. + + @retval EFI_INVALID_PARAMETER DriverName is NULL. + + @retval EFI_UNSUPPORTED The driver specified by This does not support + the language specified by Language. + +**/ EFI_STATUS EFIAPI EhciComponentNameGetDriverName ( - IN EFI_COMPONENT_NAME_PROTOCOL *This, - IN CHAR8 *Language, - OUT CHAR16 **DriverName + IN EFI_COMPONENT_NAME_PROTOCOL *This, + IN CHAR8 *Language, + OUT CHAR16 **DriverName ) -/*++ - - Routine Description: - Retrieves a Unicode string that is the user readable name of the EFI Driver. - - Arguments: - This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance. - Language - A pointer to a three character ISO 639-2 language identifier. - This is the language of the driver name that that the caller - is requesting, and it must match one of the languages specified - in SupportedLanguages. The number of languages supported by a - driver is up to the driver writer. - DriverName - A pointer to the Unicode string to return. This Unicode string - is the name of the driver specified by This in the language - specified by Language. - - Returns: - EFI_SUCCESS - The Unicode string for the Driver specified by This - and the language specified by Language was returned - in DriverName. - EFI_INVALID_PARAMETER - Language is NULL. - EFI_INVALID_PARAMETER - DriverName is NULL. - EFI_UNSUPPORTED - The driver specified by This does not support the - language specified by Language. - ---*/ { - return LookupUnicodeString ( - Language, - gEhciComponentName.SupportedLanguages, - mEhciDriverNameTable, - DriverName - ); + return LookupUnicodeString2 ( + Language, + This->SupportedLanguages, + mEhciDriverNameTable, + DriverName, + (BOOLEAN)(This == &gEhciComponentName) + ); } +/** + Retrieves a Unicode string that is the user readable name of the controller + that is being managed by a driver. + + This function retrieves the user readable name of the controller specified by + ControllerHandle and ChildHandle in the form of a Unicode string. If the + driver specified by This has a user readable name in the language specified by + Language, then a pointer to the controller name is returned in ControllerName, + and EFI_SUCCESS is returned. If the driver specified by This is not currently + managing the controller specified by ControllerHandle and ChildHandle, + then EFI_UNSUPPORTED is returned. If the driver specified by This does not + support the language specified by Language, then EFI_UNSUPPORTED is returned. + + @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or + EFI_COMPONENT_NAME_PROTOCOL instance. + + @param ControllerHandle[in] The handle of a controller that the driver + specified by This is managing. This handle + specifies the controller whose name is to be + returned. + + @param ChildHandle[in] The handle of the child controller to retrieve + the name of. This is an optional parameter that + may be NULL. It will be NULL for device + drivers. It will also be NULL for a bus drivers + that wish to retrieve the name of the bus + controller. It will not be NULL for a bus + driver that wishes to retrieve the name of a + child controller. + + @param Language[in] A pointer to a Null-terminated ASCII string + array indicating the language. This is the + language of the driver name that the caller is + requesting, and it must match one of the + languages specified in SupportedLanguages. The + number of languages supported by a driver is up + to the driver writer. Language is specified in + RFC 3066 or ISO 639-2 language code format. + + @param ControllerName[out] A pointer to the Unicode string to return. + This Unicode string is the name of the + controller specified by ControllerHandle and + ChildHandle in the language specified by + Language from the point of view of the driver + specified by This. + + @retval EFI_SUCCESS The Unicode string for the user readable name in + the language specified by Language for the + driver specified by This was returned in + DriverName. + + @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE. + + @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid + EFI_HANDLE. + + @retval EFI_INVALID_PARAMETER Language is NULL. + + @retval EFI_INVALID_PARAMETER ControllerName is NULL. + + @retval EFI_UNSUPPORTED The driver specified by This is not currently + managing the controller specified by + ControllerHandle and ChildHandle. + + @retval EFI_UNSUPPORTED The driver specified by This does not support + the language specified by Language. + +**/ EFI_STATUS EFIAPI EhciComponentNameGetControllerName ( - IN EFI_COMPONENT_NAME_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN EFI_HANDLE ChildHandle, OPTIONAL - IN CHAR8 *Language, - OUT CHAR16 **ControllerName + IN EFI_COMPONENT_NAME_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN EFI_HANDLE ChildHandle OPTIONAL, + IN CHAR8 *Language, + OUT CHAR16 **ControllerName ) -/*++ - - Routine Description: - Retrieves a Unicode string that is the user readable name of the controller - that is being managed by an EFI Driver. - - Arguments: - This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance. - ControllerHandle - The handle of a controller that the driver specified by - This is managing. This handle specifies the controller - whose name is to be returned. - ChildHandle - The handle of the child controller to retrieve the name - of. This is an optional parameter that may be NULL. It - will be NULL for device drivers. It will also be NULL - for a bus drivers that wish to retrieve the name of the - bus controller. It will not be NULL for a bus driver - that wishes to retrieve the name of a child controller. - Language - A pointer to a three character ISO 639-2 language - identifier. This is the language of the controller name - that that the caller is requesting, and it must match one - of the languages specified in SupportedLanguages. The - number of languages supported by a driver is up to the - driver writer. - ControllerName - A pointer to the Unicode string to return. This Unicode - string is the name of the controller specified by - ControllerHandle and ChildHandle in the language - specified by Language from the point of view of the - driver specified by This. - - Returns: - EFI_SUCCESS - The Unicode string for the user readable name in the - language specified by Language for the driver - specified by This was returned in DriverName. - EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE. - EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid - EFI_HANDLE. - EFI_INVALID_PARAMETER - Language is NULL. - EFI_INVALID_PARAMETER - ControllerName is NULL. - EFI_UNSUPPORTED - The driver specified by This is not currently - managing the controller specified by - ControllerHandle and ChildHandle. - EFI_UNSUPPORTED - The driver specified by This does not support the - language specified by Language. - ---*/ { EFI_STATUS Status; USB2_HC_DEV *EhciDev; @@ -192,11 +348,12 @@ EhciComponentNameGetControllerName ( EhciDev = EHC_FROM_THIS (Usb2Hc); - return LookupUnicodeString ( - Language, - gEhciComponentName.SupportedLanguages, - EhciDev->ControllerNameTable, - ControllerName - ); + return LookupUnicodeString2 ( + Language, + This->SupportedLanguages, + EhciDev->ControllerNameTable, + ControllerName, + (BOOLEAN)(This == &gEhciComponentName) + ); } diff --git a/MdeModulePkg/Bus/Pci/EhciDxe/Ehci.c b/MdeModulePkg/Bus/Pci/EhciDxe/Ehci.c index 0eaa9cce5d..13ce7fdfb1 100644 --- a/MdeModulePkg/Bus/Pci/EhciDxe/Ehci.c +++ b/MdeModulePkg/Bus/Pci/EhciDxe/Ehci.c @@ -1295,14 +1295,13 @@ Returns: --*/ { - return EfiLibInstallAllDriverProtocols ( + return EfiLibInstallDriverBindingComponentName2 ( ImageHandle, SystemTable, &gEhciDriverBinding, ImageHandle, &gEhciComponentName, - NULL, - NULL + &gEhciComponentName2 ); } @@ -1565,13 +1564,22 @@ EhcDriverBindingStart ( // Install the component name protocol, don't fail the start // because of something for display. // - AddUnicodeString ( + AddUnicodeString2 ( "eng", gEhciComponentName.SupportedLanguages, &Ehc->ControllerNameTable, - L"Enhanced Host Controller (USB 2.0)" + L"Enhanced Host Controller (USB 2.0)", + TRUE + ); + AddUnicodeString2 ( + "en", + gEhciComponentName2.SupportedLanguages, + &Ehc->ControllerNameTable, + L"Enhanced Host Controller (USB 2.0)", + FALSE ); + EHC_DEBUG (("EhcDriverBindingStart: EHCI started for controller @ %x\n", Controller)); return EFI_SUCCESS; diff --git a/MdeModulePkg/Bus/Pci/EhciDxe/Ehci.h b/MdeModulePkg/Bus/Pci/EhciDxe/Ehci.h index 2398b15667..7eb61be05a 100644 --- a/MdeModulePkg/Bus/Pci/EhciDxe/Ehci.h +++ b/MdeModulePkg/Bus/Pci/EhciDxe/Ehci.h @@ -140,7 +140,8 @@ struct _USB2_HC_DEV { }; -extern EFI_DRIVER_BINDING_PROTOCOL gEhciDriverBinding; -extern EFI_COMPONENT_NAME_PROTOCOL gEhciComponentName; +extern EFI_DRIVER_BINDING_PROTOCOL gEhciDriverBinding; +extern EFI_COMPONENT_NAME_PROTOCOL gEhciComponentName; +extern EFI_COMPONENT_NAME2_PROTOCOL gEhciComponentName2; #endif diff --git a/MdeModulePkg/Bus/Pci/UhciDxe/ComponentName.c b/MdeModulePkg/Bus/Pci/UhciDxe/ComponentName.c index d1cb1eb121..bd2c3465f8 100644 --- a/MdeModulePkg/Bus/Pci/UhciDxe/ComponentName.c +++ b/MdeModulePkg/Bus/Pci/UhciDxe/ComponentName.c @@ -23,134 +23,290 @@ Abstract: // // EFI Component Name Functions // +/** + Retrieves a Unicode string that is the user readable name of the driver. + + This function retrieves the user readable name of a driver in the form of a + Unicode string. If the driver specified by This has a user readable name in + the language specified by Language, then a pointer to the driver name is + returned in DriverName, and EFI_SUCCESS is returned. If the driver specified + by This does not support the language specified by Language, + then EFI_UNSUPPORTED is returned. + + @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or + EFI_COMPONENT_NAME_PROTOCOL instance. + + @param Language[in] A pointer to a Null-terminated ASCII string + array indicating the language. This is the + language of the driver name that the caller is + requesting, and it must match one of the + languages specified in SupportedLanguages. The + number of languages supported by a driver is up + to the driver writer. Language is specified + in RFC 3066 or ISO 639-2 language code format. + + @param DriverName[out] A pointer to the Unicode string to return. + This Unicode string is the name of the + driver specified by This in the language + specified by Language. + + @retval EFI_SUCCESS The Unicode string for the Driver specified by + This and the language specified by Language was + returned in DriverName. + + @retval EFI_INVALID_PARAMETER Language is NULL. + + @retval EFI_INVALID_PARAMETER DriverName is NULL. + + @retval EFI_UNSUPPORTED The driver specified by This does not support + the language specified by Language. + +**/ EFI_STATUS EFIAPI UhciComponentNameGetDriverName ( - IN EFI_COMPONENT_NAME_PROTOCOL *This, - IN CHAR8 *Language, - OUT CHAR16 **DriverName + IN EFI_COMPONENT_NAME_PROTOCOL *This, + IN CHAR8 *Language, + OUT CHAR16 **DriverName ); + +/** + Retrieves a Unicode string that is the user readable name of the controller + that is being managed by a driver. + + This function retrieves the user readable name of the controller specified by + ControllerHandle and ChildHandle in the form of a Unicode string. If the + driver specified by This has a user readable name in the language specified by + Language, then a pointer to the controller name is returned in ControllerName, + and EFI_SUCCESS is returned. If the driver specified by This is not currently + managing the controller specified by ControllerHandle and ChildHandle, + then EFI_UNSUPPORTED is returned. If the driver specified by This does not + support the language specified by Language, then EFI_UNSUPPORTED is returned. + + @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or + EFI_COMPONENT_NAME_PROTOCOL instance. + + @param ControllerHandle[in] The handle of a controller that the driver + specified by This is managing. This handle + specifies the controller whose name is to be + returned. + + @param ChildHandle[in] The handle of the child controller to retrieve + the name of. This is an optional parameter that + may be NULL. It will be NULL for device + drivers. It will also be NULL for a bus drivers + that wish to retrieve the name of the bus + controller. It will not be NULL for a bus + driver that wishes to retrieve the name of a + child controller. + + @param Language[in] A pointer to a Null-terminated ASCII string + array indicating the language. This is the + language of the driver name that the caller is + requesting, and it must match one of the + languages specified in SupportedLanguages. The + number of languages supported by a driver is up + to the driver writer. Language is specified in + RFC 3066 or ISO 639-2 language code format. + + @param ControllerName[out] A pointer to the Unicode string to return. + This Unicode string is the name of the + controller specified by ControllerHandle and + ChildHandle in the language specified by + Language from the point of view of the driver + specified by This. + + @retval EFI_SUCCESS The Unicode string for the user readable name in + the language specified by Language for the + driver specified by This was returned in + DriverName. + + @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE. + + @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid + EFI_HANDLE. + + @retval EFI_INVALID_PARAMETER Language is NULL. + + @retval EFI_INVALID_PARAMETER ControllerName is NULL. + + @retval EFI_UNSUPPORTED The driver specified by This is not currently + managing the controller specified by + ControllerHandle and ChildHandle. + + @retval EFI_UNSUPPORTED The driver specified by This does not support + the language specified by Language. + +**/ EFI_STATUS EFIAPI UhciComponentNameGetControllerName ( - IN EFI_COMPONENT_NAME_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN EFI_HANDLE ChildHandle, OPTIONAL - IN CHAR8 *Language, - OUT CHAR16 **ControllerName + IN EFI_COMPONENT_NAME_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN EFI_HANDLE ChildHandle OPTIONAL, + IN CHAR8 *Language, + OUT CHAR16 **ControllerName ); + // // EFI Component Name Protocol // -EFI_COMPONENT_NAME_PROTOCOL gUhciComponentName = { +EFI_COMPONENT_NAME_PROTOCOL gUhciComponentName = { UhciComponentNameGetDriverName, UhciComponentNameGetControllerName, "eng" -}; + }; + +// +// EFI Component Name 2 Protocol +// +EFI_COMPONENT_NAME2_PROTOCOL gUhciComponentName2 = { + (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) UhciComponentNameGetDriverName, + (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) UhciComponentNameGetControllerName, + "en" + }; + static EFI_UNICODE_STRING_TABLE mUhciDriverNameTable[] = { - { "eng", L"Usb Uhci Driver" }, + { "eng;en", L"Usb Uhci Driver" }, { NULL, NULL } }; +/** + Retrieves a Unicode string that is the user readable name of the driver. + + This function retrieves the user readable name of a driver in the form of a + Unicode string. If the driver specified by This has a user readable name in + the language specified by Language, then a pointer to the driver name is + returned in DriverName, and EFI_SUCCESS is returned. If the driver specified + by This does not support the language specified by Language, + then EFI_UNSUPPORTED is returned. + + @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or + EFI_COMPONENT_NAME_PROTOCOL instance. + + @param Language[in] A pointer to a Null-terminated ASCII string + array indicating the language. This is the + language of the driver name that the caller is + requesting, and it must match one of the + languages specified in SupportedLanguages. The + number of languages supported by a driver is up + to the driver writer. Language is specified + in RFC 3066 or ISO 639-2 language code format. + + @param DriverName[out] A pointer to the Unicode string to return. + This Unicode string is the name of the + driver specified by This in the language + specified by Language. + + @retval EFI_SUCCESS The Unicode string for the Driver specified by + This and the language specified by Language was + returned in DriverName. + + @retval EFI_INVALID_PARAMETER Language is NULL. + + @retval EFI_INVALID_PARAMETER DriverName is NULL. + + @retval EFI_UNSUPPORTED The driver specified by This does not support + the language specified by Language. + +**/ EFI_STATUS EFIAPI UhciComponentNameGetDriverName ( - IN EFI_COMPONENT_NAME_PROTOCOL *This, - IN CHAR8 *Language, - OUT CHAR16 **DriverName + IN EFI_COMPONENT_NAME_PROTOCOL *This, + IN CHAR8 *Language, + OUT CHAR16 **DriverName ) -/*++ - - Routine Description: - Retrieves a Unicode string that is the user readable name of the EFI Driver. - - Arguments: - This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance. - Language - A pointer to a three character ISO 639-2 language identifier. - This is the language of the driver name that that the caller - is requesting, and it must match one of the languages specified - in SupportedLanguages. The number of languages supported by a - driver is up to the driver writer. - DriverName - A pointer to the Unicode string to return. This Unicode string - is the name of the driver specified by This in the language - specified by Language. - - Returns: - EFI_SUCCESS - The Unicode string for the Driver specified by This - and the language specified by Language was returned - in DriverName. - EFI_INVALID_PARAMETER - Language is NULL. - EFI_INVALID_PARAMETER - DriverName is NULL. - EFI_UNSUPPORTED - The driver specified by This does not support the - language specified by Language. - ---*/ { - return LookupUnicodeString ( - Language, - gUhciComponentName.SupportedLanguages, - mUhciDriverNameTable, - DriverName - ); + return LookupUnicodeString2 ( + Language, + This->SupportedLanguages, + mUhciDriverNameTable, + DriverName, + (BOOLEAN)(This == &gUhciComponentName) + ); } +/** + Retrieves a Unicode string that is the user readable name of the controller + that is being managed by a driver. + + This function retrieves the user readable name of the controller specified by + ControllerHandle and ChildHandle in the form of a Unicode string. If the + driver specified by This has a user readable name in the language specified by + Language, then a pointer to the controller name is returned in ControllerName, + and EFI_SUCCESS is returned. If the driver specified by This is not currently + managing the controller specified by ControllerHandle and ChildHandle, + then EFI_UNSUPPORTED is returned. If the driver specified by This does not + support the language specified by Language, then EFI_UNSUPPORTED is returned. + + @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or + EFI_COMPONENT_NAME_PROTOCOL instance. + + @param ControllerHandle[in] The handle of a controller that the driver + specified by This is managing. This handle + specifies the controller whose name is to be + returned. + + @param ChildHandle[in] The handle of the child controller to retrieve + the name of. This is an optional parameter that + may be NULL. It will be NULL for device + drivers. It will also be NULL for a bus drivers + that wish to retrieve the name of the bus + controller. It will not be NULL for a bus + driver that wishes to retrieve the name of a + child controller. + + @param Language[in] A pointer to a Null-terminated ASCII string + array indicating the language. This is the + language of the driver name that the caller is + requesting, and it must match one of the + languages specified in SupportedLanguages. The + number of languages supported by a driver is up + to the driver writer. Language is specified in + RFC 3066 or ISO 639-2 language code format. + + @param ControllerName[out] A pointer to the Unicode string to return. + This Unicode string is the name of the + controller specified by ControllerHandle and + ChildHandle in the language specified by + Language from the point of view of the driver + specified by This. + + @retval EFI_SUCCESS The Unicode string for the user readable name in + the language specified by Language for the + driver specified by This was returned in + DriverName. + + @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE. + + @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid + EFI_HANDLE. + + @retval EFI_INVALID_PARAMETER Language is NULL. + + @retval EFI_INVALID_PARAMETER ControllerName is NULL. + + @retval EFI_UNSUPPORTED The driver specified by This is not currently + managing the controller specified by + ControllerHandle and ChildHandle. + + @retval EFI_UNSUPPORTED The driver specified by This does not support + the language specified by Language. + +**/ EFI_STATUS EFIAPI UhciComponentNameGetControllerName ( - IN EFI_COMPONENT_NAME_PROTOCOL *This, - IN EFI_HANDLE ControllerHandle, - IN EFI_HANDLE ChildHandle, OPTIONAL - IN CHAR8 *Language, - OUT CHAR16 **ControllerName + IN EFI_COMPONENT_NAME_PROTOCOL *This, + IN EFI_HANDLE ControllerHandle, + IN EFI_HANDLE ChildHandle OPTIONAL, + IN CHAR8 *Language, + OUT CHAR16 **ControllerName ) -/*++ - - Routine Description: - Retrieves a Unicode string that is the user readable name of the controller - that is being managed by an EFI Driver. - - Arguments: - This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance. - ControllerHandle - The handle of a controller that the driver specified by - This is managing. This handle specifies the controller - whose name is to be returned. - ChildHandle - The handle of the child controller to retrieve the name - of. This is an optional parameter that may be NULL. It - will be NULL for device drivers. It will also be NULL - for a bus drivers that wish to retrieve the name of the - bus controller. It will not be NULL for a bus driver - that wishes to retrieve the name of a child controller. - Language - A pointer to a three character ISO 639-2 language - identifier. This is the language of the controller name - that that the caller is requesting, and it must match one - of the languages specified in SupportedLanguages. The - number of languages supported by a driver is up to the - driver writer. - ControllerName - A pointer to the Unicode string to return. This Unicode - string is the name of the controller specified by - ControllerHandle and ChildHandle in the language - specified by Language from the point of view of the - driver specified by This. - - Returns: - EFI_SUCCESS - The Unicode string for the user readable name in the - language specified by Language for the driver - specified by This was returned in DriverName. - EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE. - EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid - EFI_HANDLE. - EFI_INVALID_PARAMETER - Language is NULL. - EFI_INVALID_PARAMETER - ControllerName is NULL. - EFI_UNSUPPORTED - The driver specified by This is not currently - managing the controller specified by - ControllerHandle and ChildHandle. - EFI_UNSUPPORTED - The driver specified by This does not support the - language specified by Language. - ---*/ { EFI_STATUS Status; USB_HC_DEV *UhciDev; @@ -193,11 +349,12 @@ UhciComponentNameGetControllerName ( UhciDev = UHC_FROM_USB_HC_PROTO (UsbHc); - return LookupUnicodeString ( - Language, - gUhciComponentName.SupportedLanguages, - UhciDev->CtrlNameTable, - ControllerName - ); + return LookupUnicodeString2 ( + Language, + This->SupportedLanguages, + UhciDev->CtrlNameTable, + ControllerName, + (BOOLEAN)(This == &gUhciComponentName) + ); } diff --git a/MdeModulePkg/Bus/Pci/UhciDxe/Uhci.c b/MdeModulePkg/Bus/Pci/UhciDxe/Uhci.c index 28d9b63d9d..1dee976504 100644 --- a/MdeModulePkg/Bus/Pci/UhciDxe/Uhci.c +++ b/MdeModulePkg/Bus/Pci/UhciDxe/Uhci.c @@ -1852,14 +1852,13 @@ UhciDriverEntryPoint ( --*/ { - return EfiLibInstallAllDriverProtocols ( + return EfiLibInstallDriverBindingComponentName2 ( ImageHandle, SystemTable, &gUhciDriverBinding, ImageHandle, &gUhciComponentName, - NULL, - NULL + &gUhciComponentName2 ); } @@ -2217,12 +2216,21 @@ UhciDriverBindingStart ( // Uhc->CtrlNameTable = NULL; - AddUnicodeString ( + AddUnicodeString2 ( "eng", gUhciComponentName.SupportedLanguages, &Uhc->CtrlNameTable, - L"Usb Universal Host Controller" + L"Usb Universal Host Controller", + TRUE ); + AddUnicodeString2 ( + "en", + gUhciComponentName2.SupportedLanguages, + &Uhc->CtrlNameTable, + L"Usb Universal Host Controller", + FALSE + ); + // // Start the UHCI hardware, also set its reclamation point to 64 bytes diff --git a/MdeModulePkg/Bus/Pci/UhciDxe/Uhci.h b/MdeModulePkg/Bus/Pci/UhciDxe/Uhci.h index 27d7497b87..3f2540faf7 100644 --- a/MdeModulePkg/Bus/Pci/UhciDxe/Uhci.h +++ b/MdeModulePkg/Bus/Pci/UhciDxe/Uhci.h @@ -128,7 +128,8 @@ struct _USB_HC_DEV { VOID *FrameMapping; }; -extern EFI_DRIVER_BINDING_PROTOCOL gUhciDriverBinding; -extern EFI_COMPONENT_NAME_PROTOCOL gUhciComponentName; +extern EFI_DRIVER_BINDING_PROTOCOL gUhciDriverBinding; +extern EFI_COMPONENT_NAME_PROTOCOL gUhciComponentName; +extern EFI_COMPONENT_NAME2_PROTOCOL gUhciComponentName2; #endif -- 2.39.2