summaryrefslogtreecommitdiff
path: root/MdeModulePkg/Universal
diff options
context:
space:
mode:
authorljin6 <ljin6@6f19259b-4bc3-4df7-8a09-765794883524>2010-02-01 03:32:28 +0000
committerljin6 <ljin6@6f19259b-4bc3-4df7-8a09-765794883524>2010-02-01 03:32:28 +0000
commitfa6d3ee4913eaf3b0fd9ddb8a4e3b618584bd965 (patch)
treefe43cd3dfd425c23d35b787c03bafebebc253c90 /MdeModulePkg/Universal
parent9f7d5b46aa54a46cf03e52569757d642c15d5175 (diff)
downloadedk2-platforms-fa6d3ee4913eaf3b0fd9ddb8a4e3b618584bd965.tar.xz
Get MaxPacketSize from IP4 mode data and reduce the head size of UDP and MTFTP, and take it as BlockSize to download.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9894 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdeModulePkg/Universal')
-rw-r--r--MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDhcp.c4
-rw-r--r--MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDriver.c11
-rw-r--r--MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.c15
-rw-r--r--MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.h10
4 files changed, 29 insertions, 11 deletions
diff --git a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDhcp.c b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDhcp.c
index f2d8eecfe2..d2e60b6a59 100644
--- a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDhcp.c
+++ b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDhcp.c
@@ -1270,7 +1270,9 @@ PxeBcDiscvBootService (
//
// free the responselist
//
- FreePool (Token.ResponseList);
+ if (Token.ResponseList != NULL) {
+ FreePool (Token.ResponseList);
+ }
}
//
// Free the dhcp packet
diff --git a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDriver.c b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDriver.c
index 9dc32f2ce7..f82f744b76 100644
--- a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDriver.c
+++ b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDriver.c
@@ -152,6 +152,7 @@ PxeBcDriverBindingStart (
PXEBC_PRIVATE_DATA *Private;
UINTN Index;
EFI_STATUS Status;
+ EFI_IP4_MODE_DATA Ip4ModeData;
Private = AllocateZeroPool (sizeof (PXEBC_PRIVATE_DATA));
if (Private == NULL) {
@@ -253,6 +254,16 @@ PxeBcDriverBindingStart (
if (EFI_ERROR (Status)) {
goto ON_ERROR;
}
+
+ //
+ // Get max packet size from Ip4 to calculate block size for Tftp later.
+ //
+ Status = Private->Ip4->GetModeData (Private->Ip4, &Ip4ModeData, NULL, NULL);
+ if (EFI_ERROR (Status)) {
+ goto ON_ERROR;
+ }
+
+ Private->Ip4MaxPacketSize = Ip4ModeData.MaxPacketSize;
Status = NetLibCreateServiceChild (
ControllerHandle,
diff --git a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.c b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.c
index e5ff4addf6..df9d2df5be 100644
--- a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.c
+++ b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.c
@@ -347,6 +347,11 @@ EfiPxeBcStart (
return Status;
}
+ //
+ // Configure block size for TFTP as a default value to handle all link layers.
+ //
+ Private->BlockSize = (UINTN) (MIN (Private->Ip4MaxPacketSize, PXEBC_DEFAULT_PACKET_SIZE) -
+ PXEBC_DEFAULT_UDP_OVERHEAD_SIZE - PXEBC_DEFAULT_TFTP_OVERHEAD_SIZE);
Private->AddressIsOk = FALSE;
ZeroMem (Mode, sizeof (EFI_PXE_BASE_CODE_MODE));
@@ -2421,7 +2426,6 @@ DiscoverBootFile (
UINT16 Type;
UINT16 Layer;
BOOLEAN UseBis;
- UINTN BlockSize;
PXEBC_CACHED_DHCP4_PACKET *Packet;
UINT16 Value;
@@ -2466,7 +2470,6 @@ DiscoverBootFile (
}
*BufferSize = 0;
- BlockSize = 0x8000;
//
// Get bootfile name and (m)tftp server ip addresss
@@ -2526,7 +2529,7 @@ DiscoverBootFile (
Buffer,
FALSE,
BufferSize,
- &BlockSize,
+ &Private->BlockSize,
&Private->ServerIp,
(UINT8 *) Private->BootFileName,
NULL,
@@ -2580,14 +2583,12 @@ EfiPxeLoadFile (
PXEBC_PRIVATE_DATA *Private;
EFI_PXE_BASE_CODE_PROTOCOL *PxeBc;
BOOLEAN NewMakeCallback;
- UINTN BlockSize;
EFI_STATUS Status;
UINT64 TmpBufSize;
Private = PXEBC_PRIVATE_DATA_FROM_LOADFILE (This);
PxeBc = &Private->PxeBc;
NewMakeCallback = FALSE;
- BlockSize = 0x8000;
Status = EFI_DEVICE_ERROR;
if (This == NULL || BufferSize == NULL) {
@@ -2646,7 +2647,7 @@ EfiPxeLoadFile (
Buffer,
FALSE,
&TmpBufSize,
- &BlockSize,
+ &Private->BlockSize,
&Private->ServerIp,
(UINT8 *) Private->BootFileName,
NULL,
@@ -2670,7 +2671,7 @@ EfiPxeLoadFile (
Buffer,
FALSE,
&TmpBufSize,
- &BlockSize,
+ &Private->BlockSize,
&Private->ServerIp,
(UINT8 *) Private->BootFileName,
NULL,
diff --git a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.h b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.h
index e8c278db04..807e4d128a 100644
--- a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.h
+++ b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.h
@@ -47,8 +47,11 @@ typedef struct _PXEBC_PRIVATE_DATA PXEBC_PRIVATE_DATA;
#include "PxeBcSupport.h"
#define PXEBC_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('P', 'X', 'E', 'P')
-#define PXEBC_MTFTP_TIMEOUT 4
-#define PXEBC_MTFTP_RETRIES 6
+#define PXEBC_MTFTP_TIMEOUT 4
+#define PXEBC_MTFTP_RETRIES 6
+#define PXEBC_DEFAULT_UDP_OVERHEAD_SIZE 8
+#define PXEBC_DEFAULT_TFTP_OVERHEAD_SIZE 4
+#define PXEBC_DEFAULT_PACKET_SIZE 1480
struct _PXEBC_PRIVATE_DATA {
UINT32 Signature;
@@ -88,7 +91,8 @@ struct _PXEBC_PRIVATE_DATA {
EFI_IP_ADDRESS GatewayIp;
EFI_IP_ADDRESS ServerIp;
BOOLEAN AddressIsOk;
-
+ UINT32 Ip4MaxPacketSize;
+ UINTN BlockSize;
UINTN FileSize;
UINT8 OptionBuffer[PXEBC_DHCP4_MAX_OPTION_SIZE];