summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>2010-07-30 09:02:11 +0000
committerlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>2010-07-30 09:02:11 +0000
commit1d9a55a9b8ea0a2892e64ed4644a20e29d8d8274 (patch)
tree21fd55461b3f55099271c79c8e91a177674141ab
parent8a6cc1ee08e7287817e7d9e641d02793b31b45b5 (diff)
downloadedk2-1d9a55a9b8ea0a2892e64ed4644a20e29d8d8274.tar.gz
Update UefiPxeBcDxe to check for media status before PXE start.
Sync patch r9066, r10318 from main trunk. r9066 - Use siaddr in DHCP packet, if zero, use option 54 instead. r10318 - Remove PxeBc->Stop () when EFI_BUFFER_TOO_SMALL, the calling PxeBc->Stop() in Driver Binding Stop() could make sure PXE functionality is stopped when disconnecting UefiPxeBcDxe module. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/branches/UDK2008@10753 6f19259b-4bc3-4df7-8a09-765794883524
-rw-r--r--MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.c82
-rw-r--r--MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.h1
2 files changed, 81 insertions, 2 deletions
diff --git a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.c b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.c
index 3eeacdcc5c..d660cbd2f7 100644
--- a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.c
+++ b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.c
@@ -243,6 +243,71 @@ IcmpErrorListenHandler (
QueueDpc (TPL_CALLBACK, IcmpErrorListenHandlerDpc, Context);
}
+/**
+ Get current media status
+
+ @param[in] Snp Pointer to the simple network protocol.
+
+ @retval TRUE Media is connected to the network interface.
+ @retval FALSE Media isn't connect to the network interface.
+
+**/
+BOOLEAN
+GetCurrentMediaStatus (
+ IN EFI_SIMPLE_NETWORK *Snp
+ )
+{
+ EFI_STATUS Status;
+ EFI_MAC_ADDRESS *MCastFilter;
+ UINT32 MCastFilterCnt;
+ UINT32 EnableFilterBits;
+ UINT32 DisableFilterBits;
+
+ if (Snp == NULL) {
+ return FALSE;
+ }
+
+ //
+ // Pre-UEFI2.3, Media Status is only refreshed when interface intialize
+ // To get the up to date media status, re-initialize the NIC is required
+ // Considering PXE boot scenario, the assumption is no other network
+ // application is running when PXE boot
+ //
+ if (Snp->Mode->State == EfiSimpleNetworkInitialized) {
+ //
+ // Save current receive filtter setting
+ //
+ EnableFilterBits = Snp->Mode->ReceiveFilterSetting;
+ DisableFilterBits = (Snp->Mode->ReceiveFilterMask) ^ EnableFilterBits;
+
+ MCastFilterCnt = Snp->Mode->MCastFilterCount;
+ MCastFilter = AllocatePool (sizeof (EFI_MAC_ADDRESS) * MCastFilterCnt);
+ if (MCastFilter == NULL) {
+ DEBUG ((EFI_D_ERROR, "GetCurrentMediaStatus: Failed to allocate memory resource for MCastFilter.\n"));
+ return FALSE;
+ }
+ CopyMem (MCastFilter, Snp->Mode->MCastFilter, sizeof (EFI_MAC_ADDRESS) * MCastFilterCnt);
+
+ //
+ // Re Initialize the NIC
+ //
+ Snp->Shutdown (Snp);
+ Snp->Stop (Snp);
+ Snp->Start (Snp);
+ Status = Snp->Initialize (Snp, 0, 0);
+ if (!EFI_ERROR(Status)) {
+ //
+ // Recover previous recieve filter setting
+ //
+ Snp->ReceiveFilters (Snp, EnableFilterBits, DisableFilterBits, FALSE, MCastFilterCnt, MCastFilter);
+ FreePool (MCastFilter);
+ return Snp->Mode->MediaPresent;
+ }
+ }
+
+ return FALSE;
+}
+
/**
Enables the use of the PXE Base Code Protocol functions.
@@ -337,6 +402,13 @@ EfiPxeBcStart (
}
//
+ // Check Up to date Media Status
+ //
+ if (FALSE == GetCurrentMediaStatus (Private->Snp)) {
+ return EFI_NO_MEDIA;
+ }
+
+ //
// Configure the udp4 instance to let it receive data
//
Status = Private->Udp4Read->Configure (
@@ -2480,9 +2552,11 @@ DiscoverBootFile (
}
//
- // use option 54, if zero, use siaddr in header
+ // Use siaddr(next server) in DHCPOFFER packet header, if zero, use option 54(server identifier)
+ // in DHCPOFFER packet.
+ // (It does not comply with PXE Spec, Ver2.1)
//
- if (Packet->Dhcp4Option[PXEBC_DHCP4_TAG_INDEX_SERVER_ID] != NULL) {
+ if (EFI_IP4_EQUAL (&Packet->Packet.Offer.Dhcp4.Header.ServerAddr, &mZeroIp4Addr)) {
CopyMem (
&Private->ServerIp,
Packet->Dhcp4Option[PXEBC_DHCP4_TAG_INDEX_SERVER_ID]->Data,
@@ -2695,12 +2769,16 @@ EfiPxeLoadFile (
// Check download status
//
if (Status == EFI_SUCCESS) {
+
return EFI_SUCCESS;
} else if (Status == EFI_BUFFER_TOO_SMALL) {
if (Buffer != NULL) {
AsciiPrint ("PXE-E05: Download buffer is smaller than requested file.\n");
} else {
+ //
+ // The functionality of PXE Base Code protocol will not be stopped.
+ //
return Status;
}
diff --git a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.h b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.h
index bc039ec730..964c71f655 100644
--- a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.h
+++ b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.h
@@ -63,6 +63,7 @@ struct _PXEBC_PRIVATE_DATA {
EFI_HANDLE Udp4WriteChild;
EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL *Nii;
+ EFI_SIMPLE_NETWORK_PROTOCOL *Snp;
EFI_PXE_BASE_CODE_PROTOCOL PxeBc;
EFI_LOAD_FILE_PROTOCOL LoadFile;