X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=MdeModulePkg%2FUniversal%2FNetwork%2FSnpDxe%2FComponentName.c;fp=MdeModulePkg%2FUniversal%2FNetwork%2FSnpDxe%2FComponentName.c;h=ef499d18cf6578b96d83e58636ca72edad72dfc8;hp=e8f7ec18bc03ee50a53f7aef784cb9a2ce63d478;hb=216f79703b8cb8dc65abdd768bedb2bcdbc1a1f8;hpb=906e1cb7f7f178f5cb2a3bebbac59f6aa8c273a4 diff --git a/MdeModulePkg/Universal/Network/SnpDxe/ComponentName.c b/MdeModulePkg/Universal/Network/SnpDxe/ComponentName.c index e8f7ec18bc..ef499d18cf 100644 --- a/MdeModulePkg/Universal/Network/SnpDxe/ComponentName.c +++ b/MdeModulePkg/Universal/Network/SnpDxe/ComponentName.c @@ -1,7 +1,7 @@ /** @file UEFI Component Name(2) protocol implementation for SnpDxe driver. -Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2012, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -175,6 +175,8 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mSimpleNetworkDriverNameT } }; +GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE *gSimpleNetworkControllerNameTable = NULL; + /** Retrieves a Unicode string that is the user readable name of the driver. @@ -231,6 +233,78 @@ SimpleNetworkComponentNameGetDriverName ( ); } +/** + Update the component name for the Snp child handle. + + @param Snp[in] A pointer to the EFI_SIMPLE_NETWORK_PROTOCOL. + + + @retval EFI_SUCCESS Update the ControllerNameTable of this instance successfully. + @retval EFI_INVALID_PARAMETER The input parameter is invalid. + +**/ +EFI_STATUS +UpdateName ( + IN EFI_SIMPLE_NETWORK_PROTOCOL *Snp + ) +{ + EFI_STATUS Status; + CHAR16 HandleName[80]; + UINTN OffSet; + UINTN Index; + + if (Snp == NULL) { + return EFI_INVALID_PARAMETER; + } + + OffSet = 0; + OffSet += UnicodeSPrint ( + HandleName, + sizeof (HandleName), + L"SNP (MAC=" + ); + for (Index = 0; Index < Snp->Mode->HwAddressSize; Index++) { + OffSet += UnicodeSPrint ( + HandleName + OffSet, + sizeof (HandleName) - OffSet, + L"%02X-", + Snp->Mode->CurrentAddress.Addr[Index] + ); + } + // + // Remove the last '-' + // + OffSet--; + OffSet += UnicodeSPrint ( + HandleName, + sizeof (HandleName), + L")" + ); + if (gSimpleNetworkControllerNameTable != NULL) { + FreeUnicodeStringTable (gSimpleNetworkControllerNameTable); + gSimpleNetworkControllerNameTable = NULL; + } + + Status = AddUnicodeString2 ( + "eng", + gSimpleNetworkComponentName.SupportedLanguages, + &gSimpleNetworkControllerNameTable, + HandleName, + TRUE + ); + if (EFI_ERROR (Status)) { + return Status; + } + + return AddUnicodeString2 ( + "en", + gSimpleNetworkComponentName2.SupportedLanguages, + &gSimpleNetworkControllerNameTable, + HandleName, + FALSE + ); +} + /** Retrieves a Unicode string that is the user readable name of the controller that is being managed by a driver. @@ -310,5 +384,52 @@ SimpleNetworkComponentNameGetControllerName ( OUT CHAR16 **ControllerName ) { - return EFI_UNSUPPORTED; + EFI_STATUS Status; + EFI_SIMPLE_NETWORK_PROTOCOL *Snp; + + if (ChildHandle != NULL) { + return EFI_UNSUPPORTED; + } + + // + // Make sure this driver is currently managing ControllHandle + // + Status = EfiTestManagedDevice ( + ControllerHandle, + gSimpleNetworkDriverBinding.DriverBindingHandle, + &gEfiSimpleNetworkProtocolGuid + ); + if (EFI_ERROR (Status)) { + return Status; + } + + // + // Retrieve an instance of a produced protocol from ControllerHandle + // + Status = gBS->OpenProtocol ( + ControllerHandle, + &gEfiSimpleNetworkProtocolGuid, + (VOID **)&Snp, + NULL, + NULL, + EFI_OPEN_PROTOCOL_GET_PROTOCOL + ); + if (EFI_ERROR (Status)) { + return Status; + } + // + // Update the component name for this child handle. + // + Status = UpdateName (Snp); + if (EFI_ERROR (Status)) { + return Status; + } + + return LookupUnicodeString2 ( + Language, + This->SupportedLanguages, + gSimpleNetworkControllerNameTable, + ControllerName, + (BOOLEAN)(This == &gSimpleNetworkComponentName) + ); }