]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDriver.c
1. add error handling in case DHCP success but boot request fail
[mirror_edk2.git] / MdeModulePkg / Universal / Network / UefiPxeBcDxe / PxeBcDriver.c
index 82a19d75177abcf4c654aa6f7eae927a2b1d6906..f82f744b762fb0a022b4089892e19207280c5bc0 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   The driver binding for UEFI PXEBC protocol.\r
   \r
-Copyright (c) 2007 - 2008, Intel Corporation.<BR>\r
+Copyright (c) 2007 - 2009, Intel Corporation.<BR>\r
 All rights reserved. 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
@@ -37,6 +37,7 @@ EFI_DRIVER_BINDING_PROTOCOL gPxeBcDriverBinding = {
 \r
 **/\r
 EFI_STATUS\r
+EFIAPI\r
 PxeBcDriverEntryPoint (\r
   IN EFI_HANDLE             ImageHandle,\r
   IN EFI_SYSTEM_TABLE       *SystemTable\r
@@ -151,6 +152,7 @@ PxeBcDriverBindingStart (
   PXEBC_PRIVATE_DATA  *Private;\r
   UINTN               Index;\r
   EFI_STATUS          Status;\r
+  EFI_IP4_MODE_DATA   Ip4ModeData;\r
 \r
   Private = AllocateZeroPool (sizeof (PXEBC_PRIVATE_DATA));\r
   if (Private == NULL) {\r
@@ -173,7 +175,7 @@ PxeBcDriverBindingStart (
   }\r
 \r
   //\r
-  // Get the NII interface\r
+  // Get the NII interface if it exists.\r
   //\r
   Status = gBS->OpenProtocol (\r
                   ControllerHandle,\r
@@ -184,7 +186,7 @@ PxeBcDriverBindingStart (
                   EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
                   );\r
   if (EFI_ERROR (Status)) {\r
-    goto ON_ERROR;\r
+    Private->Nii = NULL;\r
   }\r
 \r
   Status = NetLibCreateServiceChild (\r
@@ -252,6 +254,16 @@ PxeBcDriverBindingStart (
   if (EFI_ERROR (Status)) {\r
     goto ON_ERROR;\r
   }\r
+
+  //
+  // Get max packet size from Ip4 to calculate block size for Tftp later.\r
+  //
+  Status = Private->Ip4->GetModeData (Private->Ip4, &Ip4ModeData, NULL, NULL);
+  if (EFI_ERROR (Status)) {
+    goto ON_ERROR;  
+  }
+
+  Private->Ip4MaxPacketSize = Ip4ModeData.MaxPacketSize;\r
 \r
   Status = NetLibCreateServiceChild (\r
              ControllerHandle,\r
@@ -336,7 +348,7 @@ PxeBcDriverBindingStart (
   Private->Udp4CfgData.TypeOfService      = DEFAULT_ToS;\r
   Private->Udp4CfgData.TimeToLive         = DEFAULT_TTL;\r
   Private->Udp4CfgData.DoNotFragment      = FALSE;\r
-  Private->Udp4CfgData.ReceiveTimeout     = 10000;  // 10 milliseconds\r
+  Private->Udp4CfgData.ReceiveTimeout     = 50000;  // 50 milliseconds\r
   Private->Udp4CfgData.UseDefaultAddress  = FALSE;\r
 \r
   PxeBcInitSeedPacket (&Private->SeedPacket, Private->Udp4Read);\r
@@ -462,7 +474,7 @@ ON_ERROR:
       );\r
   }\r
 \r
-  gBS->FreePool (Private);\r
+  FreePool (Private);\r
 \r
   return Status;\r
 }\r
@@ -533,6 +545,14 @@ PxeBcDriverBindingStop (
   if (EFI_ERROR (Status)) {\r
     return Status;\r
   }\r
+  \r
+  //\r
+  // Stop functionality of PXE Base Code protocol\r
+  //\r
+  Status = PxeBc->Stop (PxeBc);\r
+  if (Status != EFI_SUCCESS && Status != EFI_NOT_STARTED) {\r
+    return Status;\r
+  }\r
 \r
   Private = PXEBC_PRIVATE_DATA_FROM_PXEBC (PxeBc);\r
 \r
@@ -625,7 +645,7 @@ PxeBcDriverBindingStop (
       Private->ArpChild\r
       );\r
 \r
-    gBS->FreePool (Private);\r
+    FreePool (Private);\r
   }\r
 \r
   return Status;\r