From: "Wang, Jian J" <jian.j.wang@intel.com>
To: "Fu, Siyuan" <siyuan.fu@intel.com>,
"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Cc: "Wu, Hao A" <hao.a.wu@intel.com>,
"Ni, Ruiyu" <ruiyu.ni@intel.com>,
"Zeng, Star" <star.zeng@intel.com>,
"Wu, Jiaxin" <jiaxin.wu@intel.com>
Subject: Re: [PATCH v2 5/6] MdeModulePkg: Delete UefiPxeBcDxe in MdeModulePkg.
Date: Thu, 20 Dec 2018 04:56:21 +0000 [thread overview]
Message-ID: <D827630B58408649ACB04F44C510003624ECE983@SHSMSX103.ccr.corp.intel.com> (raw)
In-Reply-To: <20181220014110.20324-6-siyuan.fu@intel.com>
Reviewed-by: Jian J Wang <jian.j.wang@intel.com>
> -----Original Message-----
> From: Fu, Siyuan
> Sent: Thursday, December 20, 2018 9:41 AM
> To: edk2-devel@lists.01.org
> Cc: Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A <hao.a.wu@intel.com>;
> Ni, Ruiyu <ruiyu.ni@intel.com>; Zeng, Star <star.zeng@intel.com>; Wu, Jiaxin
> <jiaxin.wu@intel.com>
> Subject: [PATCH v2 5/6] MdeModulePkg: Delete UefiPxeBcDxe in
> MdeModulePkg.
>
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1278
>
> This patch is to delete the UefiPxeBcDxe driver in MdeModulePkg. The
> driver will not be maintained and can't co-work with the dual-stack
> UefiPxeBcDxe in NetworkPkg.
>
> People should use below NetworkPkg drivers instead:
> NetworkPkg/UefiPxeBcDxe/UefiPxeBcDxe.inf
> Which is actively maintained with more bug fixes and new feature support.
>
> Cc: Jian J Wang <jian.j.wang@intel.com>
> Cc: Hao Wu <hao.a.wu@intel.com>
> Cc: Ruiyu Ni <ruiyu.ni@intel.com>
> Cc: Star Zeng <star.zeng@intel.com>
> Cc: Jiaxin Wu <jiaxin.wu@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Siyuan Fu <siyuan.fu@intel.com>
> ---
>
> Notes:
> v2:
> Break original patch to separate commits per module.
>
> MdeModulePkg/Universal/Network/UefiPxeBcDxe/ComponentName.c |
> 365 ---
> MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDhcp.c | 1999 --
> -----------
> MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDriver.c | 665 ---
> --
> MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.c | 2989 --
> ------------------
> MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcMtftp.c | 454 --
> -
> MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcSupport.c | 221 -
> -
> MdeModulePkg/MdeModulePkg.dsc | 1 -
> MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDhcp.h | 502 --
> --
> MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDriver.h | 102 -
> MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.h | 189 --
> MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcMtftp.h | 137 -
> MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcSupport.h | 134 -
> MdeModulePkg/Universal/Network/UefiPxeBcDxe/UefiPxe4BcDxe.uni | 25
> -
> MdeModulePkg/Universal/Network/UefiPxeBcDxe/UefiPxe4BcDxeExtra.uni |
> 20 -
> MdeModulePkg/Universal/Network/UefiPxeBcDxe/UefiPxeBcDxe.inf | 102
> -
> 15 files changed, 7905 deletions(-)
>
> diff --git
> a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/ComponentName.c
> b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/ComponentName.c
> deleted file mode 100644
> index a085ef61f341..000000000000
> --- a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/ComponentName.c
> +++ /dev/null
> @@ -1,365 +0,0 @@
> -/** @file
> -
> -Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
> -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
> -http://opensource.org/licenses/bsd-license.php
> -
> -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS
> OR IMPLIED.
> -
> -**/
> -
> -
> -#include "PxeBcImpl.h"
> -
> -//
> -// EFI Component Name Functions
> -//
> -/**
> - Retrieves a Unicode string that is the user readable name of the driver.
> -
> - This function retrieves the user readable name of a driver in the form of a
> - Unicode string. If the driver specified by This has a user readable name in
> - the language specified by Language, then a pointer to the driver name is
> - returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
> - by This does not support the language specified by Language,
> - then EFI_UNSUPPORTED is returned.
> -
> - @param[in] This A pointer to the
> EFI_COMPONENT_NAME2_PROTOCOL or
> - EFI_COMPONENT_NAME_PROTOCOL instance.
> -
> - @param[in] Language A pointer to a Null-terminated ASCII string
> - array indicating the language. This is the
> - language of the driver name that the caller is
> - requesting, and it must match one of the
> - languages specified in SupportedLanguages. The
> - number of languages supported by a driver is up
> - to the driver writer. Language is specified
> - in RFC 4646 or ISO 639-2 language code format.
> -
> - @param[out] DriverName A pointer to the Unicode string to return.
> - This Unicode string is the name of the
> - driver specified by This in the language
> - specified by Language.
> -
> - @retval EFI_SUCCESS The Unicode string for the Driver specified by
> - This and the language specified by Language was
> - returned in DriverName.
> -
> - @retval EFI_INVALID_PARAMETER Language is NULL.
> -
> - @retval EFI_INVALID_PARAMETER DriverName is NULL.
> -
> - @retval EFI_UNSUPPORTED The driver specified by This does not support
> - the language specified by Language.
> -
> -**/
> -EFI_STATUS
> -EFIAPI
> -PxeBcComponentNameGetDriverName (
> - IN EFI_COMPONENT_NAME_PROTOCOL * This,
> - IN CHAR8 *Language,
> - OUT CHAR16 **DriverName
> - );
> -
> -/**
> - Retrieves a Unicode string that is the user readable name of the controller
> - that is being managed by a driver.
> -
> - This function retrieves the user readable name of the controller specified by
> - ControllerHandle and ChildHandle in the form of a Unicode string. If the
> - driver specified by This has a user readable name in the language specified by
> - Language, then a pointer to the controller name is returned in ControllerName,
> - and EFI_SUCCESS is returned. If the driver specified by This is not currently
> - managing the controller specified by ControllerHandle and ChildHandle,
> - then EFI_UNSUPPORTED is returned. If the driver specified by This does not
> - support the language specified by Language, then EFI_UNSUPPORTED is
> returned.
> -
> - @param[in] This A pointer to the
> EFI_COMPONENT_NAME2_PROTOCOL or
> - EFI_COMPONENT_NAME_PROTOCOL instance.
> -
> - @param[in] ControllerHandle The handle of a controller that the driver
> - specified by This is managing. This handle
> - specifies the controller whose name is to be
> - returned.
> -
> - @param[in] ChildHandle The handle of the child controller to retrieve
> - the name of. This is an optional parameter that
> - may be NULL. It will be NULL for device
> - drivers. It will also be NULL for a bus drivers
> - that wish to retrieve the name of the bus
> - controller. It will not be NULL for a bus
> - driver that wishes to retrieve the name of a
> - child controller.
> -
> - @param[in] Language A pointer to a Null-terminated ASCII string
> - array indicating the language. This is the
> - language of the driver name that the caller is
> - requesting, and it must match one of the
> - languages specified in SupportedLanguages. The
> - number of languages supported by a driver is up
> - to the driver writer. Language is specified in
> - RFC 4646 or ISO 639-2 language code format.
> -
> - @param[out] ControllerName A pointer to the Unicode string to return.
> - This Unicode string is the name of the
> - controller specified by ControllerHandle and
> - ChildHandle in the language specified by
> - Language from the point of view of the driver
> - specified by This.
> -
> - @retval EFI_SUCCESS The Unicode string for the user readable name in
> - the language specified by Language for the
> - driver specified by This was returned in
> - DriverName.
> -
> - @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
> -
> - @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
> - EFI_HANDLE.
> -
> - @retval EFI_INVALID_PARAMETER Language is NULL.
> -
> - @retval EFI_INVALID_PARAMETER ControllerName is NULL.
> -
> - @retval EFI_UNSUPPORTED The driver specified by This is not currently
> - managing the controller specified by
> - ControllerHandle and ChildHandle.
> -
> - @retval EFI_UNSUPPORTED The driver specified by This does not support
> - the language specified by Language.
> -
> -**/
> -EFI_STATUS
> -EFIAPI
> -PxeBcComponentNameGetControllerName (
> - IN EFI_COMPONENT_NAME_PROTOCOL * This,
> - IN EFI_HANDLE ControllerHandle,
> - IN EFI_HANDLE ChildHandle OPTIONAL,
> - IN CHAR8 *Language,
> - OUT CHAR16 **ControllerName
> - );
> -
> -//
> -// EFI Component Name Protocol
> -//
> -GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL
> gPxeBcComponentName = {
> - PxeBcComponentNameGetDriverName,
> - PxeBcComponentNameGetControllerName,
> - "eng"
> -};
> -
> -GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL
> gPxeBcComponentName2 = {
> - (EFI_COMPONENT_NAME2_GET_DRIVER_NAME)
> PxeBcComponentNameGetDriverName,
> - (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)
> PxeBcComponentNameGetControllerName,
> - "en"
> -};
> -
> -GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE
> mPxeBcDriverNameTable[] = {
> - {
> - "eng;en",
> - L"UEFI PXE Base Code Driver"
> - },
> - {
> - NULL,
> - NULL
> - }
> -};
> -
> -GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE
> mPxeBcControllerNameTable[] = {
> - {
> - "eng;en",
> - L"PXE Controller"
> - },
> - {
> - NULL,
> - NULL
> - }
> -};
> -
> -/**
> - Retrieves a Unicode string that is the user readable name of the driver.
> -
> - This function retrieves the user readable name of a driver in the form of a
> - Unicode string. If the driver specified by This has a user readable name in
> - the language specified by Language, then a pointer to the driver name is
> - returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
> - by This does not support the language specified by Language,
> - then EFI_UNSUPPORTED is returned.
> -
> - @param[in] This A pointer to the
> EFI_COMPONENT_NAME2_PROTOCOL or
> - EFI_COMPONENT_NAME_PROTOCOL instance.
> -
> - @param[in] Language A pointer to a Null-terminated ASCII string
> - array indicating the language. This is the
> - language of the driver name that the caller is
> - requesting, and it must match one of the
> - languages specified in SupportedLanguages. The
> - number of languages supported by a driver is up
> - to the driver writer. Language is specified
> - in RFC 4646 or ISO 639-2 language code format.
> -
> - @param[out] DriverName A pointer to the Unicode string to return.
> - This Unicode string is the name of the
> - driver specified by This in the language
> - specified by Language.
> -
> - @retval EFI_SUCCESS The Unicode string for the Driver specified by
> - This and the language specified by Language was
> - returned in DriverName.
> -
> - @retval EFI_INVALID_PARAMETER Language is NULL.
> -
> - @retval EFI_INVALID_PARAMETER DriverName is NULL.
> -
> - @retval EFI_UNSUPPORTED The driver specified by This does not support
> - the language specified by Language.
> -
> -**/
> -EFI_STATUS
> -EFIAPI
> -PxeBcComponentNameGetDriverName (
> - IN EFI_COMPONENT_NAME_PROTOCOL * This,
> - IN CHAR8 *Language,
> - OUT CHAR16 **DriverName
> - )
> -{
> - return LookupUnicodeString2 (
> - Language,
> - This->SupportedLanguages,
> - mPxeBcDriverNameTable,
> - DriverName,
> - (BOOLEAN)(This == &gPxeBcComponentName)
> - );
> -}
> -
> -/**
> - Retrieves a Unicode string that is the user readable name of the controller
> - that is being managed by a driver.
> -
> - This function retrieves the user readable name of the controller specified by
> - ControllerHandle and ChildHandle in the form of a Unicode string. If the
> - driver specified by This has a user readable name in the language specified by
> - Language, then a pointer to the controller name is returned in ControllerName,
> - and EFI_SUCCESS is returned. If the driver specified by This is not currently
> - managing the controller specified by ControllerHandle and ChildHandle,
> - then EFI_UNSUPPORTED is returned. If the driver specified by This does not
> - support the language specified by Language, then EFI_UNSUPPORTED is
> returned.
> -
> - @param[in] This A pointer to the
> EFI_COMPONENT_NAME2_PROTOCOL or
> - EFI_COMPONENT_NAME_PROTOCOL instance.
> -
> - @param[in] ControllerHandle The handle of a controller that the driver
> - specified by This is managing. This handle
> - specifies the controller whose name is to be
> - returned.
> -
> - @param[in] ChildHandle The handle of the child controller to retrieve
> - the name of. This is an optional parameter that
> - may be NULL. It will be NULL for device
> - drivers. It will also be NULL for a bus drivers
> - that wish to retrieve the name of the bus
> - controller. It will not be NULL for a bus
> - driver that wishes to retrieve the name of a
> - child controller.
> -
> - @param[in] Language A pointer to a Null-terminated ASCII string
> - array indicating the language. This is the
> - language of the driver name that the caller is
> - requesting, and it must match one of the
> - languages specified in SupportedLanguages. The
> - number of languages supported by a driver is up
> - to the driver writer. Language is specified in
> - RFC 4646 or ISO 639-2 language code format.
> -
> - @param[out] ControllerName A pointer to the Unicode string to return.
> - This Unicode string is the name of the
> - controller specified by ControllerHandle and
> - ChildHandle in the language specified by
> - Language from the point of view of the driver
> - specified by This.
> -
> - @retval EFI_SUCCESS The Unicode string for the user readable name in
> - the language specified by Language for the
> - driver specified by This was returned in
> - DriverName.
> -
> - @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
> -
> - @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
> - EFI_HANDLE.
> -
> - @retval EFI_INVALID_PARAMETER Language is NULL.
> -
> - @retval EFI_INVALID_PARAMETER ControllerName is NULL.
> -
> - @retval EFI_UNSUPPORTED The driver specified by This is not currently
> - managing the controller specified by
> - ControllerHandle and ChildHandle.
> -
> - @retval EFI_UNSUPPORTED The driver specified by This does not support
> - the language specified by Language.
> -
> -**/
> -EFI_STATUS
> -EFIAPI
> -PxeBcComponentNameGetControllerName (
> - IN EFI_COMPONENT_NAME_PROTOCOL * This,
> - IN EFI_HANDLE ControllerHandle,
> - IN EFI_HANDLE ChildHandle OPTIONAL,
> - IN CHAR8 *Language,
> - OUT CHAR16 **ControllerName
> - )
> -{
> - EFI_PXE_BASE_CODE_PROTOCOL *PxeBc;
> - EFI_HANDLE NicHandle;
> - EFI_STATUS Status;
> -
> - if (ControllerHandle == NULL || ChildHandle != NULL) {
> - return EFI_UNSUPPORTED;
> - }
> -
> - NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiArpProtocolGuid);
> - if (NicHandle == NULL) {
> - NicHandle = NetLibGetNicHandle (ControllerHandle,
> &gEfiDhcp4ProtocolGuid);
> -
> - if (NicHandle == NULL) {
> - NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiIp4ProtocolGuid);
> -
> - if (NicHandle == NULL) {
> - NicHandle = NetLibGetNicHandle (ControllerHandle,
> &gEfiUdp4ProtocolGuid);
> -
> - if (NicHandle == NULL) {
> - NicHandle = NetLibGetNicHandle (ControllerHandle,
> &gEfiMtftp4ProtocolGuid);
> -
> - if (NicHandle == NULL) {
> - return EFI_UNSUPPORTED;
> - }
> - }
> - }
> - }
> - }
> -
> - Status = gBS->OpenProtocol (
> - NicHandle,
> - &gEfiPxeBaseCodeProtocolGuid,
> - (VOID **) &PxeBc,
> - NULL,
> - NULL,
> - EFI_OPEN_PROTOCOL_GET_PROTOCOL
> - );
> -
> - if (EFI_ERROR (Status)) {
> - return Status;
> - }
> -
> - return LookupUnicodeString2 (
> - Language,
> - This->SupportedLanguages,
> - mPxeBcControllerNameTable,
> - ControllerName,
> - (BOOLEAN)(This == &gPxeBcComponentName)
> - );
> -}
> diff --git a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDhcp.c
> b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDhcp.c
> deleted file mode 100644
> index f7b975f2997f..000000000000
> --- a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDhcp.c
> +++ /dev/null
> @@ -1,1999 +0,0 @@
> -/** @file
> - Support for PxeBc dhcp functions.
> -
> -Copyright (c) 2013, Red Hat, Inc.
> -Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
> -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
> -http://opensource.org/licenses/bsd-license.php
> -
> -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS
> OR IMPLIED.
> -
> -**/
> -
> -
> -#include "PxeBcImpl.h"
> -
> -//
> -// This is a map from the interested DHCP4 option tags' index to the tag value.
> -//
> -UINT8 mInterestedDhcp4Tags[PXEBC_DHCP4_TAG_INDEX_MAX] = {
> - DHCP4_TAG_BOOTFILE_LEN,
> - DHCP4_TAG_VENDOR,
> - DHCP4_TAG_OVERLOAD,
> - DHCP4_TAG_MSG_TYPE,
> - DHCP4_TAG_SERVER_ID,
> - DHCP4_TAG_VENDOR_CLASS_ID,
> - DHCP4_TAG_BOOTFILE
> -};
> -
> -
> -/**
> - This function initialize the DHCP4 message instance.
> -
> - This function will pad each item of dhcp4 message packet.
> -
> - @param Seed Pointer to the message instance of the DHCP4 packet.
> - @param Udp4 Pointer to the EFI_UDP4_PROTOCOL instance.
> -
> -**/
> -VOID
> -PxeBcInitSeedPacket (
> - IN EFI_DHCP4_PACKET *Seed,
> - IN EFI_UDP4_PROTOCOL *Udp4
> - )
> -{
> - EFI_SIMPLE_NETWORK_MODE Mode;
> - EFI_DHCP4_HEADER *Header;
> -
> - Udp4->GetModeData (Udp4, NULL, NULL, NULL, &Mode);
> -
> - Seed->Size = sizeof (EFI_DHCP4_PACKET);
> - Seed->Length = sizeof (Seed->Dhcp4);
> -
> - Header = &Seed->Dhcp4.Header;
> -
> - ZeroMem (Header, sizeof (EFI_DHCP4_HEADER));
> - Header->OpCode = PXEBC_DHCP4_OPCODE_REQUEST;
> - Header->HwType = Mode.IfType;
> - Header->HwAddrLen = (UINT8) Mode.HwAddressSize;
> - CopyMem (Header->ClientHwAddr, &Mode.CurrentAddress, Header-
> >HwAddrLen);
> -
> - Seed->Dhcp4.Magik = PXEBC_DHCP4_MAGIC;
> - Seed->Dhcp4.Option[0] = DHCP4_TAG_EOP;
> -}
> -
> -
> -/**
> - Copy the DCHP4 packet from srouce to destination.
> -
> - @param[in] Dst Pointer to the cache buffer for DHCPv4 packet.
> - @param[in] Src Pointer to the DHCPv4 packet to be cached.
> -
> - @retval EFI_SUCCESS Packet is copied.
> - @retval EFI_BUFFER_TOO_SMALL Cache buffer is not big enough to hold
> the packet.
> -
> -**/
> -EFI_STATUS
> -PxeBcCopyEfiDhcp4Packet (
> - IN EFI_DHCP4_PACKET *Dst,
> - IN EFI_DHCP4_PACKET *Src
> - )
> -{
> - if (Dst->Size < Src->Length) {
> - return EFI_BUFFER_TOO_SMALL;
> - }
> -
> - CopyMem (&Dst->Dhcp4, &Src->Dhcp4, Src->Length);
> - Dst->Length = Src->Length;
> - return EFI_SUCCESS;
> -}
> -
> -
> -/**
> - Copy the dhcp4 packet to the PxeBc private data and parse the dhcp4 packet.
> -
> - @param Private Pointer to PxeBc private data.
> - @param OfferIndex Index of cached packets as complements of pxe mode
> data,
> - the index is maximum offer number.
> -
> - @retval EFI_SUCCESS Cache and parse the packet successfully.
> - @retval EFI_BUFFER_TOO_SMALL Cache buffer is not big enough to hold
> the packet.
> -
> -**/
> -EFI_STATUS
> -PxeBcCopyProxyOffer (
> - IN PXEBC_PRIVATE_DATA *Private,
> - IN UINT32 OfferIndex
> - )
> -{
> - EFI_PXE_BASE_CODE_MODE *Mode;
> - EFI_DHCP4_PACKET *Offer;
> - EFI_STATUS Status;
> -
> - ASSERT (OfferIndex < Private->NumOffers);
> - ASSERT (OfferIndex < PXEBC_MAX_OFFER_NUM);
> -
> - Mode = Private->PxeBc.Mode;
> - Offer = &Private->Dhcp4Offers[OfferIndex].Packet.Offer;
> -
> - Status = PxeBcCopyEfiDhcp4Packet (&Private->ProxyOffer.Packet.Offer,
> Offer);
> - if (EFI_ERROR(Status)) {
> - return Status;
> - }
> - CopyMem (&Mode->ProxyOffer, &Offer->Dhcp4, Offer->Length);
> - Mode->ProxyOfferReceived = TRUE;
> -
> - PxeBcParseCachedDhcpPacket (&Private->ProxyOffer);
> - return EFI_SUCCESS;
> -}
> -
> -
> -/**
> - Parse the cached dhcp packet.
> -
> - @param CachedPacket Pointer to cached dhcp packet.
> -
> - @retval TRUE Succeed to parse and validation.
> - @retval FALSE Fail to parse or validation.
> -
> -**/
> -BOOLEAN
> -PxeBcParseCachedDhcpPacket (
> - IN PXEBC_CACHED_DHCP4_PACKET *CachedPacket
> - )
> -{
> - EFI_DHCP4_PACKET *Offer;
> - EFI_DHCP4_PACKET_OPTION **Options;
> - EFI_DHCP4_PACKET_OPTION *Option;
> - UINT8 OfferType;
> - UINTN Index;
> - UINT8 *Ptr8;
> -
> - CachedPacket->IsPxeOffer = FALSE;
> - ZeroMem (CachedPacket->Dhcp4Option, sizeof (CachedPacket-
> >Dhcp4Option));
> - ZeroMem (&CachedPacket->PxeVendorOption, sizeof (CachedPacket-
> >PxeVendorOption));
> -
> - Offer = &CachedPacket->Packet.Offer;
> - Options = CachedPacket->Dhcp4Option;
> -
> - //
> - // Parse interested dhcp options and store their pointers in CachedPacket-
> >Dhcp4Option.
> - // First, try to parse DHCPv4 options from the DHCP optional parameters field.
> - //
> - for (Index = 0; Index < PXEBC_DHCP4_TAG_INDEX_MAX; Index++) {
> - Options[Index] = PxeBcParseExtendOptions (
> - Offer->Dhcp4.Option,
> - GET_OPTION_BUFFER_LEN (Offer),
> - mInterestedDhcp4Tags[Index]
> - );
> - }
> - //
> - // Second, Check if bootfilename and serverhostname is overloaded to carry
> DHCP options refers to rfc-2132.
> - // If yes, try to parse options from the BootFileName field, then ServerName
> field.
> - //
> - Option = Options[PXEBC_DHCP4_TAG_INDEX_OVERLOAD];
> - if (Option != NULL) {
> - if ((Option->Data[0] & PXEBC_DHCP4_OVERLOAD_FILE) != 0) {
> - for (Index = 0; Index < PXEBC_DHCP4_TAG_INDEX_MAX; Index++) {
> - if (Options[Index] == NULL) {
> - Options[Index] = PxeBcParseExtendOptions (
> - (UINT8 *) Offer->Dhcp4.Header.BootFileName,
> - sizeof (Offer->Dhcp4.Header.BootFileName),
> - mInterestedDhcp4Tags[Index]
> - );
> - }
> - }
> - }
> - if ((Option->Data[0] & PXEBC_DHCP4_OVERLOAD_SERVER_NAME) != 0) {
> - for (Index = 0; Index < PXEBC_DHCP4_TAG_INDEX_MAX; Index++) {
> - if (Options[Index] == NULL) {
> - Options[Index] = PxeBcParseExtendOptions (
> - (UINT8 *) Offer->Dhcp4.Header.ServerName,
> - sizeof (Offer->Dhcp4.Header.ServerName),
> - mInterestedDhcp4Tags[Index]
> - );
> - }
> - }
> - }
> - }
> -
> - //
> - // Check whether is an offer with PXEClient or not.
> - //
> - Option = Options[PXEBC_DHCP4_TAG_INDEX_CLASS_ID];
> - if ((Option != NULL) && (Option->Length >= 9) &&
> - (CompareMem (Option->Data, DEFAULT_CLASS_ID_DATA, 9) == 0)) {
> -
> - CachedPacket->IsPxeOffer = TRUE;
> - }
> -
> - //
> - // Parse pxe vendor options and store their content/pointers in CachedPacket-
> >PxeVendorOption.
> - //
> - Option = Options[PXEBC_DHCP4_TAG_INDEX_VENDOR];
> - if (CachedPacket->IsPxeOffer && (Option != NULL)) {
> -
> - if (!PxeBcParseVendorOptions (Option, &CachedPacket->PxeVendorOption)) {
> - return FALSE;
> - }
> - }
> -
> -
> - //
> - // Parse PXE boot file name:
> - // According to PXE spec, boot file name should be read from DHCP option 67
> (bootfile name) if present.
> - // Otherwise, read from boot file field in DHCP header.
> - //
> - if (Options[PXEBC_DHCP4_TAG_INDEX_BOOTFILE] != NULL) {
> - //
> - // RFC 2132, Section 9.5 does not strictly state Bootfile name (option 67) is
> null
> - // terminated string. So force to append null terminated character at the end
> of string.
> - //
> - Ptr8 = (UINT8*)&Options[PXEBC_DHCP4_TAG_INDEX_BOOTFILE]->Data[0];
> - Ptr8 += Options[PXEBC_DHCP4_TAG_INDEX_BOOTFILE]->Length;
> - if (*(Ptr8 - 1) != '\0') {
> - *Ptr8 = '\0';
> - }
> - } else if (Offer->Dhcp4.Header.BootFileName[0] != 0) {
> - //
> - // If the bootfile is not present and bootfilename is present in dhcp packet,
> just parse it.
> - // And do not count dhcp option header, or else will destroy the
> serverhostname.
> - //
> - // Make sure "BootFileName" is not overloaded.
> - //
> - if (Options[PXEBC_DHCP4_TAG_INDEX_OVERLOAD] == NULL ||
> - (Options[PXEBC_DHCP4_TAG_INDEX_OVERLOAD]->Data[0] &
> PXEBC_DHCP4_OVERLOAD_FILE) == 0) {
> - Options[PXEBC_DHCP4_TAG_INDEX_BOOTFILE] =
> (EFI_DHCP4_PACKET_OPTION *) (&Offer->Dhcp4.Header.BootFileName[0] -
> - OFFSET_OF (EFI_DHCP4_PACKET_OPTION, Data[0]));
> - }
> - }
> -
> - //
> - // Determine offer type of the dhcp packet.
> - //
> - Option = Options[PXEBC_DHCP4_TAG_INDEX_MSG_TYPE];
> - if ((Option == NULL) || (Option->Data[0] == 0)) {
> - //
> - // It's a bootp offer
> - //
> - Option = CachedPacket-
> >Dhcp4Option[PXEBC_DHCP4_TAG_INDEX_BOOTFILE];
> - if (Option == NULL) {
> - //
> - // bootp offer without bootfilename, discard it.
> - //
> - return FALSE;
> - }
> -
> - OfferType = DHCP4_PACKET_TYPE_BOOTP;
> -
> - } else {
> -
> - if (IS_VALID_DISCOVER_VENDOR_OPTION (CachedPacket-
> >PxeVendorOption.BitMap)) {
> - //
> - // It's a pxe10 offer with PXEClient and discover vendor option.
> - //
> - OfferType = DHCP4_PACKET_TYPE_PXE10;
> - } else if (IS_VALID_MTFTP_VENDOR_OPTION (CachedPacket-
> >PxeVendorOption.BitMap)) {
> - //
> - // It's a wfm11a offer with PXEClient and mtftp vendor option, and
> - // return false since mtftp not supported currently.
> - //
> - return FALSE;
> - } else {
> - //
> - // If the binl offer with only PXEClient.
> - //
> - OfferType = (UINT8) ((CachedPacket->IsPxeOffer) ?
> DHCP4_PACKET_TYPE_BINL : DHCP4_PACKET_TYPE_DHCP_ONLY);
> - }
> - }
> -
> - CachedPacket->OfferType = OfferType;
> -
> - return TRUE;
> -}
> -
> -
> -/**
> - Offer dhcp service with a BINL dhcp offer.
> -
> - @param Private Pointer to PxeBc private data.
> - @param Index Index of cached packets as complements of pxe mode data,
> - the index is maximum offer number.
> -
> - @retval TRUE Offer the service successfully under priority BINL.
> - @retval FALSE Boot Service failed, parse cached dhcp packet failed or this
> - BINL ack cannot find options set or bootfile name specified.
> -
> -**/
> -BOOLEAN
> -PxeBcTryBinl (
> - IN PXEBC_PRIVATE_DATA *Private,
> - IN UINT32 Index
> - )
> -{
> - EFI_DHCP4_PACKET *Offer;
> - EFI_IP_ADDRESS ServerIp;
> - EFI_STATUS Status;
> - PXEBC_CACHED_DHCP4_PACKET *CachedPacket;
> - EFI_DHCP4_PACKET *Reply;
> -
> - ASSERT (Index < PXEBC_MAX_OFFER_NUM);
> - ASSERT (Private->Dhcp4Offers[Index].OfferType ==
> DHCP4_PACKET_TYPE_BINL);
> -
> - Offer = &Private->Dhcp4Offers[Index].Packet.Offer;
> -
> - //
> - // 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 (EFI_IP4_EQUAL (&Offer->Dhcp4.Header.ServerAddr.Addr, &mZeroIp4Addr))
> {
> - CopyMem (
> - &ServerIp.Addr[0],
> - Private-
> >Dhcp4Offers[Index].Dhcp4Option[PXEBC_DHCP4_TAG_INDEX_SERVER_ID]-
> >Data,
> - sizeof (EFI_IPv4_ADDRESS)
> - );
> - } else {
> - CopyMem (
> - &ServerIp.Addr[0],
> - &Offer->Dhcp4.Header.ServerAddr,
> - sizeof (EFI_IPv4_ADDRESS)
> - );
> - }
> - if (ServerIp.Addr[0] == 0) {
> - return FALSE;
> - }
> -
> - CachedPacket = &Private->ProxyOffer;
> - Reply = &CachedPacket->Packet.Offer;
> -
> - Status = PxeBcDiscvBootService (
> - Private,
> - 0,
> - NULL,
> - FALSE,
> - &ServerIp,
> - 0,
> - NULL,
> - FALSE,
> - Reply
> - );
> - if (EFI_ERROR (Status)) {
> - return FALSE;
> - }
> -
> - if (!PxeBcParseCachedDhcpPacket (CachedPacket)) {
> - return FALSE;
> - }
> -
> - if ((CachedPacket->OfferType != DHCP4_PACKET_TYPE_PXE10) &&
> - (CachedPacket->Dhcp4Option[PXEBC_DHCP4_TAG_INDEX_BOOTFILE] ==
> NULL)) {
> - //
> - // This BINL ack doesn't have discovery options set or bootfile name
> - // specified.
> - //
> - return FALSE;
> - }
> -
> - Private->PxeBc.Mode->ProxyOfferReceived = TRUE;
> - CopyMem (&Private->PxeBc.Mode->ProxyOffer, &Reply->Dhcp4, Reply-
> >Length);
> -
> - return TRUE;
> -}
> -
> -
> -/**
> - Offer dhcp service for each proxy with a BINL dhcp offer.
> -
> - @param Private Pointer to PxeBc private data
> - @param OfferIndex Pointer to the index of cached packets as complements
> of
> - pxe mode data, the index is maximum offer number.
> -
> - @return If there is no service needed offer return FALSE, otherwise TRUE.
> -
> -**/
> -BOOLEAN
> -PxeBcTryBinlProxy (
> - IN PXEBC_PRIVATE_DATA *Private,
> - OUT UINT32 *OfferIndex
> - )
> -{
> - UINT32 Index;
> -
> - for (Index = 0; Index < Private->ProxyIndex[DHCP4_PACKET_TYPE_BINL];
> Index++) {
> -
> - *OfferIndex = Private->BinlIndex[Index];
> - //
> - // Try this BINL proxy offer
> - //
> - if (PxeBcTryBinl (Private, *OfferIndex)) {
> - return TRUE;
> - }
> - }
> -
> - return FALSE;
> -}
> -
> -
> -/**
> - This function is to check the selected proxy offer (include BINL dhcp offer and
> - DHCP_ONLY offer ) and set the flag and copy the DHCP packets to the Pxe
> base code
> - mode structure.
> -
> - @param Private Pointer to PxeBc private data.
> -
> - @retval EFI_SUCCESS Operational successful.
> - @retval EFI_NO_RESPONSE Offer dhcp service failed.
> - @retval EFI_BUFFER_TOO_SMALL Failed to copy the packet to Pxe base
> code mode.
> -
> -**/
> -EFI_STATUS
> -PxeBcCheckSelectedOffer (
> - IN PXEBC_PRIVATE_DATA *Private
> - )
> -{
> - PXEBC_CACHED_DHCP4_PACKET *SelectedOffer;
> - EFI_DHCP4_PACKET_OPTION **Options;
> - UINT32 Index;
> - EFI_DHCP4_PACKET *Offer;
> - UINT32 ProxyOfferIndex;
> - EFI_STATUS Status;
> - EFI_PXE_BASE_CODE_MODE *Mode;
> - EFI_DHCP4_PACKET *Ack;
> -
> - ASSERT (Private->SelectedOffer != 0);
> -
> - Status = EFI_SUCCESS;
> - SelectedOffer = &Private->Dhcp4Offers[Private->SelectedOffer - 1];
> - Options = SelectedOffer->Dhcp4Option;
> -
> - if (SelectedOffer->OfferType == DHCP4_PACKET_TYPE_BINL) {
> - //
> - // The addresses are acquired from a BINL dhcp offer, try BINL to get
> - // the bootfile name
> - //
> - if (!PxeBcTryBinl (Private, Private->SelectedOffer - 1)) {
> - Status = EFI_NO_RESPONSE;
> - }
> - } else if (SelectedOffer->OfferType == DHCP4_PACKET_TYPE_DHCP_ONLY) {
> - //
> - // The selected offer to finish the D.O.R.A. is a DHCP only offer, we need
> - // try proxy offers if there are some, othewise the bootfile name must be
> - // set in this DHCP only offer.
> - //
> - if (Private->GotProxyOffer) {
> - //
> - // Get rid of the compiler warning.
> - //
> - ProxyOfferIndex = 0;
> - if (Private->SortOffers) {
> - //
> - // The offers are sorted before selecting, the proxy offer type must be
> - // already determined.
> - //
> - ASSERT (Private->ProxyIndex[Private->ProxyOfferType] > 0);
> -
> - if (Private->ProxyOfferType == DHCP4_PACKET_TYPE_BINL) {
> - //
> - // We buffer all received BINL proxy offers, try them all one by one
> - //
> - if (!PxeBcTryBinlProxy (Private, &ProxyOfferIndex)) {
> - Status = EFI_NO_RESPONSE;
> - }
> - } else {
> - //
> - // For other types, only one proxy offer is buffered.
> - //
> - ProxyOfferIndex = Private->ProxyIndex[Private->ProxyOfferType] - 1;
> - }
> - } else {
> - //
> - // The proxy offer type is not determined, choose proxy offer in the
> - // received order.
> - //
> - Status = EFI_NO_RESPONSE;
> -
> - ASSERT (Private->NumOffers < PXEBC_MAX_OFFER_NUM);
> - for (Index = 0; Index < Private->NumOffers; Index++) {
> -
> - Offer = &Private->Dhcp4Offers[Index].Packet.Offer;
> - if (!IS_PROXY_DHCP_OFFER (Offer)) {
> - //
> - // Skip non proxy dhcp offers.
> - //
> - continue;
> - }
> -
> - if (Private->Dhcp4Offers[Index].OfferType == DHCP4_PACKET_TYPE_BINL)
> {
> - //
> - // Try BINL
> - //
> - if (!PxeBcTryBinl (Private, Index)) {
> - //
> - // Failed, skip to the next offer
> - //
> - continue;
> - }
> - }
> -
> - Private->ProxyOfferType = Private->Dhcp4Offers[Index].OfferType;
> - ProxyOfferIndex = Index;
> - Status = EFI_SUCCESS;
> - break;
> - }
> - }
> -
> - if (!EFI_ERROR (Status) && (Private->ProxyOfferType !=
> DHCP4_PACKET_TYPE_BINL)) {
> - //
> - // Copy the proxy offer to Mode and set the flag
> - //
> - Status = PxeBcCopyProxyOffer (Private, ProxyOfferIndex);
> - }
> - } else {
> - //
> - // No proxy offer is received, the bootfile name MUST be set.
> - //
> - ASSERT (Options[PXEBC_DHCP4_TAG_INDEX_BOOTFILE] != NULL);
> - }
> - }
> -
> - if (!EFI_ERROR (Status)) {
> - //
> - // Everything is OK, set the flag and copy the DHCP packets.
> - //
> - Mode = Private->PxeBc.Mode;
> - Offer = &SelectedOffer->Packet.Offer;
> -
> - //
> - // The discover packet is already copied, just set flag here.
> - //
> - Mode->DhcpDiscoverValid = TRUE;
> -
> - Ack = &Private->Dhcp4Ack.Packet.Ack;
> - if (SelectedOffer->OfferType == DHCP4_PACKET_TYPE_BOOTP) {
> - //
> - // Other type of ACK is already cached. Bootp is special that we should
> - // use the bootp reply as the ACK and put it into the DHCP_ONLY buffer.
> - //
> - Status = PxeBcCopyEfiDhcp4Packet (&Private->Dhcp4Ack.Packet.Ack, Offer);
> - }
> -
> - PxeBcParseCachedDhcpPacket (&Private->Dhcp4Ack);
> -
> - Mode->DhcpAckReceived = TRUE;
> -
> - //
> - // Copy the dhcp ack.
> - //
> - CopyMem (&Mode->DhcpAck, &Ack->Dhcp4, Ack->Length);
> - }
> -
> - return Status;
> -}
> -
> -
> -/**
> - Cache the Dhcp4 packet offer, Parse and validate each option of the packet.
> -
> - @param Private Pointer to PxeBc private data.
> - @param RcvdOffer Pointer to the received Dhcp proxy offer packet.
> -
> - @retval EFI_SUCCESS Cache and parse the packet successfully.
> - @retval Others Operation failed.
> -
> -**/
> -EFI_STATUS
> -PxeBcCacheDhcpOffer (
> - IN PXEBC_PRIVATE_DATA *Private,
> - IN EFI_DHCP4_PACKET *RcvdOffer
> - )
> -{
> - PXEBC_CACHED_DHCP4_PACKET *CachedOffer;
> - EFI_DHCP4_PACKET *Offer;
> - UINT8 OfferType;
> - EFI_STATUS Status;
> -
> - CachedOffer = &Private->Dhcp4Offers[Private->NumOffers];
> - Offer = &CachedOffer->Packet.Offer;
> -
> - //
> - // Cache the orignal dhcp packet
> - //
> - Status = PxeBcCopyEfiDhcp4Packet (Offer, RcvdOffer);
> - if (EFI_ERROR(Status)) {
> - return Status;
> - }
> -
> - //
> - // Parse and validate the options (including dhcp option and vendor option)
> - //
> - if (!PxeBcParseCachedDhcpPacket (CachedOffer)) {
> - return EFI_ABORTED;
> - }
> -
> - OfferType = CachedOffer->OfferType;
> - if (OfferType >= DHCP4_PACKET_TYPE_MAX) {
> - return EFI_ABORTED;
> - }
> -
> - if (OfferType == DHCP4_PACKET_TYPE_BOOTP) {
> -
> - if (Private->BootpIndex != 0) {
> - //
> - // Only cache the first bootp offer, discard others.
> - //
> - return EFI_ABORTED;
> - } else {
> - //
> - // Take as a dhcp only offer, but record index specifically.
> - //
> - Private->BootpIndex = Private->NumOffers + 1;
> - }
> - } else {
> -
> - if (IS_PROXY_DHCP_OFFER (Offer)) {
> - //
> - // It's a proxy dhcp offer with no your address, including pxe10, wfm11a or
> binl offer.
> - //
> - Private->GotProxyOffer = TRUE;
> -
> - if (OfferType == DHCP4_PACKET_TYPE_BINL) {
> - //
> - // Cache all binl offers.
> - //
> - Private->BinlIndex[Private->ProxyIndex[DHCP4_PACKET_TYPE_BINL]] =
> Private->NumOffers;
> - Private->ProxyIndex[DHCP4_PACKET_TYPE_BINL]++;
> - } else if (Private->ProxyIndex[OfferType] != 0) {
> - //
> - // Only cache the first pxe10/wfm11a offers each, discard the others.
> - //
> - return EFI_ABORTED;
> - } else {
> - //
> - // Record index of the proxy dhcp offer with type other than binl.
> - //
> - Private->ProxyIndex[OfferType] = Private->NumOffers + 1;
> - }
> - } else {
> - //
> - // It's a dhcp offer with your address.
> - //
> - ASSERT (Private->ServerCount[OfferType] < PXEBC_MAX_OFFER_NUM);
> - Private->OfferIndex[OfferType][Private->ServerCount[OfferType]] =
> Private->NumOffers;
> - Private->ServerCount[OfferType]++;
> - }
> - }
> -
> - //
> - // Count the accepted offers.
> - //
> - Private->NumOffers++;
> -
> - return EFI_SUCCESS;
> -}
> -
> -/**
> - Switch the Ip4 policy to static.
> -
> - @param[in] Private The pointer to PXEBC_PRIVATE_DATA.
> -
> - @retval EFI_SUCCESS The policy is already configured to static.
> - @retval Others Other error as indicated..
> -
> -**/
> -EFI_STATUS
> -PxeBcSetIp4Policy (
> - IN PXEBC_PRIVATE_DATA *Private
> - )
> -{
> - EFI_STATUS Status;
> - EFI_IP4_CONFIG2_PROTOCOL *Ip4Config2;
> - EFI_IP4_CONFIG2_POLICY Policy;
> - UINTN DataSize;
> -
> - Ip4Config2 = Private->Ip4Config2;
> - DataSize = sizeof (EFI_IP4_CONFIG2_POLICY);
> - Status = Ip4Config2->GetData (
> - Ip4Config2,
> - Ip4Config2DataTypePolicy,
> - &DataSize,
> - &Policy
> - );
> - if (EFI_ERROR (Status)) {
> - return Status;
> - }
> -
> - if (Policy != Ip4Config2PolicyStatic) {
> - Policy = Ip4Config2PolicyStatic;
> - Status= Ip4Config2->SetData (
> - Ip4Config2,
> - Ip4Config2DataTypePolicy,
> - sizeof (EFI_IP4_CONFIG2_POLICY),
> - &Policy
> - );
> - if (EFI_ERROR (Status)) {
> - return Status;
> - }
> - }
> -
> - return EFI_SUCCESS;
> -}
> -
> -
> -/**
> - Select the specified proxy offer, such as BINL, DHCP_ONLY and so on.
> - If the proxy does not exist, try offers with bootfile.
> -
> - @param Private Pointer to PxeBc private data.
> -
> -**/
> -VOID
> -PxeBcSelectOffer (
> - IN PXEBC_PRIVATE_DATA *Private
> - )
> -{
> - UINT32 Index;
> - UINT32 OfferIndex;
> - EFI_DHCP4_PACKET *Offer;
> -
> - Private->SelectedOffer = 0;
> -
> - if (Private->SortOffers) {
> - //
> - // Select offer according to the priority
> - //
> - if (Private->ServerCount[DHCP4_PACKET_TYPE_PXE10] > 0) {
> - //
> - // DHCP with PXE10
> - //
> - Private->SelectedOffer = Private-
> >OfferIndex[DHCP4_PACKET_TYPE_PXE10][0] + 1;
> -
> - } else if (Private->ServerCount[DHCP4_PACKET_TYPE_WFM11A] > 0) {
> - //
> - // DHCP with WfM
> - //
> - Private->SelectedOffer = Private-
> >OfferIndex[DHCP4_PACKET_TYPE_WFM11A][0] + 1;
> -
> - } else if ((Private->ProxyIndex[DHCP4_PACKET_TYPE_PXE10] > 0) &&
> - (Private->ServerCount[DHCP4_PACKET_TYPE_DHCP_ONLY] > 0)
> - ) {
> - //
> - // DHCP only and proxy DHCP with PXE10
> - //
> - Private->SelectedOffer = Private-
> >OfferIndex[DHCP4_PACKET_TYPE_DHCP_ONLY][0] + 1;
> - Private->ProxyOfferType = DHCP4_PACKET_TYPE_PXE10;
> -
> - } else if ((Private->ProxyIndex[DHCP4_PACKET_TYPE_WFM11A] > 0) &&
> - (Private->ServerCount[DHCP4_PACKET_TYPE_DHCP_ONLY] > 0)
> - ) {
> - //
> - // DHCP only and proxy DHCP with WfM
> - //
> - Private->SelectedOffer = Private-
> >OfferIndex[DHCP4_PACKET_TYPE_DHCP_ONLY][0] + 1;
> - Private->ProxyOfferType = DHCP4_PACKET_TYPE_WFM11A;
> -
> - } else if (Private->ServerCount[DHCP4_PACKET_TYPE_BINL] > 0) {
> - //
> - // DHCP with BINL
> - //
> - Private->SelectedOffer = Private-
> >OfferIndex[DHCP4_PACKET_TYPE_BINL][0] + 1;
> -
> - } else if ((Private->ProxyIndex[DHCP4_PACKET_TYPE_BINL] > 0) &&
> - (Private->ServerCount[DHCP4_PACKET_TYPE_DHCP_ONLY] > 0)
> - ) {
> - //
> - // DHCP only and proxy DHCP with BINL
> - //
> - Private->SelectedOffer = Private-
> >OfferIndex[DHCP4_PACKET_TYPE_DHCP_ONLY][0] + 1;
> - Private->ProxyOfferType = DHCP4_PACKET_TYPE_BINL;
> -
> - } else {
> - //
> - // Try offers with bootfile
> - //
> - for (Index = 0; Index < Private-
> >ServerCount[DHCP4_PACKET_TYPE_DHCP_ONLY]; Index++) {
> - //
> - // Select the first DHCP only offer with bootfile
> - //
> - OfferIndex = Private-
> >OfferIndex[DHCP4_PACKET_TYPE_DHCP_ONLY][Index];
> - if (Private-
> >Dhcp4Offers[OfferIndex].Dhcp4Option[PXEBC_DHCP4_TAG_INDEX_BOOTFILE]
> != NULL) {
> - Private->SelectedOffer = OfferIndex + 1;
> - break;
> - }
> - }
> -
> - if (Private->SelectedOffer == 0) {
> - //
> - // Select the Bootp reply with bootfile if any
> - //
> - Private->SelectedOffer = Private->BootpIndex;
> - }
> - }
> - } else {
> - //
> - // Try the offers in the received order.
> - //
> - for (Index = 0; Index < Private->NumOffers; Index++) {
> -
> - Offer = &Private->Dhcp4Offers[Index].Packet.Offer;
> -
> - if (IS_PROXY_DHCP_OFFER (Offer)) {
> - //
> - // Skip proxy offers
> - //
> - continue;
> - }
> -
> - if ((Private->Dhcp4Offers[Index].OfferType ==
> DHCP4_PACKET_TYPE_DHCP_ONLY) &&
> - ((!Private->GotProxyOffer) && (Private-
> >Dhcp4Offers[Index].Dhcp4Option[PXEBC_DHCP4_TAG_INDEX_BOOTFILE] ==
> NULL))) {
> - //
> - // DHCP only offer but no proxy offer received and no bootfile option in
> this offer
> - //
> - continue;
> - }
> -
> - Private->SelectedOffer = Index + 1;
> - break;
> - }
> - }
> -}
> -
> -
> -/**
> - Callback routine.
> -
> - EFI_DHCP4_CALLBACK is provided by the consumer of the EFI DHCPv4
> Protocol driver
> - to intercept events that occurred in the configuration process. This structure
> - provides advanced control of each state transition of the DHCP process. The
> - returned status code determines the behavior of the EFI DHCPv4 Protocol
> driver.
> - There are three possible returned values, which are described in the following
> - table.
> -
> - @param This Pointer to the EFI DHCPv4 Protocol instance that is
> used to
> - configure this callback function.
> - @param Context Pointer to the context that is initialized by
> - EFI_DHCP4_PROTOCOL.Configure().
> - @param CurrentState The current operational state of the EFI DHCPv4
> Protocol
> - driver.
> - @param Dhcp4Event The event that occurs in the current state, which
> usually means a
> - state transition.
> - @param Packet The DHCP packet that is going to be sent or already
> received.
> - @param NewPacket The packet that is used to replace the above
> Packet.
> -
> - @retval EFI_SUCCESS Tells the EFI DHCPv4 Protocol driver to continue
> the DHCP process.
> - @retval EFI_NOT_READY Only used in the Dhcp4Selecting state. The EFI
> DHCPv4 Protocol
> - driver will continue to wait for more DHCPOFFER packets until
> the retry
> - timeout expires.
> - @retval EFI_ABORTED Tells the EFI DHCPv4 Protocol driver to abort the
> current process and
> - return to the Dhcp4Init or Dhcp4InitReboot state.
> -
> -**/
> -EFI_STATUS
> -EFIAPI
> -PxeBcDhcpCallBack (
> - IN EFI_DHCP4_PROTOCOL * This,
> - IN VOID *Context,
> - IN EFI_DHCP4_STATE CurrentState,
> - IN EFI_DHCP4_EVENT Dhcp4Event,
> - IN EFI_DHCP4_PACKET * Packet OPTIONAL,
> - OUT EFI_DHCP4_PACKET **NewPacket OPTIONAL
> - )
> -{
> - PXEBC_PRIVATE_DATA *Private;
> - EFI_PXE_BASE_CODE_MODE *Mode;
> - EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL *Callback;
> - EFI_DHCP4_PACKET_OPTION *MaxMsgSize;
> - UINT16 Value;
> - EFI_STATUS Status;
> - BOOLEAN Received;
> - EFI_DHCP4_HEADER *DhcpHeader;
> -
> - if ((Dhcp4Event != Dhcp4RcvdOffer) &&
> - (Dhcp4Event != Dhcp4SelectOffer) &&
> - (Dhcp4Event != Dhcp4SendDiscover) &&
> - (Dhcp4Event != Dhcp4RcvdAck) &&
> - (Dhcp4Event != Dhcp4SendRequest)) {
> - return EFI_SUCCESS;
> - }
> -
> - Private = (PXEBC_PRIVATE_DATA *) Context;
> - Mode = Private->PxeBc.Mode;
> - Callback = Private->PxeBcCallback;
> -
> - //
> - // Override the Maximum DHCP Message Size.
> - //
> - MaxMsgSize = PxeBcParseExtendOptions (
> - Packet->Dhcp4.Option,
> - GET_OPTION_BUFFER_LEN (Packet),
> - DHCP4_TAG_MAXMSG
> - );
> - if (MaxMsgSize != NULL) {
> - Value = HTONS (PXEBC_DHCP4_MAX_PACKET_SIZE);
> - CopyMem (MaxMsgSize->Data, &Value, sizeof (Value));
> - }
> -
> - if ((Dhcp4Event != Dhcp4SelectOffer) && (Callback != NULL)) {
> - Received = (BOOLEAN) ((Dhcp4Event == Dhcp4RcvdOffer) || (Dhcp4Event ==
> Dhcp4RcvdAck));
> - Status = Callback->Callback (
> - Callback,
> - Private->Function,
> - Received,
> - Packet->Length,
> - (EFI_PXE_BASE_CODE_PACKET *) &Packet->Dhcp4
> - );
> - if (Status != EFI_PXE_BASE_CODE_CALLBACK_STATUS_CONTINUE) {
> - return EFI_ABORTED;
> - }
> - }
> -
> - Status = EFI_SUCCESS;
> -
> - switch (Dhcp4Event) {
> -
> - case Dhcp4SendDiscover:
> - case Dhcp4SendRequest:
> - if (Packet->Length > PXEBC_DHCP4_MAX_PACKET_SIZE) {
> - //
> - // If the to be sent packet exceeds the maximum length, abort the DHCP
> process.
> - //
> - Status = EFI_ABORTED;
> - break;
> - }
> -
> - if (Mode->SendGUID) {
> - //
> - // send the system GUID instead of the MAC address as the hardware
> address
> - // in the DHCP packet header.
> - //
> - DhcpHeader = &Packet->Dhcp4.Header;
> -
> - if (EFI_ERROR (NetLibGetSystemGuid ((EFI_GUID *) DhcpHeader-
> >ClientHwAddr))) {
> - //
> - // GUID not yet set - send all 0xff's to show programable (via SetVariable)
> - // SetMem(DHCPV4_OPTIONS_BUFFER.DhcpPlatformId.Guid,
> sizeof(EFI_GUID), 0xff);
> - // GUID not yet set - send all 0's to show not programable
> - //
> - DEBUG ((EFI_D_WARN, "PXE: Failed to read system GUID from the smbios
> table!\n"));
> - ZeroMem (DhcpHeader->ClientHwAddr, sizeof (EFI_GUID));
> - }
> -
> - DhcpHeader->HwAddrLen = (UINT8) sizeof (EFI_GUID);
> - }
> -
> - if (Dhcp4Event == Dhcp4SendDiscover) {
> - //
> - // Cache the dhcp discover packet, of which some information will be used
> later.
> - //
> - CopyMem (Mode->DhcpDiscover.Raw, &Packet->Dhcp4, Packet->Length);
> - }
> -
> - break;
> -
> - case Dhcp4RcvdOffer:
> - Status = EFI_NOT_READY;
> - if (Packet->Length > PXEBC_DHCP4_MAX_PACKET_SIZE) {
> - //
> - // Ignore the incoming Offers which exceed the maximum length.
> - //
> - break;
> - }
> -
> - if (Private->NumOffers < PXEBC_MAX_OFFER_NUM) {
> - //
> - // Cache the dhcp offers in Private->Dhcp4Offers[]
> - // If error happens, just ignore this packet and continue to wait more offer.
> - //
> - PxeBcCacheDhcpOffer (Private, Packet);
> - }
> -
> - break;
> -
> - case Dhcp4SelectOffer:
> - //
> - // Select an offer, if succeeded, Private->SelectedOffer points to
> - // the index of the selected one.
> - //
> - PxeBcSelectOffer (Private);
> -
> - if (Private->SelectedOffer == 0) {
> - Status = EFI_ABORTED;
> - } else {
> - *NewPacket = &Private->Dhcp4Offers[Private->SelectedOffer -
> 1].Packet.Offer;
> - }
> -
> - break;
> -
> - case Dhcp4RcvdAck:
> - //
> - // Cache Ack
> - //
> - ASSERT (Private->SelectedOffer != 0);
> -
> - Status = PxeBcCopyEfiDhcp4Packet (&Private->Dhcp4Ack.Packet.Ack, Packet);
> - if (EFI_ERROR (Status)) {
> - return EFI_ABORTED;
> - }
> - break;
> -
> - default:
> - break;
> - }
> -
> - return Status;
> -}
> -
> -
> -/**
> - Initialize the DHCP options and build the option list.
> -
> - @param Private Pointer to PxeBc private data.
> - @param OptList Pointer to a DHCP option list.
> -
> - @param IsDhcpDiscover Discover dhcp option or not.
> -
> - @return The index item number of the option list.
> -
> -**/
> -UINT32
> -PxeBcBuildDhcpOptions (
> - IN PXEBC_PRIVATE_DATA *Private,
> - IN EFI_DHCP4_PACKET_OPTION **OptList,
> - IN BOOLEAN IsDhcpDiscover
> - )
> -{
> - UINT32 Index;
> - PXEBC_DHCP4_OPTION_ENTRY OptEnt;
> - UINT16 Value;
> -
> - Index = 0;
> - OptList[0] = (EFI_DHCP4_PACKET_OPTION *) Private->OptionBuffer;
> -
> - if (!IsDhcpDiscover) {
> - //
> - // Append message type.
> - //
> - OptList[Index]->OpCode = DHCP4_TAG_MSG_TYPE;
> - OptList[Index]->Length = 1;
> - OptEnt.Mesg = (PXEBC_DHCP4_OPTION_MESG *) OptList[Index]-
> >Data;
> - OptEnt.Mesg->Type = PXEBC_DHCP4_MSG_TYPE_REQUEST;
> - Index++;
> - OptList[Index] = GET_NEXT_DHCP_OPTION (OptList[Index - 1]);
> -
> - //
> - // Append max message size.
> - //
> - OptList[Index]->OpCode = DHCP4_TAG_MAXMSG;
> - OptList[Index]->Length = (UINT8) sizeof
> (PXEBC_DHCP4_OPTION_MAX_MESG_SIZE);
> - OptEnt.MaxMesgSize = (PXEBC_DHCP4_OPTION_MAX_MESG_SIZE *)
> OptList[Index]->Data;
> - Value = NTOHS (PXEBC_DHCP4_MAX_PACKET_SIZE);
> - CopyMem (&OptEnt.MaxMesgSize->Size, &Value, sizeof (UINT16));
> - Index++;
> - OptList[Index] = GET_NEXT_DHCP_OPTION (OptList[Index - 1]);
> - }
> - //
> - // Parameter request list option.
> - //
> - OptList[Index]->OpCode = DHCP4_TAG_PARA_LIST;
> - OptList[Index]->Length = 35;
> - OptEnt.Para = (PXEBC_DHCP4_OPTION_PARA *) OptList[Index]->Data;
> - OptEnt.Para->ParaList[0] = DHCP4_TAG_NETMASK;
> - OptEnt.Para->ParaList[1] = DHCP4_TAG_TIME_OFFSET;
> - OptEnt.Para->ParaList[2] = DHCP4_TAG_ROUTER;
> - OptEnt.Para->ParaList[3] = DHCP4_TAG_TIME_SERVER;
> - OptEnt.Para->ParaList[4] = DHCP4_TAG_NAME_SERVER;
> - OptEnt.Para->ParaList[5] = DHCP4_TAG_DNS_SERVER;
> - OptEnt.Para->ParaList[6] = DHCP4_TAG_HOSTNAME;
> - OptEnt.Para->ParaList[7] = DHCP4_TAG_BOOTFILE_LEN;
> - OptEnt.Para->ParaList[8] = DHCP4_TAG_DOMAINNAME;
> - OptEnt.Para->ParaList[9] = DHCP4_TAG_ROOTPATH;
> - OptEnt.Para->ParaList[10] = DHCP4_TAG_EXTEND_PATH;
> - OptEnt.Para->ParaList[11] = DHCP4_TAG_EMTU;
> - OptEnt.Para->ParaList[12] = DHCP4_TAG_TTL;
> - OptEnt.Para->ParaList[13] = DHCP4_TAG_BROADCAST;
> - OptEnt.Para->ParaList[14] = DHCP4_TAG_NIS_DOMAIN;
> - OptEnt.Para->ParaList[15] = DHCP4_TAG_NIS_SERVER;
> - OptEnt.Para->ParaList[16] = DHCP4_TAG_NTP_SERVER;
> - OptEnt.Para->ParaList[17] = DHCP4_TAG_VENDOR;
> - OptEnt.Para->ParaList[18] = DHCP4_TAG_REQUEST_IP;
> - OptEnt.Para->ParaList[19] = DHCP4_TAG_LEASE;
> - OptEnt.Para->ParaList[20] = DHCP4_TAG_SERVER_ID;
> - OptEnt.Para->ParaList[21] = DHCP4_TAG_T1;
> - OptEnt.Para->ParaList[22] = DHCP4_TAG_T2;
> - OptEnt.Para->ParaList[23] = DHCP4_TAG_VENDOR_CLASS_ID;
> - OptEnt.Para->ParaList[24] = DHCP4_TAG_TFTP;
> - OptEnt.Para->ParaList[25] = DHCP4_TAG_BOOTFILE;
> - OptEnt.Para->ParaList[26] = DHCP4_TAG_UUID;
> - OptEnt.Para->ParaList[27] = 0x80;
> - OptEnt.Para->ParaList[28] = 0x81;
> - OptEnt.Para->ParaList[29] = 0x82;
> - OptEnt.Para->ParaList[30] = 0x83;
> - OptEnt.Para->ParaList[31] = 0x84;
> - OptEnt.Para->ParaList[32] = 0x85;
> - OptEnt.Para->ParaList[33] = 0x86;
> - OptEnt.Para->ParaList[34] = 0x87;
> - Index++;
> - OptList[Index] = GET_NEXT_DHCP_OPTION (OptList[Index - 1]);
> -
> - //
> - // Append UUID/Guid-based client identifier option
> - //
> - OptList[Index]->OpCode = DHCP4_TAG_UUID;
> - OptList[Index]->Length = (UINT8) sizeof (PXEBC_DHCP4_OPTION_UUID);
> - OptEnt.Uuid = (PXEBC_DHCP4_OPTION_UUID *) OptList[Index]->Data;
> - OptEnt.Uuid->Type = 0;
> - Index++;
> - OptList[Index] = GET_NEXT_DHCP_OPTION (OptList[Index - 1]);
> -
> - if (EFI_ERROR (NetLibGetSystemGuid ((EFI_GUID *) OptEnt.Uuid->Guid))) {
> - //
> - // GUID not yet set - send all 0xff's to show programable (via SetVariable)
> - // SetMem(DHCPV4_OPTIONS_BUFFER.DhcpPlatformId.Guid,
> sizeof(EFI_GUID), 0xff);
> - // GUID not yet set - send all 0's to show not programable
> - //
> - DEBUG ((EFI_D_WARN, "PXE: Failed to read system GUID from the smbios
> table!\n"));
> - ZeroMem (OptEnt.Uuid->Guid, sizeof (EFI_GUID));
> - }
> -
> - //
> - // Append client network device interface option
> - //
> - OptList[Index]->OpCode = DHCP4_TAG_UNDI;
> - OptList[Index]->Length = (UINT8) sizeof (PXEBC_DHCP4_OPTION_UNDI);
> - OptEnt.Undi = (PXEBC_DHCP4_OPTION_UNDI *) OptList[Index]->Data;
> - if (Private->Nii != NULL) {
> - OptEnt.Undi->Type = Private->Nii->Type;
> - OptEnt.Undi->MajorVer = Private->Nii->MajorVer;
> - OptEnt.Undi->MinorVer = Private->Nii->MinorVer;
> - } else {
> - OptEnt.Undi->Type = DEFAULT_UNDI_TYPE;
> - OptEnt.Undi->MajorVer = DEFAULT_UNDI_MAJOR;
> - OptEnt.Undi->MinorVer = DEFAULT_UNDI_MINOR;
> - }
> -
> - Index++;
> - OptList[Index] = GET_NEXT_DHCP_OPTION (OptList[Index - 1]);
> -
> - //
> - // Append client system architecture option
> - //
> - OptList[Index]->OpCode = DHCP4_TAG_ARCH;
> - OptList[Index]->Length = (UINT8) sizeof (PXEBC_DHCP4_OPTION_ARCH);
> - OptEnt.Arch = (PXEBC_DHCP4_OPTION_ARCH *) OptList[Index]->Data;
> - Value = HTONS (EFI_PXE_CLIENT_SYSTEM_ARCHITECTURE);
> - CopyMem (&OptEnt.Arch->Type, &Value, sizeof (UINT16));
> - Index++;
> - OptList[Index] = GET_NEXT_DHCP_OPTION (OptList[Index - 1]);
> -
> - //
> - // Append client system architecture option
> - //
> - OptList[Index]->OpCode = DHCP4_TAG_VENDOR_CLASS_ID;
> - OptList[Index]->Length = (UINT8) sizeof (PXEBC_DHCP4_OPTION_CLID);
> - OptEnt.Clid = (PXEBC_DHCP4_OPTION_CLID *) OptList[Index]->Data;
> - CopyMem (OptEnt.Clid, DEFAULT_CLASS_ID_DATA, sizeof
> (PXEBC_DHCP4_OPTION_CLID));
> - CvtNum (EFI_PXE_CLIENT_SYSTEM_ARCHITECTURE, OptEnt.Clid-
> >ArchitectureType, sizeof (OptEnt.Clid->ArchitectureType));
> -
> - if (Private->Nii != NULL) {
> - //
> - // If NII protocol exists, update DHCP option data
> - //
> - CopyMem (OptEnt.Clid->InterfaceName, Private->Nii->StringId, sizeof
> (OptEnt.Clid->InterfaceName));
> - CvtNum (Private->Nii->MajorVer, OptEnt.Clid->UndiMajor, sizeof
> (OptEnt.Clid->UndiMajor));
> - CvtNum (Private->Nii->MinorVer, OptEnt.Clid->UndiMinor, sizeof
> (OptEnt.Clid->UndiMinor));
> - }
> -
> - Index++;
> -
> - return Index;
> -}
> -
> -
> -/**
> - Discover the boot of service and initialize the vendor option if exists.
> -
> - @param Private Pointer to PxeBc private data.
> - @param Type PxeBc option boot item type
> - @param Layer PxeBc option boot item layer
> - @param UseBis Use BIS or not
> - @param DestIp Ip address for server
> - @param IpCount The total count of the server ip address
> - @param SrvList Server list
> - @param IsDiscv Discover the vendor or not
> - @param Reply The dhcp4 packet of Pxe reply
> -
> - @retval EFI_SUCCESS Operation succeeds.
> - @retval EFI_OUT_OF_RESOURCES Allocate memory pool failed.
> - @retval EFI_NOT_FOUND There is no vendor option exists.
> - @retval EFI_TIMEOUT Send Pxe Discover time out.
> -
> -**/
> -EFI_STATUS
> -PxeBcDiscvBootService (
> - IN PXEBC_PRIVATE_DATA * Private,
> - IN UINT16 Type,
> - IN UINT16 *Layer,
> - IN BOOLEAN UseBis,
> - IN EFI_IP_ADDRESS * DestIp,
> - IN UINT16 IpCount,
> - IN EFI_PXE_BASE_CODE_SRVLIST * SrvList,
> - IN BOOLEAN IsDiscv,
> - OUT EFI_DHCP4_PACKET * Reply OPTIONAL
> - )
> -{
> - EFI_PXE_BASE_CODE_UDP_PORT Sport;
> - EFI_PXE_BASE_CODE_MODE *Mode;
> - EFI_DHCP4_PROTOCOL *Dhcp4;
> - EFI_DHCP4_TRANSMIT_RECEIVE_TOKEN Token;
> - BOOLEAN IsBCast;
> - EFI_STATUS Status;
> - UINT16 RepIndex;
> - UINT16 SrvIndex;
> - UINT16 TryIndex;
> - EFI_DHCP4_LISTEN_POINT ListenPoint;
> - EFI_DHCP4_PACKET *Response;
> - EFI_DHCP4_PACKET_OPTION
> *OptList[PXEBC_DHCP4_MAX_OPTION_NUM];
> - UINT32 OptCount;
> - EFI_DHCP4_PACKET_OPTION *PxeOpt;
> - PXEBC_OPTION_BOOT_ITEM *PxeBootItem;
> - UINT8 VendorOptLen;
> - EFI_DHCP4_HEADER *DhcpHeader;
> - UINT32 Xid;
> -
> - Mode = Private->PxeBc.Mode;
> - Dhcp4 = Private->Dhcp4;
> - Status = EFI_SUCCESS;
> -
> - ZeroMem (&Token, sizeof (EFI_DHCP4_TRANSMIT_RECEIVE_TOKEN));
> -
> - if (DestIp == NULL) {
> - Sport = PXEBC_DHCP4_S_PORT;
> - IsBCast = TRUE;
> - } else {
> - Sport = PXEBC_BS_DISCOVER_PORT;
> - IsBCast = FALSE;
> - }
> -
> - if (!UseBis && Layer != NULL) {
> - *Layer &= EFI_PXE_BASE_CODE_BOOT_LAYER_MASK;
> - }
> -
> - OptCount = PxeBcBuildDhcpOptions (Private, OptList, FALSE);
> -
> - if (IsDiscv) {
> - ASSERT (Layer != NULL);
> - //
> - // Add vendor option of PXE_BOOT_ITEM
> - //
> - VendorOptLen = (UINT8) ((sizeof (EFI_DHCP4_PACKET_OPTION) - 1) * 2 +
> sizeof (PXEBC_OPTION_BOOT_ITEM) + 1);
> - OptList[OptCount] = AllocatePool (VendorOptLen);
> - if (OptList[OptCount] == NULL) {
> - return EFI_OUT_OF_RESOURCES;
> - }
> -
> - OptList[OptCount]->OpCode = DHCP4_TAG_VENDOR;
> - OptList[OptCount]->Length = (UINT8) (VendorOptLen - 2);
> - PxeOpt = (EFI_DHCP4_PACKET_OPTION *) OptList[OptCount]-
> >Data;
> - PxeOpt->OpCode = PXEBC_VENDOR_TAG_BOOT_ITEM;
> - PxeOpt->Length = (UINT8) sizeof (PXEBC_OPTION_BOOT_ITEM);
> - PxeBootItem = (PXEBC_OPTION_BOOT_ITEM *) PxeOpt->Data;
> - PxeBootItem->Type = HTONS (Type);
> - PxeBootItem->Layer = HTONS (*Layer);
> - PxeOpt->Data[PxeOpt->Length] = DHCP4_TAG_EOP;
> -
> - OptCount++;
> - }
> -
> - Status = Dhcp4->Build (Dhcp4, &Private->SeedPacket, 0, NULL, OptCount,
> OptList, &Token.Packet);
> -
> - if (IsDiscv) {
> - FreePool (OptList[OptCount - 1]);
> - }
> -
> - if (EFI_ERROR (Status)) {
> - return Status;
> - }
> -
> - DhcpHeader = &Token.Packet->Dhcp4.Header;
> - if (Mode->SendGUID) {
> - if (EFI_ERROR (NetLibGetSystemGuid ((EFI_GUID *) DhcpHeader-
> >ClientHwAddr))) {
> - //
> - // GUID not yet set - send all 0's to show not programable
> - //
> - DEBUG ((EFI_D_WARN, "PXE: Failed to read system GUID from the smbios
> table!\n"));
> - ZeroMem (DhcpHeader->ClientHwAddr, sizeof (EFI_GUID));
> - }
> -
> - DhcpHeader->HwAddrLen = (UINT8) sizeof (EFI_GUID);
> - }
> -
> - Xid = NET_RANDOM (NetRandomInitSeed ());
> - Token.Packet->Dhcp4.Header.Xid = HTONL(Xid);
> - Token.Packet->Dhcp4.Header.Reserved = HTONS((UINT16) ((IsBCast) ?
> 0x8000 : 0));
> - CopyMem (&Token.Packet->Dhcp4.Header.ClientAddr, &Private->StationIp,
> sizeof (EFI_IPv4_ADDRESS));
> -
> - Token.RemotePort = Sport;
> -
> - if (IsBCast) {
> - SetMem (&Token.RemoteAddress, sizeof (EFI_IPv4_ADDRESS), 0xff);
> - } else {
> - CopyMem (&Token.RemoteAddress, DestIp, sizeof (EFI_IPv4_ADDRESS));
> - }
> -
> - CopyMem (&Token.GatewayAddress, &Private->GatewayIp, sizeof
> (EFI_IPv4_ADDRESS));
> -
> - if (!IsBCast) {
> - Token.ListenPointCount = 1;
> - Token.ListenPoints = &ListenPoint;
> - Token.ListenPoints[0].ListenPort = PXEBC_BS_DISCOVER_PORT;
> - CopyMem (&Token.ListenPoints[0].ListenAddress, &Private->StationIp,
> sizeof(EFI_IPv4_ADDRESS));
> - CopyMem (&Token.ListenPoints[0].SubnetMask, &Private->SubnetMask,
> sizeof(EFI_IPv4_ADDRESS));
> - }
> - //
> - // Send Pxe Discover
> - //
> - for (TryIndex = 1; TryIndex <= PXEBC_BOOT_REQUEST_RETRIES; TryIndex++) {
> -
> - Token.TimeoutValue = (UINT16)
> (PXEBC_BOOT_REQUEST_TIMEOUT * TryIndex);
> - Token.Packet->Dhcp4.Header.Seconds = (UINT16)
> (PXEBC_BOOT_REQUEST_TIMEOUT * (TryIndex - 1));
> -
> - Status = Dhcp4->TransmitReceive (Dhcp4, &Token);
> -
> - if (Token.Status != EFI_TIMEOUT) {
> - break;
> - }
> - }
> -
> - if (TryIndex > PXEBC_BOOT_REQUEST_RETRIES) {
> - //
> - // No server response our PXE request
> - //
> - Status = EFI_TIMEOUT;
> - }
> -
> - if (!EFI_ERROR (Status)) {
> - //
> - // Find Pxe Reply
> - //
> - RepIndex = 0;
> - SrvIndex = 0;
> - Response = Token.ResponseList;
> -
> - while (RepIndex < Token.ResponseCount) {
> - if (Response->Length > PXEBC_DHCP4_MAX_PACKET_SIZE) {
> - SrvIndex = 0;
> - RepIndex++;
> - Response = (EFI_DHCP4_PACKET *) ((UINT8 *) Response + Response->Size);
> - continue;
> - }
> -
> - while (SrvIndex < IpCount) {
> -
> - if (SrvList[SrvIndex].AcceptAnyResponse) {
> - break;
> - }
> -
> - if ((SrvList[SrvIndex].Type == Type) && EFI_IP4_EQUAL (&(Response-
> >Dhcp4.Header.ServerAddr), &(Private->ServerIp))) {
> - break;
> - }
> -
> - SrvIndex++;
> - }
> -
> - if ((IpCount != SrvIndex) || (IpCount == 0)) {
> - break;
> - }
> -
> - SrvIndex = 0;
> - RepIndex++;
> - Response = (EFI_DHCP4_PACKET *) ((UINT8 *) Response + Response->Size);
> - }
> -
> - if (RepIndex < Token.ResponseCount) {
> -
> - if (Reply != NULL) {
> - Status = PxeBcCopyEfiDhcp4Packet (Reply, Response);
> - if (EFI_ERROR(Status)) {
> - goto ON_EXIT;
> - }
> - }
> -
> - if (IsDiscv) {
> - CopyMem (&(Mode->PxeDiscover), &(Token.Packet->Dhcp4),
> Token.Packet->Length);
> - Mode->PxeDiscoverValid = TRUE;
> -
> - CopyMem (Mode->PxeReply.Raw, &Response->Dhcp4, Response->Length);
> - Mode->PxeReplyReceived = TRUE;
> - }
> - } else {
> - Status = EFI_NOT_FOUND;
> - }
> - }
> -
> -ON_EXIT:
> - //
> - // free the responselist
> - //
> - if (Token.ResponseList != NULL) {
> - FreePool (Token.ResponseList);
> - }
> - //
> - // Free the dhcp packet
> - //
> - if (Token.Packet != NULL) {
> - FreePool (Token.Packet);
> - }
> -
> - return Status;
> -}
> -
> -
> -/**
> - Parse interested dhcp options.
> -
> - @param Buffer Pointer to the dhcp options packet.
> - @param Length The length of the dhcp options.
> - @param OptTag The option OpCode.
> -
> - @return NULL if the buffer length is 0 and OpCode is not
> - DHCP4_TAG_EOP, or the pointer to the buffer.
> -
> -**/
> -EFI_DHCP4_PACKET_OPTION *
> -PxeBcParseExtendOptions (
> - IN UINT8 *Buffer,
> - IN UINT32 Length,
> - IN UINT8 OptTag
> - )
> -{
> - EFI_DHCP4_PACKET_OPTION *Option;
> - UINT32 Offset;
> -
> - Option = (EFI_DHCP4_PACKET_OPTION *) Buffer;
> - Offset = 0;
> -
> - while (Offset < Length && Option->OpCode != DHCP4_TAG_EOP) {
> -
> - if (Option->OpCode == OptTag) {
> -
> - return Option;
> - }
> -
> - if (Option->OpCode == DHCP4_TAG_PAD) {
> - Offset++;
> - } else {
> - Offset += Option->Length + 2;
> - }
> -
> - Option = (EFI_DHCP4_PACKET_OPTION *) (Buffer + Offset);
> - }
> -
> - return NULL;
> -}
> -
> -
> -/**
> - This function is to parse and check vendor options.
> -
> - @param Dhcp4Option Pointer to dhcp options
> - @param VendorOption Pointer to vendor options
> -
> - @return TRUE if valid for vendor options, or FALSE.
> -
> -**/
> -BOOLEAN
> -PxeBcParseVendorOptions (
> - IN EFI_DHCP4_PACKET_OPTION *Dhcp4Option,
> - IN PXEBC_VENDOR_OPTION *VendorOption
> - )
> -{
> - UINT32 *BitMap;
> - UINT8 VendorOptionLen;
> - EFI_DHCP4_PACKET_OPTION *PxeOption;
> - UINT8 Offset;
> -
> - BitMap = VendorOption->BitMap;
> - VendorOptionLen = Dhcp4Option->Length;
> - PxeOption = (EFI_DHCP4_PACKET_OPTION *) &Dhcp4Option->Data[0];
> - Offset = 0;
> -
> - while ((Offset < VendorOptionLen) && (PxeOption->OpCode !=
> DHCP4_TAG_EOP)) {
> - //
> - // Parse every Vendor Option and set its BitMap
> - //
> - switch (PxeOption->OpCode) {
> -
> - case PXEBC_VENDOR_TAG_MTFTP_IP:
> -
> - CopyMem (&VendorOption->MtftpIp, PxeOption->Data, sizeof
> (EFI_IPv4_ADDRESS));
> - break;
> -
> - case PXEBC_VENDOR_TAG_MTFTP_CPORT:
> -
> - CopyMem (&VendorOption->MtftpCPort, PxeOption->Data, sizeof
> (VendorOption->MtftpCPort));
> - break;
> -
> - case PXEBC_VENDOR_TAG_MTFTP_SPORT:
> -
> - CopyMem (&VendorOption->MtftpSPort, PxeOption->Data, sizeof
> (VendorOption->MtftpSPort));
> - break;
> -
> - case PXEBC_VENDOR_TAG_MTFTP_TIMEOUT:
> -
> - VendorOption->MtftpTimeout = *PxeOption->Data;
> - break;
> -
> - case PXEBC_VENDOR_TAG_MTFTP_DELAY:
> -
> - VendorOption->MtftpDelay = *PxeOption->Data;
> - break;
> -
> - case PXEBC_VENDOR_TAG_DISCOVER_CTRL:
> -
> - VendorOption->DiscoverCtrl = *PxeOption->Data;
> - break;
> -
> - case PXEBC_VENDOR_TAG_DISCOVER_MCAST:
> -
> - CopyMem (&VendorOption->DiscoverMcastIp, PxeOption->Data, sizeof
> (EFI_IPv4_ADDRESS));
> - break;
> -
> - case PXEBC_VENDOR_TAG_BOOT_SERVERS:
> -
> - VendorOption->BootSvrLen = PxeOption->Length;
> - VendorOption->BootSvr = (PXEBC_BOOT_SVR_ENTRY *) PxeOption->Data;
> - break;
> -
> - case PXEBC_VENDOR_TAG_BOOT_MENU:
> -
> - VendorOption->BootMenuLen = PxeOption->Length;
> - VendorOption->BootMenu = (PXEBC_BOOT_MENU_ENTRY *) PxeOption-
> >Data;
> - break;
> -
> - case PXEBC_VENDOR_TAG_MENU_PROMPT:
> -
> - VendorOption->MenuPromptLen = PxeOption->Length;
> - VendorOption->MenuPrompt = (PXEBC_MENU_PROMPT *) PxeOption-
> >Data;
> - break;
> -
> - case PXEBC_VENDOR_TAG_MCAST_ALLOC:
> -
> - CopyMem (&VendorOption->McastIpBase, PxeOption->Data, sizeof
> (EFI_IPv4_ADDRESS));
> - CopyMem (&VendorOption->McastIpBlock, PxeOption->Data + 4, sizeof
> (VendorOption->McastIpBlock));
> - CopyMem (&VendorOption->McastIpRange, PxeOption->Data + 6, sizeof
> (VendorOption->McastIpRange));
> - break;
> -
> - case PXEBC_VENDOR_TAG_CREDENTIAL_TYPES:
> -
> - VendorOption->CredTypeLen = PxeOption->Length;
> - VendorOption->CredType = (UINT32 *) PxeOption->Data;
> - break;
> -
> - case PXEBC_VENDOR_TAG_BOOT_ITEM:
> -
> - CopyMem (&VendorOption->BootSrvType, PxeOption->Data, sizeof
> (VendorOption->BootSrvType));
> - CopyMem (&VendorOption->BootSrvLayer, PxeOption->Data + 2, sizeof
> (VendorOption->BootSrvLayer));
> - break;
> - }
> -
> - SET_VENDOR_OPTION_BIT_MAP (BitMap, PxeOption->OpCode);
> -
> - if (PxeOption->OpCode == DHCP4_TAG_PAD) {
> - Offset++;
> - } else {
> - Offset = (UINT8) (Offset + PxeOption->Length + 2);
> - }
> -
> - PxeOption = (EFI_DHCP4_PACKET_OPTION *) (Dhcp4Option->Data + Offset);
> - }
> -
> - //
> - // FixMe, return falas if invalid of any vendor option
> - //
> -
> - return TRUE;
> -}
> -
> -
> -/**
> - This function display boot item detail.
> -
> - If the length of the boot item string over 70 Char, just display 70 Char.
> -
> - @param Str Pointer to a string (boot item string).
> - @param Len The length of string.
> -
> -**/
> -VOID
> -PxeBcDisplayBootItem (
> - IN UINT8 *Str,
> - IN UINT8 Len
> - )
> -{
> - UINT8 Tmp;
> -
> - Len = (UINT8) MIN (70, Len);
> - Tmp = Str[Len];
> - Str[Len] = 0;
> - AsciiPrint ("%a \n", Str);
> - Str[Len] = Tmp;
> -}
> -
> -
> -/**
> - Choose the boot prompt.
> -
> - @param Private Pointer to PxeBc private data.
> -
> - @retval EFI_SUCCESS Select boot prompt done.
> - @retval EFI_TIMEOUT Select boot prompt time out.
> - @retval EFI_NOT_FOUND The proxy offer is not Pxe10.
> - @retval EFI_ABORTED User cancel the operation.
> - @retval EFI_NOT_READY Read the input key from the keybroad has not
> finish.
> -
> -**/
> -EFI_STATUS
> -PxeBcSelectBootPrompt (
> - IN PXEBC_PRIVATE_DATA *Private
> - )
> -{
> - PXEBC_CACHED_DHCP4_PACKET *Packet;
> - PXEBC_VENDOR_OPTION *VendorOpt;
> - EFI_EVENT TimeoutEvent;
> - EFI_EVENT DescendEvent;
> - EFI_INPUT_KEY InputKey;
> - EFI_STATUS Status;
> - UINT8 Timeout;
> - UINT8 *Prompt;
> - UINT8 PromptLen;
> - INT32 SecCol;
> - INT32 SecRow;
> -
> - TimeoutEvent = NULL;
> - DescendEvent = NULL;
> -
> - if (Private->PxeBc.Mode->ProxyOfferReceived) {
> -
> - Packet = &Private->ProxyOffer;
> - } else {
> -
> - Packet = &Private->Dhcp4Ack;
> - }
> -
> - if (Packet->OfferType != DHCP4_PACKET_TYPE_PXE10) {
> - return EFI_NOT_FOUND;
> - }
> -
> - VendorOpt = &Packet->PxeVendorOption;
> - //
> - // According to the PXE specification 2.1, Table 2-1 PXE DHCP Options (Full
> - // List), we must not consider a boot prompt or boot menu if all of the
> - // following hold:
> - // - the PXE_DISCOVERY_CONTROL PXE tag is present inside the Vendor
> Options
> - // (=43) DHCP tag, and
> - // - the PXE_DISCOVERY_CONTROL PXE tag has bit 3 set, and
> - // - a boot file name has been presented with DHCP option 67.
> - //
> - if (IS_DISABLE_PROMPT_MENU (VendorOpt->DiscoverCtrl) &&
> - Packet->Dhcp4Option[PXEBC_DHCP4_TAG_INDEX_BOOTFILE] != NULL) {
> - return EFI_ABORTED;
> - }
> -
> - if (!IS_VALID_BOOT_PROMPT (VendorOpt->BitMap)) {
> - return EFI_SUCCESS;
> - }
> -
> - Timeout = VendorOpt->MenuPrompt->Timeout;
> - Prompt = VendorOpt->MenuPrompt->Prompt;
> - PromptLen = (UINT8) (VendorOpt->MenuPromptLen - 1);
> -
> - if (Timeout == 0) {
> - return EFI_SUCCESS;
> - }
> -
> - if (Timeout == 255) {
> - return EFI_TIMEOUT;
> - }
> -
> - Status = gBS->CreateEvent (
> - EVT_TIMER,
> - TPL_CALLBACK,
> - NULL,
> - NULL,
> - &TimeoutEvent
> - );
> -
> - if (EFI_ERROR (Status)) {
> - return Status;
> - }
> -
> - Status = gBS->SetTimer (
> - TimeoutEvent,
> - TimerRelative,
> - MultU64x32 (Timeout, TICKS_PER_SECOND)
> - );
> -
> - if (EFI_ERROR (Status)) {
> - goto ON_EXIT;
> - }
> -
> - Status = gBS->CreateEvent (
> - EVT_TIMER,
> - TPL_CALLBACK,
> - NULL,
> - NULL,
> - &DescendEvent
> - );
> -
> - if (EFI_ERROR (Status)) {
> - goto ON_EXIT;
> - }
> -
> - Status = gBS->SetTimer (
> - DescendEvent,
> - TimerPeriodic,
> - TICKS_PER_SECOND
> - );
> -
> - if (EFI_ERROR (Status)) {
> - goto ON_EXIT;
> - }
> -
> - SecCol = gST->ConOut->Mode->CursorColumn;
> - SecRow = gST->ConOut->Mode->CursorRow;
> -
> - PxeBcDisplayBootItem (Prompt, PromptLen);
> -
> - gST->ConOut->SetCursorPosition (gST->ConOut, SecCol + PromptLen,
> SecRow);
> - AsciiPrint ("(%d) ", Timeout--);
> -
> - while (EFI_ERROR (gBS->CheckEvent (TimeoutEvent))) {
> -
> - if (!EFI_ERROR (gBS->CheckEvent (DescendEvent))) {
> - gST->ConOut->SetCursorPosition (gST->ConOut, SecCol + PromptLen,
> SecRow);
> - AsciiPrint ("(%d) ", Timeout--);
> - }
> -
> - if (gST->ConIn->ReadKeyStroke (gST->ConIn, &InputKey) == EFI_NOT_READY)
> {
> -
> - gBS->Stall (10 * TICKS_PER_MS);
> - continue;
> - }
> -
> - if (InputKey.ScanCode == 0) {
> -
> - switch (InputKey.UnicodeChar) {
> - case CTRL ('c'):
> - Status = EFI_ABORTED;
> - break;
> -
> - case CTRL ('m'):
> - case 'm':
> - case 'M':
> - Status = EFI_TIMEOUT;
> - break;
> -
> - default:
> - continue;
> - }
> - } else {
> -
> - switch (InputKey.ScanCode) {
> - case SCAN_F8:
> - Status = EFI_TIMEOUT;
> - break;
> -
> - case SCAN_ESC:
> - Status = EFI_ABORTED;
> - break;
> -
> - default:
> - continue;
> - }
> - }
> -
> - break;
> - }
> -
> - gST->ConOut->SetCursorPosition (gST->ConOut, 0 , SecRow + 1);
> -
> -ON_EXIT:
> -
> - if (DescendEvent != NULL) {
> - gBS->CloseEvent (DescendEvent);
> - }
> -
> - if (TimeoutEvent != NULL) {
> - gBS->CloseEvent (TimeoutEvent);
> - }
> -
> - return Status;
> -}
> -
> -
> -/**
> - Select the boot menu.
> -
> - @param Private Pointer to PxeBc private data.
> - @param Type The type of the menu.
> - @param UseDefaultItem Use default item or not.
> -
> - @retval EFI_ABORTED User cancel operation.
> - @retval EFI_SUCCESS Select the boot menu success.
> - @retval EFI_NOT_READY Read the input key from the keybroad has not finish.
> -
> -**/
> -EFI_STATUS
> -PxeBcSelectBootMenu (
> - IN PXEBC_PRIVATE_DATA *Private,
> - OUT UINT16 *Type,
> - IN BOOLEAN UseDefaultItem
> - )
> -{
> - PXEBC_CACHED_DHCP4_PACKET *Packet;
> - PXEBC_VENDOR_OPTION *VendorOpt;
> - EFI_INPUT_KEY InputKey;
> - UINT8 MenuSize;
> - UINT8 MenuNum;
> - INT32 TopRow;
> - UINT16 Select;
> - UINT16 LastSelect;
> - UINT8 Index;
> - BOOLEAN Finish;
> - CHAR8 Blank[70];
> - PXEBC_BOOT_MENU_ENTRY *MenuItem;
> - PXEBC_BOOT_MENU_ENTRY *MenuArray[PXEBC_MAX_MENU_NUM];
> -
> - Finish = FALSE;
> - Select = 0;
> - Index = 0;
> - *Type = 0;
> -
> - if (Private->PxeBc.Mode->ProxyOfferReceived) {
> -
> - Packet = &Private->ProxyOffer;
> - } else {
> -
> - Packet = &Private->Dhcp4Ack;
> - }
> -
> - ASSERT (Packet->OfferType == DHCP4_PACKET_TYPE_PXE10);
> -
> - VendorOpt = &Packet->PxeVendorOption;
> -
> - if (!IS_VALID_BOOT_MENU (VendorOpt->BitMap)) {
> - return EFI_SUCCESS;
> - }
> -
> - SetMem (Blank, sizeof(Blank), ' ');
> -
> - MenuSize = VendorOpt->BootMenuLen;
> - MenuItem = VendorOpt->BootMenu;
> -
> - if (MenuSize == 0) {
> - return EFI_NOT_READY;
> - }
> -
> - while (MenuSize > 0) {
> - MenuArray[Index++] = MenuItem;
> - MenuSize = (UINT8) (MenuSize - (MenuItem->DescLen + 3));
> - MenuItem = (PXEBC_BOOT_MENU_ENTRY *) ((UINT8 *) MenuItem +
> MenuItem->DescLen + 3);
> - if (Index >= PXEBC_MAX_MENU_NUM) {
> - break;
> - }
> - }
> -
> - if (UseDefaultItem) {
> - *Type = MenuArray[0]->Type;
> - *Type = NTOHS (*Type);
> - return EFI_SUCCESS;
> - }
> -
> - MenuNum = Index;
> -
> - for (Index = 0; Index < MenuNum; Index++) {
> - PxeBcDisplayBootItem (MenuArray[Index]->DescStr, MenuArray[Index]-
> >DescLen);
> - }
> -
> - TopRow = gST->ConOut->Mode->CursorRow - MenuNum;
> -
> - do {
> - ASSERT (Select < PXEBC_MAX_MENU_NUM);
> - //
> - // highlight selected row
> - //
> - gST->ConOut->SetAttribute (gST->ConOut, EFI_TEXT_ATTR (EFI_BLACK,
> EFI_LIGHTGRAY));
> - gST->ConOut->SetCursorPosition (gST->ConOut, 0, TopRow + Select);
> - Blank[MenuArray[Select]->DescLen] = 0;
> - AsciiPrint ("%a\r", Blank);
> - PxeBcDisplayBootItem (MenuArray[Select]->DescStr, MenuArray[Select]-
> >DescLen);
> - gST->ConOut->SetCursorPosition (gST->ConOut, 0, TopRow + MenuNum);
> - LastSelect = Select;
> -
> - while (gST->ConIn->ReadKeyStroke (gST->ConIn, &InputKey) ==
> EFI_NOT_READY) {
> - gBS->Stall (10 * TICKS_PER_MS);
> - }
> -
> - if (InputKey.ScanCode == 0) {
> - switch (InputKey.UnicodeChar) {
> - case CTRL ('c'):
> - InputKey.ScanCode = SCAN_ESC;
> - break;
> -
> - case CTRL ('j'): /* linefeed */
> - case CTRL ('m'): /* return */
> - Finish = TRUE;
> - break;
> -
> - case CTRL ('i'): /* tab */
> - case ' ':
> - case 'd':
> - case 'D':
> - InputKey.ScanCode = SCAN_DOWN;
> - break;
> -
> - case CTRL ('h'): /* backspace */
> - case 'u':
> - case 'U':
> - InputKey.ScanCode = SCAN_UP;
> - break;
> -
> - default:
> - InputKey.ScanCode = 0;
> - }
> - }
> -
> - switch (InputKey.ScanCode) {
> - case SCAN_LEFT:
> - case SCAN_UP:
> - if (Select > 0) {
> - --Select;
> - }
> -
> - break;
> -
> - case SCAN_DOWN:
> - case SCAN_RIGHT:
> - if (++Select == MenuNum) {
> - --Select;
> - }
> -
> - break;
> -
> - case SCAN_PAGE_UP:
> - case SCAN_HOME:
> - Select = 0;
> - break;
> -
> - case SCAN_PAGE_DOWN:
> - case SCAN_END:
> - Select = (UINT16) (MenuNum - 1);
> - break;
> -
> - case SCAN_ESC:
> - return EFI_ABORTED;
> - }
> -
> - /* unhighlight last selected row */
> - gST->ConOut->SetAttribute (gST->ConOut, EFI_TEXT_ATTR (EFI_LIGHTGRAY,
> EFI_BLACK));
> - gST->ConOut->SetCursorPosition (gST->ConOut, 0, TopRow + LastSelect);
> - Blank[MenuArray[LastSelect]->DescLen] = 0;
> - AsciiPrint ("%a\r", Blank);
> - PxeBcDisplayBootItem (MenuArray[LastSelect]->DescStr,
> MenuArray[LastSelect]->DescLen);
> - gST->ConOut->SetCursorPosition (gST->ConOut, 0, TopRow + MenuNum);
> - } while (!Finish);
> -
> - ASSERT (Select < PXEBC_MAX_MENU_NUM);
> -
> - //
> - // Swap the byte order
> - //
> - CopyMem (Type, &MenuArray[Select]->Type, sizeof (UINT16));
> - *Type = NTOHS (*Type);
> -
> - return EFI_SUCCESS;
> -}
> -
> diff --git a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDriver.c
> b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDriver.c
> deleted file mode 100644
> index 76c140d8e3ff..000000000000
> --- a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDriver.c
> +++ /dev/null
> @@ -1,665 +0,0 @@
> -/** @file
> - The driver binding for UEFI PXEBC protocol.
> -
> -Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.<BR>
> -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
> -http://opensource.org/licenses/bsd-license.php
> -
> -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS
> OR IMPLIED.
> -
> -**/
> -
> -
> -#include "PxeBcImpl.h"
> -
> -EFI_DRIVER_BINDING_PROTOCOL gPxeBcDriverBinding = {
> - PxeBcDriverBindingSupported,
> - PxeBcDriverBindingStart,
> - PxeBcDriverBindingStop,
> - 0xa,
> - NULL,
> - NULL
> -};
> -
> -/**
> - This is the declaration of an EFI image entry point. This entry point is
> - the same for UEFI Applications, UEFI OS Loaders, and UEFI Drivers including
> - both device drivers and bus drivers.
> -
> - @param ImageHandle The firmware allocated handle for the UEFI
> image.
> - @param SystemTable A pointer to the EFI System Table.
> -
> - @retval EFI_SUCCESS The operation completed successfully.
> - @retval EFI_OUT_OF_RESOURCES The request could not be completed due to
> a lack of resources.
> -
> -**/
> -EFI_STATUS
> -EFIAPI
> -PxeBcDriverEntryPoint (
> - IN EFI_HANDLE ImageHandle,
> - IN EFI_SYSTEM_TABLE *SystemTable
> - )
> -{
> - return EfiLibInstallDriverBindingComponentName2 (
> - ImageHandle,
> - SystemTable,
> - &gPxeBcDriverBinding,
> - ImageHandle,
> - &gPxeBcComponentName,
> - &gPxeBcComponentName2
> - );
> -}
> -
> -
> -/**
> - Test to see if this driver supports ControllerHandle. This service
> - is called by the EFI boot service ConnectController(). In
> - order to make drivers as small as possible, there are a few calling
> - restrictions for this service. ConnectController() must
> - follow these calling restrictions. If any other agent wishes to call
> - Supported() it must also follow these calling restrictions.
> - PxeBc requires DHCP4 and MTFTP4 protocols.
> -
> - @param This Protocol instance pointer.
> - @param ControllerHandle Handle of device to test
> - @param RemainingDevicePath Optional parameter use to pick a specific child
> - device to start.
> -
> - @retval EFI_SUCCESS This driver supports this device
> - @retval EFI_ALREADY_STARTED This driver is already running on this device
> - @retval other This driver does not support this device
> -
> -**/
> -EFI_STATUS
> -EFIAPI
> -PxeBcDriverBindingSupported (
> - IN EFI_DRIVER_BINDING_PROTOCOL * This,
> - IN EFI_HANDLE ControllerHandle,
> - IN EFI_DEVICE_PATH_PROTOCOL * RemainingDevicePath OPTIONAL
> - )
> -{
> - EFI_PXE_BASE_CODE_PROTOCOL *PxeBc;
> - EFI_STATUS Status;
> -
> - Status = gBS->OpenProtocol (
> - ControllerHandle,
> - &gEfiPxeBaseCodeProtocolGuid,
> - (VOID **) &PxeBc,
> - This->DriverBindingHandle,
> - ControllerHandle,
> - EFI_OPEN_PROTOCOL_GET_PROTOCOL
> - );
> -
> - if (!EFI_ERROR (Status)) {
> - return EFI_ALREADY_STARTED;
> - }
> -
> - Status = gBS->OpenProtocol (
> - ControllerHandle,
> - &gEfiDhcp4ServiceBindingProtocolGuid,
> - NULL,
> - This->DriverBindingHandle,
> - ControllerHandle,
> - EFI_OPEN_PROTOCOL_TEST_PROTOCOL
> - );
> -
> - if (!EFI_ERROR (Status)) {
> -
> - Status = gBS->OpenProtocol (
> - ControllerHandle,
> - &gEfiMtftp4ServiceBindingProtocolGuid,
> - NULL,
> - This->DriverBindingHandle,
> - ControllerHandle,
> - EFI_OPEN_PROTOCOL_TEST_PROTOCOL
> - );
> -
> - }
> -
> - return Status;
> -}
> -
> -
> -/**
> - Start this driver on ControllerHandle. This service is called by the
> - EFI boot service ConnectController(). In order to make
> - drivers as small as possible, there are a few calling restrictions for
> - this service. ConnectController() must follow these
> - calling restrictions. If any other agent wishes to call Start() it
> - must also follow these calling restrictions.
> -
> - @param This Protocol instance pointer.
> - @param ControllerHandle Handle of device to bind driver to
> - @param RemainingDevicePath Optional parameter use to pick a specific child
> - device to start.
> -
> - @retval EFI_SUCCESS This driver is added to ControllerHandle
> - @retval EFI_ALREADY_STARTED This driver is already running on
> ControllerHandle
> - @retval other This driver does not support this device
> -
> -**/
> -EFI_STATUS
> -EFIAPI
> -PxeBcDriverBindingStart (
> - IN EFI_DRIVER_BINDING_PROTOCOL * This,
> - IN EFI_HANDLE ControllerHandle,
> - IN EFI_DEVICE_PATH_PROTOCOL * RemainingDevicePath OPTIONAL
> - )
> -{
> - PXEBC_PRIVATE_DATA *Private;
> - UINTN Index;
> - EFI_STATUS Status;
> - EFI_IP4_MODE_DATA Ip4ModeData;
> -
> - Private = AllocateZeroPool (sizeof (PXEBC_PRIVATE_DATA));
> - if (Private == NULL) {
> - return EFI_OUT_OF_RESOURCES;
> - }
> -
> - Private->Signature = PXEBC_PRIVATE_DATA_SIGNATURE;
> - Private->Controller = ControllerHandle;
> - Private->Image = This->DriverBindingHandle;
> - CopyMem (&Private->PxeBc, &mPxeBcProtocolTemplate, sizeof (Private-
> >PxeBc));
> - Private->PxeBc.Mode = &Private->Mode;
> - CopyMem (&Private->LoadFile, &mLoadFileProtocolTemplate, sizeof (Private-
> >LoadFile));
> -
> - Private->ProxyOffer.Packet.Offer.Size =
> PXEBC_CACHED_DHCP4_PACKET_MAX_SIZE;
> - Private->Dhcp4Ack.Packet.Ack.Size =
> PXEBC_CACHED_DHCP4_PACKET_MAX_SIZE;
> - Private->PxeReply.Packet.Ack.Size =
> PXEBC_CACHED_DHCP4_PACKET_MAX_SIZE;
> -
> - for (Index = 0; Index < PXEBC_MAX_OFFER_NUM; Index++) {
> - Private->Dhcp4Offers[Index].Packet.Offer.Size =
> PXEBC_CACHED_DHCP4_PACKET_MAX_SIZE;
> - }
> -
> - //
> - // Get the NII interface if it exists.
> - //
> - Status = gBS->OpenProtocol (
> - ControllerHandle,
> - &gEfiNetworkInterfaceIdentifierProtocolGuid_31,
> - (VOID **) &Private->Nii,
> - This->DriverBindingHandle,
> - ControllerHandle,
> - EFI_OPEN_PROTOCOL_GET_PROTOCOL
> - );
> - if (EFI_ERROR (Status)) {
> - Private->Nii = NULL;
> - }
> -
> - Status = NetLibCreateServiceChild (
> - ControllerHandle,
> - This->DriverBindingHandle,
> - &gEfiArpServiceBindingProtocolGuid,
> - &Private->ArpChild
> - );
> - if (EFI_ERROR (Status)) {
> - goto ON_ERROR;
> - }
> -
> - Status = gBS->OpenProtocol (
> - Private->ArpChild,
> - &gEfiArpProtocolGuid,
> - (VOID **) &Private->Arp,
> - This->DriverBindingHandle,
> - ControllerHandle,
> - EFI_OPEN_PROTOCOL_BY_DRIVER
> - );
> - if (EFI_ERROR (Status)) {
> - goto ON_ERROR;
> - }
> -
> - Status = NetLibCreateServiceChild (
> - ControllerHandle,
> - This->DriverBindingHandle,
> - &gEfiDhcp4ServiceBindingProtocolGuid,
> - &Private->Dhcp4Child
> - );
> - if (EFI_ERROR (Status)) {
> - goto ON_ERROR;
> - }
> -
> - Status = gBS->OpenProtocol (
> - Private->Dhcp4Child,
> - &gEfiDhcp4ProtocolGuid,
> - (VOID **) &Private->Dhcp4,
> - This->DriverBindingHandle,
> - ControllerHandle,
> - EFI_OPEN_PROTOCOL_BY_DRIVER
> - );
> - if (EFI_ERROR (Status)) {
> - goto ON_ERROR;
> - }
> -
> - Status = NetLibCreateServiceChild (
> - ControllerHandle,
> - This->DriverBindingHandle,
> - &gEfiIp4ServiceBindingProtocolGuid,
> - &Private->Ip4Child
> - );
> - if (EFI_ERROR (Status)) {
> - goto ON_ERROR;
> - }
> -
> - Status = gBS->OpenProtocol (
> - Private->Ip4Child,
> - &gEfiIp4ProtocolGuid,
> - (VOID **) &Private->Ip4,
> - This->DriverBindingHandle,
> - ControllerHandle,
> - EFI_OPEN_PROTOCOL_BY_DRIVER
> - );
> - 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,
> - This->DriverBindingHandle,
> - &gEfiMtftp4ServiceBindingProtocolGuid,
> - &Private->Mtftp4Child
> - );
> -
> - if (EFI_ERROR (Status)) {
> - goto ON_ERROR;
> - }
> -
> - Status = gBS->OpenProtocol (
> - Private->Mtftp4Child,
> - &gEfiMtftp4ProtocolGuid,
> - (VOID **) &Private->Mtftp4,
> - This->DriverBindingHandle,
> - ControllerHandle,
> - EFI_OPEN_PROTOCOL_BY_DRIVER
> - );
> -
> - if (EFI_ERROR (Status)) {
> - goto ON_ERROR;
> - }
> -
> - Status = NetLibCreateServiceChild (
> - ControllerHandle,
> - This->DriverBindingHandle,
> - &gEfiUdp4ServiceBindingProtocolGuid,
> - &Private->Udp4ReadChild
> - );
> -
> - if (EFI_ERROR (Status)) {
> - goto ON_ERROR;
> - }
> -
> - //
> - // The UDP instance for EfiPxeBcUdpRead
> - //
> - Status = gBS->OpenProtocol (
> - Private->Udp4ReadChild,
> - &gEfiUdp4ProtocolGuid,
> - (VOID **) &Private->Udp4Read,
> - This->DriverBindingHandle,
> - ControllerHandle,
> - EFI_OPEN_PROTOCOL_BY_DRIVER
> - );
> -
> - if (EFI_ERROR (Status)) {
> - goto ON_ERROR;
> - }
> -
> - //
> - // The UDP instance for EfiPxeBcUdpWrite
> - //
> - Status = NetLibCreateServiceChild (
> - ControllerHandle,
> - This->DriverBindingHandle,
> - &gEfiUdp4ServiceBindingProtocolGuid,
> - &Private->Udp4WriteChild
> - );
> - if (EFI_ERROR (Status)) {
> - goto ON_ERROR;
> - }
> -
> - Status = gBS->OpenProtocol (
> - Private->Udp4WriteChild,
> - &gEfiUdp4ProtocolGuid,
> - (VOID **) &Private->Udp4Write,
> - This->DriverBindingHandle,
> - ControllerHandle,
> - EFI_OPEN_PROTOCOL_BY_DRIVER
> - );
> - if (EFI_ERROR (Status)) {
> - goto ON_ERROR;
> - }
> - ZeroMem (&Private->Udp4CfgData, sizeof (EFI_UDP4_CONFIG_DATA));
> - Private->Udp4CfgData.AcceptBroadcast = FALSE;
> - Private->Udp4CfgData.AcceptPromiscuous = FALSE;
> - Private->Udp4CfgData.AcceptAnyPort = TRUE;
> - Private->Udp4CfgData.AllowDuplicatePort = TRUE;
> - Private->Udp4CfgData.TypeOfService = DEFAULT_ToS;
> - Private->Udp4CfgData.TimeToLive = DEFAULT_TTL;
> - Private->Udp4CfgData.DoNotFragment = FALSE;
> - Private->Udp4CfgData.ReceiveTimeout = PXEBC_DEFAULT_LIFETIME;
> - Private->Udp4CfgData.UseDefaultAddress = FALSE;
> -
> - PxeBcInitSeedPacket (&Private->SeedPacket, Private->Udp4Read);
> - Private->MacLen = Private->SeedPacket.Dhcp4.Header.HwAddrLen;
> - CopyMem (&Private->Mac, &Private-
> >SeedPacket.Dhcp4.Header.ClientHwAddr[0], Private->MacLen);
> -
> -
> - ZeroMem (&Private->Ip4ConfigData, sizeof (EFI_IP4_CONFIG_DATA));
> - Private->Ip4ConfigData.DefaultProtocol = EFI_IP_PROTO_ICMP;
> - Private->Ip4ConfigData.AcceptIcmpErrors = TRUE;
> - Private->Ip4ConfigData.TypeOfService = DEFAULT_ToS;
> - Private->Ip4ConfigData.TimeToLive = DEFAULT_TTL;
> - Private->Ip4ConfigData.DoNotFragment = FALSE;
> - Private->Ip4ConfigData.RawData = FALSE;
> -
> - Status = gBS->InstallMultipleProtocolInterfaces (
> - &ControllerHandle,
> - &gEfiPxeBaseCodeProtocolGuid,
> - &Private->PxeBc,
> - &gEfiLoadFileProtocolGuid,
> - &Private->LoadFile,
> - NULL
> - );
> - if (EFI_ERROR (Status)) {
> - goto ON_ERROR;
> - }
> - //
> - // Locate Ip4->Ip4Config2 and store it for set IPv4 Policy.
> - //
> - Status = gBS->HandleProtocol (
> - ControllerHandle,
> - &gEfiIp4Config2ProtocolGuid,
> - (VOID **) &Private->Ip4Config2
> - );
> - if (EFI_ERROR (Status)) {
> - goto ON_ERROR;
> - }
> -
> - return EFI_SUCCESS;
> -
> -ON_ERROR:
> -
> - if (Private->Udp4WriteChild != NULL) {
> - gBS->CloseProtocol (
> - Private->Udp4WriteChild,
> - &gEfiUdp4ProtocolGuid,
> - This->DriverBindingHandle,
> - ControllerHandle
> - );
> - NetLibDestroyServiceChild (
> - ControllerHandle,
> - This->DriverBindingHandle,
> - &gEfiUdp4ServiceBindingProtocolGuid,
> - Private->Udp4WriteChild
> - );
> - }
> -
> - if (Private->Udp4ReadChild != NULL) {
> - gBS->CloseProtocol (
> - Private->Udp4ReadChild,
> - &gEfiUdp4ProtocolGuid,
> - This->DriverBindingHandle,
> - ControllerHandle
> - );
> - NetLibDestroyServiceChild (
> - ControllerHandle,
> - This->DriverBindingHandle,
> - &gEfiUdp4ServiceBindingProtocolGuid,
> - Private->Udp4ReadChild
> - );
> - }
> -
> - if (Private->Mtftp4Child != NULL) {
> - gBS->CloseProtocol (
> - Private->Mtftp4Child,
> - &gEfiMtftp4ProtocolGuid,
> - This->DriverBindingHandle,
> - ControllerHandle
> - );
> -
> - NetLibDestroyServiceChild (
> - ControllerHandle,
> - This->DriverBindingHandle,
> - &gEfiMtftp4ServiceBindingProtocolGuid,
> - Private->Mtftp4Child
> - );
> - }
> -
> - if (Private->Ip4Child != NULL) {
> - gBS->CloseProtocol (
> - Private->Ip4Child,
> - &gEfiIp4ProtocolGuid,
> - This->DriverBindingHandle,
> - ControllerHandle
> - );
> -
> - NetLibDestroyServiceChild (
> - ControllerHandle,
> - This->DriverBindingHandle,
> - &gEfiIp4ServiceBindingProtocolGuid,
> - Private->Ip4Child
> - );
> - }
> -
> - if (Private->Dhcp4Child != NULL) {
> - gBS->CloseProtocol (
> - Private->Dhcp4Child,
> - &gEfiDhcp4ProtocolGuid,
> - This->DriverBindingHandle,
> - ControllerHandle
> - );
> -
> - NetLibDestroyServiceChild (
> - ControllerHandle,
> - This->DriverBindingHandle,
> - &gEfiDhcp4ServiceBindingProtocolGuid,
> - Private->Dhcp4Child
> - );
> - }
> -
> - if (Private->ArpChild != NULL) {
> - gBS->CloseProtocol (
> - Private->ArpChild,
> - &gEfiArpProtocolGuid,
> - This->DriverBindingHandle,
> - ControllerHandle
> - );
> -
> - NetLibDestroyServiceChild (
> - ControllerHandle,
> - This->DriverBindingHandle,
> - &gEfiArpServiceBindingProtocolGuid,
> - Private->ArpChild
> - );
> - }
> -
> - FreePool (Private);
> -
> - return Status;
> -}
> -
> -
> -/**
> - Stop this driver on ControllerHandle. This service is called by the
> - EFI boot service DisconnectController(). In order to
> - make drivers as small as possible, there are a few calling
> - restrictions for this service. DisconnectController()
> - must follow these calling restrictions. If any other agent wishes
> - to call Stop() it must also follow these calling restrictions.
> -
> - @param This Protocol instance pointer.
> - @param ControllerHandle Handle of device to stop driver on
> - @param NumberOfChildren Number of Handles in ChildHandleBuffer. If
> number of
> - children is zero stop the entire bus driver.
> - @param ChildHandleBuffer List of Child Handles to Stop.
> -
> - @retval EFI_SUCCESS This driver is removed ControllerHandle
> - @retval other This driver was not removed from this device
> -
> -**/
> -EFI_STATUS
> -EFIAPI
> -PxeBcDriverBindingStop (
> - IN EFI_DRIVER_BINDING_PROTOCOL *This,
> - IN EFI_HANDLE ControllerHandle,
> - IN UINTN NumberOfChildren,
> - IN EFI_HANDLE *ChildHandleBuffer
> - )
> -{
> - PXEBC_PRIVATE_DATA *Private;
> - EFI_PXE_BASE_CODE_PROTOCOL *PxeBc;
> - EFI_HANDLE NicHandle;
> - EFI_STATUS Status;
> -
> - NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiArpProtocolGuid);
> - if (NicHandle == NULL) {
> - NicHandle = NetLibGetNicHandle (ControllerHandle,
> &gEfiDhcp4ProtocolGuid);
> -
> - if (NicHandle == NULL) {
> - NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiIp4ProtocolGuid);
> -
> - if (NicHandle == NULL) {
> - NicHandle = NetLibGetNicHandle (ControllerHandle,
> &gEfiUdp4ProtocolGuid);
> -
> - if (NicHandle == NULL) {
> - NicHandle = NetLibGetNicHandle (ControllerHandle,
> &gEfiMtftp4ProtocolGuid);
> -
> - if (NicHandle == NULL) {
> - return EFI_SUCCESS;
> - }
> - }
> - }
> - }
> - }
> -
> - Status = gBS->OpenProtocol (
> - NicHandle,
> - &gEfiPxeBaseCodeProtocolGuid,
> - (VOID **) &PxeBc,
> - This->DriverBindingHandle,
> - ControllerHandle,
> - EFI_OPEN_PROTOCOL_GET_PROTOCOL
> - );
> -
> - if (EFI_ERROR (Status)) {
> - return Status;
> - }
> -
> - //
> - // Stop functionality of PXE Base Code protocol
> - //
> - Status = PxeBc->Stop (PxeBc);
> - if (Status != EFI_SUCCESS && Status != EFI_NOT_STARTED) {
> - return Status;
> - }
> -
> - Private = PXEBC_PRIVATE_DATA_FROM_PXEBC (PxeBc);
> -
> - Status = gBS->UninstallMultipleProtocolInterfaces (
> - NicHandle,
> - &gEfiPxeBaseCodeProtocolGuid,
> - &Private->PxeBc,
> - &gEfiLoadFileProtocolGuid,
> - &Private->LoadFile,
> - NULL
> - );
> -
> - if (!EFI_ERROR (Status)) {
> -
> - gBS->CloseProtocol (
> - Private->Udp4WriteChild,
> - &gEfiUdp4ProtocolGuid,
> - This->DriverBindingHandle,
> - NicHandle
> - );
> - NetLibDestroyServiceChild (
> - ControllerHandle,
> - This->DriverBindingHandle,
> - &gEfiUdp4ServiceBindingProtocolGuid,
> - Private->Udp4WriteChild
> - );
> -
> - gBS->CloseProtocol (
> - Private->Udp4ReadChild,
> - &gEfiUdp4ProtocolGuid,
> - This->DriverBindingHandle,
> - NicHandle
> - );
> - NetLibDestroyServiceChild (
> - NicHandle,
> - This->DriverBindingHandle,
> - &gEfiUdp4ServiceBindingProtocolGuid,
> - Private->Udp4ReadChild
> - );
> -
> - gBS->CloseProtocol (
> - Private->Dhcp4Child,
> - &gEfiDhcp4ProtocolGuid,
> - This->DriverBindingHandle,
> - NicHandle
> - );
> - NetLibDestroyServiceChild (
> - NicHandle,
> - This->DriverBindingHandle,
> - &gEfiDhcp4ServiceBindingProtocolGuid,
> - Private->Dhcp4Child
> - );
> -
> - gBS->CloseProtocol (
> - Private->Mtftp4Child,
> - &gEfiMtftp4ProtocolGuid,
> - This->DriverBindingHandle,
> - NicHandle
> - );
> - NetLibDestroyServiceChild (
> - NicHandle,
> - This->DriverBindingHandle,
> - &gEfiMtftp4ServiceBindingProtocolGuid,
> - Private->Mtftp4Child
> - );
> -
> - gBS->CloseProtocol (
> - Private->Ip4Child,
> - &gEfiIp4ProtocolGuid,
> - This->DriverBindingHandle,
> - NicHandle
> - );
> - NetLibDestroyServiceChild (
> - NicHandle,
> - This->DriverBindingHandle,
> - &gEfiIp4ServiceBindingProtocolGuid,
> - Private->Ip4Child
> - );
> -
> - gBS->CloseProtocol (
> - Private->ArpChild,
> - &gEfiArpProtocolGuid,
> - This->DriverBindingHandle,
> - NicHandle
> - );
> - NetLibDestroyServiceChild (
> - NicHandle,
> - This->DriverBindingHandle,
> - &gEfiArpServiceBindingProtocolGuid,
> - Private->ArpChild
> - );
> -
> - FreePool (Private);
> - }
> -
> - return Status;
> -}
> -
> -
> diff --git a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.c
> b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.c
> deleted file mode 100644
> index 3fa3be99c178..000000000000
> --- a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.c
> +++ /dev/null
> @@ -1,2989 +0,0 @@
> -/** @file
> - Interface routines for PxeBc.
> -
> -Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
> -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
> -http://opensource.org/licenses/bsd-license.php
> -
> -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS
> OR IMPLIED.
> -
> -**/
> -
> -
> -#include "PxeBcImpl.h"
> -
> -UINT32 mPxeDhcpTimeout[4] = { 4, 8, 16, 32 };
> -
> -/**
> - Get and record the arp cache.
> -
> - @param This Pointer to EFI_PXE_BC_PROTOCOL
> -
> - @retval EFI_SUCCESS Arp cache updated successfully
> - @retval others If error occurs when getting arp cache
> -
> -**/
> -EFI_STATUS
> -UpdateArpCache (
> - IN EFI_PXE_BASE_CODE_PROTOCOL * This
> - )
> -{
> - PXEBC_PRIVATE_DATA *Private;
> - EFI_PXE_BASE_CODE_MODE *Mode;
> - EFI_STATUS Status;
> - UINT32 EntryLength;
> - UINT32 EntryCount;
> - EFI_ARP_FIND_DATA *Entries;
> - UINT32 Index;
> -
> - Private = PXEBC_PRIVATE_DATA_FROM_PXEBC (This);
> - Mode = Private->PxeBc.Mode;
> -
> - Status = Private->Arp->Find (
> - Private->Arp,
> - TRUE,
> - NULL,
> - &EntryLength,
> - &EntryCount,
> - &Entries,
> - TRUE
> - );
> - if (EFI_ERROR (Status)) {
> - return Status;
> - }
> -
> - Mode->ArpCacheEntries = MIN (
> - EntryCount,
> - EFI_PXE_BASE_CODE_MAX_ARP_ENTRIES
> - );
> - for (Index = 0; Index < Mode->ArpCacheEntries; Index ++) {
> - CopyMem (
> - &Mode->ArpCache[Index].IpAddr,
> - Entries + 1,
> - Entries->SwAddressLength
> - );
> - CopyMem (
> - &Mode->ArpCache[Index].MacAddr,
> - (UINT8 *) (Entries + 1) + Entries->SwAddressLength,
> - Entries->HwAddressLength
> - );
> - //
> - // Slip to the next FindData.
> - //
> - Entries = (EFI_ARP_FIND_DATA *) ((UINT8 *) Entries + EntryLength);
> - }
> -
> - return EFI_SUCCESS;
> -}
> -
> -/**
> - Timeout routine to update arp cache.
> -
> - @param Event Pointer to EFI_PXE_BC_PROTOCOL
> - @param Context Context of the timer event
> -
> -**/
> -VOID
> -EFIAPI
> -ArpCacheUpdateTimeout (
> - IN EFI_EVENT Event,
> - IN VOID *Context
> - )
> -{
> - UpdateArpCache ((EFI_PXE_BASE_CODE_PROTOCOL *) Context);
> -}
> -
> -/**
> - Do arp resolution from arp cache in PxeBcMode.
> -
> - @param PxeBcMode The PXE BC mode to look into.
> - @param Ip4Addr The Ip4 address for resolution.
> - @param MacAddress The resoluted MAC address if the resolution is
> successful.
> - The value is undefined if resolution fails.
> -
> - @retval TRUE The resolution is successful.
> - @retval FALSE Otherwise.
> -
> -**/
> -BOOLEAN
> -FindInArpCache (
> - IN EFI_PXE_BASE_CODE_MODE *PxeBcMode,
> - IN EFI_IPv4_ADDRESS *Ip4Addr,
> - OUT EFI_MAC_ADDRESS *MacAddress
> - )
> -{
> - UINT32 Index;
> -
> - for (Index = 0; Index < PxeBcMode->ArpCacheEntries; Index ++) {
> - if (EFI_IP4_EQUAL (&PxeBcMode->ArpCache[Index].IpAddr.v4, Ip4Addr)) {
> - CopyMem (
> - MacAddress,
> - &PxeBcMode->ArpCache[Index].MacAddr,
> - sizeof (EFI_MAC_ADDRESS)
> - );
> - return TRUE;
> - }
> - }
> -
> - return FALSE;
> -}
> -
> -/**
> - Notify function for the ICMP receive token, used to process
> - the received ICMP packets.
> -
> - @param Context The PXEBC private data.
> -
> -**/
> -VOID
> -EFIAPI
> -IcmpErrorListenHandlerDpc (
> - IN VOID *Context
> - )
> -{
> - EFI_STATUS Status;
> - EFI_IP4_RECEIVE_DATA *RxData;
> - EFI_IP4_PROTOCOL *Ip4;
> - PXEBC_PRIVATE_DATA *Private;
> - EFI_PXE_BASE_CODE_MODE *Mode;
> - UINTN Index;
> - UINT32 CopiedLen;
> - UINT8 *CopiedPointer;
> -
> - Private = (PXEBC_PRIVATE_DATA *) Context;
> - Mode = &Private->Mode;
> - Status = Private->IcmpErrorRcvToken.Status;
> - RxData = Private->IcmpErrorRcvToken.Packet.RxData;
> - Ip4 = Private->Ip4;
> -
> - if (Status == EFI_ABORTED) {
> - //
> - // The reception is actively aborted by the consumer, directly return.
> - //
> - return;
> - }
> -
> - if (RxData == NULL) {
> - goto Resume;
> - }
> -
> - if (Status != EFI_ICMP_ERROR) {
> - //
> - // The return status should be recognized as EFI_ICMP_ERROR.
> - //
> - goto CleanUp;
> - }
> -
> - if (EFI_IP4 (RxData->Header->SourceAddress) != 0 &&
> - (NTOHL (Mode->SubnetMask.Addr[0]) != 0) &&
> - IP4_NET_EQUAL (NTOHL(Mode->StationIp.Addr[0]), EFI_NTOHL (RxData-
> >Header->SourceAddress), NTOHL (Mode->SubnetMask.Addr[0])) &&
> - !NetIp4IsUnicast (EFI_NTOHL (RxData->Header->SourceAddress), NTOHL
> (Mode->SubnetMask.Addr[0]))) {
> - //
> - // The source address is not zero and it's not a unicast IP address, discard it.
> - //
> - goto CleanUp;
> - }
> -
> - if (!EFI_IP4_EQUAL (&RxData->Header->DestinationAddress, &Mode-
> >StationIp.v4)) {
> - //
> - // The dest address is not equal to Station Ip address, discard it.
> - //
> - goto CleanUp;
> - }
> -
> - //
> - // Constructor ICMP error packet
> - //
> - CopiedLen = 0;
> - CopiedPointer = (UINT8 *) &Mode->IcmpError;
> -
> - for (Index = 0; Index < RxData->FragmentCount; Index ++) {
> - CopiedLen += RxData->FragmentTable[Index].FragmentLength;
> - if (CopiedLen <= sizeof (EFI_PXE_BASE_CODE_ICMP_ERROR)) {
> - CopyMem (
> - CopiedPointer,
> - RxData->FragmentTable[Index].FragmentBuffer,
> - RxData->FragmentTable[Index].FragmentLength
> - );
> - } else {
> - CopyMem (
> - CopiedPointer,
> - RxData->FragmentTable[Index].FragmentBuffer,
> - CopiedLen - sizeof (EFI_PXE_BASE_CODE_ICMP_ERROR)
> - );
> - }
> - CopiedPointer += CopiedLen;
> - }
> -
> -CleanUp:
> - gBS->SignalEvent (RxData->RecycleSignal);
> -
> -Resume:
> - Ip4->Receive (Ip4, &(Private->IcmpErrorRcvToken));
> -}
> -
> -/**
> - Request IcmpErrorListenHandlerDpc as a DPC at TPL_CALLBACK
> -
> - @param Event The event signaled.
> - @param Context The context passed in by the event notifier.
> -
> -**/
> -VOID
> -EFIAPI
> -IcmpErrorListenHandler (
> - IN EFI_EVENT Event,
> - IN VOID *Context
> - )
> -{
> - //
> - // Request IpIoListenHandlerDpc as a DPC at TPL_CALLBACK
> - //
> - QueueDpc (TPL_CALLBACK, IcmpErrorListenHandlerDpc, Context);
> -}
> -
> -/**
> - Enables the use of the PXE Base Code Protocol functions.
> -
> - This function enables the use of the PXE Base Code Protocol functions. If the
> - Started field of the EFI_PXE_BASE_CODE_MODE structure is already TRUE,
> then
> - EFI_ALREADY_STARTED will be returned. If UseIpv6 is TRUE, then IPv6
> formatted
> - addresses will be used in this session. If UseIpv6 is FALSE, then IPv4 formatted
> - addresses will be used in this session. If UseIpv6 is TRUE, and the
> Ipv6Supported
> - field of the EFI_PXE_BASE_CODE_MODE structure is FALSE, then
> EFI_UNSUPPORTED will
> - be returned. If there is not enough memory or other resources to start the PXE
> - Base Code Protocol, then EFI_OUT_OF_RESOURCES will be returned.
> Otherwise, the
> - PXE Base Code Protocol will be started, and all of the fields of the
> EFI_PXE_BASE_CODE_MODE
> - structure will be initialized as follows:
> - StartedSet to TRUE.
> - Ipv6SupportedUnchanged.
> - Ipv6AvailableUnchanged.
> - UsingIpv6Set to UseIpv6.
> - BisSupportedUnchanged.
> - BisDetectedUnchanged.
> - AutoArpSet to TRUE.
> - SendGUIDSet to FALSE.
> - TTLSet to DEFAULT_TTL.
> - ToSSet to DEFAULT_ToS.
> - DhcpCompletedSet to FALSE.
> - ProxyOfferReceivedSet to FALSE.
> - StationIpSet to an address of all zeros.
> - SubnetMaskSet to a subnet mask of all zeros.
> - DhcpDiscoverZero-filled.
> - DhcpAckZero-filled.
> - ProxyOfferZero-filled.
> - PxeDiscoverValidSet to FALSE.
> - PxeDiscoverZero-filled.
> - PxeReplyValidSet to FALSE.
> - PxeReplyZero-filled.
> - PxeBisReplyValidSet to FALSE.
> - PxeBisReplyZero-filled.
> - IpFilterSet the Filters field to 0 and the IpCnt field to 0.
> - ArpCacheEntriesSet to 0.
> - ArpCacheZero-filled.
> - RouteTableEntriesSet to 0.
> - RouteTableZero-filled.
> - IcmpErrorReceivedSet to FALSE.
> - IcmpErrorZero-filled.
> - TftpErroReceivedSet to FALSE.
> - TftpErrorZero-filled.
> - MakeCallbacksSet to TRUE if the PXE Base Code Callback Protocol is available.
> - Set to FALSE if the PXE Base Code Callback Protocol is not available.
> -
> - @param This Pointer to the EFI_PXE_BASE_CODE_PROTOCOL
> instance.
> - @param UseIpv6 Specifies the type of IP addresses that are to be used
> during the session
> - that is being started. Set to TRUE for IPv6 addresses, and
> FALSE for
> - IPv4 addresses.
> -
> - @retval EFI_SUCCESS The PXE Base Code Protocol was started.
> - @retval EFI_DEVICE_ERROR The network device encountered an error
> during this oper
> - @retval EFI_UNSUPPORTED UseIpv6 is TRUE, but the Ipv6Supported field
> of the
> - EFI_PXE_BASE_CODE_MODE structure is FALSE.
> - @retval EFI_ALREADY_STARTED The PXE Base Code Protocol is already in the
> started state.
> - @retval EFI_INVALID_PARAMETER The This parameter is NULL or does not
> point to a valid
> - EFI_PXE_BASE_CODE_PROTOCOL structure.
> - @retval EFI_OUT_OF_RESOURCES Could not allocate enough memory or
> other resources to start the
> - PXE Base Code Protocol.
> -
> -**/
> -EFI_STATUS
> -EFIAPI
> -EfiPxeBcStart (
> - IN EFI_PXE_BASE_CODE_PROTOCOL *This,
> - IN BOOLEAN UseIpv6
> - )
> -{
> - PXEBC_PRIVATE_DATA *Private;
> - EFI_PXE_BASE_CODE_MODE *Mode;
> - EFI_STATUS Status;
> -
> - if (This == NULL) {
> - return EFI_INVALID_PARAMETER;
> - }
> -
> - Private = PXEBC_PRIVATE_DATA_FROM_PXEBC (This);
> - Mode = Private->PxeBc.Mode;
> -
> - if (Mode->Started) {
> - return EFI_ALREADY_STARTED;
> - }
> -
> - if (UseIpv6) {
> - //
> - // IPv6 is not supported now.
> - //
> - return EFI_UNSUPPORTED;
> - }
> -
> - AsciiPrint ("\n>>Start PXE over IPv4");
> -
> - //
> - // Configure the udp4 instance to let it receive data
> - //
> - Status = Private->Udp4Read->Configure (
> - Private->Udp4Read,
> - &Private->Udp4CfgData
> - );
> - if (EFI_ERROR (Status)) {
> - return Status;
> - }
> -
> -
> - //
> - // Configure block size for TFTP as a default value to handle all link layers.
> - //
> - Private->BlockSize = MIN (Private->Ip4MaxPacketSize,
> PXEBC_DEFAULT_PACKET_SIZE) -
> - PXEBC_DEFAULT_UDP_OVERHEAD_SIZE -
> PXEBC_DEFAULT_TFTP_OVERHEAD_SIZE;
> - //
> - // If PcdTftpBlockSize is set to non-zero, override the default value.
> - //
> - if (PcdGet64 (PcdTftpBlockSize) != 0) {
> - Private->BlockSize = (UINTN) PcdGet64 (PcdTftpBlockSize);
> - }
> -
> - Private->AddressIsOk = FALSE;
> -
> - ZeroMem (Mode, sizeof (EFI_PXE_BASE_CODE_MODE));
> -
> - Mode->Started = TRUE;
> - Mode->TTL = DEFAULT_TTL;
> - Mode->ToS = DEFAULT_ToS;
> - Mode->AutoArp = TRUE;
> -
> - //
> - // Create the event for Arp Cache checking.
> - //
> - Status = gBS->CreateEvent (
> - EVT_TIMER | EVT_NOTIFY_SIGNAL,
> - TPL_CALLBACK,
> - ArpCacheUpdateTimeout,
> - This,
> - &Private->GetArpCacheEvent
> - );
> - if (EFI_ERROR (Status)) {
> - goto ON_EXIT;
> - }
> -
> - //
> - // Start the timeout timer event.
> - //
> - Status = gBS->SetTimer (
> - Private->GetArpCacheEvent,
> - TimerPeriodic,
> - TICKS_PER_SECOND
> - );
> -
> - if (EFI_ERROR (Status)) {
> - goto ON_EXIT;
> - }
> -
> - //
> - // Create ICMP error receiving event
> - //
> - Status = gBS->CreateEvent (
> - EVT_NOTIFY_SIGNAL,
> - TPL_NOTIFY,
> - IcmpErrorListenHandler,
> - Private,
> - &(Private->IcmpErrorRcvToken.Event)
> - );
> - if (EFI_ERROR (Status)) {
> - goto ON_EXIT;
> - }
> -
> - //
> - //DHCP4 service allows only one of its children to be configured in
> - //the active state, If the DHCP4 D.O.R.A started by IP4 auto
> - //configuration and has not been completed, the Dhcp4 state machine
> - //will not be in the right state for the PXE to start a new round D.O.R.A.
> - //so we need to switch it's policy to static.
> - //
> - Status = PxeBcSetIp4Policy (Private);
> - if (EFI_ERROR (Status)) {
> - goto ON_EXIT;
> - }
> -
> - Status = Private->Ip4->Configure (Private->Ip4, &Private->Ip4ConfigData);
> - if (EFI_ERROR (Status)) {
> - goto ON_EXIT;
> - }
> -
> - //
> - // start to listen incoming packet
> - //
> - Status = Private->Ip4->Receive (Private->Ip4, &Private->IcmpErrorRcvToken);
> - if (!EFI_ERROR (Status)) {
> - return Status;
> - }
> -
> -ON_EXIT:
> - Private->Ip4->Configure (Private->Ip4, NULL);
> -
> - if (Private->IcmpErrorRcvToken.Event != NULL) {
> - gBS->CloseEvent (Private->IcmpErrorRcvToken.Event);
> - }
> -
> - if (Private->GetArpCacheEvent != NULL) {
> - gBS->SetTimer (Private->GetArpCacheEvent, TimerCancel, 0);
> - gBS->CloseEvent (Private->GetArpCacheEvent);
> - }
> -
> - Mode->Started = FALSE;
> - Mode->TTL = 0;
> - Mode->ToS = 0;
> - Mode->AutoArp = FALSE;
> -
> - return Status;
> -}
> -
> -
> -/**
> - Disables the use of the PXE Base Code Protocol functions.
> -
> - This function stops all activity on the network device. All the resources
> allocated
> - in Start() are released, the Started field of the EFI_PXE_BASE_CODE_MODE
> structure is
> - set to FALSE and EFI_SUCCESS is returned. If the Started field of the
> EFI_PXE_BASE_CODE_MODE
> - structure is already FALSE, then EFI_NOT_STARTED will be returned.
> -
> - @param This Pointer to the EFI_PXE_BASE_CODE_PROTOCOL
> instance.
> -
> - @retval EFI_SUCCESS The PXE Base Code Protocol was stopped.
> - @retval EFI_NOT_STARTED The PXE Base Code Protocol is already in the
> stopped state.
> - @retval EFI_INVALID_PARAMETER The This parameter is NULL or does not
> point to a valid
> - EFI_PXE_BASE_CODE_PROTOCOL structure.
> - @retval EFI_DEVICE_ERROR The network device encountered an error
> during this operation.
> -
> -**/
> -EFI_STATUS
> -EFIAPI
> -EfiPxeBcStop (
> - IN EFI_PXE_BASE_CODE_PROTOCOL *This
> - )
> -{
> - PXEBC_PRIVATE_DATA *Private;
> - EFI_PXE_BASE_CODE_MODE *Mode;
> -
> - if (This == NULL) {
> - return EFI_INVALID_PARAMETER;
> - }
> -
> - Private = PXEBC_PRIVATE_DATA_FROM_PXEBC (This);
> - Mode = Private->PxeBc.Mode;
> -
> - if (!Mode->Started) {
> - return EFI_NOT_STARTED;
> - }
> -
> - Private->Ip4->Cancel (Private->Ip4, NULL);
> - //
> - // Dispatch the DPCs queued by the NotifyFunction of the canceled rx token's
> - // events.
> - //
> - DispatchDpc ();
> -
> - Private->Ip4->Configure (Private->Ip4, NULL);
> -
> - //
> - // Close the ICMP error receiving event.
> - //
> - gBS->CloseEvent (Private->IcmpErrorRcvToken.Event);
> -
> - //
> - // Cancel the TimeoutEvent timer.
> - //
> - gBS->SetTimer (Private->GetArpCacheEvent, TimerCancel, 0);
> -
> - //
> - // Close the TimeoutEvent event.
> - //
> - gBS->CloseEvent (Private->GetArpCacheEvent);
> -
> - Mode->Started = FALSE;
> -
> - 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);
> - Private->Dhcp4->Configure (Private->Dhcp4, NULL);
> -
> - Private->FileSize = 0;
> -
> - return EFI_SUCCESS;
> -}
> -
> -
> -/**
> - Attempts to complete a DHCPv4 D.O.R.A. (discover / offer / request /
> acknowledge) or DHCPv6
> - S.A.R.R (solicit / advertise / request / reply) sequence.
> -
> - This function attempts to complete the DHCP sequence. If this sequence is
> completed,
> - then EFI_SUCCESS is returned, and the DhcpCompleted, ProxyOfferReceived,
> StationIp,
> - SubnetMask, DhcpDiscover, DhcpAck, and ProxyOffer fields of the
> EFI_PXE_BASE_CODE_MODE
> - structure are filled in.
> - If SortOffers is TRUE, then the cached DHCP offer packets will be sorted
> before
> - they are tried. If SortOffers is FALSE, then the cached DHCP offer packets will
> - be tried in the order in which they are received. Please see the Preboot
> Execution
> - Environment (PXE) Specification for additional details on the implementation
> of DHCP.
> - This function can take at least 31 seconds to timeout and return control to the
> - caller. If the DHCP sequence does not complete, then EFI_TIMEOUT will be
> returned.
> - If the Callback Protocol does not return
> EFI_PXE_BASE_CODE_CALLBACK_STATUS_CONTINUE,
> - then the DHCP sequence will be stopped and EFI_ABORTED will be returned.
> -
> - @param This Pointer to the EFI_PXE_BASE_CODE_PROTOCOL
> instance.
> - @param SortOffers TRUE if the offers received should be sorted. Set to
> FALSE to try the
> - offers in the order that they are received.
> -
> - @retval EFI_SUCCESS Valid DHCP has completed.
> - @retval EFI_NOT_STARTED The PXE Base Code Protocol is in the stopped
> state.
> - @retval EFI_INVALID_PARAMETER The This parameter is NULL or does not
> point to a valid
> - EFI_PXE_BASE_CODE_PROTOCOL structure.
> - @retval EFI_DEVICE_ERROR The network device encountered an error
> during this operation.
> - @retval EFI_OUT_OF_RESOURCES Could not allocate enough memory to
> complete the DHCP Protocol.
> - @retval EFI_ABORTED The callback function aborted the DHCP Protocol.
> - @retval EFI_TIMEOUT The DHCP Protocol timed out.
> - @retval EFI_ICMP_ERROR An ICMP error packet was received during the
> DHCP session.
> - @retval EFI_NO_RESPONSE Valid PXE offer was not received.
> -
> -**/
> -EFI_STATUS
> -EFIAPI
> -EfiPxeBcDhcp (
> - IN EFI_PXE_BASE_CODE_PROTOCOL *This,
> - IN BOOLEAN SortOffers
> - )
> -{
> - PXEBC_PRIVATE_DATA *Private;
> - EFI_PXE_BASE_CODE_MODE *Mode;
> - EFI_DHCP4_PROTOCOL *Dhcp4;
> - EFI_DHCP4_CONFIG_DATA Dhcp4CfgData;
> - EFI_DHCP4_MODE_DATA Dhcp4Mode;
> - EFI_DHCP4_PACKET_OPTION
> *OptList[PXEBC_DHCP4_MAX_OPTION_NUM];
> - UINT32 OptCount;
> - EFI_STATUS Status;
> - EFI_ARP_CONFIG_DATA ArpConfigData;
> - EFI_PXE_BASE_CODE_IP_FILTER IpFilter;
> -
> - if (This == NULL) {
> - return EFI_INVALID_PARAMETER;
> - }
> -
> - Status = EFI_SUCCESS;
> - Private = PXEBC_PRIVATE_DATA_FROM_PXEBC (This);
> - Mode = Private->PxeBc.Mode;
> - Dhcp4 = Private->Dhcp4;
> - Private->Function = EFI_PXE_BASE_CODE_FUNCTION_DHCP;
> - Private->SortOffers = SortOffers;
> -
> - if (!Mode->Started) {
> - return EFI_NOT_STARTED;
> - }
> -
> - Mode->IcmpErrorReceived = FALSE;
> -
> - //
> - // Stop Udp4Read instance
> - //
> - Private->Udp4Read->Configure (Private->Udp4Read, NULL);
> -
> - //
> - // Initialize the DHCP options and build the option list
> - //
> - OptCount = PxeBcBuildDhcpOptions (Private, OptList, TRUE);
> -
> - //
> - // 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 = 4;
> - Dhcp4CfgData.DiscoverTimeout = mPxeDhcpTimeout;
> -
> - 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) && Status != EFI_ALREADY_STARTED) {
> - if (Status == EFI_ICMP_ERROR) {
> - Mode->IcmpErrorReceived = TRUE;
> - }
> - goto ON_EXIT;
> - }
> -
> - Status = Dhcp4->GetModeData (Dhcp4, &Dhcp4Mode);
> - if (EFI_ERROR (Status)) {
> - goto ON_EXIT;
> - }
> -
> - 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 (&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);
> -
> - AsciiPrint ("\n Station IP address is ");
> -
> - PxeBcShowIp4Addr (&Private->StationIp.v4);
> - AsciiPrint ("\n");
> -
> -ON_EXIT:
> - if (EFI_ERROR (Status)) {
> - Dhcp4->Stop (Dhcp4);
> - Dhcp4->Configure (Dhcp4, NULL);
> - } else {
> - //
> - // Remove the previously configured option list and callback function
> - //
> - ZeroMem (&Dhcp4CfgData, sizeof (EFI_DHCP4_CONFIG_DATA));
> - Dhcp4->Configure (Dhcp4, &Dhcp4CfgData);
> -
> - Private->AddressIsOk = TRUE;
> -
> - if (!Mode->UsingIpv6) {
> - //
> - // If in IPv4 mode, configure the corresponding ARP with this new
> - // station IP address.
> - //
> - ZeroMem (&ArpConfigData, sizeof (EFI_ARP_CONFIG_DATA));
> -
> - ArpConfigData.SwAddressType = 0x0800;
> - ArpConfigData.SwAddressLength = (UINT8) sizeof (EFI_IPv4_ADDRESS);
> - ArpConfigData.StationAddress = &Private->StationIp.v4;
> -
> - Private->Arp->Configure (Private->Arp, NULL);
> - Private->Arp->Configure (Private->Arp, &ArpConfigData);
> -
> - //
> - // Updated the route table. Fill the first entry.
> - //
> - Mode->RouteTableEntries = 1;
> - Mode->RouteTable[0].IpAddr.Addr[0] = Private->StationIp.Addr[0] &
> Private->SubnetMask.Addr[0];
> - Mode->RouteTable[0].SubnetMask.Addr[0] = Private->SubnetMask.Addr[0];
> - Mode->RouteTable[0].GwAddr.Addr[0] = 0;
> -
> - //
> - // Create the default route entry if there is a default router.
> - //
> - if (Private->GatewayIp.Addr[0] != 0) {
> - Mode->RouteTableEntries = 2;
> - Mode->RouteTable[1].IpAddr.Addr[0] = 0;
> - Mode->RouteTable[1].SubnetMask.Addr[0] = 0;
> - Mode->RouteTable[1].GwAddr.Addr[0] = Private->GatewayIp.Addr[0];
> - }
> -
> - //
> - // Flush new station IP address into Udp4CfgData and Ip4ConfigData
> - //
> - CopyMem (&Private->Udp4CfgData.StationAddress, &Private->StationIp,
> sizeof (EFI_IPv4_ADDRESS));
> - CopyMem (&Private->Udp4CfgData.SubnetMask, &Private->SubnetMask,
> sizeof (EFI_IPv4_ADDRESS));
> - CopyMem (&Private->Ip4ConfigData.StationAddress, &Private->StationIp,
> sizeof (EFI_IPv4_ADDRESS));
> - CopyMem (&Private->Ip4ConfigData.SubnetMask, &Private->SubnetMask,
> sizeof (EFI_IPv4_ADDRESS));
> -
> - //
> - // Reconfigure the Ip4 instance to capture background ICMP packets with
> new station Ip address.
> - //
> - Private->Ip4->Cancel (Private->Ip4, &Private->IcmpErrorRcvToken);
> - Private->Ip4->Configure (Private->Ip4, NULL);
> -
> - Status = Private->Ip4->Configure (Private->Ip4, &Private->Ip4ConfigData);
> - if (EFI_ERROR (Status)) {
> - goto ON_EXIT;
> - }
> -
> - Status = Private->Ip4->Receive (Private->Ip4, &Private->IcmpErrorRcvToken);
> - if (EFI_ERROR (Status)) {
> - goto ON_EXIT;
> - }
> - }
> - }
> -
> - Private->Udp4Read->Configure (Private->Udp4Read, &Private->Udp4CfgData);
> -
> - //
> - // Dhcp(), Discover(), and Mtftp() set the IP filter, and return with the IP
> - // receive filter list emptied and the filter set to
> EFI_PXE_BASE_CODE_IP_FILTER_STATION_IP.
> - //
> - ZeroMem(&IpFilter, sizeof (EFI_PXE_BASE_CODE_IP_FILTER));
> - IpFilter.Filters = EFI_PXE_BASE_CODE_IP_FILTER_STATION_IP;
> - This->SetIpFilter (This, &IpFilter);
> -
> - return Status;
> -}
> -
> -
> -/**
> - Attempts to complete the PXE Boot Server and/or boot image discovery
> sequence.
> -
> - This function attempts to complete the PXE Boot Server and/or boot image
> discovery
> - sequence. If this sequence is completed, then EFI_SUCCESS is returned, and
> the
> - PxeDiscoverValid, PxeDiscover, PxeReplyReceived, and PxeReply fields of the
> - EFI_PXE_BASE_CODE_MODE structure are filled in. If UseBis is TRUE, then the
> - PxeBisReplyReceived and PxeBisReply fields of the
> EFI_PXE_BASE_CODE_MODE structure
> - will also be filled in. If UseBis is FALSE, then PxeBisReplyValid will be set to
> FALSE.
> - In the structure referenced by parameter Info, the PXE Boot Server list,
> SrvList[],
> - has two uses: It is the Boot Server IP address list used for unicast discovery
> - (if the UseUCast field is TRUE), and it is the list used for Boot Server
> verification
> - (if the MustUseList field is TRUE). Also, if the MustUseList field in that
> structure
> - is TRUE and the AcceptAnyResponse field in the SrvList[] array is TRUE, any
> Boot
> - Server reply of that type will be accepted. If the AcceptAnyResponse field is
> - FALSE, only responses from Boot Servers with matching IP addresses will be
> accepted.
> - This function can take at least 10 seconds to timeout and return control to the
> - caller. If the Discovery sequence does not complete, then EFI_TIMEOUT will
> be
> - returned. Please see the Preboot Execution Environment (PXE) Specification
> for
> - additional details on the implementation of the Discovery sequence.
> - If the Callback Protocol does not return
> EFI_PXE_BASE_CODE_CALLBACK_STATUS_CONTINUE,
> - then the Discovery sequence is stopped and EFI_ABORTED will be returned.
> -
> - @param This Pointer to the EFI_PXE_BASE_CODE_PROTOCOL
> instance.
> - @param Type The type of bootstrap to perform.
> - @param Layer Pointer to the boot server layer number to discover,
> which must be
> - PXE_BOOT_LAYER_INITIAL when a new server type is being
> - discovered.
> - @param UseBis TRUE if Boot Integrity Services are to be used. FALSE
> otherwise.
> - @param Info Pointer to a data structure that contains additional
> information on the
> - type of discovery operation that is to be performed.
> -
> - @retval EFI_SUCCESS The Discovery sequence has been completed.
> - @retval EFI_NOT_STARTED The PXE Base Code Protocol is in the stopped
> state.
> - @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
> - @retval EFI_DEVICE_ERROR The network device encountered an error
> during this operation.
> - @retval EFI_OUT_OF_RESOURCES Could not allocate enough memory to
> complete Discovery.
> - @retval EFI_ABORTED The callback function aborted the Discovery
> sequence.
> - @retval EFI_TIMEOUT The Discovery sequence timed out.
> - @retval EFI_ICMP_ERROR An ICMP error packet was received during the
> PXE discovery
> - session.
> -
> -**/
> -EFI_STATUS
> -EFIAPI
> -EfiPxeBcDiscover (
> - IN EFI_PXE_BASE_CODE_PROTOCOL *This,
> - IN UINT16 Type,
> - IN UINT16 *Layer,
> - IN BOOLEAN UseBis,
> - IN EFI_PXE_BASE_CODE_DISCOVER_INFO *Info OPTIONAL
> - )
> -{
> - PXEBC_PRIVATE_DATA *Private;
> - EFI_PXE_BASE_CODE_MODE *Mode;
> - EFI_PXE_BASE_CODE_DISCOVER_INFO DefaultInfo;
> - EFI_PXE_BASE_CODE_DISCOVER_INFO *CreatedInfo;
> - EFI_PXE_BASE_CODE_SRVLIST *SrvList;
> - EFI_PXE_BASE_CODE_SRVLIST DefaultSrvList;
> - PXEBC_CACHED_DHCP4_PACKET *Packet;
> - PXEBC_VENDOR_OPTION *VendorOpt;
> - UINT16 Index;
> - EFI_STATUS Status;
> - PXEBC_BOOT_SVR_ENTRY *BootSvrEntry;
> - EFI_PXE_BASE_CODE_IP_FILTER IpFilter;
> -
> - if (This == NULL) {
> - return EFI_INVALID_PARAMETER;
> - }
> -
> - Private = PXEBC_PRIVATE_DATA_FROM_PXEBC (This);
> - Mode = Private->PxeBc.Mode;
> - BootSvrEntry = NULL;
> - SrvList = NULL;
> - CreatedInfo = NULL;
> - Status = EFI_DEVICE_ERROR;
> - Private->Function = EFI_PXE_BASE_CODE_FUNCTION_DISCOVER;
> -
> - if (!Private->AddressIsOk) {
> - return EFI_INVALID_PARAMETER;
> - }
> -
> - if (!Mode->Started) {
> - return EFI_NOT_STARTED;
> - }
> -
> - //
> - // Stop Udp4Read instance
> - //
> - Private->Udp4Read->Configure (Private->Udp4Read, NULL);
> -
> - Mode->IcmpErrorReceived = FALSE;
> -
> - //
> - // If layer isn't EFI_PXE_BASE_CODE_BOOT_LAYER_INITIAL,
> - // use the previous setting;
> - // If info isn't offered,
> - // use the cached DhcpAck and ProxyOffer packets.
> - //
> - ZeroMem (&DefaultInfo, sizeof (EFI_PXE_BASE_CODE_DISCOVER_INFO));
> - if (*Layer != EFI_PXE_BASE_CODE_BOOT_LAYER_INITIAL) {
> -
> - if (!Mode->PxeDiscoverValid || !Mode->PxeReplyReceived || (!Mode-
> >PxeBisReplyReceived && UseBis)) {
> -
> - Status = EFI_INVALID_PARAMETER;
> - goto ON_EXIT;
> - }
> -
> - DefaultInfo.IpCnt = 1;
> - DefaultInfo.UseUCast = TRUE;
> -
> - DefaultSrvList.Type = Type;
> - DefaultSrvList.AcceptAnyResponse = FALSE;
> - DefaultSrvList.IpAddr.Addr[0] = Private->ServerIp.Addr[0];
> -
> - SrvList = &DefaultSrvList;
> - Info = &DefaultInfo;
> - } else if (Info == NULL) {
> - //
> - // Create info by the cached packet before
> - //
> - Packet = (Mode->ProxyOfferReceived) ? &Private->ProxyOffer : &Private-
> >Dhcp4Ack;
> - VendorOpt = &Packet->PxeVendorOption;
> -
> - if (!Mode->DhcpAckReceived || !IS_VALID_DISCOVER_VENDOR_OPTION
> (VendorOpt->BitMap)) {
> - //
> - // Address is not acquired or no discovery options.
> - //
> - Status = EFI_INVALID_PARAMETER;
> - goto ON_EXIT;
> - }
> -
> - DefaultInfo.UseMCast = (BOOLEAN)!IS_DISABLE_MCAST_DISCOVER
> (VendorOpt->DiscoverCtrl);
> - DefaultInfo.UseBCast = (BOOLEAN)!IS_DISABLE_BCAST_DISCOVER
> (VendorOpt->DiscoverCtrl);
> - DefaultInfo.MustUseList = (BOOLEAN) IS_ENABLE_USE_SERVER_LIST
> (VendorOpt->DiscoverCtrl);
> - DefaultInfo.UseUCast = DefaultInfo.MustUseList;
> -
> - if (DefaultInfo.UseMCast) {
> - //
> - // Get the multicast discover ip address from vendor option.
> - //
> - CopyMem (
> - &DefaultInfo.ServerMCastIp.Addr,
> - &VendorOpt->DiscoverMcastIp,
> - sizeof (EFI_IPv4_ADDRESS)
> - );
> - }
> -
> - DefaultInfo.IpCnt = 0;
> - Info = &DefaultInfo;
> - SrvList = Info->SrvList;
> -
> - if (DefaultInfo.MustUseList) {
> - BootSvrEntry = VendorOpt->BootSvr;
> - Status = EFI_INVALID_PARAMETER;
> -
> - while (((UINT8) (BootSvrEntry - VendorOpt->BootSvr)) < VendorOpt-
> >BootSvrLen) {
> -
> - if (BootSvrEntry->Type == HTONS (Type)) {
> - Status = EFI_SUCCESS;
> - break;
> - }
> -
> - BootSvrEntry = GET_NEXT_BOOT_SVR_ENTRY (BootSvrEntry);
> - }
> -
> - if (EFI_ERROR (Status)) {
> - goto ON_EXIT;
> - }
> -
> - DefaultInfo.IpCnt = BootSvrEntry->IpCnt;
> -
> - if (DefaultInfo.IpCnt >= 1) {
> - CreatedInfo = AllocatePool (sizeof (DefaultInfo) + (DefaultInfo.IpCnt - 1) *
> sizeof (*SrvList));
> - if (CreatedInfo == NULL) {
> - Status = EFI_OUT_OF_RESOURCES;
> - goto ON_EXIT;
> -
> - }
> -
> - CopyMem (CreatedInfo, &DefaultInfo, sizeof (DefaultInfo));
> - Info = CreatedInfo;
> - SrvList = Info->SrvList;
> - }
> -
> - for (Index = 0; Index < DefaultInfo.IpCnt; Index++) {
> - CopyMem (&SrvList[Index].IpAddr, &BootSvrEntry->IpAddr[Index], sizeof
> (EFI_IPv4_ADDRESS));
> - SrvList[Index].AcceptAnyResponse = FALSE;
> - SrvList[Index].Type = BootSvrEntry->Type;
> - }
> - }
> -
> - } else {
> -
> - SrvList = Info->SrvList;
> -
> - if (!SrvList[0].AcceptAnyResponse) {
> -
> - for (Index = 1; Index < Info->IpCnt; Index++) {
> - if (SrvList[Index].AcceptAnyResponse) {
> - break;
> - }
> - }
> -
> - if (Index != Info->IpCnt) {
> - Status = EFI_INVALID_PARAMETER;
> - goto ON_EXIT;
> - }
> - }
> - }
> -
> - if ((!Info->UseUCast && !Info->UseBCast && !Info->UseMCast) || (Info-
> >MustUseList && Info->IpCnt == 0)) {
> -
> - Status = EFI_INVALID_PARAMETER;
> - goto ON_EXIT;
> - }
> - //
> - // Execute discover by UniCast/BroadCast/MultiCast
> - //
> - if (Info->UseUCast) {
> -
> - for (Index = 0; Index < Info->IpCnt; Index++) {
> -
> - if (BootSvrEntry == NULL) {
> - Private->ServerIp.Addr[0] = SrvList[Index].IpAddr.Addr[0];
> - } else {
> - CopyMem (
> - &Private->ServerIp,
> - &BootSvrEntry->IpAddr[Index],
> - sizeof (EFI_IPv4_ADDRESS)
> - );
> - }
> -
> - Status = PxeBcDiscvBootService (
> - Private,
> - Type,
> - Layer,
> - UseBis,
> - &SrvList[Index].IpAddr,
> - 0,
> - NULL,
> - TRUE,
> - &Private->PxeReply.Packet.Ack
> - );
> - if (!EFI_ERROR (Status)) {
> - break;
> - }
> - }
> -
> - } else if (Info->UseMCast) {
> -
> - Status = PxeBcDiscvBootService (
> - Private,
> - Type,
> - Layer,
> - UseBis,
> - &Info->ServerMCastIp,
> - 0,
> - NULL,
> - TRUE,
> - &Private->PxeReply.Packet.Ack
> - );
> -
> - } else if (Info->UseBCast) {
> -
> - Status = PxeBcDiscvBootService (
> - Private,
> - Type,
> - Layer,
> - UseBis,
> - NULL,
> - Info->IpCnt,
> - SrvList,
> - TRUE,
> - &Private->PxeReply.Packet.Ack
> - );
> - }
> -
> - if (EFI_ERROR (Status) || !Mode->PxeReplyReceived || (!Mode-
> >PxeBisReplyReceived && UseBis)) {
> - if (Status == EFI_ICMP_ERROR) {
> - Mode->IcmpErrorReceived = TRUE;
> - } else {
> - Status = EFI_DEVICE_ERROR;
> - }
> - goto ON_EXIT;
> - } else {
> - PxeBcParseCachedDhcpPacket (&Private->PxeReply);
> - }
> -
> - if (Mode->PxeBisReplyReceived) {
> - CopyMem (
> - &Private->ServerIp,
> - &Mode->PxeReply.Dhcpv4.BootpSiAddr,
> - sizeof (EFI_IPv4_ADDRESS)
> - );
> - }
> -
> - if (CreatedInfo != NULL) {
> - FreePool (CreatedInfo);
> - }
> -
> -ON_EXIT:
> -
> - Private->Udp4Read->Configure (Private->Udp4Read, &Private->Udp4CfgData);
> -
> - //
> - // Dhcp(), Discover(), and Mtftp() set the IP filter, and return with the IP
> - // receive filter list emptied and the filter set to
> EFI_PXE_BASE_CODE_IP_FILTER_STATION_IP.
> - //
> - ZeroMem(&IpFilter, sizeof (EFI_PXE_BASE_CODE_IP_FILTER));
> - IpFilter.Filters = EFI_PXE_BASE_CODE_IP_FILTER_STATION_IP;
> - This->SetIpFilter (This, &IpFilter);
> -
> - return Status;
> -}
> -
> -
> -/**
> - Used to perform TFTP and MTFTP services.
> -
> - This function is used to perform TFTP and MTFTP services. This includes the
> - TFTP operations to get the size of a file, read a directory, read a file, and
> - write a file. It also includes the MTFTP operations to get the size of a file,
> - read a directory, and read a file. The type of operation is specified by
> Operation.
> - If the callback function that is invoked during the TFTP/MTFTP operation does
> - not return EFI_PXE_BASE_CODE_CALLBACK_STATUS_CONTINUE, then
> EFI_ABORTED will
> - be returned.
> - For read operations, the return data will be placed in the buffer specified by
> - BufferPtr. If BufferSize is too small to contain the entire downloaded file,
> - then EFI_BUFFER_TOO_SMALL will be returned and BufferSize will be set to
> zero
> - or the size of the requested file (the size of the requested file is only returned
> - if the TFTP server supports TFTP options). If BufferSize is large enough for the
> - read operation, then BufferSize will be set to the size of the downloaded file,
> - and EFI_SUCCESS will be returned. Applications using the PxeBc.Mtftp()
> services
> - should use the get-file-size operations to determine the size of the
> downloaded
> - file prior to using the read-file operations-especially when downloading large
> - (greater than 64 MB) files-instead of making two calls to the read-file
> operation.
> - Following this recommendation will save time if the file is larger than expected
> - and the TFTP server does not support TFTP option extensions. Without TFTP
> option
> - extension support, the client has to download the entire file, counting and
> discarding
> - the received packets, to determine the file size.
> - For write operations, the data to be sent is in the buffer specified by BufferPtr.
> - BufferSize specifies the number of bytes to send. If the write operation
> completes
> - successfully, then EFI_SUCCESS will be returned.
> - For TFTP "get file size" operations, the size of the requested file or directory
> - is returned in BufferSize, and EFI_SUCCESS will be returned. If the TFTP server
> - does not support options, the file will be downloaded into a bit bucket and the
> - length of the downloaded file will be returned. For MTFTP "get file size"
> operations,
> - if the MTFTP server does not support the "get file size" option,
> EFI_UNSUPPORTED
> - will be returned.
> - This function can take up to 10 seconds to timeout and return control to the
> caller.
> - If the TFTP sequence does not complete, EFI_TIMEOUT will be returned.
> - If the Callback Protocol does not return
> EFI_PXE_BASE_CODE_CALLBACK_STATUS_CONTINUE,
> - then the TFTP sequence is stopped and EFI_ABORTED will be returned.
> - The format of the data returned from a TFTP read directory operation is a null-
> terminated
> - filename followed by a null-terminated information string, of the form
> - "size year-month-day hour:minute:second" (i.e. %d %d-%d-%d %d:%d:%f -
> note that
> - the seconds field can be a decimal number), where the date and time are UTC.
> For
> - an MTFTP read directory command, there is additionally a null-terminated
> multicast
> - IP address preceding the filename of the form %d.%d.%d.%d for IP v4. The
> final
> - entry is itself null-terminated, so that the final information string is terminated
> - with two null octets.
> -
> - @param This Pointer to the EFI_PXE_BASE_CODE_PROTOCOL
> instance.
> - @param Operation The type of operation to perform.
> - @param BufferPtr A pointer to the data buffer.
> - @param Overwrite Only used on write file operations. TRUE if a file on
> a remote server can
> - be overwritten.
> - @param BufferSize For get-file-size operations, *BufferSize returns the
> size of the
> - requested file.
> - @param BlockSize The requested block size to be used during a TFTP
> transfer.
> - @param ServerIp The TFTP / MTFTP server IP address.
> - @param Filename A Null-terminated ASCII string that specifies a
> directory name or a file
> - name.
> - @param Info Pointer to the MTFTP information.
> - @param DontUseBuffer Set to FALSE for normal TFTP and MTFTP read
> file operation.
> -
> - @retval EFI_SUCCESS The TFTP/MTFTP operation was completed.
> - @retval EFI_NOT_STARTED The PXE Base Code Protocol is in the stopped
> state.
> - @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
> - @retval EFI_DEVICE_ERROR The network device encountered an error
> during this operation.
> - @retval EFI_BUFFER_TOO_SMALL The buffer is not large enough to complete
> the read operation.
> - @retval EFI_ABORTED The callback function aborted the TFTP/MTFTP
> operation.
> - @retval EFI_TIMEOUT The TFTP/MTFTP operation timed out.
> - @retval EFI_ICMP_ERROR An ICMP error packet was received during the
> MTFTP session.
> - @retval EFI_TFTP_ERROR A TFTP error packet was received during the
> MTFTP session.
> -
> -**/
> -EFI_STATUS
> -EFIAPI
> -EfiPxeBcMtftp (
> - IN EFI_PXE_BASE_CODE_PROTOCOL *This,
> - IN EFI_PXE_BASE_CODE_TFTP_OPCODE Operation,
> - IN OUT VOID *BufferPtr,
> - IN BOOLEAN Overwrite,
> - IN OUT UINT64 *BufferSize,
> - IN UINTN *BlockSize OPTIONAL,
> - IN EFI_IP_ADDRESS *ServerIp,
> - IN UINT8 *Filename,
> - IN EFI_PXE_BASE_CODE_MTFTP_INFO *Info OPTIONAL,
> - IN BOOLEAN DontUseBuffer
> - )
> -{
> - PXEBC_PRIVATE_DATA *Private;
> - EFI_MTFTP4_CONFIG_DATA Mtftp4Config;
> - EFI_STATUS Status;
> - EFI_PXE_BASE_CODE_MODE *Mode;
> - EFI_MAC_ADDRESS TempMacAddr;
> - EFI_PXE_BASE_CODE_IP_FILTER IpFilter;
> -
> - if ((This == NULL) ||
> - (Filename == NULL) ||
> - (BufferSize == NULL) ||
> - ((ServerIp == NULL) ||
> - (IP4_IS_UNSPECIFIED (NTOHL (ServerIp->Addr[0])) ||
> - IP4_IS_LOCAL_BROADCAST (NTOHL (ServerIp->Addr[0])))) ||
> - ((BufferPtr == NULL) && DontUseBuffer) ||
> - ((BlockSize != NULL) && (*BlockSize < 512))) {
> -
> - return EFI_INVALID_PARAMETER;
> - }
> -
> - Status = EFI_DEVICE_ERROR;
> - Private = PXEBC_PRIVATE_DATA_FROM_PXEBC (This);
> - Mode = &Private->Mode;
> -
> - if (!Mode->AutoArp) {
> - //
> - // If AutoArp is set false, check arp cache
> - //
> - UpdateArpCache (This);
> - if (!FindInArpCache (Mode, &ServerIp->v4, &TempMacAddr)) {
> - return EFI_DEVICE_ERROR;
> - }
> - }
> -
> - //
> - // Stop Udp4Read instance
> - //
> - Private->Udp4Read->Configure (Private->Udp4Read, NULL);
> -
> - Mode->TftpErrorReceived = FALSE;
> - Mode->IcmpErrorReceived = FALSE;
> -
> - Mtftp4Config.UseDefaultSetting = FALSE;
> - Mtftp4Config.TimeoutValue = PXEBC_MTFTP_TIMEOUT;
> - Mtftp4Config.TryCount = PXEBC_MTFTP_RETRIES;
> -
> - CopyMem (
> - &Mtftp4Config.StationIp,
> - &Private->StationIp,
> - sizeof (EFI_IPv4_ADDRESS)
> - );
> - CopyMem (
> - &Mtftp4Config.SubnetMask,
> - &Private->SubnetMask,
> - sizeof (EFI_IPv4_ADDRESS)
> - );
> - CopyMem (
> - &Mtftp4Config.GatewayIp,
> - &Private->GatewayIp,
> - sizeof (EFI_IPv4_ADDRESS)
> - );
> - CopyMem (
> - &Mtftp4Config.ServerIp,
> - ServerIp,
> - sizeof (EFI_IPv4_ADDRESS)
> - );
> -
> - switch (Operation) {
> -
> - case EFI_PXE_BASE_CODE_TFTP_GET_FILE_SIZE:
> -
> - Status = PxeBcTftpGetFileSize (
> - Private,
> - &Mtftp4Config,
> - Filename,
> - BlockSize,
> - BufferSize
> - );
> -
> - break;
> -
> - case EFI_PXE_BASE_CODE_TFTP_READ_FILE:
> -
> - Status = PxeBcTftpReadFile (
> - Private,
> - &Mtftp4Config,
> - Filename,
> - BlockSize,
> - BufferPtr,
> - BufferSize,
> - DontUseBuffer
> - );
> -
> - break;
> -
> - case EFI_PXE_BASE_CODE_TFTP_WRITE_FILE:
> -
> - Status = PxeBcTftpWriteFile (
> - Private,
> - &Mtftp4Config,
> - Filename,
> - Overwrite,
> - BlockSize,
> - BufferPtr,
> - BufferSize
> - );
> -
> - break;
> -
> - case EFI_PXE_BASE_CODE_TFTP_READ_DIRECTORY:
> -
> - Status = PxeBcTftpReadDirectory (
> - Private,
> - &Mtftp4Config,
> - Filename,
> - BlockSize,
> - BufferPtr,
> - BufferSize,
> - DontUseBuffer
> - );
> -
> - break;
> -
> - case EFI_PXE_BASE_CODE_MTFTP_GET_FILE_SIZE:
> - case EFI_PXE_BASE_CODE_MTFTP_READ_FILE:
> - case EFI_PXE_BASE_CODE_MTFTP_READ_DIRECTORY:
> - Status = EFI_UNSUPPORTED;
> - break;
> -
> - default:
> -
> - Status = EFI_INVALID_PARAMETER;
> - break;
> - }
> -
> - if (Status == EFI_ICMP_ERROR) {
> - Mode->IcmpErrorReceived = TRUE;
> - }
> -
> - if (EFI_ERROR (Status)) {
> - goto ON_EXIT;
> - }
> -
> -ON_EXIT:
> - Private->Udp4Read->Configure (Private->Udp4Read, &Private->Udp4CfgData);
> - //
> - // Dhcp(), Discover(), and Mtftp() set the IP filter, and return with the IP
> - // receive filter list emptied and the filter set to
> EFI_PXE_BASE_CODE_IP_FILTER_STATION_IP.
> - //
> - ZeroMem(&IpFilter, sizeof (EFI_PXE_BASE_CODE_IP_FILTER));
> - IpFilter.Filters = EFI_PXE_BASE_CODE_IP_FILTER_STATION_IP;
> - This->SetIpFilter (This, &IpFilter);
> -
> - return Status;
> -}
> -
> -
> -/**
> - Writes a UDP packet to the network interface.
> -
> - This function writes a UDP packet specified by the (optional HeaderPtr and)
> - BufferPtr parameters to the network interface. The UDP header is
> automatically
> - built by this routine. It uses the parameters OpFlags, DestIp, DestPort,
> GatewayIp,
> - SrcIp, and SrcPort to build this header. If the packet is successfully built and
> - transmitted through the network interface, then EFI_SUCCESS will be returned.
> - If a timeout occurs during the transmission of the packet, then EFI_TIMEOUT
> will
> - be returned. If an ICMP error occurs during the transmission of the packet,
> then
> - the IcmpErrorReceived field is set to TRUE, the IcmpError field is filled in and
> - EFI_ICMP_ERROR will be returned. If the Callback Protocol does not return
> - EFI_PXE_BASE_CODE_CALLBACK_STATUS_CONTINUE, then EFI_ABORTED will
> be returned.
> -
> - @param This Pointer to the EFI_PXE_BASE_CODE_PROTOCOL
> instance.
> - @param OpFlags The UDP operation flags.
> - @param DestIp The destination IP address.
> - @param DestPort The destination UDP port number.
> - @param GatewayIp The gateway IP address.
> - @param SrcIp The source IP address.
> - @param SrcPort The source UDP port number.
> - @param HeaderSize An optional field which may be set to the length of
> a header at
> - HeaderPtr to be prefixed to the data at BufferPtr.
> - @param HeaderPtr If HeaderSize is not NULL, a pointer to a header to
> be prefixed to the
> - data at BufferPtr.
> - @param BufferSize A pointer to the size of the data at BufferPtr.
> - @param BufferPtr A pointer to the data to be written.
> -
> - @retval EFI_SUCCESS The UDP Write operation was completed.
> - @retval EFI_NOT_STARTED The PXE Base Code Protocol is in the stopped
> state.
> - @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
> - @retval EFI_BAD_BUFFER_SIZE The buffer is too long to be transmitted.
> - @retval EFI_ABORTED The callback function aborted the UDP Write
> operation.
> - @retval EFI_TIMEOUT The UDP Write operation timed out.
> - @retval EFI_ICMP_ERROR An ICMP error packet was received during the
> UDP write session.
> -
> -**/
> -EFI_STATUS
> -EFIAPI
> -EfiPxeBcUdpWrite (
> - IN EFI_PXE_BASE_CODE_PROTOCOL *This,
> - IN UINT16 OpFlags,
> - IN EFI_IP_ADDRESS *DestIp,
> - IN EFI_PXE_BASE_CODE_UDP_PORT *DestPort,
> - IN EFI_IP_ADDRESS *GatewayIp OPTIONAL,
> - IN EFI_IP_ADDRESS *SrcIp OPTIONAL,
> - IN OUT EFI_PXE_BASE_CODE_UDP_PORT *SrcPort OPTIONAL,
> - IN UINTN *HeaderSize OPTIONAL,
> - IN VOID *HeaderPtr OPTIONAL,
> - IN UINTN *BufferSize,
> - IN VOID *BufferPtr
> - )
> -{
> - PXEBC_PRIVATE_DATA *Private;
> - EFI_UDP4_PROTOCOL *Udp4;
> - EFI_UDP4_COMPLETION_TOKEN Token;
> - EFI_UDP4_TRANSMIT_DATA *Udp4TxData;
> - UINT32 FragCount;
> - UINT32 DataLength;
> - EFI_UDP4_SESSION_DATA Udp4Session;
> - EFI_STATUS Status;
> - BOOLEAN IsDone;
> - EFI_PXE_BASE_CODE_MODE *Mode;
> - EFI_MAC_ADDRESS TempMacAddr;
> -
> - IsDone = FALSE;
> -
> - if ((This == NULL) || (DestIp == NULL) || (DestPort == NULL)) {
> - return EFI_INVALID_PARAMETER;
> - }
> -
> - if ((GatewayIp != NULL) && (IP4_IS_UNSPECIFIED (NTOHL (GatewayIp-
> >Addr[0])) || IP4_IS_LOCAL_BROADCAST (NTOHL (GatewayIp->Addr[0])))) {
> - //
> - // Gateway is provided but it's not a unicast IP address.
> - //
> - return EFI_INVALID_PARAMETER;
> - }
> -
> - if ((HeaderSize != NULL) && ((*HeaderSize == 0) || (HeaderPtr == NULL))) {
> - //
> - // The HeaderSize ptr isn't NULL and: 1. the value is zero; or 2. the HeaderPtr
> - // is NULL.
> - //
> - return EFI_INVALID_PARAMETER;
> - }
> -
> - if ((BufferSize == NULL) || ((*BufferSize != 0) && (BufferPtr == NULL))) {
> - return EFI_INVALID_PARAMETER;
> - }
> -
> - Private = PXEBC_PRIVATE_DATA_FROM_PXEBC (This);
> - Udp4 = Private->Udp4Write;
> - Mode = &Private->Mode;
> - if (!Mode->Started) {
> - return EFI_NOT_STARTED;
> - }
> -
> - if (!Private->AddressIsOk && (SrcIp == NULL)) {
> - return EFI_INVALID_PARAMETER;
> - }
> -
> - if (!Mode->AutoArp) {
> - //
> - // If AutoArp is set false, check arp cache
> - //
> - UpdateArpCache (This);
> - if (!FindInArpCache (Mode, &DestIp->v4, &TempMacAddr)) {
> - return EFI_DEVICE_ERROR;
> - }
> - }
> -
> - Mode->IcmpErrorReceived = FALSE;
> -
> - if ((Private->CurrentUdpSrcPort == 0) ||
> - ((SrcPort != NULL) && (*SrcPort != Private->CurrentUdpSrcPort))) {
> - //
> - // Port is changed, (re)configure the Udp4Write instance
> - //
> - if (SrcPort != NULL) {
> - Private->CurrentUdpSrcPort = *SrcPort;
> - }
> - }
> -
> - Status = PxeBcConfigureUdpWriteInstance (
> - Udp4,
> - &Private->StationIp.v4,
> - &Private->SubnetMask.v4,
> - &Private->GatewayIp.v4,
> - &Private->CurrentUdpSrcPort,
> - Private->Mode.TTL,
> - Private->Mode.ToS
> - );
> - if (EFI_ERROR (Status)) {
> - Private->CurrentUdpSrcPort = 0;
> - return EFI_INVALID_PARAMETER;
> - }
> -
> - ZeroMem (&Token, sizeof (EFI_UDP4_COMPLETION_TOKEN));
> - ZeroMem (&Udp4Session, sizeof (EFI_UDP4_SESSION_DATA));
> -
> - CopyMem (&Udp4Session.DestinationAddress, DestIp, sizeof
> (EFI_IPv4_ADDRESS));
> - Udp4Session.DestinationPort = *DestPort;
> - if (SrcIp != NULL) {
> - CopyMem (&Udp4Session.SourceAddress, SrcIp, sizeof (EFI_IPv4_ADDRESS));
> - }
> - if (SrcPort != NULL) {
> - Udp4Session.SourcePort = *SrcPort;
> - }
> -
> - FragCount = (HeaderSize != NULL) ? 2 : 1;
> - Udp4TxData = (EFI_UDP4_TRANSMIT_DATA *) AllocateZeroPool (sizeof
> (EFI_UDP4_TRANSMIT_DATA) + (FragCount - 1) * sizeof
> (EFI_UDP4_FRAGMENT_DATA));
> - if (Udp4TxData == NULL) {
> - return EFI_OUT_OF_RESOURCES;
> - }
> -
> - Udp4TxData->FragmentCount = FragCount;
> - Udp4TxData->FragmentTable[FragCount - 1].FragmentLength = (UINT32)
> *BufferSize;
> - Udp4TxData->FragmentTable[FragCount - 1].FragmentBuffer = BufferPtr;
> - DataLength = (UINT32) *BufferSize;
> -
> - if (FragCount == 2) {
> -
> - Udp4TxData->FragmentTable[0].FragmentLength = (UINT32) *HeaderSize;
> - Udp4TxData->FragmentTable[0].FragmentBuffer = HeaderPtr;
> - DataLength += (UINT32) *HeaderSize;
> - }
> -
> - if (GatewayIp != NULL) {
> - Udp4TxData->GatewayAddress = (EFI_IPv4_ADDRESS *) GatewayIp;
> - }
> - Udp4TxData->UdpSessionData = &Udp4Session;
> - Udp4TxData->DataLength = DataLength;
> - Token.Packet.TxData = Udp4TxData;
> -
> - Status = gBS->CreateEvent (
> - EVT_NOTIFY_SIGNAL,
> - TPL_NOTIFY,
> - PxeBcCommonNotify,
> - &IsDone,
> - &Token.Event
> - );
> - if (EFI_ERROR (Status)) {
> - goto ON_EXIT;
> - }
> -
> - Status = Udp4->Transmit (Udp4, &Token);
> - if (EFI_ERROR (Status)) {
> - if (Status == EFI_ICMP_ERROR) {
> - Mode->IcmpErrorReceived = TRUE;
> - }
> - goto ON_EXIT;
> - }
> -
> - while (!IsDone) {
> -
> - Udp4->Poll (Udp4);
> - }
> -
> - Status = Token.Status;
> -
> -ON_EXIT:
> -
> - if (Token.Event != NULL) {
> - gBS->CloseEvent (Token.Event);
> - }
> -
> - FreePool (Udp4TxData);
> -
> - //
> - // Reset the instance.
> - //
> - Udp4->Configure (Udp4, NULL);
> - return Status;
> -}
> -
> -/**
> - Decide whether the incoming UDP packet is acceptable per IP filter settings
> - in provided PxeBcMode.
> -
> - @param PxeBcMode Pointer to EFI_PXE_BASE_CODE_MODE.
> - @param Session Received UDP session.
> -
> - @retval TRUE The UDP package matches IP filters.
> - @retval FALSE The UDP package doesn't matches IP filters.
> -
> -**/
> -BOOLEAN
> -CheckIpByFilter (
> - IN EFI_PXE_BASE_CODE_MODE *PxeBcMode,
> - IN EFI_UDP4_SESSION_DATA *Session
> - )
> -{
> - UINTN Index;
> - EFI_IPv4_ADDRESS Ip4Address;
> - EFI_IPv4_ADDRESS DestIp4Address;
> -
> - if ((PxeBcMode->IpFilter.Filters &
> EFI_PXE_BASE_CODE_IP_FILTER_PROMISCUOUS) != 0) {
> - return TRUE;
> - }
> -
> - CopyMem (&DestIp4Address, &Session->DestinationAddress, sizeof
> (DestIp4Address));
> - if (((PxeBcMode->IpFilter.Filters &
> EFI_PXE_BASE_CODE_IP_FILTER_PROMISCUOUS_MULTICAST) != 0) &&
> - IP4_IS_MULTICAST (EFI_NTOHL (DestIp4Address))
> - ) {
> - return TRUE;
> - }
> -
> - if (((PxeBcMode->IpFilter.Filters &
> EFI_PXE_BASE_CODE_IP_FILTER_BROADCAST) != 0) &&
> - IP4_IS_LOCAL_BROADCAST (EFI_NTOHL (DestIp4Address))
> - ) {
> - return TRUE;
> - }
> -
> - CopyMem (&Ip4Address, &PxeBcMode->StationIp.v4, sizeof (Ip4Address));
> - if (((PxeBcMode->IpFilter.Filters &
> EFI_PXE_BASE_CODE_IP_FILTER_STATION_IP) != 0) &&
> - EFI_IP4_EQUAL (&Ip4Address, &DestIp4Address)
> - ) {
> - return TRUE;
> - }
> -
> - ASSERT (PxeBcMode->IpFilter.IpCnt < EFI_PXE_BASE_CODE_MAX_IPCNT);
> -
> - for (Index = 0; Index < PxeBcMode->IpFilter.IpCnt; Index++) {
> - CopyMem (
> - &Ip4Address,
> - &PxeBcMode->IpFilter.IpList[Index].v4,
> - sizeof (Ip4Address)
> - );
> - if (EFI_IP4_EQUAL (&Ip4Address, &DestIp4Address)) {
> - return TRUE;
> - }
> - }
> -
> - return FALSE;
> -}
> -
> -/**
> - Reads a UDP packet from the network interface.
> -
> - This function reads a UDP packet from a network interface. The data contents
> - are returned in (the optional HeaderPtr and) BufferPtr, and the size of the
> - buffer received is returned in BufferSize . If the input BufferSize is smaller
> - than the UDP packet received (less optional HeaderSize), it will be set to the
> - required size, and EFI_BUFFER_TOO_SMALL will be returned. In this case, the
> - contents of BufferPtr are undefined, and the packet is lost. If a UDP packet is
> - successfully received, then EFI_SUCCESS will be returned, and the information
> - from the UDP header will be returned in DestIp, DestPort, SrcIp, and SrcPort if
> - they are not NULL. Depending on the values of OpFlags and the DestIp,
> DestPort,
> - SrcIp, and SrcPort input values, different types of UDP packet receive filtering
> - will be performed. The following tables summarize these receive filter
> operations.
> -
> - @param This Pointer to the EFI_PXE_BASE_CODE_PROTOCOL
> instance.
> - @param OpFlags The UDP operation flags.
> - @param DestIp The destination IP address.
> - @param DestPort The destination UDP port number.
> - @param SrcIp The source IP address.
> - @param SrcPort The source UDP port number.
> - @param HeaderSize An optional field which may be set to the length of
> a header at
> - HeaderPtr to be prefixed to the data at BufferPtr.
> - @param HeaderPtr If HeaderSize is not NULL, a pointer to a header to
> be prefixed to the
> - data at BufferPtr.
> - @param BufferSize A pointer to the size of the data at BufferPtr.
> - @param BufferPtr A pointer to the data to be read.
> -
> - @retval EFI_SUCCESS The UDP Read operation was completed.
> - @retval EFI_NOT_STARTED The PXE Base Code Protocol is in the stopped
> state.
> - @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
> - @retval EFI_DEVICE_ERROR The network device encountered an error
> during this operation.
> - @retval EFI_BUFFER_TOO_SMALL The packet is larger than Buffer can hold.
> - @retval EFI_ABORTED The callback function aborted the UDP Read
> operation.
> - @retval EFI_TIMEOUT The UDP Read operation timed out.
> -
> -**/
> -EFI_STATUS
> -EFIAPI
> -EfiPxeBcUdpRead (
> - IN EFI_PXE_BASE_CODE_PROTOCOL *This,
> - IN UINT16 OpFlags,
> - IN OUT EFI_IP_ADDRESS *DestIp OPTIONAL,
> - IN OUT EFI_PXE_BASE_CODE_UDP_PORT *DestPort OPTIONAL,
> - IN OUT EFI_IP_ADDRESS *SrcIp OPTIONAL,
> - IN OUT EFI_PXE_BASE_CODE_UDP_PORT *SrcPort OPTIONAL,
> - IN UINTN *HeaderSize OPTIONAL,
> - IN VOID *HeaderPtr OPTIONAL,
> - IN OUT UINTN *BufferSize,
> - IN VOID *BufferPtr
> - )
> -{
> - PXEBC_PRIVATE_DATA *Private;
> - EFI_PXE_BASE_CODE_MODE *Mode;
> - EFI_UDP4_PROTOCOL *Udp4;
> - EFI_UDP4_COMPLETION_TOKEN Token;
> - EFI_UDP4_RECEIVE_DATA *RxData;
> - EFI_UDP4_SESSION_DATA *Session;
> - EFI_STATUS Status;
> - BOOLEAN IsDone;
> - BOOLEAN Matched;
> - UINTN CopiedLen;
> - UINTN HeaderLen;
> - UINTN HeaderCopiedLen;
> - UINTN BufferCopiedLen;
> - UINT32 FragmentLength;
> - UINTN FragmentIndex;
> - UINT8 *FragmentBuffer;
> -
> - if (This == NULL || DestIp == NULL || DestPort == NULL) {
> - return EFI_INVALID_PARAMETER;
> - }
> -
> - if (((OpFlags & EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_DEST_PORT) == 0
> && (DestPort == NULL)) ||
> - ((OpFlags & EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_DEST_PORT) == 0
> && (SrcIp == NULL)) ||
> - ((OpFlags & EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_SRC_PORT) == 0 &&
> (SrcPort == NULL))) {
> - return EFI_INVALID_PARAMETER;
> - }
> -
> - if (((HeaderSize != NULL) && (*HeaderSize == 0)) || ((HeaderSize != NULL) &&
> (HeaderPtr == NULL))) {
> - return EFI_INVALID_PARAMETER;
> - }
> -
> - if ((BufferSize == NULL) || (BufferPtr == NULL)) {
> - return EFI_INVALID_PARAMETER;
> - }
> -
> - Private = PXEBC_PRIVATE_DATA_FROM_PXEBC (This);
> - Mode = Private->PxeBc.Mode;
> - Udp4 = Private->Udp4Read;
> -
> - if (!Mode->Started) {
> - return EFI_NOT_STARTED;
> - }
> -
> - Mode->IcmpErrorReceived = FALSE;
> -
> - Status = gBS->CreateEvent (
> - EVT_NOTIFY_SIGNAL,
> - TPL_NOTIFY,
> - PxeBcCommonNotify,
> - &IsDone,
> - &Token.Event
> - );
> - if (EFI_ERROR (Status)) {
> - return EFI_OUT_OF_RESOURCES;
> - }
> -
> -TRY_AGAIN:
> -
> - IsDone = FALSE;
> - Status = Udp4->Receive (Udp4, &Token);
> - if (EFI_ERROR (Status)) {
> - if (Status == EFI_ICMP_ERROR) {
> - Mode->IcmpErrorReceived = TRUE;
> - }
> - goto ON_EXIT;
> - }
> -
> - Udp4->Poll (Udp4);
> -
> - if (!IsDone) {
> - Status = EFI_TIMEOUT;
> - } else {
> -
> - //
> - // check whether this packet matches the filters
> - //
> - if (EFI_ERROR (Token.Status)){
> - goto ON_EXIT;
> - }
> -
> - RxData = Token.Packet.RxData;
> - Session = &RxData->UdpSession;
> -
> - Matched = TRUE;
> -
> - if ((OpFlags & EFI_PXE_BASE_CODE_UDP_OPFLAGS_USE_FILTER) != 0) {
> - Matched = FALSE;
> - //
> - // Check UDP package by IP filter settings
> - //
> - if (CheckIpByFilter (Mode, Session)) {
> - Matched = TRUE;
> - }
> - }
> -
> - if (Matched) {
> - Matched = FALSE;
> -
> - //
> - // Match the destination ip of the received udp dgram
> - //
> - if ((OpFlags & EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_DEST_IP) != 0) {
> - Matched = TRUE;
> -
> - if (DestIp != NULL) {
> - CopyMem (DestIp, &Session->DestinationAddress, sizeof
> (EFI_IPv4_ADDRESS));
> - }
> - } else {
> - if (DestIp != NULL) {
> - if (EFI_IP4_EQUAL (DestIp, &Session->DestinationAddress)) {
> - Matched = TRUE;
> - }
> - } else {
> - if (EFI_IP4_EQUAL (&Private->StationIp, &Session->DestinationAddress)) {
> - Matched = TRUE;
> - }
> - }
> - }
> - }
> -
> - if (Matched) {
> - //
> - // Match the destination port of the received udp dgram
> - //
> - if ((OpFlags & EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_DEST_PORT) != 0)
> {
> -
> - if (DestPort != NULL) {
> - *DestPort = Session->DestinationPort;
> - }
> - } else {
> -
> - if (*DestPort != Session->DestinationPort) {
> - Matched = FALSE;
> - }
> - }
> - }
> -
> - if (Matched) {
> - //
> - // Match the source ip of the received udp dgram
> - //
> - if ((OpFlags & EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_SRC_IP) != 0) {
> -
> - if (SrcIp != NULL) {
> - CopyMem (SrcIp, &Session->SourceAddress, sizeof (EFI_IPv4_ADDRESS));
> - }
> - } else {
> -
> - if (!EFI_IP4_EQUAL (SrcIp, &Session->SourceAddress)) {
> - Matched = FALSE;
> - }
> - }
> - }
> -
> - if (Matched) {
> - //
> - // Match the source port of the received udp dgram
> - //
> - if ((OpFlags & EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_SRC_PORT) != 0) {
> -
> - if (SrcPort != NULL) {
> - *SrcPort = Session->SourcePort;
> - }
> - } else {
> -
> - if (*SrcPort != Session->SourcePort) {
> - Matched = FALSE;
> - }
> - }
> - }
> -
> - if (Matched) {
> - ASSERT (RxData != NULL);
> -
> - HeaderLen = 0;
> - if (HeaderSize != NULL) {
> - HeaderLen = MIN (*HeaderSize, RxData->DataLength);
> - }
> -
> - if (RxData->DataLength - HeaderLen > *BufferSize) {
> - Status = EFI_BUFFER_TOO_SMALL;
> - } else {
> - *HeaderSize = HeaderLen;
> - *BufferSize = RxData->DataLength - HeaderLen;
> -
> - HeaderCopiedLen = 0;
> - BufferCopiedLen = 0;
> - for (FragmentIndex = 0; FragmentIndex < RxData->FragmentCount;
> FragmentIndex++) {
> - FragmentLength = RxData-
> >FragmentTable[FragmentIndex].FragmentLength;
> - FragmentBuffer = RxData-
> >FragmentTable[FragmentIndex].FragmentBuffer;
> - if (HeaderCopiedLen + FragmentLength < HeaderLen) {
> - //
> - // Copy the header part of received data.
> - //
> - CopyMem ((UINT8 *) HeaderPtr + HeaderCopiedLen, FragmentBuffer,
> FragmentLength);
> - HeaderCopiedLen += FragmentLength;
> - } else if (HeaderCopiedLen < HeaderLen) {
> - //
> - // Copy the header part of received data.
> - //
> - CopiedLen = HeaderLen - HeaderCopiedLen;
> - CopyMem ((UINT8 *) HeaderPtr + HeaderCopiedLen, FragmentBuffer,
> CopiedLen);
> - HeaderCopiedLen += CopiedLen;
> -
> - //
> - // Copy the other part of received data.
> - //
> - CopyMem ((UINT8 *) BufferPtr + BufferCopiedLen, FragmentBuffer +
> CopiedLen, FragmentLength - CopiedLen);
> - BufferCopiedLen += (FragmentLength - CopiedLen);
> - } else {
> - //
> - // Copy the other part of received data.
> - //
> - CopyMem ((UINT8 *) BufferPtr + BufferCopiedLen, FragmentBuffer,
> FragmentLength);
> - BufferCopiedLen += FragmentLength;
> - }
> - }
> - }
> - } else {
> -
> - Status = EFI_TIMEOUT;
> - }
> -
> - //
> - // Recycle the RxData
> - //
> - gBS->SignalEvent (RxData->RecycleSignal);
> -
> - if (!Matched) {
> - goto TRY_AGAIN;
> - }
> - }
> -
> -ON_EXIT:
> -
> - Udp4->Cancel (Udp4, &Token);
> -
> - gBS->CloseEvent (Token.Event);
> -
> - return Status;
> -}
> -
> -/**
> - Updates the IP receive filters of a network device and enables software
> filtering.
> -
> - The NewFilter field is used to modify the network device's current IP receive
> - filter settings and to enable a software filter. This function updates the IpFilter
> - field of the EFI_PXE_BASE_CODE_MODE structure with the contents of
> NewIpFilter.
> - The software filter is used when the USE_FILTER in OpFlags is set to UdpRead().
> - The current hardware filter remains in effect no matter what the settings of
> OpFlags
> - are, so that the meaning of ANY_DEST_IP set in OpFlags to UdpRead() is from
> those
> - packets whose reception is enabled in hardware-physical NIC address (unicast),
> - broadcast address, logical address or addresses (multicast), or all
> (promiscuous).
> - UdpRead() does not modify the IP filter settings.
> - Dhcp(), Discover(), and Mtftp() set the IP filter, and return with the IP receive
> - filter list emptied and the filter set to
> EFI_PXE_BASE_CODE_IP_FILTER_STATION_IP.
> - If an application or driver wishes to preserve the IP receive filter settings,
> - it will have to preserve the IP receive filter settings before these calls, and
> - use SetIpFilter() to restore them after the calls. If incompatible filtering is
> - requested (for example, PROMISCUOUS with anything else) or if the device
> does not
> - support a requested filter setting and it cannot be accommodated in software
> - (for example, PROMISCUOUS not supported), EFI_INVALID_PARAMETER will
> be returned.
> - The IPlist field is used to enable IPs other than the StationIP. They may be
> - multicast or unicast. If IPcnt is set as well as
> EFI_PXE_BASE_CODE_IP_FILTER_STATION_IP,
> - then both the StationIP and the IPs from the IPlist will be used.
> -
> - @param This Pointer to the EFI_PXE_BASE_CODE_PROTOCOL
> instance.
> - @param NewFilter Pointer to the new set of IP receive filters.
> -
> - @retval EFI_SUCCESS The IP receive filter settings were updated.
> - @retval EFI_NOT_STARTED The PXE Base Code Protocol is in the stopped
> state.
> - @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
> -
> -**/
> -EFI_STATUS
> -EFIAPI
> -EfiPxeBcSetIpFilter (
> - IN EFI_PXE_BASE_CODE_PROTOCOL *This,
> - IN EFI_PXE_BASE_CODE_IP_FILTER *NewFilter
> - )
> -{
> - EFI_STATUS Status;
> - PXEBC_PRIVATE_DATA *Private;
> - EFI_PXE_BASE_CODE_MODE *Mode;
> - UINTN Index;
> - EFI_UDP4_CONFIG_DATA *Udp4Cfg;
> - BOOLEAN PromiscuousNeed;
> - BOOLEAN AcceptPromiscuous;
> - BOOLEAN AcceptBroadcast;
> - BOOLEAN MultiCastUpdate;
> -
> - if (This == NULL) {
> - DEBUG ((EFI_D_ERROR, "This == NULL.\n"));
> - return EFI_INVALID_PARAMETER;
> - }
> -
> - Private = PXEBC_PRIVATE_DATA_FROM_PXEBC (This);
> - Mode = Private->PxeBc.Mode;
> -
> - if (NewFilter == NULL) {
> - DEBUG ((EFI_D_ERROR, "NewFilter == NULL.\n"));
> - return EFI_INVALID_PARAMETER;
> - }
> -
> - 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;
> - }
> -
> - if (!Mode->Started) {
> - DEBUG ((EFI_D_ERROR, "BC was not started.\n"));
> - return EFI_NOT_STARTED;
> - }
> -
> - if (Mode->UsingIpv6) {
> - DEBUG ((EFI_D_ERROR, "This driver is PXE for IPv4 Only.\n"));
> - return EFI_INVALID_PARAMETER;
> - }
> -
> - PromiscuousNeed = FALSE;
> -
> - for (Index = 0; Index < NewFilter->IpCnt; ++Index) {
> - if (IP4_IS_LOCAL_BROADCAST (EFI_IP4 (NewFilter->IpList[Index].v4))) {
> - //
> - // The IP is a broadcast address.
> - //
> - DEBUG ((EFI_D_ERROR, "There is broadcast address in NewFilter.\n"));
> - return EFI_INVALID_PARAMETER;
> - }
> - if ((EFI_NTOHL(Mode->StationIp) != 0) &&
> - (EFI_NTOHL(Mode->SubnetMask) != 0) &&
> - IP4_NET_EQUAL(EFI_NTOHL(Mode->StationIp), EFI_NTOHL(NewFilter-
> >IpList[Index].v4), EFI_NTOHL(Mode->SubnetMask)) &&
> - NetIp4IsUnicast (EFI_IP4 (NewFilter->IpList[Index].v4), EFI_NTOHL(Mode-
> >SubnetMask)) &&
> - ((NewFilter->Filters & EFI_PXE_BASE_CODE_IP_FILTER_STATION_IP) != 0)) {
> - //
> - // If EFI_PXE_BASE_CODE_IP_FILTER_STATION_IP is set and IP4 address is in
> IpList,
> - // promiscuous mode is needed.
> - //
> - PromiscuousNeed = TRUE;
> - }
> - }
> -
> - AcceptPromiscuous = FALSE;
> - AcceptBroadcast = FALSE;
> - MultiCastUpdate = FALSE;
> -
> - if (PromiscuousNeed ||
> - ((NewFilter->Filters & EFI_PXE_BASE_CODE_IP_FILTER_PROMISCUOUS) != 0)
> ||
> - ((NewFilter->Filters &
> EFI_PXE_BASE_CODE_IP_FILTER_PROMISCUOUS_MULTICAST) != 0)
> - ) {
> - //
> - // Configure the udp4 filter to receive all packages.
> - //
> - AcceptPromiscuous = TRUE;
> - } else if ((NewFilter->Filters &
> EFI_PXE_BASE_CODE_IP_FILTER_BROADCAST) != 0) {
> - //
> - // Configure the udp4 filter to receive all broadcast packages.
> - //
> - AcceptBroadcast = TRUE;
> - }
> -
> - //
> - // In multicast condition when Promiscuous FALSE and IpCnt no-zero.
> - // Here check if there is any update of the multicast ip address. If yes,
> - // we need leave the old multicast group (by Config UDP instance to NULL),
> - // and join the new multicast group.
> - //
> - if (!AcceptPromiscuous) {
> - if ((NewFilter->Filters & EFI_PXE_BASE_CODE_IP_FILTER_STATION_IP) != 0) {
> - if (Mode->IpFilter.IpCnt != NewFilter->IpCnt) {
> - MultiCastUpdate = TRUE;
> - } else if (CompareMem (Mode->IpFilter.IpList, NewFilter->IpList, NewFilter-
> >IpCnt * sizeof (EFI_IP_ADDRESS)) != 0 ) {
> - MultiCastUpdate = TRUE;
> - }
> - }
> - }
> -
> - //
> - // Check whether we need reconfigure the UDP instance.
> - //
> - Udp4Cfg = &Private->Udp4CfgData;
> - if ((AcceptPromiscuous != Udp4Cfg->AcceptPromiscuous) ||
> - (AcceptBroadcast != Udp4Cfg->AcceptBroadcast) || MultiCastUpdate) {
> - //
> - // Clear the UDP instance configuration, all joined groups will be left
> - // during the operation.
> - //
> - Private->Udp4Read->Configure (Private->Udp4Read, NULL);
> -
> - //
> - // Configure the UDP instance with the new configuration.
> - //
> - Udp4Cfg->AcceptPromiscuous = AcceptPromiscuous;
> - Udp4Cfg->AcceptBroadcast = AcceptBroadcast;
> - Status = Private->Udp4Read->Configure (Private->Udp4Read, Udp4Cfg);
> - if (EFI_ERROR (Status)) {
> - return Status;
> - }
> -
> - //
> - // In not Promiscuous mode, need to join the new multicast group.
> - //
> - if (!AcceptPromiscuous) {
> - for (Index = 0; Index < NewFilter->IpCnt; ++Index) {
> - if (IP4_IS_MULTICAST (EFI_NTOHL (NewFilter->IpList[Index].v4))) {
> - //
> - // Join the mutilcast group.
> - //
> - Status = Private->Udp4Read->Groups (Private->Udp4Read, TRUE,
> &NewFilter->IpList[Index].v4);
> - if (EFI_ERROR (Status)) {
> - return Status;
> - }
> - }
> - }
> - }
> - }
> -
> -
> - //
> - // Save the new filter.
> - //
> - CopyMem (&Mode->IpFilter, NewFilter, sizeof (Mode->IpFilter));
> -
> - return EFI_SUCCESS;
> -}
> -
> -
> -/**
> - Uses the ARP protocol to resolve a MAC address.
> -
> - This function uses the ARP protocol to resolve a MAC address. The UsingIpv6
> field
> - of the EFI_PXE_BASE_CODE_MODE structure is used to determine if IPv4 or
> IPv6
> - addresses are being used. The IP address specified by IpAddr is used to resolve
> - a MAC address. If the ARP protocol succeeds in resolving the specified address,
> - then the ArpCacheEntries and ArpCache fields of the
> EFI_PXE_BASE_CODE_MODE structure
> - are updated, and EFI_SUCCESS is returned. If MacAddr is not NULL, the
> resolved
> - MAC address is placed there as well. If the PXE Base Code protocol is in the
> - stopped state, then EFI_NOT_STARTED is returned. If the ARP protocol
> encounters
> - a timeout condition while attempting to resolve an address, then
> EFI_TIMEOUT is
> - returned. If the Callback Protocol does not return
> EFI_PXE_BASE_CODE_CALLBACK_STATUS_CONTINUE,
> - then EFI_ABORTED is returned.
> -
> - @param This Pointer to the EFI_PXE_BASE_CODE_PROTOCOL
> instance.
> - @param IpAddr Pointer to the IP address that is used to resolve a
> MAC address.
> - @param MacAddr If not NULL, a pointer to the MAC address that was
> resolved with the
> - ARP protocol.
> -
> - @retval EFI_SUCCESS The IP or MAC address was resolved.
> - @retval EFI_NOT_STARTED The PXE Base Code Protocol is in the stopped
> state.
> - @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
> - @retval EFI_DEVICE_ERROR The network device encountered an error
> during this operation.
> - @retval EFI_ICMP_ERROR Something error occur with the ICMP packet
> message.
> -
> -**/
> -EFI_STATUS
> -EFIAPI
> -EfiPxeBcArp (
> - IN EFI_PXE_BASE_CODE_PROTOCOL * This,
> - IN EFI_IP_ADDRESS * IpAddr,
> - IN EFI_MAC_ADDRESS * MacAddr OPTIONAL
> - )
> -{
> - PXEBC_PRIVATE_DATA *Private;
> - EFI_PXE_BASE_CODE_MODE *Mode;
> - EFI_STATUS Status;
> - EFI_MAC_ADDRESS TempMacAddr;
> -
> - if (This == NULL || IpAddr == NULL) {
> - return EFI_INVALID_PARAMETER;
> - }
> -
> - Private = PXEBC_PRIVATE_DATA_FROM_PXEBC (This);
> - Mode = Private->PxeBc.Mode;
> -
> - if (!Mode->Started) {
> - return EFI_NOT_STARTED;
> - }
> -
> - if (!Private->AddressIsOk || Mode->UsingIpv6) {
> - //
> - // We can't resolve the IP address if we don't have a local address now.
> - // Don't have ARP for IPv6.
> - //
> - return EFI_INVALID_PARAMETER;
> - }
> -
> - Mode->IcmpErrorReceived = FALSE;
> -
> - if (!Mode->AutoArp) {
> - //
> - // If AutoArp is set false, check arp cache
> - //
> - UpdateArpCache (This);
> - if (!FindInArpCache (Mode, &IpAddr->v4, &TempMacAddr)) {
> - return EFI_DEVICE_ERROR;
> - }
> - } else {
> - Status = Private->Arp->Request (Private->Arp, &IpAddr->v4, NULL,
> &TempMacAddr);
> - if (EFI_ERROR (Status)) {
> - if (Status == EFI_ICMP_ERROR) {
> - Mode->IcmpErrorReceived = TRUE;
> - }
> - return Status;
> - }
> - }
> -
> - if (MacAddr != NULL) {
> - CopyMem (MacAddr, &TempMacAddr, sizeof (EFI_MAC_ADDRESS));
> - }
> -
> - return EFI_SUCCESS;
> -}
> -
> -/**
> - Updates the parameters that affect the operation of the PXE Base Code
> Protocol.
> -
> - This function sets parameters that affect the operation of the PXE Base Code
> Protocol.
> - The parameter specified by NewAutoArp is used to control the generation of
> ARP
> - protocol packets. If NewAutoArp is TRUE, then ARP Protocol packets will be
> generated
> - as required by the PXE Base Code Protocol. If NewAutoArp is FALSE, then no
> ARP
> - Protocol packets will be generated. In this case, the only mappings that are
> - available are those stored in the ArpCache of the EFI_PXE_BASE_CODE_MODE
> structure.
> - If there are not enough mappings in the ArpCache to perform a PXE Base Code
> Protocol
> - service, then the service will fail. This function updates the AutoArp field of
> - the EFI_PXE_BASE_CODE_MODE structure to NewAutoArp.
> - The SetParameters() call must be invoked after a Callback Protocol is installed
> - to enable the use of callbacks.
> -
> - @param This Pointer to the EFI_PXE_BASE_CODE_PROTOCOL
> instance.
> - @param NewAutoArp If not NULL, a pointer to a value that specifies
> whether to replace the
> - current value of AutoARP.
> - @param NewSendGUID If not NULL, a pointer to a value that specifies
> whether to replace the
> - current value of SendGUID.
> - @param NewTTL If not NULL, a pointer to be used in place of the
> current value of TTL,
> - the "time to live" field of the IP header.
> - @param NewToS If not NULL, a pointer to be used in place of the
> current value of ToS,
> - the "type of service" field of the IP header.
> - @param NewMakeCallback If not NULL, a pointer to a value that specifies
> whether to replace the
> - current value of the MakeCallback field of the Mode structure.
> -
> - @retval EFI_SUCCESS The new parameters values were updated.
> - @retval EFI_NOT_STARTED The PXE Base Code Protocol is in the stopped
> state.
> - @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
> -
> -**/
> -EFI_STATUS
> -EFIAPI
> -EfiPxeBcSetParameters (
> - IN EFI_PXE_BASE_CODE_PROTOCOL *This,
> - IN BOOLEAN *NewAutoArp OPTIONAL,
> - IN BOOLEAN *NewSendGUID OPTIONAL,
> - IN UINT8 *NewTTL OPTIONAL,
> - IN UINT8 *NewToS OPTIONAL,
> - IN BOOLEAN *NewMakeCallback // OPTIONAL
> - )
> -{
> - PXEBC_PRIVATE_DATA *Private;
> - EFI_PXE_BASE_CODE_MODE *Mode;
> - EFI_STATUS Status;
> -
> - Status = EFI_SUCCESS;
> -
> - if (This == NULL) {
> - Status = EFI_INVALID_PARAMETER;
> - goto ON_EXIT;
> - }
> -
> - Private = PXEBC_PRIVATE_DATA_FROM_PXEBC (This);
> - Mode = Private->PxeBc.Mode;
> -
> - if (NewSendGUID != NULL && *NewSendGUID) {
> - //
> - // FixMe, cann't locate SendGuid
> - //
> - }
> -
> - if (NewMakeCallback != NULL && *NewMakeCallback) {
> -
> - Status = gBS->HandleProtocol (
> - Private->Controller,
> - &gEfiPxeBaseCodeCallbackProtocolGuid,
> - (VOID **) &Private->PxeBcCallback
> - );
> - if (EFI_ERROR (Status) || (Private->PxeBcCallback->Callback == NULL)) {
> -
> - Status = EFI_INVALID_PARAMETER;
> - goto ON_EXIT;
> - }
> - }
> -
> - if (!Mode->Started) {
> - Status = EFI_NOT_STARTED;
> - goto ON_EXIT;
> - }
> -
> - if (NewMakeCallback != NULL) {
> -
> - if (*NewMakeCallback) {
> - //
> - // Update the Callback protocol.
> - //
> - Status = gBS->HandleProtocol (
> - Private->Controller,
> - &gEfiPxeBaseCodeCallbackProtocolGuid,
> - (VOID **) &Private->PxeBcCallback
> - );
> -
> - if (EFI_ERROR (Status) || (Private->PxeBcCallback->Callback == NULL)) {
> - Status = EFI_INVALID_PARAMETER;
> - goto ON_EXIT;
> - }
> - } else {
> - Private->PxeBcCallback = NULL;
> - }
> -
> - Mode->MakeCallbacks = *NewMakeCallback;
> - }
> -
> - if (NewAutoArp != NULL) {
> - Mode->AutoArp = *NewAutoArp;
> - }
> -
> - if (NewSendGUID != NULL) {
> - Mode->SendGUID = *NewSendGUID;
> - }
> -
> - if (NewTTL != NULL) {
> - Mode->TTL = *NewTTL;
> - }
> -
> - if (NewToS != NULL) {
> - Mode->ToS = *NewToS;
> - }
> -
> -ON_EXIT:
> - return Status;
> -}
> -
> -/**
> - Updates the station IP address and/or subnet mask values of a network device.
> -
> - This function updates the station IP address and/or subnet mask values of a
> network
> - device. The NewStationIp field is used to modify the network device's current
> IP address.
> - If NewStationIP is NULL, then the current IP address will not be modified.
> Otherwise,
> - this function updates the StationIp field of the EFI_PXE_BASE_CODE_MODE
> structure
> - with NewStationIp. The NewSubnetMask field is used to modify the network
> device's current subnet
> - mask. If NewSubnetMask is NULL, then the current subnet mask will not be
> modified.
> - Otherwise, this function updates the SubnetMask field of the
> EFI_PXE_BASE_CODE_MODE
> - structure with NewSubnetMask.
> -
> - @param This Pointer to the EFI_PXE_BASE_CODE_PROTOCOL
> instance.
> - @param NewStationIp Pointer to the new IP address to be used by the
> network device.
> - @param NewSubnetMask Pointer to the new subnet mask to be used by
> the network device.
> -
> - @retval EFI_SUCCESS The new station IP address and/or subnet mask
> were updated.
> - @retval EFI_NOT_STARTED The PXE Base Code Protocol is in the stopped
> state.
> - @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
> -
> -**/
> -EFI_STATUS
> -EFIAPI
> -EfiPxeBcSetStationIP (
> - IN EFI_PXE_BASE_CODE_PROTOCOL * This,
> - IN EFI_IP_ADDRESS * NewStationIp OPTIONAL,
> - IN EFI_IP_ADDRESS * NewSubnetMask OPTIONAL
> - )
> -{
> - PXEBC_PRIVATE_DATA *Private;
> - EFI_PXE_BASE_CODE_MODE *Mode;
> - EFI_ARP_CONFIG_DATA ArpConfigData;
> -
> - if (This == NULL) {
> - return EFI_INVALID_PARAMETER;
> - }
> -
> - if (NewSubnetMask != NULL && !IP4_IS_VALID_NETMASK (NTOHL
> (NewSubnetMask->Addr[0]))) {
> - return EFI_INVALID_PARAMETER;
> - }
> -
> - if (NewStationIp != NULL) {
> - if (IP4_IS_UNSPECIFIED(NTOHL (NewStationIp->Addr[0])) ||
> - IP4_IS_LOCAL_BROADCAST(NTOHL (NewStationIp->Addr[0])) ||
> - (NewSubnetMask != NULL && NewSubnetMask->Addr[0] != 0
> && !NetIp4IsUnicast (NTOHL (NewStationIp->Addr[0]), NTOHL
> (NewSubnetMask->Addr[0])))) {
> - return EFI_INVALID_PARAMETER;
> - }
> - }
> -
> - Private = PXEBC_PRIVATE_DATA_FROM_PXEBC (This);
> - Mode = Private->PxeBc.Mode;
> -
> - if (!Mode->Started) {
> - return EFI_NOT_STARTED;
> - }
> -
> - if (NewStationIp != NULL) {
> - CopyMem (&Mode->StationIp, NewStationIp, sizeof (EFI_IP_ADDRESS));
> - CopyMem (&Private->StationIp, NewStationIp, sizeof (EFI_IP_ADDRESS));
> - }
> -
> - if (NewSubnetMask != NULL) {
> - CopyMem (&Mode->SubnetMask, NewSubnetMask, sizeof
> (EFI_IP_ADDRESS));
> - CopyMem (&Private->SubnetMask ,NewSubnetMask, sizeof
> (EFI_IP_ADDRESS));
> - }
> -
> - Private->AddressIsOk = TRUE;
> -
> - if (!Mode->UsingIpv6) {
> - //
> - // If in IPv4 mode, configure the corresponding ARP with this new
> - // station IP address.
> - //
> - ZeroMem (&ArpConfigData, sizeof (EFI_ARP_CONFIG_DATA));
> -
> - ArpConfigData.SwAddressType = 0x0800;
> - ArpConfigData.SwAddressLength = (UINT8) sizeof (EFI_IPv4_ADDRESS);
> - ArpConfigData.StationAddress = &Private->StationIp.v4;
> -
> - Private->Arp->Configure (Private->Arp, NULL);
> - Private->Arp->Configure (Private->Arp, &ArpConfigData);
> -
> - //
> - // Update the route table.
> - //
> - Mode->RouteTableEntries = 1;
> - Mode->RouteTable[0].IpAddr.Addr[0] = Private->StationIp.Addr[0] &
> Private->SubnetMask.Addr[0];
> - Mode->RouteTable[0].SubnetMask.Addr[0] = Private->SubnetMask.Addr[0];
> - Mode->RouteTable[0].GwAddr.Addr[0] = 0;
> - }
> -
> - return EFI_SUCCESS;
> -}
> -
> -/**
> - Updates the contents of the cached DHCP and Discover packets.
> -
> - The pointers to the new packets are used to update the contents of the
> cached
> - packets in the EFI_PXE_BASE_CODE_MODE structure.
> -
> - @param This Pointer to the EFI_PXE_BASE_CODE_PROTOCOL
> instance.
> - @param NewDhcpDiscoverValid Pointer to a value that will replace the
> current
> - DhcpDiscoverValid field.
> - @param NewDhcpAckReceived Pointer to a value that will replace the
> current
> - DhcpAckReceived field.
> - @param NewProxyOfferReceived Pointer to a value that will replace the
> current
> - ProxyOfferReceived field.
> - @param NewPxeDiscoverValid Pointer to a value that will replace the
> current
> - ProxyOfferReceived field.
> - @param NewPxeReplyReceived Pointer to a value that will replace the
> current
> - PxeReplyReceived field.
> - @param NewPxeBisReplyReceived Pointer to a value that will replace the
> current
> - PxeBisReplyReceived field.
> - @param NewDhcpDiscover Pointer to the new cached DHCP Discover
> packet contents.
> - @param NewDhcpAck Pointer to the new cached DHCP Ack packet
> contents.
> - @param NewProxyOffer Pointer to the new cached Proxy Offer packet
> contents.
> - @param NewPxeDiscover Pointer to the new cached PXE Discover packet
> contents.
> - @param NewPxeReply Pointer to the new cached PXE Reply packet
> contents.
> - @param NewPxeBisReply Pointer to the new cached PXE BIS Reply
> packet contents.
> -
> - @retval EFI_SUCCESS The cached packet contents were updated.
> - @retval EFI_NOT_STARTED The PXE Base Code Protocol is in the stopped
> state.
> - @retval EFI_INVALID_PARAMETER This is NULL or not point to a valid
> EFI_PXE_BASE_CODE_PROTOCOL structure.
> -
> -**/
> -EFI_STATUS
> -EFIAPI
> -EfiPxeBcSetPackets (
> - IN EFI_PXE_BASE_CODE_PROTOCOL * This,
> - IN BOOLEAN * NewDhcpDiscoverValid OPTIONAL,
> - IN BOOLEAN * NewDhcpAckReceived OPTIONAL,
> - IN BOOLEAN * NewProxyOfferReceived OPTIONAL,
> - IN BOOLEAN * NewPxeDiscoverValid OPTIONAL,
> - IN BOOLEAN * NewPxeReplyReceived OPTIONAL,
> - IN BOOLEAN * NewPxeBisReplyReceived OPTIONAL,
> - IN EFI_PXE_BASE_CODE_PACKET * NewDhcpDiscover OPTIONAL,
> - IN EFI_PXE_BASE_CODE_PACKET * NewDhcpAck OPTIONAL,
> - IN EFI_PXE_BASE_CODE_PACKET * NewProxyOffer OPTIONAL,
> - IN EFI_PXE_BASE_CODE_PACKET * NewPxeDiscover OPTIONAL,
> - IN EFI_PXE_BASE_CODE_PACKET * NewPxeReply OPTIONAL,
> - IN EFI_PXE_BASE_CODE_PACKET * NewPxeBisReply OPTIONAL
> - )
> -{
> - PXEBC_PRIVATE_DATA *Private;
> - EFI_PXE_BASE_CODE_MODE *Mode;
> -
> - if (This == NULL) {
> - return EFI_INVALID_PARAMETER;
> - }
> -
> - Private = PXEBC_PRIVATE_DATA_FROM_PXEBC (This);
> - Mode = Private->PxeBc.Mode;
> -
> - if (!Mode->Started) {
> - return EFI_NOT_STARTED;
> - }
> -
> - if (NewDhcpDiscoverValid != NULL) {
> - Mode->DhcpDiscoverValid = *NewDhcpDiscoverValid;
> - }
> -
> - if (NewDhcpAckReceived != NULL) {
> - Mode->DhcpAckReceived = *NewDhcpAckReceived;
> - }
> -
> - if (NewProxyOfferReceived != NULL) {
> - Mode->ProxyOfferReceived = *NewProxyOfferReceived;
> - }
> -
> - if (NewPxeDiscoverValid != NULL) {
> - Mode->PxeDiscoverValid = *NewPxeDiscoverValid;
> - }
> -
> - if (NewPxeReplyReceived != NULL) {
> - Mode->PxeReplyReceived = *NewPxeReplyReceived;
> - }
> -
> - if (NewPxeBisReplyReceived != NULL) {
> - Mode->PxeBisReplyReceived = *NewPxeBisReplyReceived;
> - }
> -
> - if (NewDhcpDiscover != NULL) {
> - CopyMem (&Mode->DhcpDiscover, NewDhcpDiscover, sizeof
> (EFI_PXE_BASE_CODE_PACKET));
> - }
> -
> - if (NewDhcpAck != NULL) {
> - CopyMem (&Mode->DhcpAck, NewDhcpAck, sizeof
> (EFI_PXE_BASE_CODE_PACKET));
> - }
> -
> - if (NewProxyOffer != NULL) {
> - CopyMem (&Mode->ProxyOffer, NewProxyOffer, sizeof
> (EFI_PXE_BASE_CODE_PACKET));
> - }
> -
> - if (NewPxeDiscover != NULL) {
> - CopyMem (&Mode->PxeDiscover, NewPxeDiscover, sizeof
> (EFI_PXE_BASE_CODE_PACKET));
> - }
> -
> - if (NewPxeReply != NULL) {
> - CopyMem (&Mode->PxeReply, NewPxeReply, sizeof
> (EFI_PXE_BASE_CODE_PACKET));
> - }
> -
> - if (NewPxeBisReply != NULL) {
> - CopyMem (&Mode->PxeBisReply, NewPxeBisReply, sizeof
> (EFI_PXE_BASE_CODE_PACKET));
> - }
> -
> - return EFI_SUCCESS;
> -}
> -
> -EFI_PXE_BASE_CODE_PROTOCOL mPxeBcProtocolTemplate = {
> - EFI_PXE_BASE_CODE_PROTOCOL_REVISION,
> - EfiPxeBcStart,
> - EfiPxeBcStop,
> - EfiPxeBcDhcp,
> - EfiPxeBcDiscover,
> - EfiPxeBcMtftp,
> - EfiPxeBcUdpWrite,
> - EfiPxeBcUdpRead,
> - EfiPxeBcSetIpFilter,
> - EfiPxeBcArp,
> - EfiPxeBcSetParameters,
> - EfiPxeBcSetStationIP,
> - EfiPxeBcSetPackets,
> - NULL
> -};
> -
> -/**
> - Callback function that is invoked when the PXE Base Code Protocol is about to
> transmit, has
> - received, or is waiting to receive a packet.
> -
> - This function is invoked when the PXE Base Code Protocol is about to transmit,
> has received,
> - or is waiting to receive a packet. Parameters Function and Received specify
> the type of event.
> - Parameters PacketLen and Packet specify the packet that generated the event.
> If these fields
> - are zero and NULL respectively, then this is a status update callback. If the
> operation specified
> - by Function is to continue, then CALLBACK_STATUS_CONTINUE should be
> returned. If the operation
> - specified by Function should be aborted, then CALLBACK_STATUS_ABORT
> should be returned. Due to
> - the polling nature of UEFI device drivers, a callback function should not
> execute for more than 5 ms.
> - The SetParameters() function must be called after a Callback Protocol is
> installed to enable the
> - use of callbacks.
> -
> - @param This Pointer to the
> EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL instance.
> - @param Function The PXE Base Code Protocol function that is waiting
> for an event.
> - @param Received TRUE if the callback is being invoked due to a
> receive event. FALSE if
> - the callback is being invoked due to a transmit event.
> - @param PacketLength The length, in bytes, of Packet. This field will have
> a value of zero if
> - this is a wait for receive event.
> - @param PacketPtr If Received is TRUE, a pointer to the packet that
> was just received;
> - otherwise a pointer to the packet that is about to be
> transmitted.
> -
> - @retval EFI_PXE_BASE_CODE_CALLBACK_STATUS_CONTINUE if Function
> specifies a continue operation
> - @retval EFI_PXE_BASE_CODE_CALLBACK_STATUS_ABORT if Function
> specifies an abort operation
> -
> -**/
> -EFI_PXE_BASE_CODE_CALLBACK_STATUS
> -EFIAPI
> -EfiPxeLoadFileCallback (
> - IN EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL * This,
> - IN EFI_PXE_BASE_CODE_FUNCTION Function,
> - IN BOOLEAN Received,
> - IN UINT32 PacketLength,
> - IN EFI_PXE_BASE_CODE_PACKET * PacketPtr OPTIONAL
> - )
> -{
> - EFI_INPUT_KEY Key;
> - EFI_STATUS Status;
> -
> - //
> - // Catch Ctrl-C or ESC to abort.
> - //
> - Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);
> -
> - if (!EFI_ERROR (Status)) {
> -
> - if (Key.ScanCode == SCAN_ESC || Key.UnicodeChar == (0x1F & 'c')) {
> -
> - return EFI_PXE_BASE_CODE_CALLBACK_STATUS_ABORT;
> - }
> - }
> - //
> - // No print if receive packet
> - //
> - if (Received) {
> - return EFI_PXE_BASE_CODE_CALLBACK_STATUS_CONTINUE;
> - }
> - //
> - // Print only for three functions
> - //
> - switch (Function) {
> -
> - case EFI_PXE_BASE_CODE_FUNCTION_MTFTP:
> - //
> - // Print only for open MTFTP packets, not every MTFTP packets
> - //
> - if (PacketLength != 0 && PacketPtr != NULL) {
> - if (PacketPtr->Raw[0x1C] != 0x00 || PacketPtr->Raw[0x1D] != 0x01) {
> - return EFI_PXE_BASE_CODE_CALLBACK_STATUS_CONTINUE;
> - }
> - }
> - break;
> -
> - case EFI_PXE_BASE_CODE_FUNCTION_DHCP:
> - case EFI_PXE_BASE_CODE_FUNCTION_DISCOVER:
> - break;
> -
> - default:
> - return EFI_PXE_BASE_CODE_CALLBACK_STATUS_CONTINUE;
> - }
> -
> - if (PacketLength != 0 && PacketPtr != NULL) {
> - //
> - // Print '.' when transmit a packet
> - //
> - AsciiPrint (".");
> -
> - }
> -
> - return EFI_PXE_BASE_CODE_CALLBACK_STATUS_CONTINUE;
> -}
> -
> -EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL mPxeBcCallBackTemplate = {
> - EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL_REVISION,
> - EfiPxeLoadFileCallback
> -};
> -
> -
> -/**
> - Find the boot file.
> -
> - @param Private Pointer to PxeBc private data.
> - @param BufferSize Pointer to buffer size.
> - @param Buffer Pointer to buffer.
> -
> - @retval EFI_SUCCESS Discover the boot file successfully.
> - @retval EFI_TIMEOUT The TFTP/MTFTP operation timed out.
> - @retval EFI_ABORTED PXE bootstrap server, so local boot need abort.
> - @retval EFI_BUFFER_TOO_SMALL The buffer is too small to load the boot file.
> -
> -**/
> -EFI_STATUS
> -DiscoverBootFile (
> - IN PXEBC_PRIVATE_DATA *Private,
> - IN OUT UINT64 *BufferSize,
> - IN VOID *Buffer
> - )
> -{
> - EFI_PXE_BASE_CODE_PROTOCOL *PxeBc;
> - EFI_PXE_BASE_CODE_MODE *Mode;
> - EFI_STATUS Status;
> - UINT16 Type;
> - UINT16 Layer;
> - BOOLEAN UseBis;
> - PXEBC_CACHED_DHCP4_PACKET *Packet;
> - UINT16 Value;
> -
> - PxeBc = &Private->PxeBc;
> - Mode = PxeBc->Mode;
> - Type = EFI_PXE_BASE_CODE_BOOT_TYPE_BOOTSTRAP;
> - Layer = EFI_PXE_BASE_CODE_BOOT_LAYER_INITIAL;
> -
> - //
> - // do DHCP.
> - //
> - Status = PxeBc->Dhcp (PxeBc, TRUE);
> - if (EFI_ERROR (Status)) {
> - return Status;
> - }
> -
> - //
> - // Select a boot server
> - //
> - Status = PxeBcSelectBootPrompt (Private);
> -
> - if (Status == EFI_SUCCESS) {
> - Status = PxeBcSelectBootMenu (Private, &Type, TRUE);
> - } else if (Status == EFI_TIMEOUT) {
> - Status = PxeBcSelectBootMenu (Private, &Type, FALSE);
> - }
> -
> - if (!EFI_ERROR (Status)) {
> -
> - if (Type == EFI_PXE_BASE_CODE_BOOT_TYPE_BOOTSTRAP) {
> - //
> - // Local boot(PXE bootstrap server) need abort
> - //
> - return EFI_ABORTED;
> - }
> -
> - UseBis = (BOOLEAN) (Mode->BisSupported && Mode->BisDetected);
> - Status = PxeBc->Discover (PxeBc, Type, &Layer, UseBis, NULL);
> - if (EFI_ERROR (Status)) {
> - return Status;
> - }
> - }
> -
> - *BufferSize = 0;
> -
> - //
> - // Get bootfile name and (m)tftp server ip addresss
> - //
> - if (Mode->PxeReplyReceived) {
> - Packet = &Private->PxeReply;
> - } else if (Mode->ProxyOfferReceived) {
> - Packet = &Private->ProxyOffer;
> - } else {
> - Packet = &Private->Dhcp4Ack;
> - }
> -
> - //
> - // 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 (EFI_IP4_EQUAL (&Packet->Packet.Offer.Dhcp4.Header.ServerAddr,
> &mZeroIp4Addr)) {
> - CopyMem (
> - &Private->ServerIp,
> - Packet->Dhcp4Option[PXEBC_DHCP4_TAG_INDEX_SERVER_ID]->Data,
> - sizeof (EFI_IPv4_ADDRESS)
> - );
> - } else {
> - CopyMem (
> - &Private->ServerIp,
> - &Packet->Packet.Offer.Dhcp4.Header.ServerAddr,
> - sizeof (EFI_IPv4_ADDRESS)
> - );
> - }
> - if (Private->ServerIp.Addr[0] == 0) {
> - return EFI_DEVICE_ERROR;
> - }
> -
> - ASSERT (Packet->Dhcp4Option[PXEBC_DHCP4_TAG_INDEX_BOOTFILE] !=
> NULL);
> -
> - //
> - // bootlfile name
> - //
> - Private->BootFileName = (CHAR8 *) (Packet-
> >Dhcp4Option[PXEBC_DHCP4_TAG_INDEX_BOOTFILE]->Data);
> -
> - if (Packet->Dhcp4Option[PXEBC_DHCP4_TAG_INDEX_BOOTFILE_LEN] != NULL)
> {
> - //
> - // Already have the bootfile length option, compute the file size
> - //
> - CopyMem (&Value, Packet-
> >Dhcp4Option[PXEBC_DHCP4_TAG_INDEX_BOOTFILE_LEN]->Data, sizeof
> (Value));
> - Value = NTOHS (Value);
> - *BufferSize = 512 * Value;
> - Status = EFI_BUFFER_TOO_SMALL;
> - } else {
> - //
> - // Get the bootfile size from tftp
> - //
> - Status = PxeBc->Mtftp (
> - PxeBc,
> - EFI_PXE_BASE_CODE_TFTP_GET_FILE_SIZE,
> - Buffer,
> - FALSE,
> - BufferSize,
> - &Private->BlockSize,
> - &Private->ServerIp,
> - (UINT8 *) Private->BootFileName,
> - NULL,
> - FALSE
> - );
> - }
> -
> - Private->FileSize = (UINTN) *BufferSize;
> -
> - //
> - // Display all the information: boot server address, boot file name and boot
> file size.
> - //
> - AsciiPrint ("\n Server IP address is ");
> - PxeBcShowIp4Addr (&Private->ServerIp.v4);
> - AsciiPrint ("\n NBP filename is %a", Private->BootFileName);
> - AsciiPrint ("\n NBP filesize is %d Bytes", Private->FileSize);
> -
> - return Status;
> -}
> -
> -/**
> - Causes the driver to load a specified file.
> -
> - @param This Protocol instance pointer.
> - @param FilePath The device specific path of the file to load.
> - @param BootPolicy If TRUE, indicates that the request originates from
> the
> - boot manager is attempting to load FilePath as a boot
> - selection. If FALSE, then FilePath must match as exact file
> - to be loaded.
> - @param BufferSize On input the size of Buffer in bytes. On output with
> a return
> - code of EFI_SUCCESS, the amount of data transferred to
> - Buffer. On output with a return code of
> EFI_BUFFER_TOO_SMALL,
> - the size of Buffer required to retrieve the requested file.
> - @param Buffer The memory buffer to transfer the file to. IF Buffer is
> NULL,
> - then no the size of the requested file is returned in
> - BufferSize.
> -
> - @retval EFI_SUCCESS The file was loaded.
> - @retval EFI_UNSUPPORTED The device does not support the provided
> BootPolicy
> - @retval EFI_INVALID_PARAMETER FilePath is not a valid device path, or
> - BufferSize is NULL.
> - @retval EFI_NO_MEDIA No medium was present to load the file.
> - @retval EFI_DEVICE_ERROR The file was not loaded due to a device
> error.
> - @retval EFI_NO_RESPONSE The remote system did not respond.
> - @retval EFI_NOT_FOUND The file was not found.
> - @retval EFI_ABORTED The file load process was manually cancelled.
> -
> -**/
> -EFI_STATUS
> -EFIAPI
> -EfiPxeLoadFile (
> - IN EFI_LOAD_FILE_PROTOCOL * This,
> - IN EFI_DEVICE_PATH_PROTOCOL * FilePath,
> - IN BOOLEAN BootPolicy,
> - IN OUT UINTN *BufferSize,
> - IN VOID *Buffer OPTIONAL
> - )
> -{
> - PXEBC_PRIVATE_DATA *Private;
> - EFI_PXE_BASE_CODE_PROTOCOL *PxeBc;
> - BOOLEAN NewMakeCallback;
> - EFI_STATUS Status;
> - UINT64 TmpBufSize;
> - EFI_STATUS MediaStatus;
> -
> - if (FilePath == NULL || !IsDevicePathEnd (FilePath)) {
> - return EFI_INVALID_PARAMETER;
> - }
> -
> - Private = PXEBC_PRIVATE_DATA_FROM_LOADFILE (This);
> - PxeBc = &Private->PxeBc;
> - NewMakeCallback = FALSE;
> - Status = EFI_DEVICE_ERROR;
> -
> - if (This == NULL || BufferSize == NULL) {
> -
> - return EFI_INVALID_PARAMETER;
> - }
> -
> - //
> - // Only support BootPolicy
> - //
> - if (!BootPolicy) {
> - return EFI_UNSUPPORTED;
> - }
> -
> - //
> - // Check media status before PXE start
> - //
> - MediaStatus = EFI_SUCCESS;
> - NetLibDetectMediaWaitTimeout (Private->Controller,
> PXEBC_CHECK_MEDIA_WAITING_TIME, &MediaStatus);
> - if (MediaStatus != EFI_SUCCESS) {
> - return EFI_NO_MEDIA;
> - }
> -
> - Status = PxeBc->Start (PxeBc, FALSE);
> - if (EFI_ERROR (Status) && (Status != EFI_ALREADY_STARTED)) {
> - return Status;
> - }
> -
> - Status = gBS->HandleProtocol (
> - Private->Controller,
> - &gEfiPxeBaseCodeCallbackProtocolGuid,
> - (VOID **) &Private->PxeBcCallback
> - );
> - if (Status == EFI_UNSUPPORTED) {
> -
> - CopyMem (&Private->LoadFileCallback, &mPxeBcCallBackTemplate, sizeof
> (Private->LoadFileCallback));
> -
> - Status = gBS->InstallProtocolInterface (
> - &Private->Controller,
> - &gEfiPxeBaseCodeCallbackProtocolGuid,
> - EFI_NATIVE_INTERFACE,
> - &Private->LoadFileCallback
> - );
> -
> - NewMakeCallback = (BOOLEAN) (Status == EFI_SUCCESS);
> -
> - Status = PxeBc->SetParameters (PxeBc, NULL, NULL, NULL, NULL,
> &NewMakeCallback);
> - if (EFI_ERROR (Status)) {
> - PxeBc->Stop (PxeBc);
> - return Status;
> - }
> - }
> -
> - if (Private->FileSize == 0) {
> - TmpBufSize = 0;
> - Status = DiscoverBootFile (Private, &TmpBufSize, Buffer);
> -
> - if (sizeof (UINTN) < sizeof (UINT64) && (TmpBufSize > 0xFFFFFFFF)) {
> - Status = EFI_DEVICE_ERROR;
> - } else if (TmpBufSize > 0 && *BufferSize >= (UINTN) TmpBufSize && Buffer !=
> NULL) {
> - AsciiPrint ("\n Downloading NBP file...\n");
> - *BufferSize = (UINTN) TmpBufSize;
> - Status = PxeBc->Mtftp (
> - PxeBc,
> - EFI_PXE_BASE_CODE_TFTP_READ_FILE,
> - Buffer,
> - FALSE,
> - &TmpBufSize,
> - &Private->BlockSize,
> - &Private->ServerIp,
> - (UINT8 *) Private->BootFileName,
> - NULL,
> - FALSE
> - );
> - } else if (TmpBufSize > 0) {
> - *BufferSize = (UINTN) TmpBufSize;
> - Status = EFI_BUFFER_TOO_SMALL;
> - }
> - } else if (Buffer == NULL || Private->FileSize > *BufferSize) {
> - *BufferSize = Private->FileSize;
> - Status = EFI_BUFFER_TOO_SMALL;
> - } else {
> - //
> - // Download the file.
> - //
> - AsciiPrint ("\n Downloading NBP file...\n");
> - TmpBufSize = (UINT64) (*BufferSize);
> - Status = PxeBc->Mtftp (
> - PxeBc,
> - EFI_PXE_BASE_CODE_TFTP_READ_FILE,
> - Buffer,
> - FALSE,
> - &TmpBufSize,
> - &Private->BlockSize,
> - &Private->ServerIp,
> - (UINT8 *) Private->BootFileName,
> - NULL,
> - FALSE
> - );
> - }
> - //
> - // If we added a callback protocol, now is the time to remove it.
> - //
> - if (NewMakeCallback) {
> -
> - NewMakeCallback = FALSE;
> -
> - PxeBc->SetParameters (PxeBc, NULL, NULL, NULL, NULL,
> &NewMakeCallback);
> -
> - gBS->UninstallProtocolInterface (
> - Private->Controller,
> - &gEfiPxeBaseCodeCallbackProtocolGuid,
> - &Private->LoadFileCallback
> - );
> - }
> -
> - //
> - // Check download status
> - //
> - if (Status == EFI_SUCCESS) {
> - AsciiPrint ("\n NBP file downloaded successfully.\n");
> - //
> - // The DHCP4 can have only one configured child instance so we need to stop
> - // reset the DHCP4 child before we return. Otherwise the other programs
> which
> - // also need to use DHCP4 will be impacted.
> - // The functionality of PXE Base Code protocol will not be stopped,
> - // when downloading is successfully.
> - //
> - Private->Dhcp4->Stop (Private->Dhcp4);
> - Private->Dhcp4->Configure (Private->Dhcp4, NULL);
> - 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;
> - }
> -
> - } else if (Status == EFI_DEVICE_ERROR) {
> - AsciiPrint ("PXE-E07: Network device error.\n");
> -
> - } else if (Status == EFI_OUT_OF_RESOURCES) {
> - AsciiPrint ("PXE-E09: Could not allocate I/O buffers.\n");
> -
> - } else if (Status == EFI_NO_MEDIA) {
> - AsciiPrint ("PXE-E12: Could not detect network connection.\n");
> -
> - } else if (Status == EFI_NO_RESPONSE) {
> - AsciiPrint ("PXE-E16: No offer received.\n");
> -
> - } else if (Status == EFI_TIMEOUT) {
> - AsciiPrint ("PXE-E18: Server response timeout.\n");
> -
> - } else if (Status == EFI_ABORTED) {
> - AsciiPrint ("PXE-E21: Remote boot cancelled.\n");
> -
> - } else if (Status == EFI_ICMP_ERROR) {
> - AsciiPrint ("PXE-E22: Client received ICMP error from server.\n");
> -
> - } else if (Status == EFI_TFTP_ERROR) {
> - AsciiPrint ("PXE-E23: Client received TFTP error from server.\n");
> -
> - } else {
> - AsciiPrint ("PXE-E99: Unexpected network error.\n");
> - }
> -
> - PxeBc->Stop (PxeBc);
> -
> - return Status;
> -}
> -
> -EFI_LOAD_FILE_PROTOCOL mLoadFileProtocolTemplate = { EfiPxeLoadFile };
> -
> diff --git a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcMtftp.c
> b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcMtftp.c
> deleted file mode 100644
> index 88767c8394ab..000000000000
> --- a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcMtftp.c
> +++ /dev/null
> @@ -1,454 +0,0 @@
> -/** @file
> - PxeBc MTFTP functions.
> -
> -Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
> -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
> -http://opensource.org/licenses/bsd-license.php
> -
> -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS
> OR IMPLIED.
> -
> -**/
> -
> -#include "PxeBcImpl.h"
> -
> -CHAR8 *mMtftpOptions[PXE_MTFTP_OPTION_MAXIMUM_INDEX] = {
> - "blksize",
> - "timeout",
> - "tsize",
> - "multicast"
> -};
> -
> -
> -/**
> - This is a callback function when packets received/transmitted in Mtftp driver.
> -
> - A callback function that is provided by the caller to intercept
> - the EFI_MTFTP4_OPCODE_DATA or EFI_MTFTP4_OPCODE_DATA8 packets
> processed in the
> - EFI_MTFTP4_PROTOCOL.ReadFile() function, and alternatively to intercept
> - EFI_MTFTP4_OPCODE_OACK or EFI_MTFTP4_OPCODE_ERROR packets during
> a call to
> - EFI_MTFTP4_PROTOCOL.ReadFile(), WriteFile() or ReadDirectory().
> -
> - @param This Pointer to Mtftp protocol instance
> - @param Token Pointer to Mtftp token
> - @param PacketLen Length of Mtftp packet
> - @param Packet Pointer to Mtftp packet
> -
> - @retval EFI_SUCCESS Operation sucess
> - @retval EFI_ABORTED Abort transfer process
> -
> -**/
> -EFI_STATUS
> -EFIAPI
> -PxeBcCheckPacket (
> - IN EFI_MTFTP4_PROTOCOL *This,
> - IN EFI_MTFTP4_TOKEN *Token,
> - IN UINT16 PacketLen,
> - IN EFI_MTFTP4_PACKET *Packet
> - )
> -{
> - PXEBC_PRIVATE_DATA *Private;
> - EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL *Callback;
> - EFI_STATUS Status;
> -
> - Private = (PXEBC_PRIVATE_DATA *) Token->Context;
> - Callback = Private->PxeBcCallback;
> - Status = EFI_SUCCESS;
> -
> - if (Packet->OpCode == EFI_MTFTP4_OPCODE_ERROR) {
> - Private->Mode.TftpErrorReceived = TRUE;
> - Private->Mode.TftpError.ErrorCode = (UINT8) Packet->Error.ErrorCode;
> - AsciiStrnCpyS (Private->Mode.TftpError.ErrorString,
> PXE_MTFTP_ERROR_STRING_LENGTH, (CHAR8 *) Packet->Error.ErrorMessage,
> PXE_MTFTP_ERROR_STRING_LENGTH - 1);
> - Private->Mode.TftpError.ErrorString[PXE_MTFTP_ERROR_STRING_LENGTH -
> 1] = '\0';
> - }
> -
> - if (Callback != NULL) {
> -
> - Status = Callback->Callback (
> - Callback,
> - Private->Function,
> - TRUE,
> - PacketLen,
> - (EFI_PXE_BASE_CODE_PACKET *) Packet
> - );
> - if (Status != EFI_PXE_BASE_CODE_CALLBACK_STATUS_CONTINUE) {
> -
> - Status = EFI_ABORTED;
> - } else {
> -
> - Status = EFI_SUCCESS;
> - }
> - }
> -
> - return Status;
> -}
> -
> -
> -/**
> - This function is to get size of a file by Tftp.
> -
> - @param Private Pointer to PxeBc private data
> - @param Config Pointer to Mtftp configuration data
> - @param Filename Pointer to file name
> - @param BlockSize Pointer to block size
> - @param BufferSize Pointer to buffer size
> -
> - @retval EFI_SUCCESS Get the size of file success
> - @retval EFI_NOT_FOUND Parse the tftp ptions failed.
> - @retval EFI_DEVICE_ERROR The network device encountered an error during
> this operation.
> - @retval Other Has not get the size of the file.
> -
> -**/
> -EFI_STATUS
> -PxeBcTftpGetFileSize (
> - IN PXEBC_PRIVATE_DATA *Private,
> - IN EFI_MTFTP4_CONFIG_DATA *Config,
> - IN UINT8 *Filename,
> - IN UINTN *BlockSize,
> - IN OUT UINT64 *BufferSize
> - )
> -{
> - EFI_MTFTP4_PROTOCOL *Mtftp4;
> - EFI_MTFTP4_OPTION ReqOpt[2];
> - EFI_MTFTP4_PACKET *Packet;
> - EFI_MTFTP4_OPTION *Option;
> - UINT32 PktLen;
> - UINT8 OptBuf[128];
> - UINT32 OptCnt;
> - EFI_STATUS Status;
> -
> - *BufferSize = 0;
> - Status = EFI_DEVICE_ERROR;
> - Mtftp4 = Private->Mtftp4;
> - Packet = NULL;
> - Option = NULL;
> - PktLen = 0;
> - OptCnt = 1;
> - Config->InitialServerPort = PXEBC_BS_DOWNLOAD_PORT;
> -
> - Status = Mtftp4->Configure (Mtftp4, Config);
> - if (EFI_ERROR (Status)) {
> -
> - return Status;
> - }
> -
> - ReqOpt[0].OptionStr =
> (UINT8*)mMtftpOptions[PXE_MTFTP_OPTION_TSIZE_INDEX];
> - UtoA10 (0, (CHAR8 *) OptBuf, PXE_MTFTP_OPTBUF_MAXNUM_INDEX);
> - ReqOpt[0].ValueStr = OptBuf;
> -
> - if (BlockSize != NULL) {
> - ReqOpt[1].OptionStr =
> (UINT8*)mMtftpOptions[PXE_MTFTP_OPTION_BLKSIZE_INDEX];
> - ReqOpt[1].ValueStr = ReqOpt[0].ValueStr + AsciiStrLen ((CHAR8 *)
> ReqOpt[0].ValueStr) + 1;
> - UtoA10 (*BlockSize, (CHAR8 *) ReqOpt[1].ValueStr,
> PXE_MTFTP_OPTBUF_MAXNUM_INDEX - (AsciiStrLen ((CHAR8 *)
> ReqOpt[0].ValueStr) + 1));
> - OptCnt++;
> - }
> -
> - Status = Mtftp4->GetInfo (
> - Mtftp4,
> - NULL,
> - Filename,
> - NULL,
> - (UINT8) OptCnt,
> - ReqOpt,
> - &PktLen,
> - &Packet
> - );
> -
> - if (EFI_ERROR (Status)) {
> - if (Status == EFI_TFTP_ERROR) {
> - Private->Mode.TftpErrorReceived = TRUE;
> - Private->Mode.TftpError.ErrorCode = (UINT8) Packet->Error.ErrorCode;
> - AsciiStrnCpyS (
> - Private->Mode.TftpError.ErrorString,
> - PXE_MTFTP_ERROR_STRING_LENGTH,
> - (CHAR8 *) Packet->Error.ErrorMessage,
> - PXE_MTFTP_ERROR_STRING_LENGTH - 1
> - );
> - Private->Mode.TftpError.ErrorString[PXE_MTFTP_ERROR_STRING_LENGTH
> - 1] = '\0';
> - }
> - goto ON_ERROR;
> - }
> -
> - OptCnt = 0;
> -
> - Status = Mtftp4->ParseOptions (
> - Mtftp4,
> - PktLen,
> - Packet,
> - (UINT32 *) &OptCnt,
> - &Option
> - );
> -
> - if (EFI_ERROR (Status)) {
> -
> - goto ON_ERROR;
> - }
> -
> - Status = EFI_NOT_FOUND;
> -
> - while (OptCnt != 0) {
> -
> - if (AsciiStrnCmp ((CHAR8 *) Option[OptCnt - 1].OptionStr, "tsize", 5) == 0) {
> -
> - *BufferSize = AtoU64 (Option[OptCnt - 1].ValueStr);
> - Status = EFI_SUCCESS;
> - }
> -
> - OptCnt--;
> - }
> -
> - FreePool (Option);
> -
> -ON_ERROR:
> -
> - if (Packet != NULL) {
> - FreePool (Packet);
> - }
> -
> - Mtftp4->Configure (Mtftp4, NULL);
> -
> - return Status;
> -}
> -
> -
> -/**
> - This function is to get data of a file by Tftp.
> -
> - @param Private Pointer to PxeBc private data
> - @param Config Pointer to Mtftp configuration data
> - @param Filename Pointer to file name
> - @param BlockSize Pointer to block size
> - @param BufferPtr Pointer to buffer
> - @param BufferSize Pointer to buffer size
> - @param DontUseBuffer Indicate whether with a receive buffer
> -
> - @retval EFI_SUCCESS Read the data success from the special file.
> - @retval EFI_DEVICE_ERROR The network device encountered an error during
> this operation.
> - @retval other Read data from file failed.
> -
> -**/
> -EFI_STATUS
> -PxeBcTftpReadFile (
> - IN PXEBC_PRIVATE_DATA *Private,
> - IN EFI_MTFTP4_CONFIG_DATA *Config,
> - IN UINT8 *Filename,
> - IN UINTN *BlockSize,
> - IN UINT8 *BufferPtr,
> - IN OUT UINT64 *BufferSize,
> - IN BOOLEAN DontUseBuffer
> - )
> -{
> - EFI_MTFTP4_PROTOCOL *Mtftp4;
> - EFI_MTFTP4_TOKEN Token;
> - EFI_MTFTP4_OPTION ReqOpt[1];
> - UINT32 OptCnt;
> - UINT8 OptBuf[128];
> - EFI_STATUS Status;
> -
> - Status = EFI_DEVICE_ERROR;
> - Mtftp4 = Private->Mtftp4;
> - OptCnt = 0;
> - Config->InitialServerPort = PXEBC_BS_DOWNLOAD_PORT;
> -
> - Status = Mtftp4->Configure (Mtftp4, Config);
> - if (EFI_ERROR (Status)) {
> -
> - return Status;
> - }
> -
> - if (BlockSize != NULL) {
> -
> - ReqOpt[0].OptionStr = (UINT8*)
> mMtftpOptions[PXE_MTFTP_OPTION_BLKSIZE_INDEX];
> - ReqOpt[0].ValueStr = OptBuf;
> - UtoA10 (*BlockSize, (CHAR8 *) ReqOpt[0].ValueStr,
> PXE_MTFTP_OPTBUF_MAXNUM_INDEX);
> - OptCnt++;
> - }
> -
> - Token.Event = NULL;
> - Token.OverrideData = NULL;
> - Token.Filename = Filename;
> - Token.ModeStr = NULL;
> - Token.OptionCount = OptCnt;
> - Token.OptionList = ReqOpt;
> - Token.Context = Private;
> -
> - if (DontUseBuffer) {
> - Token.BufferSize = 0;
> - Token.Buffer = NULL;
> - } else {
> - Token.BufferSize = *BufferSize;
> - Token.Buffer = BufferPtr;
> - }
> -
> - Token.CheckPacket = PxeBcCheckPacket;
> - Token.TimeoutCallback = NULL;
> - Token.PacketNeeded = NULL;
> -
> - Status = Mtftp4->ReadFile (Mtftp4, &Token);
> -
> - *BufferSize = Token.BufferSize;
> -
> - Mtftp4->Configure (Mtftp4, NULL);
> -
> - return Status;
> -}
> -
> -
> -/**
> - This function is put data of a file by Tftp.
> -
> - @param Private Pointer to PxeBc private data
> - @param Config Pointer to Mtftp configuration data
> - @param Filename Pointer to file name
> - @param Overwrite Indicate whether with overwrite attribute
> - @param BlockSize Pointer to block size
> - @param BufferPtr Pointer to buffer
> - @param BufferSize Pointer to buffer size
> -
> - @retval EFI_SUCCESS Write the data success into the special file.
> - @retval EFI_DEVICE_ERROR The network device encountered an error during
> this operation.
> - @retval other Write data into file failed.
> -
> -**/
> -EFI_STATUS
> -PxeBcTftpWriteFile (
> - IN PXEBC_PRIVATE_DATA *Private,
> - IN EFI_MTFTP4_CONFIG_DATA *Config,
> - IN UINT8 *Filename,
> - IN BOOLEAN Overwrite,
> - IN UINTN *BlockSize,
> - IN UINT8 *BufferPtr,
> - IN OUT UINT64 *BufferSize
> - )
> -{
> - EFI_MTFTP4_PROTOCOL *Mtftp4;
> - EFI_MTFTP4_TOKEN Token;
> - EFI_MTFTP4_OPTION ReqOpt[1];
> - UINT32 OptCnt;
> - UINT8 OptBuf[128];
> - EFI_STATUS Status;
> -
> - Status = EFI_DEVICE_ERROR;
> - Mtftp4 = Private->Mtftp4;
> - OptCnt = 0;
> - Config->InitialServerPort = PXEBC_BS_DOWNLOAD_PORT;
> -
> - Status = Mtftp4->Configure (Mtftp4, Config);
> - if (EFI_ERROR (Status)) {
> -
> - return Status;
> - }
> -
> - if (BlockSize != NULL) {
> -
> - ReqOpt[0].OptionStr = (UINT8*)
> mMtftpOptions[PXE_MTFTP_OPTION_BLKSIZE_INDEX];
> - ReqOpt[0].ValueStr = OptBuf;
> - UtoA10 (*BlockSize, (CHAR8 *) ReqOpt[0].ValueStr,
> PXE_MTFTP_OPTBUF_MAXNUM_INDEX);
> - OptCnt++;
> - }
> -
> - Token.Event = NULL;
> - Token.OverrideData = NULL;
> - Token.Filename = Filename;
> - Token.ModeStr = NULL;
> - Token.OptionCount = OptCnt;
> - Token.OptionList = ReqOpt;
> - Token.BufferSize = *BufferSize;
> - Token.Buffer = BufferPtr;
> - Token.CheckPacket = PxeBcCheckPacket;
> - Token.TimeoutCallback = NULL;
> - Token.PacketNeeded = NULL;
> -
> - Status = Mtftp4->WriteFile (Mtftp4, &Token);
> - *BufferSize = Token.BufferSize;
> -
> - Mtftp4->Configure (Mtftp4, NULL);
> -
> - return Status;
> -}
> -
> -
> -/**
> - This function is to get data(file) from a directory(may be a server) by Tftp.
> -
> - @param Private Pointer to PxeBc private data.
> - @param Config Pointer to Mtftp configuration data.
> - @param Filename Pointer to file name.
> - @param BlockSize Pointer to block size.
> - @param BufferPtr Pointer to buffer.
> - @param BufferSize Pointer to buffer size.
> - @param DontUseBuffer Indicate whether with a receive buffer.
> -
> - @retval EFI_SUCCES Get the data from the file included in directory
> success.
> - @retval EFI_DEVICE_ERROR The network device encountered an error during
> this operation.
> - @retval other Operation failed.
> -
> -**/
> -EFI_STATUS
> -PxeBcTftpReadDirectory (
> - IN PXEBC_PRIVATE_DATA *Private,
> - IN EFI_MTFTP4_CONFIG_DATA *Config,
> - IN UINT8 *Filename,
> - IN UINTN *BlockSize,
> - IN UINT8 *BufferPtr,
> - IN OUT UINT64 *BufferSize,
> - IN BOOLEAN DontUseBuffer
> - )
> -{
> - EFI_MTFTP4_PROTOCOL *Mtftp4;
> - EFI_MTFTP4_TOKEN Token;
> - EFI_MTFTP4_OPTION ReqOpt[1];
> - UINT32 OptCnt;
> - UINT8 OptBuf[128];
> - EFI_STATUS Status;
> -
> - Status = EFI_DEVICE_ERROR;
> - Mtftp4 = Private->Mtftp4;
> - OptCnt = 0;
> - Config->InitialServerPort = PXEBC_BS_DOWNLOAD_PORT;
> -
> - Status = Mtftp4->Configure (Mtftp4, Config);
> - if (EFI_ERROR (Status)) {
> -
> - return Status;
> - }
> -
> - if (BlockSize != NULL) {
> -
> - ReqOpt[0].OptionStr = (UINT8*)
> mMtftpOptions[PXE_MTFTP_OPTION_BLKSIZE_INDEX];
> - ReqOpt[0].ValueStr = OptBuf;
> - UtoA10 (*BlockSize, (CHAR8 *) ReqOpt[0].ValueStr,
> PXE_MTFTP_OPTBUF_MAXNUM_INDEX);
> - OptCnt++;
> - }
> -
> - Token.Event = NULL;
> - Token.OverrideData = NULL;
> - Token.Filename = Filename;
> - Token.ModeStr = NULL;
> - Token.OptionCount = OptCnt;
> - Token.OptionList = ReqOpt;
> - Token.Context = Private;
> -
> - if (DontUseBuffer) {
> - Token.BufferSize = 0;
> - Token.Buffer = NULL;
> - } else {
> - Token.BufferSize = *BufferSize;
> - Token.Buffer = BufferPtr;
> - }
> -
> - Token.CheckPacket = PxeBcCheckPacket;
> - Token.TimeoutCallback = NULL;
> - Token.PacketNeeded = NULL;
> -
> - Status = Mtftp4->ReadDirectory (Mtftp4, &Token);
> -
> - *BufferSize = Token.BufferSize;
> -
> - Mtftp4->Configure (Mtftp4, NULL);
> -
> - return Status;
> -}
> -
> diff --git a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcSupport.c
> b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcSupport.c
> deleted file mode 100644
> index 1401ca5ec2fd..000000000000
> --- a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcSupport.c
> +++ /dev/null
> @@ -1,221 +0,0 @@
> -/** @file
> - Support routines for PxeBc.
> -
> -Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
> -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
> -http://opensource.org/licenses/bsd-license.php
> -
> -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS
> OR IMPLIED.
> -
> -**/
> -
> -
> -#include "PxeBcImpl.h"
> -
> -
> -/**
> - The common notify function associated with various PxeBc events.
> -
> - @param Event The event signaled.
> - @param Context The context.
> -
> -**/
> -VOID
> -EFIAPI
> -PxeBcCommonNotify (
> - IN EFI_EVENT Event,
> - IN VOID *Context
> - )
> -{
> - *((BOOLEAN *) Context) = TRUE;
> -}
> -
> -
> -/**
> - This function initialize(or configure) the Udp4Write instance.
> -
> - @param Udp4 Pointer to the EFI_UDP4_PROTOCOL instance.
> - @param StationIp Pointer to the station ip address.
> - @param SubnetMask Pointer to the subnetmask of the station ip address.
> - @param Gateway Pointer to the gateway ip address.
> - @param SrcPort Pointer to the srouce port of the station.
> - @param Ttl The time to live field of the IP header.
> - @param ToS The type of service field of the IP header.
> -
> - @retval EFI_SUCCESS The configuration settings were set, changed, or
> reset successfully.
> - @retval EFI_NO_MAPPING When using a default address, configuration
> (DHCP, BOOTP,
> - RARP, etc.) is not finished yet.
> - @retval EFI_INVALID_PARAMETER One or more following conditions are
> TRUE:
> - @retval EFI_ALREADY_STARTED The EFI UDPv4 Protocol instance is already
> started/configured
> - and must be stopped/reset before it can be reconfigured.
> - @retval EFI_ACCESS_DENIED UdpConfigData. AllowDuplicatePort is FALSE
> - and UdpConfigData.StationPort is already used by
> - other instance.
> - @retval EFI_OUT_OF_RESOURCES The EFI UDPv4 Protocol driver cannot
> allocate memory for this
> - EFI UDPv4 Protocol instance.
> - @retval EFI_DEVICE_ERROR An unexpected network or system error
> occurred and this instance
> - was not opened.
> - @retval Others Please examine the function Udp4->Routes(Udp4,
> FALSE, &mZeroIp4Addr, &mZeroIp4Addr, Gateway) returns.
> -
> -**/
> -EFI_STATUS
> -PxeBcConfigureUdpWriteInstance (
> - IN EFI_UDP4_PROTOCOL *Udp4,
> - IN EFI_IPv4_ADDRESS *StationIp,
> - IN EFI_IPv4_ADDRESS *SubnetMask,
> - IN EFI_IPv4_ADDRESS *Gateway,
> - IN OUT UINT16 *SrcPort,
> - IN UINT8 Ttl,
> - IN UINT8 ToS
> - )
> -{
> - EFI_UDP4_CONFIG_DATA Udp4CfgData;
> - EFI_STATUS Status;
> -
> - ZeroMem (&Udp4CfgData, sizeof (Udp4CfgData));
> -
> - Udp4CfgData.ReceiveTimeout = PXEBC_DEFAULT_LIFETIME;
> - Udp4CfgData.TypeOfService = ToS;
> - Udp4CfgData.TimeToLive = Ttl;
> - Udp4CfgData.AllowDuplicatePort = TRUE;
> -
> - CopyMem (&Udp4CfgData.StationAddress, StationIp, sizeof (*StationIp));
> - CopyMem (&Udp4CfgData.SubnetMask, SubnetMask, sizeof (*SubnetMask));
> -
> - Udp4CfgData.StationPort = *SrcPort;
> -
> - //
> - // Reset the instance.
> - //
> - Udp4->Configure (Udp4, NULL);
> -
> - Status = Udp4->Configure (Udp4, &Udp4CfgData);
> - if (!EFI_ERROR (Status) && (Gateway->Addr[0] != 0)) {
> - //
> - // basic configuration OK, need to add the default route entry
> - //
> - Status = Udp4->Routes (Udp4, FALSE, &mZeroIp4Addr, &mZeroIp4Addr,
> Gateway);
> - if (EFI_ERROR (Status)) {
> - //
> - // roll back
> - //
> - Udp4->Configure (Udp4, NULL);
> - }
> - }
> -
> - if (!EFI_ERROR (Status) && (*SrcPort == 0)) {
> - Udp4->GetModeData (Udp4, &Udp4CfgData, NULL, NULL, NULL);
> - *SrcPort = Udp4CfgData.StationPort;
> - }
> -
> - return Status;
> -}
> -
> -/**
> - This function is to display the IPv4 address.
> -
> - @param[in] Ip The pointer to the IPv4 address.
> -
> -**/
> -VOID
> -PxeBcShowIp4Addr (
> - IN EFI_IPv4_ADDRESS *Ip
> - )
> -{
> - UINTN Index;
> -
> - for (Index = 0; Index < 4; Index++) {
> - AsciiPrint ("%d", Ip->Addr[Index]);
> - if (Index < 3) {
> - AsciiPrint (".");
> - }
> - }
> -}
> -
> -/**
> - Convert number to ASCII value.
> -
> - @param Number Numeric value to convert to decimal ASCII value.
> - @param Buffer Buffer to place ASCII version of the Number.
> - @param Length Length of Buffer.
> -
> -**/
> -VOID
> -CvtNum (
> - IN UINTN Number,
> - IN UINT8 *Buffer,
> - IN UINTN Length
> - )
> -{
> - UINTN Remainder;
> -
> - for (; Length > 0; Length--) {
> - Remainder = Number % 10;
> - Number /= 10;
> - Buffer[Length - 1] = (UINT8) ('0' + Remainder);
> - }
> -}
> -
> -
> -/**
> - Convert unsigned int number to decimal number.
> -
> - @param Number The unsigned int number will be converted.
> - @param Buffer Pointer to the buffer to store the decimal number after
> transform.
> - @param[in] BufferSize The maxsize of the buffer.
> -
> - @return the length of the number after transform.
> -
> -**/
> -UINTN
> -UtoA10 (
> - IN UINTN Number,
> - IN CHAR8 *Buffer,
> - IN UINTN BufferSize
> - )
> -{
> - UINTN Index;
> - CHAR8 TempStr[64];
> -
> - Index = 63;
> - TempStr[Index] = 0;
> -
> - do {
> - Index--;
> - TempStr[Index] = (CHAR8) ('0' + (Number % 10));
> - Number = Number / 10;
> - } while (Number != 0);
> -
> - AsciiStrCpyS (Buffer, BufferSize, &TempStr[Index]);
> -
> - return AsciiStrLen (Buffer);
> -}
> -
> -
> -/**
> - Convert ASCII numeric string to a UINTN value.
> -
> - @param Buffer Pointer to the 8-byte unsigned int value.
> -
> - @return UINTN value of the ASCII string.
> -
> -**/
> -UINT64
> -AtoU64 (
> - IN UINT8 *Buffer
> - )
> -{
> - UINT64 Value;
> - UINT8 Character;
> -
> - Value = 0;
> - while ((Character = *Buffer++) != '\0') {
> - Value = MultU64x32 (Value, 10) + (Character - '0');
> - }
> -
> - return Value;
> -}
> -
> diff --git a/MdeModulePkg/MdeModulePkg.dsc
> b/MdeModulePkg/MdeModulePkg.dsc
> index b787fb5692d3..5d042be3a862 100644
> --- a/MdeModulePkg/MdeModulePkg.dsc
> +++ b/MdeModulePkg/MdeModulePkg.dsc
> @@ -420,7 +420,6 @@ [Components]
> MdeModulePkg/Library/DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf
>
> [Components.IA32, Components.X64, Components.AARCH64]
> - MdeModulePkg/Universal/Network/UefiPxeBcDxe/UefiPxeBcDxe.inf
> MdeModulePkg/Universal/DebugSupportDxe/DebugSupportDxe.inf
> MdeModulePkg/Universal/EbcDxe/EbcDxe.inf
> MdeModulePkg/Universal/EbcDxe/EbcDebugger.inf
> diff --git a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDhcp.h
> b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDhcp.h
> deleted file mode 100644
> index d8336c5e82e9..000000000000
> --- a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDhcp.h
> +++ /dev/null
> @@ -1,502 +0,0 @@
> -/** @file
> - Dhcp and Discover routines for PxeBc.
> -
> -Copyright (c) 2013, Red Hat, Inc.
> -Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
> -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
> -http://opensource.org/licenses/bsd-license.php
> -
> -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS
> OR IMPLIED.
> -
> -**/
> -
> -#ifndef __EFI_PXEBC_DHCP_H__
> -#define __EFI_PXEBC_DHCP_H__
> -
> -#define PXEBC_DHCP4_MAX_OPTION_NUM 16
> -#define PXEBC_DHCP4_MAX_OPTION_SIZE 312
> -#define PXEBC_DHCP4_MAX_PACKET_SIZE (sizeof
> (EFI_PXE_BASE_CODE_PACKET))
> -
> -#define PXEBC_DHCP4_S_PORT 67
> -#define PXEBC_DHCP4_C_PORT 68
> -#define PXEBC_BS_DOWNLOAD_PORT 69
> -#define PXEBC_BS_DISCOVER_PORT 4011
> -
> -#define PXEBC_DHCP4_OPCODE_REQUEST 1
> -#define PXEBC_DHCP4_OPCODE_REPLY 2
> -#define PXEBC_DHCP4_MSG_TYPE_REQUEST 3
> -#define PXEBC_DHCP4_MAGIC 0x63538263 // network byte order
> -
> -//
> -// Sub-Options in Dhcp Vendor Option
> -//
> -#define PXEBC_VENDOR_TAG_MTFTP_IP 1
> -#define PXEBC_VENDOR_TAG_MTFTP_CPORT 2
> -#define PXEBC_VENDOR_TAG_MTFTP_SPORT 3
> -#define PXEBC_VENDOR_TAG_MTFTP_TIMEOUT 4
> -#define PXEBC_VENDOR_TAG_MTFTP_DELAY 5
> -#define PXEBC_VENDOR_TAG_DISCOVER_CTRL 6
> -#define PXEBC_VENDOR_TAG_DISCOVER_MCAST 7
> -#define PXEBC_VENDOR_TAG_BOOT_SERVERS 8
> -#define PXEBC_VENDOR_TAG_BOOT_MENU 9
> -#define PXEBC_VENDOR_TAG_MENU_PROMPT 10
> -#define PXEBC_VENDOR_TAG_MCAST_ALLOC 11
> -#define PXEBC_VENDOR_TAG_CREDENTIAL_TYPES 12
> -#define PXEBC_VENDOR_TAG_BOOT_ITEM 71
> -
> -#define PXEBC_DHCP4_DISCOVER_INIT_TIMEOUT 4
> -#define PXEBC_DHCP4_DISCOVER_RETRIES 4
> -
> -#define PXEBC_MAX_MENU_NUM 24
> -#define PXEBC_MAX_OFFER_NUM 16
> -
> -#define PXEBC_BOOT_REQUEST_TIMEOUT 1
> -#define PXEBC_BOOT_REQUEST_RETRIES 4
> -
> -#define PXEBC_DHCP4_OVERLOAD_FILE 1
> -#define PXEBC_DHCP4_OVERLOAD_SERVER_NAME 2
> -
> -//
> -// The array index of the DHCP4 option tag interested
> -//
> -#define PXEBC_DHCP4_TAG_INDEX_BOOTFILE_LEN 0
> -#define PXEBC_DHCP4_TAG_INDEX_VENDOR 1
> -#define PXEBC_DHCP4_TAG_INDEX_OVERLOAD 2
> -#define PXEBC_DHCP4_TAG_INDEX_MSG_TYPE 3
> -#define PXEBC_DHCP4_TAG_INDEX_SERVER_ID 4
> -#define PXEBC_DHCP4_TAG_INDEX_CLASS_ID 5
> -#define PXEBC_DHCP4_TAG_INDEX_BOOTFILE 6
> -#define PXEBC_DHCP4_TAG_INDEX_MAX 7
> -
> -//
> -// The type of DHCP OFFER, arranged by priority, PXE10 has the highest priority.
> -//
> -#define DHCP4_PACKET_TYPE_PXE10 0
> -#define DHCP4_PACKET_TYPE_WFM11A 1
> -#define DHCP4_PACKET_TYPE_BINL 2
> -#define DHCP4_PACKET_TYPE_DHCP_ONLY 3
> -#define DHCP4_PACKET_TYPE_BOOTP 4
> -#define DHCP4_PACKET_TYPE_MAX 5
> -
> -#define BIT(x) (1 << x)
> -#define CTRL(x) (0x1F & (x))
> -
> -//
> -// WfM11a options
> -//
> -#define MTFTP_VENDOR_OPTION_BIT_MAP (BIT
> (PXEBC_VENDOR_TAG_MTFTP_IP) | \
> - BIT (PXEBC_VENDOR_TAG_MTFTP_CPORT) | \
> - BIT (PXEBC_VENDOR_TAG_MTFTP_SPORT) | \
> - BIT (PXEBC_VENDOR_TAG_MTFTP_TIMEOUT) | \
> - BIT (PXEBC_VENDOR_TAG_MTFTP_DELAY))
> -//
> -// Discoverty options
> -//
> -#define DISCOVER_VENDOR_OPTION_BIT_MAP (BIT
> (PXEBC_VENDOR_TAG_DISCOVER_CTRL) | \
> - BIT (PXEBC_VENDOR_TAG_DISCOVER_MCAST) | \
> - BIT (PXEBC_VENDOR_TAG_BOOT_SERVERS) | \
> - BIT (PXEBC_VENDOR_TAG_BOOT_MENU) | \
> - BIT (PXEBC_VENDOR_TAG_MENU_PROMPT))
> -
> -#define IS_VALID_BOOT_PROMPT(x) \
> - ((((x)[0]) & BIT (PXEBC_VENDOR_TAG_MENU_PROMPT)) == BIT
> (PXEBC_VENDOR_TAG_MENU_PROMPT))
> -
> -#define IS_VALID_BOOT_MENU(x) \
> - ((((x)[0]) & BIT (PXEBC_VENDOR_TAG_BOOT_MENU)) == BIT
> (PXEBC_VENDOR_TAG_BOOT_MENU))
> -
> -#define IS_VALID_MTFTP_VENDOR_OPTION(x) \
> - (((UINT32) ((x)[0]) & MTFTP_VENDOR_OPTION_BIT_MAP) ==
> MTFTP_VENDOR_OPTION_BIT_MAP)
> -
> -#define IS_VALID_DISCOVER_VENDOR_OPTION(x) (((UINT32) ((x)[0]) &
> DISCOVER_VENDOR_OPTION_BIT_MAP) != 0)
> -
> -#define IS_VALID_CREDENTIAL_VENDOR_OPTION(x) \
> - (((UINT32) ((x)[0]) & BIT (PXEBC_VENDOR_TAG_CREDENTIAL_TYPES)) == BIT
> (PXEBC_VENDOR_TAG_CREDENTIAL_TYPES))
> -
> -#define IS_VALID_BOOTITEM_VENDOR_OPTION(x) \
> - (((UINT32) ((x)[PXEBC_VENDOR_TAG_BOOT_ITEM / 32]) & BIT
> (PXEBC_VENDOR_TAG_BOOT_ITEM % 32)) \
> - == BIT (PXEBC_VENDOR_TAG_BOOT_ITEM % 32))
> -
> -#define IS_DISABLE_BCAST_DISCOVER(x) (((x) & BIT (0)) == BIT (0))
> -#define IS_DISABLE_MCAST_DISCOVER(x) (((x) & BIT (1)) == BIT (1))
> -#define IS_ENABLE_USE_SERVER_LIST(x) (((x) & BIT (2)) == BIT (2))
> -#define IS_DISABLE_PROMPT_MENU(x) (((x) & BIT (3)) == BIT (3))
> -
> -#define SET_VENDOR_OPTION_BIT_MAP(x, y) (((x)[(y) / 32]) = (UINT32) ((x)[(y) /
> 32]) | BIT ((y) % 32))
> -
> -#pragma pack(1)
> -typedef struct {
> - UINT8 ParaList[135];
> -} PXEBC_DHCP4_OPTION_PARA;
> -
> -typedef struct {
> - UINT16 Size;
> -} PXEBC_DHCP4_OPTION_MAX_MESG_SIZE;
> -
> -typedef struct {
> - UINT8 Type;
> - UINT8 MajorVer;
> - UINT8 MinorVer;
> -} PXEBC_DHCP4_OPTION_UNDI;
> -
> -typedef struct {
> - UINT8 Type;
> -} PXEBC_DHCP4_OPTION_MESG;
> -
> -typedef struct {
> - UINT16 Type;
> -} PXEBC_DHCP4_OPTION_ARCH;
> -
> -#define DEFAULT_CLASS_ID_DATA "PXEClient:Arch:xxxxx:UNDI:003000"
> -#define DEFAULT_UNDI_TYPE 1
> -#define DEFAULT_UNDI_MAJOR 3
> -#define DEFAULT_UNDI_MINOR 0
> -
> -typedef struct {
> - UINT8 ClassIdentifier[10];
> - UINT8 ArchitecturePrefix[5];
> - UINT8 ArchitectureType[5];
> - UINT8 Lit3[1];
> - UINT8 InterfaceName[4];
> - UINT8 Lit4[1];
> - UINT8 UndiMajor[3];
> - UINT8 UndiMinor[3];
> -} PXEBC_DHCP4_OPTION_CLID;
> -
> -typedef struct {
> - UINT8 Type;
> - UINT8 Guid[16];
> -} PXEBC_DHCP4_OPTION_UUID;
> -
> -typedef struct {
> - UINT16 Type;
> - UINT16 Layer;
> -} PXEBC_OPTION_BOOT_ITEM;
> -
> -#pragma pack()
> -
> -typedef union {
> - PXEBC_DHCP4_OPTION_PARA *Para;
> - PXEBC_DHCP4_OPTION_UNDI *Undi;
> - PXEBC_DHCP4_OPTION_ARCH *Arch;
> - PXEBC_DHCP4_OPTION_CLID *Clid;
> - PXEBC_DHCP4_OPTION_UUID *Uuid;
> - PXEBC_DHCP4_OPTION_MESG *Mesg;
> - PXEBC_DHCP4_OPTION_MAX_MESG_SIZE *MaxMesgSize;
> -} PXEBC_DHCP4_OPTION_ENTRY;
> -
> -typedef struct {
> - UINT16 Type;
> - UINT8 IpCnt;
> - EFI_IPv4_ADDRESS IpAddr[1];
> -} PXEBC_BOOT_SVR_ENTRY;
> -
> -typedef struct {
> - UINT16 Type;
> - UINT8 DescLen;
> - UINT8 DescStr[1];
> -} PXEBC_BOOT_MENU_ENTRY;
> -
> -typedef struct {
> - UINT8 Timeout;
> - UINT8 Prompt[1];
> -} PXEBC_MENU_PROMPT;
> -
> -typedef struct {
> - UINT32 BitMap[8];
> - EFI_IPv4_ADDRESS MtftpIp;
> - UINT16 MtftpCPort;
> - UINT16 MtftpSPort;
> - UINT8 MtftpTimeout;
> - UINT8 MtftpDelay;
> - UINT8 DiscoverCtrl;
> - EFI_IPv4_ADDRESS DiscoverMcastIp;
> - EFI_IPv4_ADDRESS McastIpBase;
> - UINT16 McastIpBlock;
> - UINT16 McastIpRange;
> - UINT16 BootSrvType;
> - UINT16 BootSrvLayer;
> - PXEBC_BOOT_SVR_ENTRY *BootSvr;
> - UINT8 BootSvrLen;
> - PXEBC_BOOT_MENU_ENTRY *BootMenu;
> - UINT8 BootMenuLen;
> - PXEBC_MENU_PROMPT *MenuPrompt;
> - UINT8 MenuPromptLen;
> - UINT32 *CredType;
> - UINT8 CredTypeLen;
> -} PXEBC_VENDOR_OPTION;
> -
> -#define PXEBC_CACHED_DHCP4_PACKET_MAX_SIZE (OFFSET_OF
> (EFI_DHCP4_PACKET, Dhcp4) + PXEBC_DHCP4_MAX_PACKET_SIZE)
> -
> -typedef union {
> - EFI_DHCP4_PACKET Offer;
> - EFI_DHCP4_PACKET Ack;
> - UINT8 Buffer[PXEBC_CACHED_DHCP4_PACKET_MAX_SIZE];
> -} PXEBC_DHCP4_PACKET;
> -
> -typedef struct {
> - PXEBC_DHCP4_PACKET Packet;
> - BOOLEAN IsPxeOffer;
> - UINT8 OfferType;
> - EFI_DHCP4_PACKET_OPTION
> *Dhcp4Option[PXEBC_DHCP4_TAG_INDEX_MAX];
> - PXEBC_VENDOR_OPTION PxeVendorOption;
> -} PXEBC_CACHED_DHCP4_PACKET;
> -
> -#define GET_NEXT_DHCP_OPTION(Opt) \
> - (EFI_DHCP4_PACKET_OPTION *) ((UINT8 *) (Opt) + sizeof
> (EFI_DHCP4_PACKET_OPTION) + (Opt)->Length - 1)
> -
> -#define GET_OPTION_BUFFER_LEN(Pkt) ((Pkt)->Length - sizeof
> (EFI_DHCP4_HEADER) - 4)
> -#define IS_PROXY_DHCP_OFFER(Offer) EFI_IP4_EQUAL (&((Offer)-
> >Dhcp4.Header.YourAddr), &mZeroIp4Addr)
> -
> -#define GET_NEXT_BOOT_SVR_ENTRY(Ent) \
> - (PXEBC_BOOT_SVR_ENTRY *) ((UINT8 *) Ent + sizeof (*(Ent)) + ((Ent)->IpCnt - 1)
> * sizeof (EFI_IPv4_ADDRESS))
> -
> -
> -/**
> - This function initialize the DHCP4 message instance.
> -
> - This function will pad each item of dhcp4 message packet.
> -
> - @param Seed Pointer to the message instance of the DHCP4 packet.
> - @param Udp4 Pointer to the EFI_UDP4_PROTOCOL instance.
> -
> -**/
> -VOID
> -PxeBcInitSeedPacket (
> - IN EFI_DHCP4_PACKET *Seed,
> - IN EFI_UDP4_PROTOCOL *Udp4
> - );
> -
> -
> -/**
> - Parse the cached dhcp packet.
> -
> - @param CachedPacket Pointer to cached dhcp packet.
> -
> - @retval TRUE Succeed to parse and validation.
> - @retval FALSE Fail to parse or validation.
> -
> -**/
> -BOOLEAN
> -PxeBcParseCachedDhcpPacket (
> - IN PXEBC_CACHED_DHCP4_PACKET *CachedPacket
> - );
> -
> -/**
> - This function is to check the selected proxy offer (include BINL dhcp offer and
> - DHCP_ONLY offer ) and set the flag and copy the DHCP packets to the Pxe
> base code
> - mode structure.
> -
> - @param Private Pointer to PxeBc private data.
> -
> - @retval EFI_SUCCESS Operational successful.
> - @retval EFI_NO_RESPONSE Offer dhcp service failed.
> - @retval EFI_BUFFER_TOO_SMALL Failed to copy the packet to Pxe base
> code mode.
> -
> -**/
> -EFI_STATUS
> -PxeBcCheckSelectedOffer (
> - IN PXEBC_PRIVATE_DATA *Private
> - );
> -
> -
> -/**
> - Callback routine.
> -
> - EFI_DHCP4_CALLBACK is provided by the consumer of the EFI DHCPv4
> Protocol driver
> - to intercept events that occurred in the configuration process. This structure
> - provides advanced control of each state transition of the DHCP process. The
> - returned status code determines the behavior of the EFI DHCPv4 Protocol
> driver.
> - There are three possible returned values, which are described in the following
> - table.
> -
> - @param This Pointer to the EFI DHCPv4 Protocol instance that is
> used to
> - configure this callback function.
> - @param Context Pointer to the context that is initialized by
> - EFI_DHCP4_PROTOCOL.Configure().
> - @param CurrentState The current operational state of the EFI DHCPv4
> Protocol
> - driver.
> - @param Dhcp4Event The event that occurs in the current state, which
> usually means a
> - state transition.
> - @param Packet The DHCP packet that is going to be sent or already
> received.
> - @param NewPacket The packet that is used to replace the above
> Packet.
> -
> - @retval EFI_SUCCESS Tells the EFI DHCPv4 Protocol driver to continue
> the DHCP process.
> - @retval EFI_NOT_READY Only used in the Dhcp4Selecting state. The EFI
> DHCPv4 Protocol
> - driver will continue to wait for more DHCPOFFER packets until
> the retry
> - timeout expires.
> - @retval EFI_ABORTED Tells the EFI DHCPv4 Protocol driver to abort the
> current process and
> - return to the Dhcp4Init or Dhcp4InitReboot state.
> -
> -**/
> -EFI_STATUS
> -EFIAPI
> -PxeBcDhcpCallBack (
> - IN EFI_DHCP4_PROTOCOL * This,
> - IN VOID *Context,
> - IN EFI_DHCP4_STATE CurrentState,
> - IN EFI_DHCP4_EVENT Dhcp4Event,
> - IN EFI_DHCP4_PACKET * Packet OPTIONAL,
> - OUT EFI_DHCP4_PACKET **NewPacket OPTIONAL
> - );
> -
> -/**
> - Switch the Ip4 policy to static.
> -
> - @param[in] Private The pointer to PXEBC_PRIVATE_DATA.
> -
> - @retval EFI_SUCCESS The policy is already configured to static.
> - @retval Others Other error as indicated..
> -
> -**/
> -EFI_STATUS
> -PxeBcSetIp4Policy (
> - IN PXEBC_PRIVATE_DATA *Private
> - );
> -
> -/**
> - Discover the boot of service and initialize the vendor option if exists.
> -
> - @param Private Pointer to PxeBc private data.
> - @param Type PxeBc option boot item type
> - @param Layer PxeBc option boot item layer
> - @param UseBis Use BIS or not
> - @param DestIp Ip address for server
> - @param IpCount The total count of the server ip address
> - @param SrvList Server list
> - @param IsDiscv Discover the vendor or not
> - @param Reply The dhcp4 packet of Pxe reply
> -
> - @retval EFI_SUCCESS Operation succeeds.
> - @retval EFI_OUT_OF_RESOURCES Allocate memory pool failed.
> - @retval EFI_NOT_FOUND There is no vendor option exists.
> - @retval EFI_TIMEOUT Send Pxe Discover time out.
> -
> -**/
> -EFI_STATUS
> -PxeBcDiscvBootService (
> - IN PXEBC_PRIVATE_DATA * Private,
> - IN UINT16 Type,
> - IN UINT16 *Layer,
> - IN BOOLEAN UseBis,
> - IN EFI_IP_ADDRESS * DestIp,
> - IN UINT16 IpCount,
> - IN EFI_PXE_BASE_CODE_SRVLIST * SrvList,
> - IN BOOLEAN IsDiscv,
> - OUT EFI_DHCP4_PACKET * Reply OPTIONAL
> - );
> -
> -
> -/**
> - Initialize the DHCP options and build the option list.
> -
> - @param Private Pointer to PxeBc private data.
> - @param OptList Pointer to a DHCP option list.
> -
> - @param IsDhcpDiscover Discover dhcp option or not.
> -
> - @return The index item number of the option list.
> -
> -**/
> -UINT32
> -PxeBcBuildDhcpOptions (
> - IN PXEBC_PRIVATE_DATA *Private,
> - IN EFI_DHCP4_PACKET_OPTION **OptList,
> - IN BOOLEAN IsDhcpDiscover
> - );
> -
> -
> -/**
> - Create the boot options.
> -
> - @param OptList Pointer to the list of the options
> - @param Type the type of option
> - @param Layer the layer of the boot options
> - @param OptLen length of opotion
> -
> -**/
> -VOID
> -PxeBcCreateBootOptions (
> - IN EFI_DHCP4_PACKET_OPTION *OptList,
> - IN UINT16 Type,
> - IN UINT16 *Layer,
> - OUT UINT32 *OptLen
> - );
> -
> -
> -/**
> - Parse interested dhcp options.
> -
> - @param Buffer Pointer to the dhcp options packet.
> - @param Length The length of the dhcp options.
> - @param OptTag The option OpCode.
> -
> - @return NULL if the buffer length is 0 and OpCode is not
> - DHCP4_TAG_EOP, or the pointer to the buffer.
> -
> -**/
> -EFI_DHCP4_PACKET_OPTION *
> -PxeBcParseExtendOptions (
> - IN UINT8 *Buffer,
> - IN UINT32 Length,
> - IN UINT8 OptTag
> - );
> -
> -
> -/**
> - This function is to parse and check vendor options.
> -
> - @param Dhcp4Option Pointer to dhcp options
> - @param VendorOption Pointer to vendor options
> -
> - @return TRUE if valid for vendor options, or FALSE.
> -
> -**/
> -BOOLEAN
> -PxeBcParseVendorOptions (
> - IN EFI_DHCP4_PACKET_OPTION *Dhcp4Option,
> - IN PXEBC_VENDOR_OPTION *VendorOption
> - );
> -
> -
> -/**
> - Choose the boot prompt.
> -
> - @param Private Pointer to PxeBc private data.
> -
> - @retval EFI_SUCCESS Select boot prompt done.
> - @retval EFI_TIMEOUT Select boot prompt time out.
> - @retval EFI_NOT_FOUND The proxy offer is not Pxe10.
> - @retval EFI_ABORTED User cancel the operation.
> - @retval EFI_NOT_READY Read the input key from the keybroad has not
> finish.
> -
> -**/
> -EFI_STATUS
> -PxeBcSelectBootPrompt (
> - IN PXEBC_PRIVATE_DATA *Private
> - );
> -
> -
> -/**
> - Select the boot menu.
> -
> - @param Private Pointer to PxeBc private data.
> - @param Type The type of the menu.
> - @param UseDefaultItem Use default item or not.
> -
> - @retval EFI_ABORTED User cancel operation.
> - @retval EFI_SUCCESS Select the boot menu success.
> - @retval EFI_NOT_READY Read the input key from the keybroad has not finish.
> -
> -**/
> -EFI_STATUS
> -PxeBcSelectBootMenu (
> - IN PXEBC_PRIVATE_DATA *Private,
> - OUT UINT16 *Type,
> - IN BOOLEAN UseDefaultItem
> - );
> -
> -#endif
> -
> diff --git a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDriver.h
> b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDriver.h
> deleted file mode 100644
> index b7bf069dd637..000000000000
> --- a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDriver.h
> +++ /dev/null
> @@ -1,102 +0,0 @@
> -/** @file
> -
> -Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
> -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
> -http://opensource.org/licenses/bsd-license.php
> -
> -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS
> OR IMPLIED.
> -
> -**/
> -
> -#ifndef __EFI_PXEBC_DRIVER_H__
> -#define __EFI_PXEBC_DRIVER_H__
> -
> -/**
> - Test to see if this driver supports ControllerHandle. This service
> - is called by the EFI boot service ConnectController(). In
> - order to make drivers as small as possible, there are a few calling
> - restrictions for this service. ConnectController() must
> - follow these calling restrictions. If any other agent wishes to call
> - Supported() it must also follow these calling restrictions.
> - PxeBc requires DHCP4 and MTFTP4 protocols.
> -
> - @param This Protocol instance pointer.
> - @param ControllerHandle Handle of device to test
> - @param RemainingDevicePath Optional parameter use to pick a specific child
> - device to start.
> -
> - @retval EFI_SUCCESS This driver supports this device
> - @retval EFI_ALREADY_STARTED This driver is already running on this device
> - @retval other This driver does not support this device
> -
> -**/
> -EFI_STATUS
> -EFIAPI
> -PxeBcDriverBindingSupported (
> - IN EFI_DRIVER_BINDING_PROTOCOL * This,
> - IN EFI_HANDLE ControllerHandle,
> - IN EFI_DEVICE_PATH_PROTOCOL * RemainingDevicePath OPTIONAL
> - );
> -
> -/**
> - Start this driver on ControllerHandle. This service is called by the
> - EFI boot service ConnectController(). In order to make
> - drivers as small as possible, there are a few calling restrictions for
> - this service. ConnectController() must follow these
> - calling restrictions. If any other agent wishes to call Start() it
> - must also follow these calling restrictions.
> -
> - @param This Protocol instance pointer.
> - @param ControllerHandle Handle of device to bind driver to
> - @param RemainingDevicePath Optional parameter use to pick a specific child
> - device to start.
> -
> - @retval EFI_SUCCESS This driver is added to ControllerHandle
> - @retval EFI_ALREADY_STARTED This driver is already running on
> ControllerHandle
> - @retval other This driver does not support this device
> -
> -**/
> -EFI_STATUS
> -EFIAPI
> -PxeBcDriverBindingStart (
> - IN EFI_DRIVER_BINDING_PROTOCOL * This,
> - IN EFI_HANDLE ControllerHandle,
> - IN EFI_DEVICE_PATH_PROTOCOL * RemainingDevicePath OPTIONAL
> - );
> -
> -/**
> - Stop this driver on ControllerHandle. This service is called by the
> - EFI boot service DisconnectController(). In order to
> - make drivers as small as possible, there are a few calling
> - restrictions for this service. DisconnectController()
> - must follow these calling restrictions. If any other agent wishes
> - to call Stop() it must also follow these calling restrictions.
> -
> - @param This Protocol instance pointer.
> - @param ControllerHandle Handle of device to stop driver on
> - @param NumberOfChildren Number of Handles in ChildHandleBuffer. If
> number of
> - children is zero stop the entire bus driver.
> - @param ChildHandleBuffer List of Child Handles to Stop.
> -
> - @retval EFI_SUCCESS This driver is removed ControllerHandle
> - @retval other This driver was not removed from this device
> -
> -**/
> -EFI_STATUS
> -EFIAPI
> -PxeBcDriverBindingStop (
> - IN EFI_DRIVER_BINDING_PROTOCOL *This,
> - IN EFI_HANDLE ControllerHandle,
> - IN UINTN NumberOfChildren,
> - IN EFI_HANDLE *ChildHandleBuffer
> - );
> -
> -extern EFI_COMPONENT_NAME2_PROTOCOL gPxeBcComponentName2;
> -extern EFI_COMPONENT_NAME_PROTOCOL gPxeBcComponentName;
> -extern EFI_DRIVER_BINDING_PROTOCOL gPxeBcDriverBinding;
> -
> -#endif
> -
> diff --git a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.h
> b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.h
> deleted file mode 100644
> index e96b6f2c5d14..000000000000
> --- a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.h
> +++ /dev/null
> @@ -1,189 +0,0 @@
> -/** @file
> -
> -Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>
> -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
> -http://opensource.org/licenses/bsd-license.php
> -
> -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS
> OR IMPLIED.
> -
> -**/
> -
> -#ifndef __EFI_PXEBC_IMPL_H__
> -#define __EFI_PXEBC_IMPL_H__
> -
> -
> -typedef struct _PXEBC_PRIVATE_DATA PXEBC_PRIVATE_DATA;
> -
> -#include <Uefi.h>
> -
> -#include <Guid/SmBios.h>
> -#include <IndustryStandard/SmBios.h>
> -#include <IndustryStandard/Dhcp.h>
> -#include <Protocol/Dhcp4.h>
> -#include <Protocol/PxeBaseCode.h>
> -#include <Protocol/Mtftp4.h>
> -#include <Protocol/Udp4.h>
> -#include <Protocol/LoadFile.h>
> -#include <Protocol/NetworkInterfaceIdentifier.h>
> -#include <Protocol/PxeBaseCodeCallBack.h>
> -#include <Protocol/Arp.h>
> -#include <Protocol/Ip4.h>
> -#include <Protocol/Ip4Config2.h>
> -
> -#include <Library/DebugLib.h>
> -#include <Library/DevicePathLib.h>
> -#include <Library/BaseMemoryLib.h>
> -#include <Library/MemoryAllocationLib.h>
> -#include <Library/UefiDriverEntryPoint.h>
> -#include <Library/UefiBootServicesTableLib.h>
> -#include <Library/UefiLib.h>
> -#include <Library/BaseLib.h>
> -#include <Library/NetLib.h>
> -#include <Library/DpcLib.h>
> -#include <Library/PcdLib.h>
> -
> -#include "PxeBcDriver.h"
> -#include "PxeBcDhcp.h"
> -#include "PxeBcMtftp.h"
> -#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_DEFAULT_UDP_OVERHEAD_SIZE 8
> -#define PXEBC_DEFAULT_TFTP_OVERHEAD_SIZE 4
> -#define PXEBC_DEFAULT_PACKET_SIZE 1480
> -#define PXEBC_DEFAULT_LIFETIME 50000 // 50ms, unit is microsecond
> -#define PXEBC_CHECK_MEDIA_WAITING_TIME
> EFI_TIMER_PERIOD_SECONDS(20)
> -
> -struct _PXEBC_PRIVATE_DATA {
> - UINT32 Signature;
> - EFI_HANDLE Controller;
> - EFI_HANDLE Image;
> - EFI_HANDLE ArpChild;
> - EFI_HANDLE Dhcp4Child;
> - EFI_HANDLE Ip4Child;
> - EFI_HANDLE Mtftp4Child;
> - EFI_HANDLE Udp4ReadChild;
> - EFI_HANDLE Udp4WriteChild;
> -
> - EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL *Nii;
> -
> - EFI_PXE_BASE_CODE_PROTOCOL PxeBc;
> - EFI_LOAD_FILE_PROTOCOL LoadFile;
> - EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL LoadFileCallback;
> - EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL *PxeBcCallback;
> - EFI_ARP_PROTOCOL *Arp;
> - EFI_DHCP4_PROTOCOL *Dhcp4;
> - EFI_IP4_PROTOCOL *Ip4;
> - EFI_IP4_CONFIG2_PROTOCOL *Ip4Config2;
> - EFI_IP4_CONFIG_DATA Ip4ConfigData;
> - EFI_MTFTP4_PROTOCOL *Mtftp4;
> - EFI_UDP4_PROTOCOL *Udp4Read;
> - EFI_UDP4_PROTOCOL *Udp4Write;
> - UINT16 CurrentUdpSrcPort;
> - EFI_UDP4_CONFIG_DATA Udp4CfgData;
> -
> -
> - EFI_PXE_BASE_CODE_MODE Mode;
> - EFI_PXE_BASE_CODE_FUNCTION Function;
> -
> - CHAR8 *BootFileName;
> -
> - EFI_IP_ADDRESS StationIp;
> - EFI_IP_ADDRESS SubnetMask;
> - EFI_IP_ADDRESS GatewayIp;
> - EFI_IP_ADDRESS ServerIp;
> - BOOLEAN AddressIsOk;
> - UINT32 Ip4MaxPacketSize;
> - UINTN BlockSize;
> - UINTN FileSize;
> -
> - UINT8 OptionBuffer[PXEBC_DHCP4_MAX_OPTION_SIZE];
> - EFI_DHCP4_PACKET SeedPacket;
> - EFI_MAC_ADDRESS Mac;
> - UINT8 MacLen;
> -
> - BOOLEAN SortOffers;
> - BOOLEAN GotProxyOffer;
> - UINT32 NumOffers;
> - UINT32 SelectedOffer;
> - UINT32 ProxyOfferType;
> -
> - //
> - // Cached packets as complements of pxe mode data
> - //
> - PXEBC_CACHED_DHCP4_PACKET ProxyOffer;
> - PXEBC_CACHED_DHCP4_PACKET Dhcp4Ack;
> - PXEBC_CACHED_DHCP4_PACKET PxeReply;
> - PXEBC_CACHED_DHCP4_PACKET
> Dhcp4Offers[PXEBC_MAX_OFFER_NUM];
> -
> - //
> - // Arrays for different types of offers:
> - // ServerCount records the count of the servers we got the offers,
> - // OfferIndex records the index of the offer sent by the server indexed by
> ServerCount.
> - //
> - UINT32 ServerCount[DHCP4_PACKET_TYPE_MAX];
> - UINT32
> OfferIndex[DHCP4_PACKET_TYPE_MAX][PXEBC_MAX_OFFER_NUM];
> - UINT32 BootpIndex;
> - UINT32 ProxyIndex[DHCP4_PACKET_TYPE_MAX];
> - UINT32 BinlIndex[PXEBC_MAX_OFFER_NUM];
> -
> - EFI_EVENT GetArpCacheEvent;
> - //
> - // token and event used to get ICMP error data from IP
> - //
> - EFI_IP4_COMPLETION_TOKEN IcmpErrorRcvToken;
> -};
> -
> -#define PXEBC_PRIVATE_DATA_FROM_PXEBC(a) CR (a,
> PXEBC_PRIVATE_DATA, PxeBc, PXEBC_PRIVATE_DATA_SIGNATURE)
> -
> -#define PXEBC_PRIVATE_DATA_FROM_LOADFILE(a) CR (a,
> PXEBC_PRIVATE_DATA, LoadFile, PXEBC_PRIVATE_DATA_SIGNATURE)
> -
> -#define PXEBC_PRIVATE_DATA_FROM_PXEBCCALLBACK(a) CR (a,
> PXEBC_PRIVATE_DATA, PxeBcCallback, PXEBC_PRIVATE_DATA_SIGNATURE)
> -
> -extern EFI_PXE_BASE_CODE_PROTOCOL mPxeBcProtocolTemplate;
> -extern EFI_LOAD_FILE_PROTOCOL mLoadFileProtocolTemplate;
> -
> -/**
> - Causes the driver to load a specified file.
> -
> - @param This Protocol instance pointer.
> - @param FilePath The device specific path of the file to load.
> - @param BootPolicy If TRUE, indicates that the request originates from
> the
> - boot manager is attempting to load FilePath as a boot
> - selection. If FALSE, then FilePath must match as exact file
> - to be loaded.
> - @param BufferSize On input the size of Buffer in bytes. On output with
> a return
> - code of EFI_SUCCESS, the amount of data transferred to
> - Buffer. On output with a return code of
> EFI_BUFFER_TOO_SMALL,
> - the size of Buffer required to retrieve the requested file.
> - @param Buffer The memory buffer to transfer the file to. IF Buffer is
> NULL,
> - then no the size of the requested file is returned in
> - BufferSize.
> -
> - @retval EFI_SUCCESS The file was loaded.
> - @retval EFI_UNSUPPORTED The device does not support the provided
> BootPolicy
> - @retval EFI_INVALID_PARAMETER FilePath is not a valid device path, or
> - BufferSize is NULL.
> - @retval EFI_NO_MEDIA No medium was present to load the file.
> - @retval EFI_DEVICE_ERROR The file was not loaded due to a device
> error.
> - @retval EFI_NO_RESPONSE The remote system did not respond.
> - @retval EFI_NOT_FOUND The file was not found.
> - @retval EFI_ABORTED The file load process was manually cancelled.
> -
> -**/
> -EFI_STATUS
> -EFIAPI
> -EfiPxeLoadFile (
> - IN EFI_LOAD_FILE_PROTOCOL * This,
> - IN EFI_DEVICE_PATH_PROTOCOL * FilePath,
> - IN BOOLEAN BootPolicy,
> - IN OUT UINTN *BufferSize,
> - IN VOID *Buffer OPTIONAL
> - );
> -
> -#endif
> diff --git a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcMtftp.h
> b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcMtftp.h
> deleted file mode 100644
> index 903dd4fbb69a..000000000000
> --- a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcMtftp.h
> +++ /dev/null
> @@ -1,137 +0,0 @@
> -/** @file
> - Mtftp routines for PxeBc.
> -
> -Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
> -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
> -http://opensource.org/licenses/bsd-license.php
> -
> -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS
> OR IMPLIED.
> -
> -**/
> -
> -#ifndef __EFI_PXEBC_MTFTP_H__
> -#define __EFI_PXEBC_MTFTP_H__
> -
> -#define PXE_MTFTP_OPTION_BLKSIZE_INDEX 0
> -#define PXE_MTFTP_OPTION_TIMEOUT_INDEX 1
> -#define PXE_MTFTP_OPTION_TSIZE_INDEX 2
> -#define PXE_MTFTP_OPTION_MULTICAST_INDEX 3
> -#define PXE_MTFTP_OPTION_MAXIMUM_INDEX 4
> -
> -#define PXE_MTFTP_ERROR_STRING_LENGTH 127
> -#define PXE_MTFTP_OPTBUF_MAXNUM_INDEX 128
> -
> -
> -/**
> - This function is to get size of a file by Tftp.
> -
> - @param Private Pointer to PxeBc private data
> - @param Config Pointer to Mtftp configuration data
> - @param Filename Pointer to file name
> - @param BlockSize Pointer to block size
> - @param BufferSize Pointer to buffer size
> -
> - @retval EFI_SUCCESS Get the size of file success
> - @retval EFI_NOT_FOUND Parse the tftp ptions failed.
> - @retval EFI_DEVICE_ERROR The network device encountered an error during
> this operation.
> - @retval Other Has not get the size of the file.
> -
> -**/
> -EFI_STATUS
> -PxeBcTftpGetFileSize (
> - IN PXEBC_PRIVATE_DATA *Private,
> - IN EFI_MTFTP4_CONFIG_DATA *Config,
> - IN UINT8 *Filename,
> - IN UINTN *BlockSize,
> - IN OUT UINT64 *BufferSize
> - );
> -
> -
> -/**
> - This function is to get data of a file by Tftp.
> -
> - @param Private Pointer to PxeBc private data
> - @param Config Pointer to Mtftp configuration data
> - @param Filename Pointer to file name
> - @param BlockSize Pointer to block size
> - @param BufferPtr Pointer to buffer
> - @param BufferSize Pointer to buffer size
> - @param DontUseBuffer Indicate whether with a receive buffer
> -
> - @retval EFI_SUCCESS Read the data success from the special file.
> - @retval EFI_DEVICE_ERROR The network device encountered an error during
> this operation.
> - @retval other Read data from file failed.
> -
> -**/
> -EFI_STATUS
> -PxeBcTftpReadFile (
> - IN PXEBC_PRIVATE_DATA *Private,
> - IN EFI_MTFTP4_CONFIG_DATA *Config,
> - IN UINT8 *Filename,
> - IN UINTN *BlockSize,
> - IN UINT8 *BufferPtr,
> - IN OUT UINT64 *BufferSize,
> - IN BOOLEAN DontUseBuffer
> - );
> -
> -
> -/**
> - This function is put data of a file by Tftp.
> -
> - @param Private Pointer to PxeBc private data
> - @param Config Pointer to Mtftp configuration data
> - @param Filename Pointer to file name
> - @param Overwrite Indicate whether with overwrite attribute
> - @param BlockSize Pointer to block size
> - @param BufferPtr Pointer to buffer
> - @param BufferSize Pointer to buffer size
> -
> - @retval EFI_SUCCESS Write the data success into the special file.
> - @retval EFI_DEVICE_ERROR The network device encountered an error during
> this operation.
> - @retval other Write data into file failed.
> -
> -**/
> -EFI_STATUS
> -PxeBcTftpWriteFile (
> - IN PXEBC_PRIVATE_DATA *Private,
> - IN EFI_MTFTP4_CONFIG_DATA *Config,
> - IN UINT8 *Filename,
> - IN BOOLEAN Overwrite,
> - IN UINTN *BlockSize,
> - IN UINT8 *BufferPtr,
> - IN OUT UINT64 *BufferSize
> - );
> -
> -
> -/**
> - This function is to get data(file) from a directory(may be a server) by Tftp.
> -
> - @param Private Pointer to PxeBc private data.
> - @param Config Pointer to Mtftp configuration data.
> - @param Filename Pointer to file name.
> - @param BlockSize Pointer to block size.
> - @param BufferPtr Pointer to buffer.
> - @param BufferSize Pointer to buffer size.
> - @param DontUseBuffer Indicate whether with a receive buffer.
> -
> - @retval EFI_SUCCES Get the data from the file included in directory
> success.
> - @retval EFI_DEVICE_ERROR The network device encountered an error during
> this operation.
> - @retval other Operation failed.
> -
> -**/
> -EFI_STATUS
> -PxeBcTftpReadDirectory (
> - IN PXEBC_PRIVATE_DATA *Private,
> - IN EFI_MTFTP4_CONFIG_DATA *Config,
> - IN UINT8 *Filename,
> - IN UINTN *BlockSize,
> - IN UINT8 *BufferPtr,
> - IN OUT UINT64 *BufferSize,
> - IN BOOLEAN DontUseBuffer
> - );
> -
> -#endif
> -
> diff --git a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcSupport.h
> b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcSupport.h
> deleted file mode 100644
> index a28c9740c171..000000000000
> --- a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcSupport.h
> +++ /dev/null
> @@ -1,134 +0,0 @@
> -/** @file
> - Support routines for PxeBc.
> -Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
> -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
> -http://opensource.org/licenses/bsd-license.php
> -
> -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS
> OR IMPLIED.
> -
> -**/
> -
> -#ifndef __EFI_PXEBC_SUPPORT_H__
> -#define __EFI_PXEBC_SUPPORT_H__
> -
> -
> -/**
> - The common notify function associated with various PxeBc events.
> -
> - @param Event The event signaled.
> - @param Context The context.
> -
> -**/
> -VOID
> -EFIAPI
> -PxeBcCommonNotify (
> - IN EFI_EVENT Event,
> - IN VOID *Context
> - );
> -
> -
> -/**
> - This function initialize(or configure) the Udp4Write instance.
> -
> - @param Udp4 Pointer to the EFI_UDP4_PROTOCOL instance.
> - @param StationIp Pointer to the station ip address.
> - @param SubnetMask Pointer to the subnetmask of the station ip address.
> - @param Gateway Pointer to the gateway ip address.
> - @param SrcPort Pointer to the srouce port of the station.
> - @param Ttl The time to live field of the IP header.
> - @param ToS The type of service field of the IP header.
> -
> - @retval EFI_SUCCESS The configuration settings were set, changed, or
> reset successfully.
> - @retval EFI_NO_MAPPING When using a default address, configuration
> (DHCP, BOOTP,
> - RARP, etc.) is not finished yet.
> - @retval EFI_INVALID_PARAMETER One or more following conditions are
> TRUE:
> - @retval EFI_ALREADY_STARTED The EFI UDPv4 Protocol instance is already
> started/configured
> - and must be stopped/reset before it can be reconfigured.
> - @retval EFI_ACCESS_DENIED UdpConfigData. AllowDuplicatePort is FALSE
> - and UdpConfigData.StationPort is already used by
> - other instance.
> - @retval EFI_OUT_OF_RESOURCES The EFI UDPv4 Protocol driver cannot
> allocate memory for this
> - EFI UDPv4 Protocol instance.
> - @retval EFI_DEVICE_ERROR An unexpected network or system error
> occurred and this instance
> - was not opened.
> - @retval Others Please examine the function Udp4->Routes(Udp4,
> FALSE, &mZeroIp4Addr, &mZeroIp4Addr, Gateway) returns.
> -
> -**/
> -EFI_STATUS
> -PxeBcConfigureUdpWriteInstance (
> - IN EFI_UDP4_PROTOCOL *Udp4,
> - IN EFI_IPv4_ADDRESS *StationIp,
> - IN EFI_IPv4_ADDRESS *SubnetMask,
> - IN EFI_IPv4_ADDRESS *Gateway,
> - IN OUT UINT16 *SrcPort,
> - IN UINT8 Ttl,
> - IN UINT8 ToS
> - );
> -
> -
> -/**
> - This function is to display the IPv4 address.
> -
> - @param[in] Ip The pointer to the IPv4 address.
> -
> -**/
> -VOID
> -PxeBcShowIp4Addr (
> - IN EFI_IPv4_ADDRESS *Ip
> - );
> -
> -
> -/**
> - Convert number to ASCII value.
> -
> - @param Number Numeric value to convert to decimal ASCII value.
> - @param Buffer Buffer to place ASCII version of the Number.
> - @param Length Length of Buffer.
> -
> -**/
> -VOID
> -CvtNum (
> - IN UINTN Number,
> - IN UINT8 *Buffer,
> - IN UINTN Length
> - );
> -
> -
> -/**
> - Convert unsigned int number to decimal number.
> -
> - @param Number The unsigned int number will be converted.
> - @param Buffer Pointer to the buffer to store the decimal number after
> transform.
> - @param[in] BufferSize The maxsize of the buffer.
> -
> - @return the length of the number after transform.
> -
> -**/
> -UINTN
> -UtoA10 (
> - IN UINTN Number,
> - IN CHAR8 *Buffer,
> - IN UINTN BufferSize
> -
> - );
> -
> -
> -/**
> - Convert ASCII numeric string to a UINTN value.
> -
> - @param Buffer Pointer to the 8-byte unsigned int value.
> -
> - @return UINTN value of the ASCII string.
> -
> -**/
> -UINT64
> -AtoU64 (
> - IN UINT8 *Buffer
> - );
> -
> -
> -#endif
> -
> diff --git
> a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/UefiPxe4BcDxe.uni
> b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/UefiPxe4BcDxe.uni
> deleted file mode 100644
> index e97c3cadd973..000000000000
> --- a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/UefiPxe4BcDxe.uni
> +++ /dev/null
> @@ -1,25 +0,0 @@
> -// /** @file
> -// This module produces EFI Preboot Execution Environment (PXE) Base Code
> Protocol.
> -//
> -// This module produces EFI PXE Base Code Protocol upon EFI MMP Protocl and
> IPv4
> -// network stack, used to control PXE-compatible devices. It produces EFI Load
> File
> -// Protocol to provide one clean way to otain control from the boot manager if
> the
> -// boot patch is from the remote device.
> -//
> -// Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
> -//
> -// 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
> -// http://opensource.org/licenses/bsd-license.php
> -//
> -// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"
> BASIS,
> -// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER
> EXPRESS OR IMPLIED.
> -//
> -// **/
> -
> -
> -#string STR_MODULE_ABSTRACT #language en-US "Produces EFI
> Preboot Execution Environment (PXE) Base Code Protocol"
> -
> -#string STR_MODULE_DESCRIPTION #language en-US "This module
> produces EFI PXE Base Code Protocol upon the EFI MMP Protocol and the IPv4
> network stack, and is used to control PXE-compatible devices. It produces the
> EFI Load File Protocol to provide a clean method to obtain control from the
> boot manager if the boot patch is from the remote device."
> -
> diff --git
> a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/UefiPxe4BcDxeExtra.uni
> b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/UefiPxe4BcDxeExtra.uni
> deleted file mode 100644
> index 2c1bda1a8bd2..000000000000
> ---
> a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/UefiPxe4BcDxeExtra.uni
> +++ /dev/null
> @@ -1,20 +0,0 @@
> -// /** @file
> -// UefiPxe4BcDxe Localized Strings and Content
> -//
> -// Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR>
> -//
> -// 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
> -// http://opensource.org/licenses/bsd-license.php
> -//
> -// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"
> BASIS,
> -// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER
> EXPRESS OR IMPLIED.
> -//
> -// **/
> -
> -#string STR_PROPERTIES_MODULE_NAME
> -#language en-US
> -"UEFI PXE Base Code DXE Driver"
> -
> -
> diff --git a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/UefiPxeBcDxe.inf
> b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/UefiPxeBcDxe.inf
> deleted file mode 100644
> index 042401992945..000000000000
> --- a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/UefiPxeBcDxe.inf
> +++ /dev/null
> @@ -1,102 +0,0 @@
> -## @file
> -# This module produces EFI Preboot Execution Environment (PXE) Base Code
> Protocol.
> -#
> -# This module produces EFI PXE Base Code Protocol upon EFI MMP Protocl and
> IPv4
> -# network stack, used to control PXE-compatible devices. It produces EFI Load
> File
> -# Protocol to provide one clean way to otain control from the boot manager if
> the
> -# boot patch is from the remote device. This driver only supports IPv4 network
> stack.
> -#
> -# Notes:
> -# 1) This driver can't co-work with the UefiPxeBcDxe driver in NetworkPkg.
> -# 2) This driver might have some issues that have been fixed in the
> UefiPxeBcDxe
> -# driver in NetworkPkg.
> -# 3) This driver supports fewer features than the UefiPxeBcDxe driver in
> NetworkPkg
> -# (e.g. IPv6, MTFTP windowsize).
> -# 4) UefiPxeBcDxe driver in NetworkPkg is recommended for use instead of this
> one even
> -# though both of them can be used.
> -#
> -# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
> -# 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
> -# http://opensource.org/licenses/bsd-license.php
> -#
> -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"
> BASIS,
> -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER
> EXPRESS OR IMPLIED.
> -#
> -#
> -##
> -
> -
> -[Defines]
> - INF_VERSION = 0x00010005
> - BASE_NAME = UefiPxe4BcDxe
> - MODULE_UNI_FILE = UefiPxe4BcDxe.uni
> - FILE_GUID = 3B1DEAB5-C75D-442e-9238-8E2FFB62B0BB
> - MODULE_TYPE = UEFI_DRIVER
> - VERSION_STRING = 1.0
> - ENTRY_POINT = PxeBcDriverEntryPoint
> - UNLOAD_IMAGE = NetLibDefaultUnload
> -
> -#
> -# The following information is for reference only and not required by the build
> tools.
> -#
> -# VALID_ARCHITECTURES = IA32 X64
> -#
> -# DRIVER_BINDING = gPxeBcDriverBinding
> -# COMPONENT_NAME = gPxeBcComponentName
> -# COMPONENT_NAME2 = gPxeBcComponentName2
> -#
> -
> -[Sources]
> - PxeBcMtftp.c
> - PxeBcSupport.h
> - PxeBcSupport.c
> - PxeBcDriver.c
> - PxeBcDhcp.h
> - ComponentName.c
> - PxeBcImpl.c
> - PxeBcImpl.h
> - PxeBcDhcp.c
> - PxeBcMtftp.h
> - PxeBcDriver.h
> -
> -
> -[Packages]
> - MdePkg/MdePkg.dec
> - MdeModulePkg/MdeModulePkg.dec
> -
> -[LibraryClasses]
> - BaseLib
> - UefiLib
> - UefiBootServicesTableLib
> - UefiDriverEntryPoint
> - BaseMemoryLib
> - MemoryAllocationLib
> - DebugLib
> - NetLib
> - DpcLib
> - PcdLib
> -
> -[Protocols]
> - gEfiPxeBaseCodeCallbackProtocolGuid ## SOMETIMES_PRODUCES
> - gEfiPxeBaseCodeProtocolGuid ## BY_START
> - gEfiLoadFileProtocolGuid ## BY_START
> - gEfiNetworkInterfaceIdentifierProtocolGuid_31 ## SOMETIMES_CONSUMES
> - gEfiArpServiceBindingProtocolGuid ## TO_START
> - gEfiArpProtocolGuid ## TO_START
> - gEfiMtftp4ServiceBindingProtocolGuid ## TO_START
> - gEfiMtftp4ProtocolGuid ## TO_START
> - gEfiUdp4ServiceBindingProtocolGuid ## TO_START
> - gEfiUdp4ProtocolGuid ## TO_START
> - gEfiDhcp4ServiceBindingProtocolGuid ## TO_START
> - gEfiDhcp4ProtocolGuid ## TO_START
> - gEfiIp4ServiceBindingProtocolGuid ## TO_START
> - gEfiIp4ProtocolGuid ## TO_START
> - gEfiIp4Config2ProtocolGuid ## TO_START
> -
> -[Pcd]
> - gEfiMdeModulePkgTokenSpaceGuid.PcdTftpBlockSize ##
> SOMETIMES_CONSUMES
> -
> -[UserExtensions.TianoCore."ExtraFiles"]
> - UefiPxe4BcDxeExtra.uni
> --
> 2.19.1.windows.1
next prev parent reply other threads:[~2018-12-20 4:56 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-20 1:41 [PATCH v2 0/6] Delete TCP, PXE, iSCSI driver in MdeModulePkg Siyuan Fu
2018-12-20 1:41 ` [PATCH v2 1/6] MdeModulePkg: Delete Tcp4Dxe " Siyuan Fu
2018-12-20 2:09 ` Ni, Ruiyu
2018-12-20 4:59 ` Wang, Jian J
2018-12-20 1:41 ` [PATCH v2 2/6] NetworkPkg: Remove some clarification from TcpDxe.inf Siyuan Fu
2018-12-20 1:41 ` [PATCH v2 3/6] MdeModulePkg: Delete IScsiDxe in MdeModulePkg Siyuan Fu
2018-12-20 2:07 ` Ni, Ruiyu
2018-12-20 4:43 ` Wang, Jian J
2018-12-20 1:41 ` [PATCH v2 4/6] NetworkPkg: Remove some clarification from IScsiDxe.inf Siyuan Fu
2018-12-20 1:41 ` [PATCH v2 5/6] MdeModulePkg: Delete UefiPxeBcDxe in MdeModulePkg Siyuan Fu
2018-12-20 4:56 ` Wang, Jian J [this message]
2018-12-20 1:41 ` [PATCH v2 6/6] NetworkPkg: Remove some clarification from UefiPxeBcDxe.inf Siyuan Fu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=D827630B58408649ACB04F44C510003624ECE983@SHSMSX103.ccr.corp.intel.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox