]> git.proxmox.com Git - mirror_edk2.git/blobdiff - NetworkPkg/UefiPxeBcDxe/PxeBcDriver.c
NetworkPkg/UefiPxeBcDxe: Fix various typos
[mirror_edk2.git] / NetworkPkg / UefiPxeBcDxe / PxeBcDriver.c
index a6f66682f3b8f2fc108d6d3c9b75e54f94de180a..0e2675be3c984b7a15a37d70e627bf610dc6cdec 100644 (file)
@@ -1,16 +1,10 @@
 /** @file\r
-  Driver Binding functions implementationfor for UefiPxeBc Driver.\r
+  Driver Binding functions implementation for UefiPxeBc Driver.\r
 \r
   (C) Copyright 2014 Hewlett-Packard Development Company, L.P.<BR>\r
-  Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2007 - 2019, 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
@@ -254,8 +248,9 @@ PxeBcDestroyIp4Children (
            &Private->PxeBc,\r
            NULL\r
            );\r
+    FreePool (Private->Ip4Nic->DevicePath);\r
 \r
-    if (Private->Snp != NULL) { \r
+    if (Private->Snp != NULL) {\r
       //\r
       // Close SNP from the child virtual handle\r
       //\r
@@ -265,7 +260,7 @@ PxeBcDestroyIp4Children (
              This->DriverBindingHandle,\r
              Private->Ip4Nic->Controller\r
              );\r
-             \r
+\r
       gBS->UninstallProtocolInterface (\r
              Private->Ip4Nic->Controller,\r
              &gEfiSimpleNetworkProtocolGuid,\r
@@ -414,6 +409,8 @@ PxeBcDestroyIp6Children (
            &Private->PxeBc,\r
            NULL\r
            );\r
+    FreePool (Private->Ip6Nic->DevicePath);\r
+\r
     if (Private->Snp != NULL) {\r
       //\r
       // Close SNP from the child virtual handle\r
@@ -486,7 +483,7 @@ PxeBcCheckIpv6Support (
 \r
   //\r
   // Get the NIC handle by SNP protocol.\r
-  //  \r
+  //\r
   Handle = NetLibGetSnpHandle (ControllerHandle, NULL);\r
   if (Handle == NULL) {\r
     return EFI_NOT_FOUND;\r
@@ -532,7 +529,7 @@ PxeBcCheckIpv6Support (
   if (EFI_ERROR (Status) || InfoBlock == NULL) {\r
     FreePool (InfoBlock);\r
     return EFI_NOT_FOUND;\r
-  }  \r
+  }\r
 \r
   *Ipv6Support = ((EFI_ADAPTER_INFO_UNDI_IPV6_SUPPORT *) InfoBlock)->Ipv6Support;\r
   FreePool (InfoBlock);\r
@@ -811,7 +808,7 @@ PxeBcCreateIp4Children (
     }\r
 \r
     //\r
-    // Open SNP on the child handle BY_DRIVER. It will prevent any additionally \r
+    // Open SNP on the child handle BY_DRIVER|EXCLUSIVE. It will prevent any additionally\r
     // layering to perform the experiment.\r
     //\r
     Status = gBS->OpenProtocol (\r
@@ -820,7 +817,7 @@ PxeBcCreateIp4Children (
                     (VOID **) &Snp,\r
                     This->DriverBindingHandle,\r
                     Private->Ip4Nic->Controller,\r
-                    EFI_OPEN_PROTOCOL_BY_DRIVER\r
+                    EFI_OPEN_PROTOCOL_BY_DRIVER|EFI_OPEN_PROTOCOL_EXCLUSIVE\r
                     );\r
     if (EFI_ERROR (Status)) {\r
       goto ON_ERROR;\r
@@ -948,7 +945,7 @@ PxeBcCreateIp6Children (
   if (Private->Snp != NULL) {\r
     for (Index = 0; Index < Private->Snp->Mode->HwAddressSize; Index++) {\r
       Private->IaId |= (Private->Snp->Mode->CurrentAddress.Addr[Index] << ((Index << 3) & 31));\r
-    }  \r
+    }\r
   }\r
 \r
   //\r
@@ -1061,6 +1058,30 @@ PxeBcCreateIp6Children (
 \r
   Private->Ip6MaxPacketSize = Ip6ModeData.MaxPacketSize;\r
 \r
+  if (Ip6ModeData.AddressList != NULL) {\r
+    FreePool (Ip6ModeData.AddressList);\r
+  }\r
+\r
+  if (Ip6ModeData.GroupTable != NULL) {\r
+    FreePool (Ip6ModeData.GroupTable);\r
+  }\r
+\r
+  if (Ip6ModeData.RouteTable != NULL) {\r
+    FreePool (Ip6ModeData.RouteTable);\r
+  }\r
+\r
+  if (Ip6ModeData.NeighborCache != NULL) {\r
+    FreePool (Ip6ModeData.NeighborCache);\r
+  }\r
+\r
+  if (Ip6ModeData.PrefixTable != NULL) {\r
+    FreePool (Ip6ModeData.PrefixTable);\r
+  }\r
+\r
+  if (Ip6ModeData.IcmpTypeList != NULL) {\r
+    FreePool (Ip6ModeData.IcmpTypeList);\r
+  }\r
+\r
   //\r
   // Locate Ip6->Ip6Config and store it for set IPv6 address.\r
   //\r
@@ -1113,7 +1134,7 @@ PxeBcCreateIp6Children (
   if (EFI_ERROR (Status)) {\r
     goto ON_ERROR;\r
   }\r
-  \r
+\r
   if (Private->Snp != NULL) {\r
     //\r
     // Install SNP protocol on purpose is for some OS loader backward\r
@@ -1130,7 +1151,7 @@ PxeBcCreateIp6Children (
     }\r
 \r
     //\r
-    // Open SNP on the child handle BY_DRIVER. It will prevent any additionally \r
+    // Open SNP on the child handle BY_DRIVER|EXCLUSIVE. It will prevent any additionally\r
     // layering to perform the experiment.\r
     //\r
     Status = gBS->OpenProtocol (\r
@@ -1139,7 +1160,7 @@ PxeBcCreateIp6Children (
                     (VOID **) &Snp,\r
                     This->DriverBindingHandle,\r
                     Private->Ip6Nic->Controller,\r
-                    EFI_OPEN_PROTOCOL_BY_DRIVER\r
+                    EFI_OPEN_PROTOCOL_BY_DRIVER|EFI_OPEN_PROTOCOL_EXCLUSIVE\r
                     );\r
     if (EFI_ERROR (Status)) {\r
       goto ON_ERROR;\r
@@ -1163,7 +1184,7 @@ PxeBcCreateIp6Children (
   }\r
 \r
   //\r
-  // Set IPv6 avaiable flag and set default configure data for\r
+  // Set IPv6 available flag and set default configure data for\r
   // Udp6Read and Ip6 instance.\r
   //\r
   Status = PxeBcCheckIpv6Support (ControllerHandle, Private, &Private->Mode.Ipv6Available);\r
@@ -1221,6 +1242,10 @@ PxeBcDriverEntryPoint (
 {\r
   EFI_STATUS  Status;\r
 \r
+  if ((PcdGet8(PcdIPv4PXESupport) == PXE_DISABLED) && (PcdGet8(PcdIPv6PXESupport) == PXE_DISABLED)) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
   Status = EfiLibInstallDriverBindingComponentName2 (\r
              ImageHandle,\r
              SystemTable,\r
@@ -1242,16 +1267,11 @@ PxeBcDriverEntryPoint (
              &gPxeBcComponentName2\r
              );\r
   if (EFI_ERROR (Status)) {\r
-    gBS->UninstallMultipleProtocolInterfaces (\r
-           ImageHandle,\r
-           &gEfiDriverBindingProtocolGuid,\r
-           &gPxeBcIp4DriverBinding,\r
-           &gEfiComponentName2ProtocolGuid,\r
-           &gPxeBcComponentName2,\r
-           &gEfiComponentNameProtocolGuid,\r
-           &gPxeBcComponentName,\r
-           NULL\r
-           );\r
+    EfiLibUninstallDriverBindingComponentName2 (\r
+      &gPxeBcIp4DriverBinding,\r
+      &gPxeBcComponentName,\r
+      &gPxeBcComponentName2\r
+      );\r
   }\r
 \r
   return Status;\r
@@ -1266,7 +1286,7 @@ PxeBcDriverEntryPoint (
   @param[in]  RemainingDevicePath Optional parameter used to pick a specific child\r
                                   device to be started.\r
   @param[in]  IpVersion           IP_VERSION_4 or IP_VERSION_6.\r
-  \r
+\r
   @retval EFI_SUCCESS         This driver supports this device.\r
   @retval EFI_UNSUPPORTED     This driver does not support this device.\r
 \r
@@ -1283,11 +1303,17 @@ PxeBcSupported (
   EFI_STATUS                      Status;\r
   EFI_GUID                        *DhcpServiceBindingGuid;\r
   EFI_GUID                        *MtftpServiceBindingGuid;\r
-  \r
+\r
   if (IpVersion == IP_VERSION_4) {\r
+    if (PcdGet8(PcdIPv4PXESupport) == PXE_DISABLED) {\r
+      return EFI_UNSUPPORTED;\r
+    }\r
     DhcpServiceBindingGuid  = &gEfiDhcp4ServiceBindingProtocolGuid;\r
     MtftpServiceBindingGuid = &gEfiMtftp4ServiceBindingProtocolGuid;\r
   } else {\r
+    if (PcdGet8(PcdIPv6PXESupport) == PXE_DISABLED) {\r
+      return EFI_UNSUPPORTED;\r
+    }\r
     DhcpServiceBindingGuid  = &gEfiDhcp6ServiceBindingProtocolGuid;\r
     MtftpServiceBindingGuid = &gEfiMtftp6ServiceBindingProtocolGuid;\r
   }\r
@@ -1426,7 +1452,7 @@ PxeBcStart (
 \r
     //\r
     // Install PxeBaseCodePrivate protocol onto the real NIC handler.\r
-    // PxeBaseCodePrivate protocol is only used to keep the relationship between \r
+    // PxeBaseCodePrivate protocol is only used to keep the relationship between\r
     // NIC handle and virtual child handles.\r
     // gEfiCallerIdGuid will be used as its protocol guid.\r
     //\r
@@ -1443,7 +1469,7 @@ PxeBcStart (
     //\r
     // Try to locate SNP protocol.\r
     //\r
-    NetLibGetSnpHandle(ControllerHandle, &Private->Snp);    \r
+    NetLibGetSnpHandle(ControllerHandle, &Private->Snp);\r
   }\r
 \r
   if (IpVersion == IP_VERSION_4) {\r