]> git.proxmox.com Git - mirror_edk2.git/blobdiff - NetworkPkg/UefiPxeBcDxe/ComponentName.c
SecurityPkg: SecureBootConfigDxe: Updated invocation pattern
[mirror_edk2.git] / NetworkPkg / UefiPxeBcDxe / ComponentName.c
index 4228519d18b29feac1638686abdef07315675e4e..07b8f7d42fff648787439508748c3a5357b16b3b 100644 (file)
@@ -1,15 +1,9 @@
 /** @file\r
   UEFI Component Name(2) protocol implementation for UefiPxeBc driver.\r
 \r
-  Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
 \r
-  This program and the accompanying materials\r
-  are licensed and made available under the terms and conditions of the BSD License\r
-  which accompanies this distribution.  The full text of the license may be found at\r
-  http://opensource.org/licenses/bsd-license.php.\r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+  SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 \r
@@ -62,7 +56,6 @@ PxeBcComponentNameGetDriverName (
   OUT CHAR16                       **DriverName\r
   );\r
 \r
-\r
 /**\r
   Retrieves a Unicode string that is the user-readable name of the controller\r
   that is being managed by a driver.\r
@@ -114,7 +107,7 @@ PxeBcComponentNameGetDriverName (
                                 driver specified by This was returned in\r
                                 DriverName.\r
 \r
-  @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.\r
+  @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
 \r
   @retval EFI_INVALID_PARAMETER ChildHandle is not NULL, and it is not a valid\r
                                 EFI_HANDLE.\r
@@ -141,11 +134,10 @@ PxeBcComponentNameGetControllerName (
   OUT CHAR16                       **ControllerName\r
   );\r
 \r
-\r
 //\r
 // EFI Component Name Protocol\r
 //\r
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL    gPxeBcComponentName  = {\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL  gPxeBcComponentName = {\r
   PxeBcComponentNameGetDriverName,\r
   PxeBcComponentNameGetControllerName,\r
   "eng"\r
@@ -154,13 +146,13 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL    gPxeBcComponentName
 //\r
 // EFI Component Name 2 Protocol\r
 //\r
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL   gPxeBcComponentName2 = {\r
-  (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) PxeBcComponentNameGetDriverName,\r
-  (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) PxeBcComponentNameGetControllerName,\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL  gPxeBcComponentName2 = {\r
+  (EFI_COMPONENT_NAME2_GET_DRIVER_NAME)PxeBcComponentNameGetDriverName,\r
+  (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)PxeBcComponentNameGetControllerName,\r
   "en"\r
 };\r
 \r
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE       mPxeBcDriverNameTable[] = {\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE  mPxeBcDriverNameTable[] = {\r
   {\r
     "eng;en",\r
     L"UEFI PXE Base Code Driver"\r
@@ -171,6 +163,16 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE       mPxeBcDriverNameTab
   }\r
 };\r
 \r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE  mPxeBcControllerNameTable[] = {\r
+  {\r
+    "eng;en",\r
+    L"PXE Controller"\r
+  },\r
+  {\r
+    NULL,\r
+    NULL\r
+  }\r
+};\r
 \r
 /**\r
   Retrieves a Unicode string that is the user-readable name of the driver.\r
@@ -219,7 +221,7 @@ PxeBcComponentNameGetDriverName (
   OUT CHAR16                       **DriverName\r
   )\r
 {\r
-  return LookupUnicodeString2(\r
+  return LookupUnicodeString2 (\r
            Language,\r
            This->SupportedLanguages,\r
            mPxeBcDriverNameTable,\r
@@ -228,7 +230,6 @@ PxeBcComponentNameGetDriverName (
            );\r
 }\r
 \r
-\r
 /**\r
   Retrieves a Unicode string that is the user-readable name of the controller\r
   that is being managed by a driver.\r
@@ -280,7 +281,7 @@ PxeBcComponentNameGetDriverName (
                                 driver specified by This was returned in\r
                                 DriverName.\r
 \r
-  @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.\r
+  @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
 \r
   @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
                                 EFI_HANDLE.\r
@@ -307,6 +308,42 @@ PxeBcComponentNameGetControllerName (
   OUT CHAR16                       **ControllerName\r
   )\r
 {\r
-  return EFI_UNSUPPORTED;\r
-}\r
+  EFI_STATUS              Status;\r
+  EFI_HANDLE              NicHandle;\r
+  PXEBC_PRIVATE_PROTOCOL  *Id;\r
+\r
+  if ((ControllerHandle == NULL) || (ChildHandle != NULL)) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  NicHandle = PxeBcGetNicByIp4Children (ControllerHandle);\r
+  if (NicHandle == NULL) {\r
+    NicHandle = PxeBcGetNicByIp6Children (ControllerHandle);\r
+    if (NicHandle == NULL) {\r
+      return EFI_UNSUPPORTED;\r
+    }\r
+  }\r
+\r
+  //\r
+  // Try to retrieve the private data by PxeBcPrivate protocol.\r
+  //\r
+  Status = gBS->OpenProtocol (\r
+                  NicHandle,\r
+                  &gEfiCallerIdGuid,\r
+                  (VOID **)&Id,\r
+                  NULL,\r
+                  NULL,\r
+                  EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
 \r
+  return LookupUnicodeString2 (\r
+           Language,\r
+           This->SupportedLanguages,\r
+           mPxeBcControllerNameTable,\r
+           ControllerName,\r
+           (BOOLEAN)(This == &gPxeBcComponentName)\r
+           );\r
+}\r