X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=MdeModulePkg%2FUniversal%2FNetwork%2FUefiPxeBcDxe%2FPxeBcImpl.c;h=3eeacdcc5c8065c51c56213b5a7dee9d9fb03db0;hp=5a17537b1266b51bf7dbfe74e7a1698219ca8a01;hb=d8d26fb207e02aa5ef57e2bcb213f9dda16166cc;hpb=319075ff6e1d1fb470667453ec24a2ba685f60a0 diff --git a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.c b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.c index 5a17537b12..3eeacdcc5c 100644 --- a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.c +++ b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.c @@ -1,7 +1,7 @@ /** @file Interface routines for PxeBc. -Copyright (c) 2007 - 2008, Intel Corporation.
+Copyright (c) 2007 - 2009, Intel Corporation.
All rights reserved. This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -15,7 +15,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include "PxeBcImpl.h" -EFI_LOAD_FILE_PROTOCOL mLoadFileProtocolTemplate = { EfiPxeLoadFile }; +UINT32 mPxeDhcpTimeout[4] = { 4, 8, 16, 32 }; /** Get and record the arp cache. @@ -84,8 +84,6 @@ UpdateArpCache ( @param Event Pointer to EFI_PXE_BC_PROTOCOL @param Context Context of the timer event - - @return None. **/ VOID @@ -139,8 +137,6 @@ FindInArpCache ( @param Context The PXEBC private data. - @return None. - **/ VOID EFIAPI @@ -233,8 +229,6 @@ Resume: @param Event The event signaled. @param Context The context passed in by the event notifier. - @return None. - **/ VOID EFIAPI @@ -246,7 +240,7 @@ IcmpErrorListenHandler ( // // Request IpIoListenHandlerDpc as a DPC at TPL_CALLBACK // - NetLibQueueDpc (TPL_CALLBACK, IcmpErrorListenHandlerDpc, Context); + QueueDpc (TPL_CALLBACK, IcmpErrorListenHandlerDpc, Context); } /** @@ -479,7 +473,7 @@ EfiPxeBcStop ( // Dispatch the DPCs queued by the NotifyFunction of the canceled rx token's // events. // - NetLibDispatchDpc (); + DispatchDpc (); Private->Ip4->Configure (Private->Ip4, NULL); @@ -502,6 +496,7 @@ EfiPxeBcStop ( Private->CurrentUdpSrcPort = 0; Private->Udp4Write->Configure (Private->Udp4Write, NULL); + Private->Udp4Read->Groups (Private->Udp4Read, FALSE, NULL); Private->Udp4Read->Configure (Private->Udp4Read, NULL); Private->Dhcp4->Stop (Private->Dhcp4); @@ -560,8 +555,6 @@ EfiPxeBcDhcp ( EFI_DHCP4_MODE_DATA Dhcp4Mode; EFI_DHCP4_PACKET_OPTION *OptList[PXEBC_DHCP4_MAX_OPTION_NUM]; UINT32 OptCount; - UINT32 DiscoverTimeout; - UINTN Index; EFI_STATUS Status; EFI_ARP_CONFIG_DATA ArpConfigData; @@ -589,76 +582,62 @@ EfiPxeBcDhcp ( // // Set the DHCP4 config data. + // The four discovery timeouts are 4, 8, 16, 32 seconds respectively. // ZeroMem (&Dhcp4CfgData, sizeof (EFI_DHCP4_CONFIG_DATA)); Dhcp4CfgData.OptionCount = OptCount; Dhcp4CfgData.OptionList = OptList; Dhcp4CfgData.Dhcp4Callback = PxeBcDhcpCallBack; Dhcp4CfgData.CallbackContext = Private; - Dhcp4CfgData.DiscoverTryCount = 1; - Dhcp4CfgData.DiscoverTimeout = &DiscoverTimeout; + Dhcp4CfgData.DiscoverTryCount = 4; + Dhcp4CfgData.DiscoverTimeout = mPxeDhcpTimeout; - for (Index = 0; Index < PXEBC_DHCP4_DISCOVER_RETRIES; Index++) { - // - // The four discovery timeouts are 4, 8, 16, 32 seconds respectively. - // - DiscoverTimeout = (PXEBC_DHCP4_DISCOVER_INIT_TIMEOUT << Index); - - Status = Dhcp4->Configure (Dhcp4, &Dhcp4CfgData); - if (EFI_ERROR (Status)) { - break; - } - // - // Zero those arrays to record the varies numbers of DHCP OFFERS. - // - Private->GotProxyOffer = FALSE; - Private->NumOffers = 0; - Private->BootpIndex = 0; - ZeroMem (Private->ServerCount, sizeof (Private->ServerCount)); - ZeroMem (Private->ProxyIndex, sizeof (Private->ProxyIndex)); + Status = Dhcp4->Configure (Dhcp4, &Dhcp4CfgData); + if (EFI_ERROR (Status)) { + goto ON_EXIT; + } + + // + // Zero those arrays to record the varies numbers of DHCP OFFERS. + // + Private->GotProxyOffer = FALSE; + Private->NumOffers = 0; + Private->BootpIndex = 0; + ZeroMem (Private->ServerCount, sizeof (Private->ServerCount)); + ZeroMem (Private->ProxyIndex, sizeof (Private->ProxyIndex)); - Status = Dhcp4->Start (Dhcp4, NULL); - if (EFI_ERROR (Status)) { - if (Status == EFI_TIMEOUT) { - // - // If no response is received or all received offers don't match - // the PXE boot requirements, EFI_TIMEOUT will be returned. - // - continue; - } - if (Status == EFI_ICMP_ERROR) { - Mode->IcmpErrorReceived = TRUE; - } - // - // Other error status means the DHCP really fails. - // - break; + Status = Dhcp4->Start (Dhcp4, NULL); + if (EFI_ERROR (Status)) { + if (Status == EFI_ICMP_ERROR) { + Mode->IcmpErrorReceived = TRUE; } + goto ON_EXIT; + } - Status = Dhcp4->GetModeData (Dhcp4, &Dhcp4Mode); - if (EFI_ERROR (Status)) { - break; - } + Status = Dhcp4->GetModeData (Dhcp4, &Dhcp4Mode); + if (EFI_ERROR (Status)) { + goto ON_EXIT; + } - ASSERT (Dhcp4Mode.State == Dhcp4Bound); + ASSERT (Dhcp4Mode.State == Dhcp4Bound); - CopyMem (&Private->StationIp, &Dhcp4Mode.ClientAddress, sizeof (EFI_IPv4_ADDRESS)); - CopyMem (&Private->SubnetMask, &Dhcp4Mode.SubnetMask, sizeof (EFI_IPv4_ADDRESS)); - CopyMem (&Private->GatewayIp, &Dhcp4Mode.RouterAddress, sizeof (EFI_IPv4_ADDRESS)); + CopyMem (&Private->StationIp, &Dhcp4Mode.ClientAddress, sizeof (EFI_IPv4_ADDRESS)); + CopyMem (&Private->SubnetMask, &Dhcp4Mode.SubnetMask, sizeof (EFI_IPv4_ADDRESS)); + CopyMem (&Private->GatewayIp, &Dhcp4Mode.RouterAddress, sizeof (EFI_IPv4_ADDRESS)); - CopyMem (&Mode->StationIp, &Private->StationIp, sizeof (EFI_IPv4_ADDRESS)); - CopyMem (&Mode->SubnetMask, &Private->SubnetMask, sizeof (EFI_IPv4_ADDRESS)); + CopyMem (&Mode->StationIp, &Private->StationIp, sizeof (EFI_IPv4_ADDRESS)); + CopyMem (&Mode->SubnetMask, &Private->SubnetMask, sizeof (EFI_IPv4_ADDRESS)); - // - // Check the selected offer to see whether BINL is required, if no or BINL is - // finished, set the various Mode members. - // - Status = PxeBcCheckSelectedOffer (Private); - if (!EFI_ERROR (Status)) { - break; - } + // + // Check the selected offer to see whether BINL is required, if no or BINL is + // finished, set the various Mode members. + // + Status = PxeBcCheckSelectedOffer (Private); + if (!EFI_ERROR (Status)) { + goto ON_EXIT; } +ON_EXIT: if (EFI_ERROR (Status)) { Dhcp4->Stop (Dhcp4); Dhcp4->Configure (Dhcp4, NULL); @@ -1447,6 +1426,8 @@ CheckIpByFilter ( return TRUE; } + ASSERT (PxeBcMode->IpFilter.IpCnt < EFI_PXE_BASE_CODE_MAX_IPCNT); + for (Index = 0; Index < PxeBcMode->IpFilter.IpCnt; Index++) { CopyMem ( &Ip4Address, @@ -1770,20 +1751,20 @@ EfiPxeBcSetIpFilter ( BOOLEAN PromiscuousNeed; if (This == NULL) { - DEBUG ((EFI_D_ERROR, "BC *This pointer == NULL.\n")); + DEBUG ((EFI_D_ERROR, "This == NULL.\n")); return EFI_INVALID_PARAMETER; } Private = PXEBC_PRIVATE_DATA_FROM_PXEBC (This); Mode = Private->PxeBc.Mode; - if (Private == NULL) { - DEBUG ((EFI_D_ERROR, "PXEBC_PRIVATE_DATA poiner == NULL.\n")); + if (NewFilter == NULL) { + DEBUG ((EFI_D_ERROR, "NewFilter == NULL.\n")); return EFI_INVALID_PARAMETER; } - if (NewFilter == NULL) { - DEBUG ((EFI_D_ERROR, "IP Filter *NewFilter == NULL.\n")); + if (NewFilter->IpCnt > EFI_PXE_BASE_CODE_MAX_IPCNT) { + DEBUG ((EFI_D_ERROR, "NewFilter->IpCnt > %d.\n", EFI_PXE_BASE_CODE_MAX_IPCNT)); return EFI_INVALID_PARAMETER; } @@ -1793,6 +1774,7 @@ EfiPxeBcSetIpFilter ( } PromiscuousNeed = FALSE; + for (Index = 0; Index < NewFilter->IpCnt; ++Index) { if (IP4_IS_LOCAL_BROADCAST (EFI_IP4 (NewFilter->IpList[Index].v4))) { // @@ -2654,7 +2636,7 @@ EfiPxeLoadFile ( if (sizeof (UINTN) < sizeof (UINT64) && (TmpBufSize > 0xFFFFFFFF)) { Status = EFI_DEVICE_ERROR; - } else if (*BufferSize >= (UINTN) TmpBufSize && Buffer != NULL) { + } else if (TmpBufSize > 0 && *BufferSize >= (UINTN) TmpBufSize && Buffer != NULL) { *BufferSize = (UINTN) TmpBufSize; Status = PxeBc->Mtftp ( PxeBc, @@ -2668,7 +2650,7 @@ EfiPxeLoadFile ( NULL, FALSE ); - } else { + } else if (TmpBufSize > 0) { *BufferSize = (UINTN) TmpBufSize; Status = EFI_BUFFER_TOO_SMALL; } @@ -2755,3 +2737,5 @@ EfiPxeLoadFile ( return Status; } +EFI_LOAD_FILE_PROTOCOL mLoadFileProtocolTemplate = { EfiPxeLoadFile }; +