From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.93; helo=mga11.intel.com; envelope-from=jian.j.wang@intel.com; receiver=edk2-devel@lists.01.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id B4524211A2D99 for ; Wed, 19 Dec 2018 20:56:28 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Dec 2018 20:56:27 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,375,1539673200"; d="scan'208";a="112008381" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by orsmga003.jf.intel.com with ESMTP; 19 Dec 2018 20:56:26 -0800 Received: from fmsmsx152.amr.corp.intel.com (10.18.125.5) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.408.0; Wed, 19 Dec 2018 20:56:26 -0800 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by FMSMSX152.amr.corp.intel.com (10.18.125.5) with Microsoft SMTP Server (TLS) id 14.3.408.0; Wed, 19 Dec 2018 20:56:24 -0800 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.59]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.222]) with mapi id 14.03.0415.000; Thu, 20 Dec 2018 12:56:22 +0800 From: "Wang, Jian J" To: "Fu, Siyuan" , "edk2-devel@lists.01.org" CC: "Wu, Hao A" , "Ni, Ruiyu" , "Zeng, Star" , "Wu, Jiaxin" Thread-Topic: [PATCH v2 5/6] MdeModulePkg: Delete UefiPxeBcDxe in MdeModulePkg. Thread-Index: AQHUmAUk+6IRGbkqkEen4Vjl8y09q6WHEG6Q Date: Thu, 20 Dec 2018 04:56:21 +0000 Message-ID: References: <20181220014110.20324-1-siyuan.fu@intel.com> <20181220014110.20324-6-siyuan.fu@intel.com> In-Reply-To: <20181220014110.20324-6-siyuan.fu@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMzcyMTBhMjQtY2E1Ni00NjAzLThiYzAtM2ZkMDYxNzA3NDNjIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoidFFUOFpOVFFyM1BTckFEemJRWk1JUW50MHdhN3hQdERSYlVtanBWZnNodm45SmJLMG5KeVkwQ2JWK3BVNWhJTyJ9 x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.400.15 dlp-reaction: request-justification,no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH v2 5/6] MdeModulePkg: Delete UefiPxeBcDxe in MdeModulePkg. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 Dec 2018 04:56:29 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Jian J Wang > -----Original Message----- > From: Fu, Siyuan > Sent: Thursday, December 20, 2018 9:41 AM > To: edk2-devel@lists.01.org > Cc: Wang, Jian J ; Wu, Hao A ; > Ni, Ruiyu ; Zeng, Star ; Wu, Jia= xin > > Subject: [PATCH v2 5/6] MdeModulePkg: Delete UefiPxeBcDxe in > MdeModulePkg. >=20 > REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1278 >=20 > 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. >=20 > People should use below NetworkPkg drivers instead: > NetworkPkg/UefiPxeBcDxe/UefiPxeBcDxe.inf > Which is actively maintained with more bug fixes and new feature support. >=20 > Cc: Jian J Wang > Cc: Hao Wu > Cc: Ruiyu Ni > Cc: Star Zeng > Cc: Jiaxin Wu > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Siyuan Fu > --- >=20 > Notes: > v2: > Break original patch to separate commits per module. >=20 > MdeModulePkg/Universal/Network/UefiPxeBcDxe/ComponentName.c | > 365 --- > MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDhcp.c | 199= 9 -- > ----------- > MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDriver.c | 66= 5 --- > -- > MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.c | 298= 9 -- > ------------------ > MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcMtftp.c | 45= 4 -- > - > MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcSupport.c | 22= 1 - > - > MdeModulePkg/MdeModulePkg.dsc | = 1 - > MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDhcp.h | 50= 2 -- > -- > MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDriver.h | 10= 2 - > MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.h | 18= 9 -- > MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcMtftp.h | 13= 7 - > MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcSupport.h | 13= 4 - > MdeModulePkg/Universal/Network/UefiPxeBcDxe/UefiPxe4BcDxe.uni | 2= 5 > - > MdeModulePkg/Universal/Network/UefiPxeBcDxe/UefiPxe4BcDxeExtra.uni | > 20 - > MdeModulePkg/Universal/Network/UefiPxeBcDxe/UefiPxeBcDxe.inf | 10= 2 > - > 15 files changed, 7905 deletions(-) >=20 > 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.
> -This program and the accompanying materials > -are licensed and made available under the terms and conditions of the BS= D > License > -which accompanies this distribution. The full text of the license may b= e 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 drive= r. > - > - 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 na= me 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 spe= cified > - 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 str= ing > - array indicating the language. This is t= he > - language of the driver name that the cal= ler is > - requesting, and it must match one of the > - languages specified in SupportedLanguage= s. The > - number of languages supported by a drive= r is up > - to the driver writer. Language is specif= ied > - in RFC 4646 or ISO 639-2 language code f= ormat. > - > - @param[out] DriverName A pointer to the Unicode string to retur= n. > - 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 specif= ied by > - This and the language specified by Langu= age 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 su= pport > - 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 contr= oller > - that is being managed by a driver. > - > - This function retrieves the user readable name of the controller speci= fied by > - ControllerHandle and ChildHandle in the form of a Unicode string. If t= he > - driver specified by This has a user readable name in the language spec= ified by > - Language, then a pointer to the controller name is returned in Control= lerName, > - and EFI_SUCCESS is returned. If the driver specified by This is not c= urrently > - managing the controller specified by ControllerHandle and ChildHandle, > - then EFI_UNSUPPORTED is returned. If the driver specified by This doe= s 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 driv= er > - specified by This is managing. This han= dle > - specifies the controller whose name is t= o be > - returned. > - > - @param[in] ChildHandle The handle of the child controller to re= trieve > - the name of. This is an optional parame= ter 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 bu= s > - controller. It will not be NULL for a b= us > - driver that wishes to retrieve the name = of a > - child controller. > - > - @param[in] Language A pointer to a Null-terminated ASCII str= ing > - array indicating the language. This is = the > - language of the driver name that the cal= ler is > - requesting, and it must match one of the > - languages specified in SupportedLanguage= s. The > - number of languages supported by a drive= r is up > - to the driver writer. Language is specif= ied in > - RFC 4646 or ISO 639-2 language code form= at. > - > - @param[out] ControllerName A pointer to the Unicode string to retur= n. > - 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 d= river > - specified by This. > - > - @retval EFI_SUCCESS The Unicode string for the user readable= name in > - the language specified by Language for t= he > - 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 curr= ently > - managing the controller specified by > - ControllerHandle and ChildHandle. > - > - @retval EFI_UNSUPPORTED The driver specified by This does not su= pport > - 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 =3D { > - PxeBcComponentNameGetDriverName, > - PxeBcComponentNameGetControllerName, > - "eng" > -}; > - > -GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL > gPxeBcComponentName2 =3D { > - (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) > PxeBcComponentNameGetDriverName, > - (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) > PxeBcComponentNameGetControllerName, > - "en" > -}; > - > -GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE > mPxeBcDriverNameTable[] =3D { > - { > - "eng;en", > - L"UEFI PXE Base Code Driver" > - }, > - { > - NULL, > - NULL > - } > -}; > - > -GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE > mPxeBcControllerNameTable[] =3D { > - { > - "eng;en", > - L"PXE Controller" > - }, > - { > - NULL, > - NULL > - } > -}; > - > -/** > - Retrieves a Unicode string that is the user readable name of the drive= r. > - > - 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 na= me 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 spe= cified > - 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 str= ing > - array indicating the language. This is t= he > - language of the driver name that the cal= ler is > - requesting, and it must match one of the > - languages specified in SupportedLanguage= s. The > - number of languages supported by a drive= r is up > - to the driver writer. Language is specif= ied > - in RFC 4646 or ISO 639-2 language code f= ormat. > - > - @param[out] DriverName A pointer to the Unicode string to retur= n. > - 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 specif= ied by > - This and the language specified by Langu= age 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 su= pport > - 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 =3D=3D &gPxeBcComponentName) > - ); > -} > - > -/** > - Retrieves a Unicode string that is the user readable name of the contr= oller > - that is being managed by a driver. > - > - This function retrieves the user readable name of the controller speci= fied by > - ControllerHandle and ChildHandle in the form of a Unicode string. If t= he > - driver specified by This has a user readable name in the language spec= ified by > - Language, then a pointer to the controller name is returned in Control= lerName, > - and EFI_SUCCESS is returned. If the driver specified by This is not c= urrently > - managing the controller specified by ControllerHandle and ChildHandle, > - then EFI_UNSUPPORTED is returned. If the driver specified by This doe= s 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 driv= er > - specified by This is managing. This han= dle > - specifies the controller whose name is t= o be > - returned. > - > - @param[in] ChildHandle The handle of the child controller to re= trieve > - the name of. This is an optional parame= ter 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 bu= s > - controller. It will not be NULL for a b= us > - driver that wishes to retrieve the name = of a > - child controller. > - > - @param[in] Language A pointer to a Null-terminated ASCII str= ing > - array indicating the language. This is = the > - language of the driver name that the cal= ler is > - requesting, and it must match one of the > - languages specified in SupportedLanguage= s. The > - number of languages supported by a drive= r is up > - to the driver writer. Language is specif= ied in > - RFC 4646 or ISO 639-2 language code form= at. > - > - @param[out] ControllerName A pointer to the Unicode string to retur= n. > - 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 d= river > - specified by This. > - > - @retval EFI_SUCCESS The Unicode string for the user readable= name in > - the language specified by Language for t= he > - 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 curr= ently > - managing the controller specified by > - ControllerHandle and ChildHandle. > - > - @retval EFI_UNSUPPORTED The driver specified by This does not su= pport > - 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 =3D=3D NULL || ChildHandle !=3D NULL) { > - return EFI_UNSUPPORTED; > - } > - > - NicHandle =3D NetLibGetNicHandle (ControllerHandle, &gEfiArpProtocolGu= id); > - if (NicHandle =3D=3D NULL) { > - NicHandle =3D NetLibGetNicHandle (ControllerHandle, > &gEfiDhcp4ProtocolGuid); > - > - if (NicHandle =3D=3D NULL) { > - NicHandle =3D NetLibGetNicHandle (ControllerHandle, &gEfiIp4Protoc= olGuid); > - > - if (NicHandle =3D=3D NULL) { > - NicHandle =3D NetLibGetNicHandle (ControllerHandle, > &gEfiUdp4ProtocolGuid); > - > - if (NicHandle =3D=3D NULL) { > - NicHandle =3D NetLibGetNicHandle (ControllerHandle, > &gEfiMtftp4ProtocolGuid); > - > - if (NicHandle =3D=3D NULL) { > - return EFI_UNSUPPORTED; > - } > - } > - } > - } > - } > - > - Status =3D 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 =3D=3D &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.
> -This program and the accompanying materials > -are licensed and made available under the terms and conditions of the BS= D > License > -which accompanies this distribution. The full text of the license may b= e 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] =3D { > - 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 =3D sizeof (EFI_DHCP4_PACKET); > - Seed->Length =3D sizeof (Seed->Dhcp4); > - > - Header =3D &Seed->Dhcp4.Header; > - > - ZeroMem (Header, sizeof (EFI_DHCP4_HEADER)); > - Header->OpCode =3D PXEBC_DHCP4_OPCODE_REQUEST; > - Header->HwType =3D Mode.IfType; > - Header->HwAddrLen =3D (UINT8) Mode.HwAddressSize; > - CopyMem (Header->ClientHwAddr, &Mode.CurrentAddress, Header- > >HwAddrLen); > - > - Seed->Dhcp4.Magik =3D PXEBC_DHCP4_MAGIC; > - Seed->Dhcp4.Option[0] =3D 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 =3D Src->Length; > - return EFI_SUCCESS; > -} > - > - > -/** > - Copy the dhcp4 packet to the PxeBc private data and parse the dhcp4 pa= cket. > - > - @param Private Pointer to PxeBc private data. > - @param OfferIndex Index of cached packets as complements of pxe mo= de > data, > - the index is maximum offer number. > - > - @retval EFI_SUCCESS Cache and parse the packet succ= essfully. > - @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 =3D Private->PxeBc.Mode; > - Offer =3D &Private->Dhcp4Offers[OfferIndex].Packet.Offer; > - > - Status =3D PxeBcCopyEfiDhcp4Packet (&Private->ProxyOffer.Packet.Offer, > Offer); > - if (EFI_ERROR(Status)) { > - return Status; > - } > - CopyMem (&Mode->ProxyOffer, &Offer->Dhcp4, Offer->Length); > - Mode->ProxyOfferReceived =3D 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 =3D FALSE; > - ZeroMem (CachedPacket->Dhcp4Option, sizeof (CachedPacket- > >Dhcp4Option)); > - ZeroMem (&CachedPacket->PxeVendorOption, sizeof (CachedPacket- > >PxeVendorOption)); > - > - Offer =3D &CachedPacket->Packet.Offer; > - Options =3D CachedPacket->Dhcp4Option; > - > - // > - // Parse interested dhcp options and store their pointers in CachedPac= ket- > >Dhcp4Option. > - // First, try to parse DHCPv4 options from the DHCP optional parameter= s field. > - // > - for (Index =3D 0; Index < PXEBC_DHCP4_TAG_INDEX_MAX; Index++) { > - Options[Index] =3D PxeBcParseExtendOptions ( > - Offer->Dhcp4.Option, > - GET_OPTION_BUFFER_LEN (Offer), > - mInterestedDhcp4Tags[Index] > - ); > - } > - // > - // Second, Check if bootfilename and serverhostname is overloaded to c= arry > DHCP options refers to rfc-2132. > - // If yes, try to parse options from the BootFileName field, then Serv= erName > field. > - // > - Option =3D Options[PXEBC_DHCP4_TAG_INDEX_OVERLOAD]; > - if (Option !=3D NULL) { > - if ((Option->Data[0] & PXEBC_DHCP4_OVERLOAD_FILE) !=3D 0) { > - for (Index =3D 0; Index < PXEBC_DHCP4_TAG_INDEX_MAX; Index++) { > - if (Options[Index] =3D=3D NULL) { > - Options[Index] =3D PxeBcParseExtendOptions ( > - (UINT8 *) Offer->Dhcp4.Header.BootFileName, > - sizeof (Offer->Dhcp4.Header.BootFileName), > - mInterestedDhcp4Tags[Index] > - ); > - } > - } > - } > - if ((Option->Data[0] & PXEBC_DHCP4_OVERLOAD_SERVER_NAME) !=3D 0) { > - for (Index =3D 0; Index < PXEBC_DHCP4_TAG_INDEX_MAX; Index++) { > - if (Options[Index] =3D=3D NULL) { > - Options[Index] =3D PxeBcParseExtendOptions ( > - (UINT8 *) Offer->Dhcp4.Header.ServerName, > - sizeof (Offer->Dhcp4.Header.ServerName), > - mInterestedDhcp4Tags[Index] > - ); > - } > - } > - } > - } > - > - // > - // Check whether is an offer with PXEClient or not. > - // > - Option =3D Options[PXEBC_DHCP4_TAG_INDEX_CLASS_ID]; > - if ((Option !=3D NULL) && (Option->Length >=3D 9) && > - (CompareMem (Option->Data, DEFAULT_CLASS_ID_DATA, 9) =3D=3D 0)) { > - > - CachedPacket->IsPxeOffer =3D TRUE; > - } > - > - // > - // Parse pxe vendor options and store their content/pointers in Cached= Packet- > >PxeVendorOption. > - // > - Option =3D Options[PXEBC_DHCP4_TAG_INDEX_VENDOR]; > - if (CachedPacket->IsPxeOffer && (Option !=3D 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 opti= on 67 > (bootfile name) if present. > - // Otherwise, read from boot file field in DHCP header. > - // > - if (Options[PXEBC_DHCP4_TAG_INDEX_BOOTFILE] !=3D NULL) { > - // > - // RFC 2132, Section 9.5 does not strictly state Bootfile name (opti= on 67) is > null > - // terminated string. So force to append null terminated character a= t the end > of string. > - // > - Ptr8 =3D (UINT8*)&Options[PXEBC_DHCP4_TAG_INDEX_BOOTFILE]->Data[0]; > - Ptr8 +=3D Options[PXEBC_DHCP4_TAG_INDEX_BOOTFILE]->Length; > - if (*(Ptr8 - 1) !=3D '\0') { > - *Ptr8 =3D '\0'; > - } > - } else if (Offer->Dhcp4.Header.BootFileName[0] !=3D 0) { > - // > - // If the bootfile is not present and bootfilename is present in dhc= p 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] =3D=3D NULL || > - (Options[PXEBC_DHCP4_TAG_INDEX_OVERLOAD]->Data[0] & > PXEBC_DHCP4_OVERLOAD_FILE) =3D=3D 0) { > - Options[PXEBC_DHCP4_TAG_INDEX_BOOTFILE] =3D > (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 =3D Options[PXEBC_DHCP4_TAG_INDEX_MSG_TYPE]; > - if ((Option =3D=3D NULL) || (Option->Data[0] =3D=3D 0)) { > - // > - // It's a bootp offer > - // > - Option =3D CachedPacket- > >Dhcp4Option[PXEBC_DHCP4_TAG_INDEX_BOOTFILE]; > - if (Option =3D=3D NULL) { > - // > - // bootp offer without bootfilename, discard it. > - // > - return FALSE; > - } > - > - OfferType =3D 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 =3D 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 =3D (UINT8) ((CachedPacket->IsPxeOffer) ? > DHCP4_PACKET_TYPE_BINL : DHCP4_PACKET_TYPE_DHCP_ONLY); > - } > - } > - > - CachedPacket->OfferType =3D 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 d= ata, > - 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 sp= ecified. > - > -**/ > -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 =3D=3D > DHCP4_PACKET_TYPE_BINL); > - > - Offer =3D &Private->Dhcp4Offers[Index].Packet.Offer; > - > - // > - // Use siaddr(next server) in DHCPOFFER packet header, if zero, use op= tion > 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] =3D=3D 0) { > - return FALSE; > - } > - > - CachedPacket =3D &Private->ProxyOffer; > - Reply =3D &CachedPacket->Packet.Offer; > - > - Status =3D PxeBcDiscvBootService ( > - Private, > - 0, > - NULL, > - FALSE, > - &ServerIp, > - 0, > - NULL, > - FALSE, > - Reply > - ); > - if (EFI_ERROR (Status)) { > - return FALSE; > - } > - > - if (!PxeBcParseCachedDhcpPacket (CachedPacket)) { > - return FALSE; > - } > - > - if ((CachedPacket->OfferType !=3D DHCP4_PACKET_TYPE_PXE10) && > - (CachedPacket->Dhcp4Option[PXEBC_DHCP4_TAG_INDEX_BOOTFILE] =3D=3D > NULL)) { > - // > - // This BINL ack doesn't have discovery options set or bootfile name > - // specified. > - // > - return FALSE; > - } > - > - Private->PxeBc.Mode->ProxyOfferReceived =3D 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 compleme= nts > of > - pxe mode data, the index is maximum offer number. > - > - @return If there is no service needed offer return FALSE, otherwise TR= UE. > - > -**/ > -BOOLEAN > -PxeBcTryBinlProxy ( > - IN PXEBC_PRIVATE_DATA *Private, > - OUT UINT32 *OfferIndex > - ) > -{ > - UINT32 Index; > - > - for (Index =3D 0; Index < Private->ProxyIndex[DHCP4_PACKET_TYPE_BINL]; > Index++) { > - > - *OfferIndex =3D 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 Px= e > 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 ba= se > 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 !=3D 0); > - > - Status =3D EFI_SUCCESS; > - SelectedOffer =3D &Private->Dhcp4Offers[Private->SelectedOffer - 1]; > - Options =3D SelectedOffer->Dhcp4Option; > - > - if (SelectedOffer->OfferType =3D=3D DHCP4_PACKET_TYPE_BINL) { > - // > - // The addresses are acquired from a BINL dhcp offer, try BINL to ge= t > - // the bootfile name > - // > - if (!PxeBcTryBinl (Private, Private->SelectedOffer - 1)) { > - Status =3D EFI_NO_RESPONSE; > - } > - } else if (SelectedOffer->OfferType =3D=3D DHCP4_PACKET_TYPE_DHCP_ONLY= ) { > - // > - // The selected offer to finish the D.O.R.A. is a DHCP only offer, w= e need > - // try proxy offers if there are some, othewise the bootfile name mu= st be > - // set in this DHCP only offer. > - // > - if (Private->GotProxyOffer) { > - // > - // Get rid of the compiler warning. > - // > - ProxyOfferIndex =3D 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 =3D=3D DHCP4_PACKET_TYPE_BINL) { > - // > - // We buffer all received BINL proxy offers, try them all one = by one > - // > - if (!PxeBcTryBinlProxy (Private, &ProxyOfferIndex)) { > - Status =3D EFI_NO_RESPONSE; > - } > - } else { > - // > - // For other types, only one proxy offer is buffered. > - // > - ProxyOfferIndex =3D Private->ProxyIndex[Private->ProxyOfferTyp= e] - 1; > - } > - } else { > - // > - // The proxy offer type is not determined, choose proxy offer in= the > - // received order. > - // > - Status =3D EFI_NO_RESPONSE; > - > - ASSERT (Private->NumOffers < PXEBC_MAX_OFFER_NUM); > - for (Index =3D 0; Index < Private->NumOffers; Index++) { > - > - Offer =3D &Private->Dhcp4Offers[Index].Packet.Offer; > - if (!IS_PROXY_DHCP_OFFER (Offer)) { > - // > - // Skip non proxy dhcp offers. > - // > - continue; > - } > - > - if (Private->Dhcp4Offers[Index].OfferType =3D=3D DHCP4_PACKET_= TYPE_BINL) > { > - // > - // Try BINL > - // > - if (!PxeBcTryBinl (Private, Index)) { > - // > - // Failed, skip to the next offer > - // > - continue; > - } > - } > - > - Private->ProxyOfferType =3D Private->Dhcp4Offers[Index].OfferT= ype; > - ProxyOfferIndex =3D Index; > - Status =3D EFI_SUCCESS; > - break; > - } > - } > - > - if (!EFI_ERROR (Status) && (Private->ProxyOfferType !=3D > DHCP4_PACKET_TYPE_BINL)) { > - // > - // Copy the proxy offer to Mode and set the flag > - // > - Status =3D PxeBcCopyProxyOffer (Private, ProxyOfferIndex); > - } > - } else { > - // > - // No proxy offer is received, the bootfile name MUST be set. > - // > - ASSERT (Options[PXEBC_DHCP4_TAG_INDEX_BOOTFILE] !=3D NULL); > - } > - } > - > - if (!EFI_ERROR (Status)) { > - // > - // Everything is OK, set the flag and copy the DHCP packets. > - // > - Mode =3D Private->PxeBc.Mode; > - Offer =3D &SelectedOffer->Packet.Offer; > - > - // > - // The discover packet is already copied, just set flag here. > - // > - Mode->DhcpDiscoverValid =3D TRUE; > - > - Ack =3D &Private->Dhcp4Ack.Packet.Ack; > - if (SelectedOffer->OfferType =3D=3D DHCP4_PACKET_TYPE_BOOTP) { > - // > - // Other type of ACK is already cached. Bootp is special that we s= hould > - // use the bootp reply as the ACK and put it into the DHCP_ONLY bu= ffer. > - // > - Status =3D PxeBcCopyEfiDhcp4Packet (&Private->Dhcp4Ack.Packet.Ack,= Offer); > - } > - > - PxeBcParseCachedDhcpPacket (&Private->Dhcp4Ack); > - > - Mode->DhcpAckReceived =3D 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 pa= cket. > - > - @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 =3D &Private->Dhcp4Offers[Private->NumOffers]; > - Offer =3D &CachedOffer->Packet.Offer; > - > - // > - // Cache the orignal dhcp packet > - // > - Status =3D PxeBcCopyEfiDhcp4Packet (Offer, RcvdOffer); > - if (EFI_ERROR(Status)) { > - return Status; > - } > - > - // > - // Parse and validate the options (including dhcp option and vendor op= tion) > - // > - if (!PxeBcParseCachedDhcpPacket (CachedOffer)) { > - return EFI_ABORTED; > - } > - > - OfferType =3D CachedOffer->OfferType; > - if (OfferType >=3D DHCP4_PACKET_TYPE_MAX) { > - return EFI_ABORTED; > - } > - > - if (OfferType =3D=3D DHCP4_PACKET_TYPE_BOOTP) { > - > - if (Private->BootpIndex !=3D 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 =3D 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 =3D TRUE; > - > - if (OfferType =3D=3D DHCP4_PACKET_TYPE_BINL) { > - // > - // Cache all binl offers. > - // > - Private->BinlIndex[Private->ProxyIndex[DHCP4_PACKET_TYPE_BINL]] = =3D > Private->NumOffers; > - Private->ProxyIndex[DHCP4_PACKET_TYPE_BINL]++; > - } else if (Private->ProxyIndex[OfferType] !=3D 0) { > - // > - // Only cache the first pxe10/wfm11a offers each, discard the ot= hers. > - // > - return EFI_ABORTED; > - } else { > - // > - // Record index of the proxy dhcp offer with type other than bin= l. > - // > - Private->ProxyIndex[OfferType] =3D 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]] = =3D > 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 st= atic. > - @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 =3D Private->Ip4Config2; > - DataSize =3D sizeof (EFI_IP4_CONFIG2_POLICY); > - Status =3D Ip4Config2->GetData ( > - Ip4Config2, > - Ip4Config2DataTypePolicy, > - &DataSize, > - &Policy > - ); > - if (EFI_ERROR (Status)) { > - return Status; > - } > - > - if (Policy !=3D Ip4Config2PolicyStatic) { > - Policy =3D Ip4Config2PolicyStatic; > - Status=3D 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 =3D 0; > - > - if (Private->SortOffers) { > - // > - // Select offer according to the priority > - // > - if (Private->ServerCount[DHCP4_PACKET_TYPE_PXE10] > 0) { > - // > - // DHCP with PXE10 > - // > - Private->SelectedOffer =3D Private- > >OfferIndex[DHCP4_PACKET_TYPE_PXE10][0] + 1; > - > - } else if (Private->ServerCount[DHCP4_PACKET_TYPE_WFM11A] > 0) { > - // > - // DHCP with WfM > - // > - Private->SelectedOffer =3D 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 =3D Private- > >OfferIndex[DHCP4_PACKET_TYPE_DHCP_ONLY][0] + 1; > - Private->ProxyOfferType =3D 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 =3D Private- > >OfferIndex[DHCP4_PACKET_TYPE_DHCP_ONLY][0] + 1; > - Private->ProxyOfferType =3D DHCP4_PACKET_TYPE_WFM11A; > - > - } else if (Private->ServerCount[DHCP4_PACKET_TYPE_BINL] > 0) { > - // > - // DHCP with BINL > - // > - Private->SelectedOffer =3D 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 =3D Private- > >OfferIndex[DHCP4_PACKET_TYPE_DHCP_ONLY][0] + 1; > - Private->ProxyOfferType =3D DHCP4_PACKET_TYPE_BINL; > - > - } else { > - // > - // Try offers with bootfile > - // > - for (Index =3D 0; Index < Private- > >ServerCount[DHCP4_PACKET_TYPE_DHCP_ONLY]; Index++) { > - // > - // Select the first DHCP only offer with bootfile > - // > - OfferIndex =3D Private- > >OfferIndex[DHCP4_PACKET_TYPE_DHCP_ONLY][Index]; > - if (Private- > >Dhcp4Offers[OfferIndex].Dhcp4Option[PXEBC_DHCP4_TAG_INDEX_BOOTFILE] > !=3D NULL) { > - Private->SelectedOffer =3D OfferIndex + 1; > - break; > - } > - } > - > - if (Private->SelectedOffer =3D=3D 0) { > - // > - // Select the Bootp reply with bootfile if any > - // > - Private->SelectedOffer =3D Private->BootpIndex; > - } > - } > - } else { > - // > - // Try the offers in the received order. > - // > - for (Index =3D 0; Index < Private->NumOffers; Index++) { > - > - Offer =3D &Private->Dhcp4Offers[Index].Packet.Offer; > - > - if (IS_PROXY_DHCP_OFFER (Offer)) { > - // > - // Skip proxy offers > - // > - continue; > - } > - > - if ((Private->Dhcp4Offers[Index].OfferType =3D=3D > DHCP4_PACKET_TYPE_DHCP_ONLY) && > - ((!Private->GotProxyOffer) && (Private- > >Dhcp4Offers[Index].Dhcp4Option[PXEBC_DHCP4_TAG_INDEX_BOOTFILE] =3D=3D > NULL))) { > - // > - // DHCP only offer but no proxy offer received and no bootfile o= ption in > this offer > - // > - continue; > - } > - > - Private->SelectedOffer =3D 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 s= tructure > - provides advanced control of each state transition of the DHCP process= . The > - returned status code determines the behavior of the EFI DHCPv4 Protoco= l > driver. > - There are three possible returned values, which are described in the f= ollowing > - table. > - > - @param This Pointer to the EFI DHCPv4 Protocol insta= nce that is > used to > - configure this callback function. > - @param Context Pointer to the context that is initializ= ed 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 sta= te, 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 a= bove > 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. T= he EFI > DHCPv4 Protocol > - driver will continue to wait for more DH= CPOFFER 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 Dhcp4InitRebo= ot 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 !=3D Dhcp4RcvdOffer) && > - (Dhcp4Event !=3D Dhcp4SelectOffer) && > - (Dhcp4Event !=3D Dhcp4SendDiscover) && > - (Dhcp4Event !=3D Dhcp4RcvdAck) && > - (Dhcp4Event !=3D Dhcp4SendRequest)) { > - return EFI_SUCCESS; > - } > - > - Private =3D (PXEBC_PRIVATE_DATA *) Context; > - Mode =3D Private->PxeBc.Mode; > - Callback =3D Private->PxeBcCallback; > - > - // > - // Override the Maximum DHCP Message Size. > - // > - MaxMsgSize =3D PxeBcParseExtendOptions ( > - Packet->Dhcp4.Option, > - GET_OPTION_BUFFER_LEN (Packet), > - DHCP4_TAG_MAXMSG > - ); > - if (MaxMsgSize !=3D NULL) { > - Value =3D HTONS (PXEBC_DHCP4_MAX_PACKET_SIZE); > - CopyMem (MaxMsgSize->Data, &Value, sizeof (Value)); > - } > - > - if ((Dhcp4Event !=3D Dhcp4SelectOffer) && (Callback !=3D NULL)) { > - Received =3D (BOOLEAN) ((Dhcp4Event =3D=3D Dhcp4RcvdOffer) || (Dhcp4= Event =3D=3D > Dhcp4RcvdAck)); > - Status =3D Callback->Callback ( > - Callback, > - Private->Function, > - Received, > - Packet->Length, > - (EFI_PXE_BASE_CODE_PACKET *) &Packet->Dhcp4 > - ); > - if (Status !=3D EFI_PXE_BASE_CODE_CALLBACK_STATUS_CONTINUE) { > - return EFI_ABORTED; > - } > - } > - > - Status =3D 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 =3D 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 =3D &Packet->Dhcp4.Header; > - > - if (EFI_ERROR (NetLibGetSystemGuid ((EFI_GUID *) DhcpHeader- > >ClientHwAddr))) { > - // > - // GUID not yet set - send all 0xff's to show programable (via S= etVariable) > - // 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 sm= bios > table!\n")); > - ZeroMem (DhcpHeader->ClientHwAddr, sizeof (EFI_GUID)); > - } > - > - DhcpHeader->HwAddrLen =3D (UINT8) sizeof (EFI_GUID); > - } > - > - if (Dhcp4Event =3D=3D 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 =3D 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 =3D=3D 0) { > - Status =3D EFI_ABORTED; > - } else { > - *NewPacket =3D &Private->Dhcp4Offers[Private->SelectedOffer - > 1].Packet.Offer; > - } > - > - break; > - > - case Dhcp4RcvdAck: > - // > - // Cache Ack > - // > - ASSERT (Private->SelectedOffer !=3D 0); > - > - Status =3D PxeBcCopyEfiDhcp4Packet (&Private->Dhcp4Ack.Packet.Ack, P= acket); > - 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 =3D 0; > - OptList[0] =3D (EFI_DHCP4_PACKET_OPTION *) Private->OptionBuffer; > - > - if (!IsDhcpDiscover) { > - // > - // Append message type. > - // > - OptList[Index]->OpCode =3D DHCP4_TAG_MSG_TYPE; > - OptList[Index]->Length =3D 1; > - OptEnt.Mesg =3D (PXEBC_DHCP4_OPTION_MESG *) OptList[Inde= x]- > >Data; > - OptEnt.Mesg->Type =3D PXEBC_DHCP4_MSG_TYPE_REQUEST; > - Index++; > - OptList[Index] =3D GET_NEXT_DHCP_OPTION (OptList[Index - 1]= ); > - > - // > - // Append max message size. > - // > - OptList[Index]->OpCode =3D DHCP4_TAG_MAXMSG; > - OptList[Index]->Length =3D (UINT8) sizeof > (PXEBC_DHCP4_OPTION_MAX_MESG_SIZE); > - OptEnt.MaxMesgSize =3D (PXEBC_DHCP4_OPTION_MAX_MESG_SIZE *) > OptList[Index]->Data; > - Value =3D NTOHS (PXEBC_DHCP4_MAX_PACKET_SIZE); > - CopyMem (&OptEnt.MaxMesgSize->Size, &Value, sizeof (UINT16)); > - Index++; > - OptList[Index] =3D GET_NEXT_DHCP_OPTION (OptList[Index - 1]= ); > - } > - // > - // Parameter request list option. > - // > - OptList[Index]->OpCode =3D DHCP4_TAG_PARA_LIST; > - OptList[Index]->Length =3D 35; > - OptEnt.Para =3D (PXEBC_DHCP4_OPTION_PARA *) OptList[Inde= x]->Data; > - OptEnt.Para->ParaList[0] =3D DHCP4_TAG_NETMASK; > - OptEnt.Para->ParaList[1] =3D DHCP4_TAG_TIME_OFFSET; > - OptEnt.Para->ParaList[2] =3D DHCP4_TAG_ROUTER; > - OptEnt.Para->ParaList[3] =3D DHCP4_TAG_TIME_SERVER; > - OptEnt.Para->ParaList[4] =3D DHCP4_TAG_NAME_SERVER; > - OptEnt.Para->ParaList[5] =3D DHCP4_TAG_DNS_SERVER; > - OptEnt.Para->ParaList[6] =3D DHCP4_TAG_HOSTNAME; > - OptEnt.Para->ParaList[7] =3D DHCP4_TAG_BOOTFILE_LEN; > - OptEnt.Para->ParaList[8] =3D DHCP4_TAG_DOMAINNAME; > - OptEnt.Para->ParaList[9] =3D DHCP4_TAG_ROOTPATH; > - OptEnt.Para->ParaList[10] =3D DHCP4_TAG_EXTEND_PATH; > - OptEnt.Para->ParaList[11] =3D DHCP4_TAG_EMTU; > - OptEnt.Para->ParaList[12] =3D DHCP4_TAG_TTL; > - OptEnt.Para->ParaList[13] =3D DHCP4_TAG_BROADCAST; > - OptEnt.Para->ParaList[14] =3D DHCP4_TAG_NIS_DOMAIN; > - OptEnt.Para->ParaList[15] =3D DHCP4_TAG_NIS_SERVER; > - OptEnt.Para->ParaList[16] =3D DHCP4_TAG_NTP_SERVER; > - OptEnt.Para->ParaList[17] =3D DHCP4_TAG_VENDOR; > - OptEnt.Para->ParaList[18] =3D DHCP4_TAG_REQUEST_IP; > - OptEnt.Para->ParaList[19] =3D DHCP4_TAG_LEASE; > - OptEnt.Para->ParaList[20] =3D DHCP4_TAG_SERVER_ID; > - OptEnt.Para->ParaList[21] =3D DHCP4_TAG_T1; > - OptEnt.Para->ParaList[22] =3D DHCP4_TAG_T2; > - OptEnt.Para->ParaList[23] =3D DHCP4_TAG_VENDOR_CLASS_ID; > - OptEnt.Para->ParaList[24] =3D DHCP4_TAG_TFTP; > - OptEnt.Para->ParaList[25] =3D DHCP4_TAG_BOOTFILE; > - OptEnt.Para->ParaList[26] =3D DHCP4_TAG_UUID; > - OptEnt.Para->ParaList[27] =3D 0x80; > - OptEnt.Para->ParaList[28] =3D 0x81; > - OptEnt.Para->ParaList[29] =3D 0x82; > - OptEnt.Para->ParaList[30] =3D 0x83; > - OptEnt.Para->ParaList[31] =3D 0x84; > - OptEnt.Para->ParaList[32] =3D 0x85; > - OptEnt.Para->ParaList[33] =3D 0x86; > - OptEnt.Para->ParaList[34] =3D 0x87; > - Index++; > - OptList[Index] =3D GET_NEXT_DHCP_OPTION (OptList[Index - 1]= ); > - > - // > - // Append UUID/Guid-based client identifier option > - // > - OptList[Index]->OpCode =3D DHCP4_TAG_UUID; > - OptList[Index]->Length =3D (UINT8) sizeof (PXEBC_DHCP4_OPTION_UUID); > - OptEnt.Uuid =3D (PXEBC_DHCP4_OPTION_UUID *) OptList[Index]= ->Data; > - OptEnt.Uuid->Type =3D 0; > - Index++; > - OptList[Index] =3D 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 SetVa= riable) > - // 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 =3D DHCP4_TAG_UNDI; > - OptList[Index]->Length =3D (UINT8) sizeof (PXEBC_DHCP4_OPTION_UNDI); > - OptEnt.Undi =3D (PXEBC_DHCP4_OPTION_UNDI *) OptList[Index]= ->Data; > - if (Private->Nii !=3D NULL) { > - OptEnt.Undi->Type =3D Private->Nii->Type; > - OptEnt.Undi->MajorVer =3D Private->Nii->MajorVer; > - OptEnt.Undi->MinorVer =3D Private->Nii->MinorVer; > - } else { > - OptEnt.Undi->Type =3D DEFAULT_UNDI_TYPE; > - OptEnt.Undi->MajorVer =3D DEFAULT_UNDI_MAJOR; > - OptEnt.Undi->MinorVer =3D DEFAULT_UNDI_MINOR; > - } > - > - Index++; > - OptList[Index] =3D GET_NEXT_DHCP_OPTION (OptList[Index - 1]); > - > - // > - // Append client system architecture option > - // > - OptList[Index]->OpCode =3D DHCP4_TAG_ARCH; > - OptList[Index]->Length =3D (UINT8) sizeof (PXEBC_DHCP4_OPTION_ARCH); > - OptEnt.Arch =3D (PXEBC_DHCP4_OPTION_ARCH *) OptList[Index]= ->Data; > - Value =3D HTONS (EFI_PXE_CLIENT_SYSTEM_ARCHITECTURE)= ; > - CopyMem (&OptEnt.Arch->Type, &Value, sizeof (UINT16)); > - Index++; > - OptList[Index] =3D GET_NEXT_DHCP_OPTION (OptList[Index - 1]); > - > - // > - // Append client system architecture option > - // > - OptList[Index]->OpCode =3D DHCP4_TAG_VENDOR_CLASS_ID; > - OptList[Index]->Length =3D (UINT8) sizeof (PXEBC_DHCP4_OPTION_CLID); > - OptEnt.Clid =3D (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 !=3D 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 exist= s. > - > - @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 =3D Private->PxeBc.Mode; > - Dhcp4 =3D Private->Dhcp4; > - Status =3D EFI_SUCCESS; > - > - ZeroMem (&Token, sizeof (EFI_DHCP4_TRANSMIT_RECEIVE_TOKEN)); > - > - if (DestIp =3D=3D NULL) { > - Sport =3D PXEBC_DHCP4_S_PORT; > - IsBCast =3D TRUE; > - } else { > - Sport =3D PXEBC_BS_DISCOVER_PORT; > - IsBCast =3D FALSE; > - } > - > - if (!UseBis && Layer !=3D NULL) { > - *Layer &=3D EFI_PXE_BASE_CODE_BOOT_LAYER_MASK; > - } > - > - OptCount =3D PxeBcBuildDhcpOptions (Private, OptList, FALSE); > - > - if (IsDiscv) { > - ASSERT (Layer !=3D NULL); > - // > - // Add vendor option of PXE_BOOT_ITEM > - // > - VendorOptLen =3D (UINT8) ((sizeof (EFI_DHCP4_PACKET_OPTION) - 1) * 2= + > sizeof (PXEBC_OPTION_BOOT_ITEM) + 1); > - OptList[OptCount] =3D AllocatePool (VendorOptLen); > - if (OptList[OptCount] =3D=3D NULL) { > - return EFI_OUT_OF_RESOURCES; > - } > - > - OptList[OptCount]->OpCode =3D DHCP4_TAG_VENDOR; > - OptList[OptCount]->Length =3D (UINT8) (VendorOptLen - 2); > - PxeOpt =3D (EFI_DHCP4_PACKET_OPTION *) OptLis= t[OptCount]- > >Data; > - PxeOpt->OpCode =3D PXEBC_VENDOR_TAG_BOOT_ITEM; > - PxeOpt->Length =3D (UINT8) sizeof (PXEBC_OPTION_BOOT_= ITEM); > - PxeBootItem =3D (PXEBC_OPTION_BOOT_ITEM *) PxeOpt-= >Data; > - PxeBootItem->Type =3D HTONS (Type); > - PxeBootItem->Layer =3D HTONS (*Layer); > - PxeOpt->Data[PxeOpt->Length] =3D DHCP4_TAG_EOP; > - > - OptCount++; > - } > - > - Status =3D Dhcp4->Build (Dhcp4, &Private->SeedPacket, 0, NULL, OptCoun= t, > OptList, &Token.Packet); > - > - if (IsDiscv) { > - FreePool (OptList[OptCount - 1]); > - } > - > - if (EFI_ERROR (Status)) { > - return Status; > - } > - > - DhcpHeader =3D &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 smbi= os > table!\n")); > - ZeroMem (DhcpHeader->ClientHwAddr, sizeof (EFI_GUID)); > - } > - > - DhcpHeader->HwAddrLen =3D (UINT8) sizeof (EFI_GUID); > - } > - > - Xid =3D NET_RANDOM (NetRandomInitSeed = ()); > - Token.Packet->Dhcp4.Header.Xid =3D HTONL(Xid); > - Token.Packet->Dhcp4.Header.Reserved =3D HTONS((UINT16) ((IsBCast) ? > 0x8000 : 0)); > - CopyMem (&Token.Packet->Dhcp4.Header.ClientAddr, &Private->StationIp, > sizeof (EFI_IPv4_ADDRESS)); > - > - Token.RemotePort =3D 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 =3D 1; > - Token.ListenPoints =3D &ListenPoint; > - Token.ListenPoints[0].ListenPort =3D 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 =3D 1; TryIndex <=3D PXEBC_BOOT_REQUEST_RETRIES; TryInde= x++) { > - > - Token.TimeoutValue =3D (UINT16) > (PXEBC_BOOT_REQUEST_TIMEOUT * TryIndex); > - Token.Packet->Dhcp4.Header.Seconds =3D (UINT16) > (PXEBC_BOOT_REQUEST_TIMEOUT * (TryIndex - 1)); > - > - Status =3D Dhcp4->TransmitReceive (Dhcp4, &Token); > - > - if (Token.Status !=3D EFI_TIMEOUT) { > - break; > - } > - } > - > - if (TryIndex > PXEBC_BOOT_REQUEST_RETRIES) { > - // > - // No server response our PXE request > - // > - Status =3D EFI_TIMEOUT; > - } > - > - if (!EFI_ERROR (Status)) { > - // > - // Find Pxe Reply > - // > - RepIndex =3D 0; > - SrvIndex =3D 0; > - Response =3D Token.ResponseList; > - > - while (RepIndex < Token.ResponseCount) { > - if (Response->Length > PXEBC_DHCP4_MAX_PACKET_SIZE) { > - SrvIndex =3D 0; > - RepIndex++; > - Response =3D (EFI_DHCP4_PACKET *) ((UINT8 *) Response + Response= ->Size); > - continue; > - } > - > - while (SrvIndex < IpCount) { > - > - if (SrvList[SrvIndex].AcceptAnyResponse) { > - break; > - } > - > - if ((SrvList[SrvIndex].Type =3D=3D Type) && EFI_IP4_EQUAL (&(Res= ponse- > >Dhcp4.Header.ServerAddr), &(Private->ServerIp))) { > - break; > - } > - > - SrvIndex++; > - } > - > - if ((IpCount !=3D SrvIndex) || (IpCount =3D=3D 0)) { > - break; > - } > - > - SrvIndex =3D 0; > - RepIndex++; > - Response =3D (EFI_DHCP4_PACKET *) ((UINT8 *) Response + Response->= Size); > - } > - > - if (RepIndex < Token.ResponseCount) { > - > - if (Reply !=3D NULL) { > - Status =3D PxeBcCopyEfiDhcp4Packet (Reply, Response); > - if (EFI_ERROR(Status)) { > - goto ON_EXIT; > - } > - } > - > - if (IsDiscv) { > - CopyMem (&(Mode->PxeDiscover), &(Token.Packet->Dhcp4), > Token.Packet->Length); > - Mode->PxeDiscoverValid =3D TRUE; > - > - CopyMem (Mode->PxeReply.Raw, &Response->Dhcp4, Response->Length)= ; > - Mode->PxeReplyReceived =3D TRUE; > - } > - } else { > - Status =3D EFI_NOT_FOUND; > - } > - } > - > -ON_EXIT: > - // > - // free the responselist > - // > - if (Token.ResponseList !=3D NULL) { > - FreePool (Token.ResponseList); > - } > - // > - // Free the dhcp packet > - // > - if (Token.Packet !=3D 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 =3D (EFI_DHCP4_PACKET_OPTION *) Buffer; > - Offset =3D 0; > - > - while (Offset < Length && Option->OpCode !=3D DHCP4_TAG_EOP) { > - > - if (Option->OpCode =3D=3D OptTag) { > - > - return Option; > - } > - > - if (Option->OpCode =3D=3D DHCP4_TAG_PAD) { > - Offset++; > - } else { > - Offset +=3D Option->Length + 2; > - } > - > - Option =3D (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 =3D VendorOption->BitMap; > - VendorOptionLen =3D Dhcp4Option->Length; > - PxeOption =3D (EFI_DHCP4_PACKET_OPTION *) &Dhcp4Option->Data[0]; > - Offset =3D 0; > - > - while ((Offset < VendorOptionLen) && (PxeOption->OpCode !=3D > 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 =3D *PxeOption->Data; > - break; > - > - case PXEBC_VENDOR_TAG_MTFTP_DELAY: > - > - VendorOption->MtftpDelay =3D *PxeOption->Data; > - break; > - > - case PXEBC_VENDOR_TAG_DISCOVER_CTRL: > - > - VendorOption->DiscoverCtrl =3D *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 =3D PxeOption->Length; > - VendorOption->BootSvr =3D (PXEBC_BOOT_SVR_ENTRY *) PxeOption->= Data; > - break; > - > - case PXEBC_VENDOR_TAG_BOOT_MENU: > - > - VendorOption->BootMenuLen =3D PxeOption->Length; > - VendorOption->BootMenu =3D (PXEBC_BOOT_MENU_ENTRY *) PxeOption- > >Data; > - break; > - > - case PXEBC_VENDOR_TAG_MENU_PROMPT: > - > - VendorOption->MenuPromptLen =3D PxeOption->Length; > - VendorOption->MenuPrompt =3D (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 =3D PxeOption->Length; > - VendorOption->CredType =3D (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 =3D=3D DHCP4_TAG_PAD) { > - Offset++; > - } else { > - Offset =3D (UINT8) (Offset + PxeOption->Length + 2); > - } > - > - PxeOption =3D (EFI_DHCP4_PACKET_OPTION *) (Dhcp4Option->Data + Offse= t); > - } > - > - // > - // 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 Ch= ar. > - > - @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 =3D (UINT8) MIN (70, Len); > - Tmp =3D Str[Len]; > - Str[Len] =3D 0; > - AsciiPrint ("%a \n", Str); > - Str[Len] =3D 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 =3D NULL; > - DescendEvent =3D NULL; > - > - if (Private->PxeBc.Mode->ProxyOfferReceived) { > - > - Packet =3D &Private->ProxyOffer; > - } else { > - > - Packet =3D &Private->Dhcp4Ack; > - } > - > - if (Packet->OfferType !=3D DHCP4_PACKET_TYPE_PXE10) { > - return EFI_NOT_FOUND; > - } > - > - VendorOpt =3D &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 th= e > - // following hold: > - // - the PXE_DISCOVERY_CONTROL PXE tag is present inside the Vendor > Options > - // (=3D43) 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] !=3D NULL) { > - return EFI_ABORTED; > - } > - > - if (!IS_VALID_BOOT_PROMPT (VendorOpt->BitMap)) { > - return EFI_SUCCESS; > - } > - > - Timeout =3D VendorOpt->MenuPrompt->Timeout; > - Prompt =3D VendorOpt->MenuPrompt->Prompt; > - PromptLen =3D (UINT8) (VendorOpt->MenuPromptLen - 1); > - > - if (Timeout =3D=3D 0) { > - return EFI_SUCCESS; > - } > - > - if (Timeout =3D=3D 255) { > - return EFI_TIMEOUT; > - } > - > - Status =3D gBS->CreateEvent ( > - EVT_TIMER, > - TPL_CALLBACK, > - NULL, > - NULL, > - &TimeoutEvent > - ); > - > - if (EFI_ERROR (Status)) { > - return Status; > - } > - > - Status =3D gBS->SetTimer ( > - TimeoutEvent, > - TimerRelative, > - MultU64x32 (Timeout, TICKS_PER_SECOND) > - ); > - > - if (EFI_ERROR (Status)) { > - goto ON_EXIT; > - } > - > - Status =3D gBS->CreateEvent ( > - EVT_TIMER, > - TPL_CALLBACK, > - NULL, > - NULL, > - &DescendEvent > - ); > - > - if (EFI_ERROR (Status)) { > - goto ON_EXIT; > - } > - > - Status =3D gBS->SetTimer ( > - DescendEvent, > - TimerPeriodic, > - TICKS_PER_SECOND > - ); > - > - if (EFI_ERROR (Status)) { > - goto ON_EXIT; > - } > - > - SecCol =3D gST->ConOut->Mode->CursorColumn; > - SecRow =3D 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) =3D=3D EFI_NOT= _READY) > { > - > - gBS->Stall (10 * TICKS_PER_MS); > - continue; > - } > - > - if (InputKey.ScanCode =3D=3D 0) { > - > - switch (InputKey.UnicodeChar) { > - case CTRL ('c'): > - Status =3D EFI_ABORTED; > - break; > - > - case CTRL ('m'): > - case 'm': > - case 'M': > - Status =3D EFI_TIMEOUT; > - break; > - > - default: > - continue; > - } > - } else { > - > - switch (InputKey.ScanCode) { > - case SCAN_F8: > - Status =3D EFI_TIMEOUT; > - break; > - > - case SCAN_ESC: > - Status =3D EFI_ABORTED; > - break; > - > - default: > - continue; > - } > - } > - > - break; > - } > - > - gST->ConOut->SetCursorPosition (gST->ConOut, 0 , SecRow + 1); > - > -ON_EXIT: > - > - if (DescendEvent !=3D NULL) { > - gBS->CloseEvent (DescendEvent); > - } > - > - if (TimeoutEvent !=3D 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 f= inish. > - > -**/ > -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 =3D FALSE; > - Select =3D 0; > - Index =3D 0; > - *Type =3D 0; > - > - if (Private->PxeBc.Mode->ProxyOfferReceived) { > - > - Packet =3D &Private->ProxyOffer; > - } else { > - > - Packet =3D &Private->Dhcp4Ack; > - } > - > - ASSERT (Packet->OfferType =3D=3D DHCP4_PACKET_TYPE_PXE10); > - > - VendorOpt =3D &Packet->PxeVendorOption; > - > - if (!IS_VALID_BOOT_MENU (VendorOpt->BitMap)) { > - return EFI_SUCCESS; > - } > - > - SetMem (Blank, sizeof(Blank), ' '); > - > - MenuSize =3D VendorOpt->BootMenuLen; > - MenuItem =3D VendorOpt->BootMenu; > - > - if (MenuSize =3D=3D 0) { > - return EFI_NOT_READY; > - } > - > - while (MenuSize > 0) { > - MenuArray[Index++] =3D MenuItem; > - MenuSize =3D (UINT8) (MenuSize - (MenuItem->DescLen + 3)); > - MenuItem =3D (PXEBC_BOOT_MENU_ENTRY *) ((UINT8 *) MenuItem = + > MenuItem->DescLen + 3); > - if (Index >=3D PXEBC_MAX_MENU_NUM) { > - break; > - } > - } > - > - if (UseDefaultItem) { > - *Type =3D MenuArray[0]->Type; > - *Type =3D NTOHS (*Type); > - return EFI_SUCCESS; > - } > - > - MenuNum =3D Index; > - > - for (Index =3D 0; Index < MenuNum; Index++) { > - PxeBcDisplayBootItem (MenuArray[Index]->DescStr, MenuArray[Index]- > >DescLen); > - } > - > - TopRow =3D 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] =3D 0; > - AsciiPrint ("%a\r", Blank); > - PxeBcDisplayBootItem (MenuArray[Select]->DescStr, MenuArray[Select]- > >DescLen); > - gST->ConOut->SetCursorPosition (gST->ConOut, 0, TopRow + MenuNum); > - LastSelect =3D Select; > - > - while (gST->ConIn->ReadKeyStroke (gST->ConIn, &InputKey) =3D=3D > EFI_NOT_READY) { > - gBS->Stall (10 * TICKS_PER_MS); > - } > - > - if (InputKey.ScanCode =3D=3D 0) { > - switch (InputKey.UnicodeChar) { > - case CTRL ('c'): > - InputKey.ScanCode =3D SCAN_ESC; > - break; > - > - case CTRL ('j'): /* linefeed */ > - case CTRL ('m'): /* return */ > - Finish =3D TRUE; > - break; > - > - case CTRL ('i'): /* tab */ > - case ' ': > - case 'd': > - case 'D': > - InputKey.ScanCode =3D SCAN_DOWN; > - break; > - > - case CTRL ('h'): /* backspace */ > - case 'u': > - case 'U': > - InputKey.ScanCode =3D SCAN_UP; > - break; > - > - default: > - InputKey.ScanCode =3D 0; > - } > - } > - > - switch (InputKey.ScanCode) { > - case SCAN_LEFT: > - case SCAN_UP: > - if (Select > 0) { > - --Select; > - } > - > - break; > - > - case SCAN_DOWN: > - case SCAN_RIGHT: > - if (++Select =3D=3D MenuNum) { > - --Select; > - } > - > - break; > - > - case SCAN_PAGE_UP: > - case SCAN_HOME: > - Select =3D 0; > - break; > - > - case SCAN_PAGE_DOWN: > - case SCAN_END: > - Select =3D (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] =3D 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 =3D 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.
> -This program and the accompanying materials > -are licensed and made available under the terms and conditions of the BS= D > License > -which accompanies this distribution. The full text of the license may b= e 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 =3D { > - 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 incl= uding > - both device drivers and bus drivers. > - > - @param ImageHandle The firmware allocated handle for the UE= FI > 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 t= o > 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 dev= ice > - @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 =3D gBS->OpenProtocol ( > - ControllerHandle, > - &gEfiPxeBaseCodeProtocolGuid, > - (VOID **) &PxeBc, > - This->DriverBindingHandle, > - ControllerHandle, > - EFI_OPEN_PROTOCOL_GET_PROTOCOL > - ); > - > - if (!EFI_ERROR (Status)) { > - return EFI_ALREADY_STARTED; > - } > - > - Status =3D gBS->OpenProtocol ( > - ControllerHandle, > - &gEfiDhcp4ServiceBindingProtocolGuid, > - NULL, > - This->DriverBindingHandle, > - ControllerHandle, > - EFI_OPEN_PROTOCOL_TEST_PROTOCOL > - ); > - > - if (!EFI_ERROR (Status)) { > - > - Status =3D 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 =3D AllocateZeroPool (sizeof (PXEBC_PRIVATE_DATA)); > - if (Private =3D=3D NULL) { > - return EFI_OUT_OF_RESOURCES; > - } > - > - Private->Signature =3D PXEBC_PRIVATE_DATA_SIGNATURE= ; > - Private->Controller =3D ControllerHandle; > - Private->Image =3D This->DriverBindingHandle; > - CopyMem (&Private->PxeBc, &mPxeBcProtocolTemplate, sizeof (Private- > >PxeBc)); > - Private->PxeBc.Mode =3D &Private->Mode; > - CopyMem (&Private->LoadFile, &mLoadFileProtocolTemplate, sizeof (Priva= te- > >LoadFile)); > - > - Private->ProxyOffer.Packet.Offer.Size =3D > PXEBC_CACHED_DHCP4_PACKET_MAX_SIZE; > - Private->Dhcp4Ack.Packet.Ack.Size =3D > PXEBC_CACHED_DHCP4_PACKET_MAX_SIZE; > - Private->PxeReply.Packet.Ack.Size =3D > PXEBC_CACHED_DHCP4_PACKET_MAX_SIZE; > - > - for (Index =3D 0; Index < PXEBC_MAX_OFFER_NUM; Index++) { > - Private->Dhcp4Offers[Index].Packet.Offer.Size =3D > PXEBC_CACHED_DHCP4_PACKET_MAX_SIZE; > - } > - > - // > - // Get the NII interface if it exists. > - // > - Status =3D gBS->OpenProtocol ( > - ControllerHandle, > - &gEfiNetworkInterfaceIdentifierProtocolGuid_31, > - (VOID **) &Private->Nii, > - This->DriverBindingHandle, > - ControllerHandle, > - EFI_OPEN_PROTOCOL_GET_PROTOCOL > - ); > - if (EFI_ERROR (Status)) { > - Private->Nii =3D NULL; > - } > - > - Status =3D NetLibCreateServiceChild ( > - ControllerHandle, > - This->DriverBindingHandle, > - &gEfiArpServiceBindingProtocolGuid, > - &Private->ArpChild > - ); > - if (EFI_ERROR (Status)) { > - goto ON_ERROR; > - } > - > - Status =3D gBS->OpenProtocol ( > - Private->ArpChild, > - &gEfiArpProtocolGuid, > - (VOID **) &Private->Arp, > - This->DriverBindingHandle, > - ControllerHandle, > - EFI_OPEN_PROTOCOL_BY_DRIVER > - ); > - if (EFI_ERROR (Status)) { > - goto ON_ERROR; > - } > - > - Status =3D NetLibCreateServiceChild ( > - ControllerHandle, > - This->DriverBindingHandle, > - &gEfiDhcp4ServiceBindingProtocolGuid, > - &Private->Dhcp4Child > - ); > - if (EFI_ERROR (Status)) { > - goto ON_ERROR; > - } > - > - Status =3D gBS->OpenProtocol ( > - Private->Dhcp4Child, > - &gEfiDhcp4ProtocolGuid, > - (VOID **) &Private->Dhcp4, > - This->DriverBindingHandle, > - ControllerHandle, > - EFI_OPEN_PROTOCOL_BY_DRIVER > - ); > - if (EFI_ERROR (Status)) { > - goto ON_ERROR; > - } > - > - Status =3D NetLibCreateServiceChild ( > - ControllerHandle, > - This->DriverBindingHandle, > - &gEfiIp4ServiceBindingProtocolGuid, > - &Private->Ip4Child > - ); > - if (EFI_ERROR (Status)) { > - goto ON_ERROR; > - } > - > - Status =3D 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 =3D Private->Ip4->GetModeData (Private->Ip4, &Ip4ModeData, NULL= , > NULL); > - if (EFI_ERROR (Status)) { > - goto ON_ERROR; > - } > - > - Private->Ip4MaxPacketSize =3D Ip4ModeData.MaxPacketSize; > - > - Status =3D NetLibCreateServiceChild ( > - ControllerHandle, > - This->DriverBindingHandle, > - &gEfiMtftp4ServiceBindingProtocolGuid, > - &Private->Mtftp4Child > - ); > - > - if (EFI_ERROR (Status)) { > - goto ON_ERROR; > - } > - > - Status =3D gBS->OpenProtocol ( > - Private->Mtftp4Child, > - &gEfiMtftp4ProtocolGuid, > - (VOID **) &Private->Mtftp4, > - This->DriverBindingHandle, > - ControllerHandle, > - EFI_OPEN_PROTOCOL_BY_DRIVER > - ); > - > - if (EFI_ERROR (Status)) { > - goto ON_ERROR; > - } > - > - Status =3D NetLibCreateServiceChild ( > - ControllerHandle, > - This->DriverBindingHandle, > - &gEfiUdp4ServiceBindingProtocolGuid, > - &Private->Udp4ReadChild > - ); > - > - if (EFI_ERROR (Status)) { > - goto ON_ERROR; > - } > - > - // > - // The UDP instance for EfiPxeBcUdpRead > - // > - Status =3D 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 =3D NetLibCreateServiceChild ( > - ControllerHandle, > - This->DriverBindingHandle, > - &gEfiUdp4ServiceBindingProtocolGuid, > - &Private->Udp4WriteChild > - ); > - if (EFI_ERROR (Status)) { > - goto ON_ERROR; > - } > - > - Status =3D 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 =3D FALSE; > - Private->Udp4CfgData.AcceptPromiscuous =3D FALSE; > - Private->Udp4CfgData.AcceptAnyPort =3D TRUE; > - Private->Udp4CfgData.AllowDuplicatePort =3D TRUE; > - Private->Udp4CfgData.TypeOfService =3D DEFAULT_ToS; > - Private->Udp4CfgData.TimeToLive =3D DEFAULT_TTL; > - Private->Udp4CfgData.DoNotFragment =3D FALSE; > - Private->Udp4CfgData.ReceiveTimeout =3D PXEBC_DEFAULT_LIFETIME; > - Private->Udp4CfgData.UseDefaultAddress =3D FALSE; > - > - PxeBcInitSeedPacket (&Private->SeedPacket, Private->Udp4Read); > - Private->MacLen =3D 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 =3D EFI_IP_PROTO_ICMP; > - Private->Ip4ConfigData.AcceptIcmpErrors =3D TRUE; > - Private->Ip4ConfigData.TypeOfService =3D DEFAULT_ToS; > - Private->Ip4ConfigData.TimeToLive =3D DEFAULT_TTL; > - Private->Ip4ConfigData.DoNotFragment =3D FALSE; > - Private->Ip4ConfigData.RawData =3D FALSE; > - > - Status =3D 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 =3D gBS->HandleProtocol ( > - ControllerHandle, > - &gEfiIp4Config2ProtocolGuid, > - (VOID **) &Private->Ip4Config2 > - ); > - if (EFI_ERROR (Status)) { > - goto ON_ERROR; > - } > - > - return EFI_SUCCESS; > - > -ON_ERROR: > - > - if (Private->Udp4WriteChild !=3D NULL) { > - gBS->CloseProtocol ( > - Private->Udp4WriteChild, > - &gEfiUdp4ProtocolGuid, > - This->DriverBindingHandle, > - ControllerHandle > - ); > - NetLibDestroyServiceChild ( > - ControllerHandle, > - This->DriverBindingHandle, > - &gEfiUdp4ServiceBindingProtocolGuid, > - Private->Udp4WriteChild > - ); > - } > - > - if (Private->Udp4ReadChild !=3D NULL) { > - gBS->CloseProtocol ( > - Private->Udp4ReadChild, > - &gEfiUdp4ProtocolGuid, > - This->DriverBindingHandle, > - ControllerHandle > - ); > - NetLibDestroyServiceChild ( > - ControllerHandle, > - This->DriverBindingHandle, > - &gEfiUdp4ServiceBindingProtocolGuid, > - Private->Udp4ReadChild > - ); > - } > - > - if (Private->Mtftp4Child !=3D NULL) { > - gBS->CloseProtocol ( > - Private->Mtftp4Child, > - &gEfiMtftp4ProtocolGuid, > - This->DriverBindingHandle, > - ControllerHandle > - ); > - > - NetLibDestroyServiceChild ( > - ControllerHandle, > - This->DriverBindingHandle, > - &gEfiMtftp4ServiceBindingProtocolGuid, > - Private->Mtftp4Child > - ); > - } > - > - if (Private->Ip4Child !=3D NULL) { > - gBS->CloseProtocol ( > - Private->Ip4Child, > - &gEfiIp4ProtocolGuid, > - This->DriverBindingHandle, > - ControllerHandle > - ); > - > - NetLibDestroyServiceChild ( > - ControllerHandle, > - This->DriverBindingHandle, > - &gEfiIp4ServiceBindingProtocolGuid, > - Private->Ip4Child > - ); > - } > - > - if (Private->Dhcp4Child !=3D NULL) { > - gBS->CloseProtocol ( > - Private->Dhcp4Child, > - &gEfiDhcp4ProtocolGuid, > - This->DriverBindingHandle, > - ControllerHandle > - ); > - > - NetLibDestroyServiceChild ( > - ControllerHandle, > - This->DriverBindingHandle, > - &gEfiDhcp4ServiceBindingProtocolGuid, > - Private->Dhcp4Child > - ); > - } > - > - if (Private->ArpChild !=3D 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 =3D NetLibGetNicHandle (ControllerHandle, &gEfiArpProtocolGu= id); > - if (NicHandle =3D=3D NULL) { > - NicHandle =3D NetLibGetNicHandle (ControllerHandle, > &gEfiDhcp4ProtocolGuid); > - > - if (NicHandle =3D=3D NULL) { > - NicHandle =3D NetLibGetNicHandle (ControllerHandle, &gEfiIp4Protoc= olGuid); > - > - if (NicHandle =3D=3D NULL) { > - NicHandle =3D NetLibGetNicHandle (ControllerHandle, > &gEfiUdp4ProtocolGuid); > - > - if (NicHandle =3D=3D NULL) { > - NicHandle =3D NetLibGetNicHandle (ControllerHandle, > &gEfiMtftp4ProtocolGuid); > - > - if (NicHandle =3D=3D NULL) { > - return EFI_SUCCESS; > - } > - } > - } > - } > - } > - > - Status =3D 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 =3D PxeBc->Stop (PxeBc); > - if (Status !=3D EFI_SUCCESS && Status !=3D EFI_NOT_STARTED) { > - return Status; > - } > - > - Private =3D PXEBC_PRIVATE_DATA_FROM_PXEBC (PxeBc); > - > - Status =3D 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.
> -This program and the accompanying materials > -are licensed and made available under the terms and conditions of the BS= D > License > -which accompanies this distribution. The full text of the license may b= e 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] =3D { 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 =3D PXEBC_PRIVATE_DATA_FROM_PXEBC (This); > - Mode =3D Private->PxeBc.Mode; > - > - Status =3D Private->Arp->Find ( > - Private->Arp, > - TRUE, > - NULL, > - &EntryLength, > - &EntryCount, > - &Entries, > - TRUE > - ); > - if (EFI_ERROR (Status)) { > - return Status; > - } > - > - Mode->ArpCacheEntries =3D MIN ( > - EntryCount, > - EFI_PXE_BASE_CODE_MAX_ARP_ENTRIES > - ); > - for (Index =3D 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 =3D (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 =3D 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 =3D (PXEBC_PRIVATE_DATA *) Context; > - Mode =3D &Private->Mode; > - Status =3D Private->IcmpErrorRcvToken.Status; > - RxData =3D Private->IcmpErrorRcvToken.Packet.RxData; > - Ip4 =3D Private->Ip4; > - > - if (Status =3D=3D EFI_ABORTED) { > - // > - // The reception is actively aborted by the consumer, directly retur= n. > - // > - return; > - } > - > - if (RxData =3D=3D NULL) { > - goto Resume; > - } > - > - if (Status !=3D EFI_ICMP_ERROR) { > - // > - // The return status should be recognized as EFI_ICMP_ERROR. > - // > - goto CleanUp; > - } > - > - if (EFI_IP4 (RxData->Header->SourceAddress) !=3D 0 && > - (NTOHL (Mode->SubnetMask.Addr[0]) !=3D 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 =3D 0; > - CopiedPointer =3D (UINT8 *) &Mode->IcmpError; > - > - for (Index =3D 0; Index < RxData->FragmentCount; Index ++) { > - CopiedLen +=3D RxData->FragmentTable[Index].FragmentLength; > - if (CopiedLen <=3D 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 +=3D 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 notif= ier. > - > -**/ > -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 a= vailable. > - Set to FALSE if the PXE Base Code Callback Protocol is not available= . > - > - @param This Pointer to the EFI_PXE_BASE_CODE_PROTOCO= L > 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 I= Pv6 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 f= ield > of the > - EFI_PXE_BASE_CODE_MODE structure is FALS= E. > - @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 =3D=3D NULL) { > - return EFI_INVALID_PARAMETER; > - } > - > - Private =3D PXEBC_PRIVATE_DATA_FROM_PXEBC (This); > - Mode =3D 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 =3D 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 =3D 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) !=3D 0) { > - Private->BlockSize =3D (UINTN) PcdGet64 (PcdTftpBlockSize); > - } > - > - Private->AddressIsOk =3D FALSE; > - > - ZeroMem (Mode, sizeof (EFI_PXE_BASE_CODE_MODE)); > - > - Mode->Started =3D TRUE; > - Mode->TTL =3D DEFAULT_TTL; > - Mode->ToS =3D DEFAULT_ToS; > - Mode->AutoArp =3D TRUE; > - > - // > - // Create the event for Arp Cache checking. > - // > - Status =3D 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 =3D gBS->SetTimer ( > - Private->GetArpCacheEvent, > - TimerPeriodic, > - TICKS_PER_SECOND > - ); > - > - if (EFI_ERROR (Status)) { > - goto ON_EXIT; > - } > - > - // > - // Create ICMP error receiving event > - // > - Status =3D 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 =3D PxeBcSetIp4Policy (Private); > - if (EFI_ERROR (Status)) { > - goto ON_EXIT; > - } > - > - Status =3D Private->Ip4->Configure (Private->Ip4, &Private->Ip4ConfigD= ata); > - if (EFI_ERROR (Status)) { > - goto ON_EXIT; > - } > - > - // > - // start to listen incoming packet > - // > - Status =3D Private->Ip4->Receive (Private->Ip4, &Private->IcmpErrorRcv= Token); > - if (!EFI_ERROR (Status)) { > - return Status; > - } > - > -ON_EXIT: > - Private->Ip4->Configure (Private->Ip4, NULL); > - > - if (Private->IcmpErrorRcvToken.Event !=3D NULL) { > - gBS->CloseEvent (Private->IcmpErrorRcvToken.Event); > - } > - > - if (Private->GetArpCacheEvent !=3D NULL) { > - gBS->SetTimer (Private->GetArpCacheEvent, TimerCancel, 0); > - gBS->CloseEvent (Private->GetArpCacheEvent); > - } > - > - Mode->Started =3D FALSE; > - Mode->TTL =3D 0; > - Mode->ToS =3D 0; > - Mode->AutoArp =3D FALSE; > - > - return Status; > -} > - > - > -/** > - Disables the use of the PXE Base Code Protocol functions. > - > - This function stops all activity on the network device. All the resour= ces > allocated > - in Start() are released, the Started field of the EFI_PXE_BASE_CODE_MO= DE > 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_PROTOCO= L > 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 =3D=3D NULL) { > - return EFI_INVALID_PARAMETER; > - } > - > - Private =3D PXEBC_PRIVATE_DATA_FROM_PXEBC (This); > - Mode =3D 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 t= oken'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 =3D FALSE; > - > - Private->CurrentUdpSrcPort =3D 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 =3D 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, ProxyOfferReceive= d, > 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 sort= ed > before > - they are tried. If SortOffers is FALSE, then the cached DHCP offer pac= kets will > - be tried in the order in which they are received. Please see the Prebo= ot > Execution > - Environment (PXE) Specification for additional details on the implemen= tation > of DHCP. > - This function can take at least 31 seconds to timeout and return contr= ol 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 returne= d. > - > - @param This Pointer to the EFI_PXE_BASE_CODE_PROTOCO= L > instance. > - @param SortOffers TRUE if the offers received should be so= rted. Set to > FALSE to try the > - offers in the order that they are receiv= ed. > - > - @retval EFI_SUCCESS Valid DHCP has completed. > - @retval EFI_NOT_STARTED The PXE Base Code Protocol is in the sto= pped > 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 P= rotocol. > - @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 =3D=3D NULL) { > - return EFI_INVALID_PARAMETER; > - } > - > - Status =3D EFI_SUCCESS; > - Private =3D PXEBC_PRIVATE_DATA_FROM_PXEBC (This); > - Mode =3D Private->PxeBc.Mode; > - Dhcp4 =3D Private->Dhcp4; > - Private->Function =3D EFI_PXE_BASE_CODE_FUNCTION_DHCP; > - Private->SortOffers =3D SortOffers; > - > - if (!Mode->Started) { > - return EFI_NOT_STARTED; > - } > - > - Mode->IcmpErrorReceived =3D FALSE; > - > - // > - // Stop Udp4Read instance > - // > - Private->Udp4Read->Configure (Private->Udp4Read, NULL); > - > - // > - // Initialize the DHCP options and build the option list > - // > - OptCount =3D 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 =3D OptCount; > - Dhcp4CfgData.OptionList =3D OptList; > - Dhcp4CfgData.Dhcp4Callback =3D PxeBcDhcpCallBack; > - Dhcp4CfgData.CallbackContext =3D Private; > - Dhcp4CfgData.DiscoverTryCount =3D 4; > - Dhcp4CfgData.DiscoverTimeout =3D mPxeDhcpTimeout; > - > - Status =3D Dhcp4->Configure (Dhcp4, &Dhcp4CfgData); > - if (EFI_ERROR (Status)) { > - goto ON_EXIT; > - } > - > - // > - // Zero those arrays to record the varies numbers of DHCP OFFERS. > - // > - Private->GotProxyOffer =3D FALSE; > - Private->NumOffers =3D 0; > - Private->BootpIndex =3D 0; > - ZeroMem (Private->ServerCount, sizeof (Private->ServerCount)); > - ZeroMem (Private->ProxyIndex, sizeof (Private->ProxyIndex)); > - > - Status =3D Dhcp4->Start (Dhcp4, NULL); > - if (EFI_ERROR (Status) && Status !=3D EFI_ALREADY_STARTED) { > - if (Status =3D=3D EFI_ICMP_ERROR) { > - Mode->IcmpErrorReceived =3D TRUE; > - } > - goto ON_EXIT; > - } > - > - Status =3D Dhcp4->GetModeData (Dhcp4, &Dhcp4Mode); > - if (EFI_ERROR (Status)) { > - goto ON_EXIT; > - } > - > - ASSERT (Dhcp4Mode.State =3D=3D 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 =3D 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 functio= n > - // > - ZeroMem (&Dhcp4CfgData, sizeof (EFI_DHCP4_CONFIG_DATA)); > - Dhcp4->Configure (Dhcp4, &Dhcp4CfgData); > - > - Private->AddressIsOk =3D 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 =3D 0x0800; > - ArpConfigData.SwAddressLength =3D (UINT8) sizeof (EFI_IPv4_ADDRESS= ); > - ArpConfigData.StationAddress =3D &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 =3D 1; > - Mode->RouteTable[0].IpAddr.Addr[0] =3D Private->StationIp.Addr= [0] & > Private->SubnetMask.Addr[0]; > - Mode->RouteTable[0].SubnetMask.Addr[0] =3D Private->SubnetMask.Add= r[0]; > - Mode->RouteTable[0].GwAddr.Addr[0] =3D 0; > - > - // > - // Create the default route entry if there is a default router. > - // > - if (Private->GatewayIp.Addr[0] !=3D 0) { > - Mode->RouteTableEntries =3D 2; > - Mode->RouteTable[1].IpAddr.Addr[0] =3D 0; > - Mode->RouteTable[1].SubnetMask.Addr[0] =3D 0; > - Mode->RouteTable[1].GwAddr.Addr[0] =3D Private->GatewayIp.Ad= dr[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->Station= Ip, > 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 =3D Private->Ip4->Configure (Private->Ip4, &Private->Ip4Con= figData); > - if (EFI_ERROR (Status)) { > - goto ON_EXIT; > - } > - > - Status =3D Private->Ip4->Receive (Private->Ip4, &Private->IcmpErro= rRcvToken); > - 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 =3D 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 ima= ge > discovery > - sequence. If this sequence is completed, then EFI_SUCCESS is returned,= and > the > - PxeDiscoverValid, PxeDiscover, PxeReplyReceived, and PxeReply fields o= f the > - EFI_PXE_BASE_CODE_MODE structure are filled in. If UseBis is TRUE, the= n 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 lis= t, > SrvList[], > - has two uses: It is the Boot Server IP address list used for unicast d= iscovery > - (if the UseUCast field is TRUE), and it is the list used for Boot Serv= er > 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 f= ield is > - FALSE, only responses from Boot Servers with matching IP addresses wil= l be > accepted. > - This function can take at least 10 seconds to timeout and return contr= ol to the > - caller. If the Discovery sequence does not complete, then EFI_TIMEOUT = will > be > - returned. Please see the Preboot Execution Environment (PXE) Specifica= tion > 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 returne= d. > - > - @param This Pointer to the EFI_PXE_BASE_CODE_PROTOCO= L > 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 b= e used. FALSE > otherwise. > - @param Info Pointer to a data structure that contain= s additional > information on the > - type of discovery operation that is to b= e performed. > - > - @retval EFI_SUCCESS The Discovery sequence has been complete= d. > - @retval EFI_NOT_STARTED The PXE Base Code Protocol is in the sto= pped > 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 Discov= ery > 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 =3D=3D NULL) { > - return EFI_INVALID_PARAMETER; > - } > - > - Private =3D PXEBC_PRIVATE_DATA_FROM_PXEBC (This); > - Mode =3D Private->PxeBc.Mode; > - BootSvrEntry =3D NULL; > - SrvList =3D NULL; > - CreatedInfo =3D NULL; > - Status =3D EFI_DEVICE_ERROR; > - Private->Function =3D 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 =3D 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 !=3D EFI_PXE_BASE_CODE_BOOT_LAYER_INITIAL) { > - > - if (!Mode->PxeDiscoverValid || !Mode->PxeReplyReceived || (!Mode- > >PxeBisReplyReceived && UseBis)) { > - > - Status =3D EFI_INVALID_PARAMETER; > - goto ON_EXIT; > - } > - > - DefaultInfo.IpCnt =3D 1; > - DefaultInfo.UseUCast =3D TRUE; > - > - DefaultSrvList.Type =3D Type; > - DefaultSrvList.AcceptAnyResponse =3D FALSE; > - DefaultSrvList.IpAddr.Addr[0] =3D Private->ServerIp.Addr[0]; > - > - SrvList =3D &DefaultSrvList; > - Info =3D &DefaultInfo; > - } else if (Info =3D=3D NULL) { > - // > - // Create info by the cached packet before > - // > - Packet =3D (Mode->ProxyOfferReceived) ? &Private->ProxyOffer : &P= rivate- > >Dhcp4Ack; > - VendorOpt =3D &Packet->PxeVendorOption; > - > - if (!Mode->DhcpAckReceived || !IS_VALID_DISCOVER_VENDOR_OPTION > (VendorOpt->BitMap)) { > - // > - // Address is not acquired or no discovery options. > - // > - Status =3D EFI_INVALID_PARAMETER; > - goto ON_EXIT; > - } > - > - DefaultInfo.UseMCast =3D (BOOLEAN)!IS_DISABLE_MCAST_DISCOVER > (VendorOpt->DiscoverCtrl); > - DefaultInfo.UseBCast =3D (BOOLEAN)!IS_DISABLE_BCAST_DISCOVER > (VendorOpt->DiscoverCtrl); > - DefaultInfo.MustUseList =3D (BOOLEAN) IS_ENABLE_USE_SERVER_LIST > (VendorOpt->DiscoverCtrl); > - DefaultInfo.UseUCast =3D 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 =3D 0; > - Info =3D &DefaultInfo; > - SrvList =3D Info->SrvList; > - > - if (DefaultInfo.MustUseList) { > - BootSvrEntry =3D VendorOpt->BootSvr; > - Status =3D EFI_INVALID_PARAMETER; > - > - while (((UINT8) (BootSvrEntry - VendorOpt->BootSvr)) < VendorOpt- > >BootSvrLen) { > - > - if (BootSvrEntry->Type =3D=3D HTONS (Type)) { > - Status =3D EFI_SUCCESS; > - break; > - } > - > - BootSvrEntry =3D GET_NEXT_BOOT_SVR_ENTRY (BootSvrEntry); > - } > - > - if (EFI_ERROR (Status)) { > - goto ON_EXIT; > - } > - > - DefaultInfo.IpCnt =3D BootSvrEntry->IpCnt; > - > - if (DefaultInfo.IpCnt >=3D 1) { > - CreatedInfo =3D AllocatePool (sizeof (DefaultInfo) + (DefaultInf= o.IpCnt - 1) * > sizeof (*SrvList)); > - if (CreatedInfo =3D=3D NULL) { > - Status =3D EFI_OUT_OF_RESOURCES; > - goto ON_EXIT; > - > - } > - > - CopyMem (CreatedInfo, &DefaultInfo, sizeof (DefaultInfo)); > - Info =3D CreatedInfo; > - SrvList =3D Info->SrvList; > - } > - > - for (Index =3D 0; Index < DefaultInfo.IpCnt; Index++) { > - CopyMem (&SrvList[Index].IpAddr, &BootSvrEntry->IpAddr[Index], s= izeof > (EFI_IPv4_ADDRESS)); > - SrvList[Index].AcceptAnyResponse =3D FALSE; > - SrvList[Index].Type =3D BootSvrEntry->Type; > - } > - } > - > - } else { > - > - SrvList =3D Info->SrvList; > - > - if (!SrvList[0].AcceptAnyResponse) { > - > - for (Index =3D 1; Index < Info->IpCnt; Index++) { > - if (SrvList[Index].AcceptAnyResponse) { > - break; > - } > - } > - > - if (Index !=3D Info->IpCnt) { > - Status =3D EFI_INVALID_PARAMETER; > - goto ON_EXIT; > - } > - } > - } > - > - if ((!Info->UseUCast && !Info->UseBCast && !Info->UseMCast) || (Info- > >MustUseList && Info->IpCnt =3D=3D 0)) { > - > - Status =3D EFI_INVALID_PARAMETER; > - goto ON_EXIT; > - } > - // > - // Execute discover by UniCast/BroadCast/MultiCast > - // > - if (Info->UseUCast) { > - > - for (Index =3D 0; Index < Info->IpCnt; Index++) { > - > - if (BootSvrEntry =3D=3D NULL) { > - Private->ServerIp.Addr[0] =3D SrvList[Index].IpAddr.Addr[0]; > - } else { > - CopyMem ( > - &Private->ServerIp, > - &BootSvrEntry->IpAddr[Index], > - sizeof (EFI_IPv4_ADDRESS) > - ); > - } > - > - Status =3D 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 =3D PxeBcDiscvBootService ( > - Private, > - Type, > - Layer, > - UseBis, > - &Info->ServerMCastIp, > - 0, > - NULL, > - TRUE, > - &Private->PxeReply.Packet.Ack > - ); > - > - } else if (Info->UseBCast) { > - > - Status =3D 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 =3D=3D EFI_ICMP_ERROR) { > - Mode->IcmpErrorReceived =3D TRUE; > - } else { > - Status =3D 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 !=3D 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 =3D 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 include= s the > - TFTP operations to get the size of a file, read a directory, read a fi= le, 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 operati= on 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 spec= ified 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 o= nly returned > - if the TFTP server supports TFTP options). If BufferSize is large enou= gh for the > - read operation, then BufferSize will be set to the size of the downloa= ded 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 downloadi= ng large > - (greater than 64 MB) files-instead of making two calls to the read-fil= e > operation. > - Following this recommendation will save time if the file is larger tha= n expected > - and the TFTP server does not support TFTP option extensions. Without T= FTP > option > - extension support, the client has to download the entire file, countin= g and > discarding > - the received packets, to determine the file size. > - For write operations, the data to be sent is in the buffer specified b= y BufferPtr. > - BufferSize specifies the number of bytes to send. If the write operati= on > 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 TF= TP server > - does not support options, the file will be downloaded into a bit bucke= t and the > - length of the downloaded file will be returned. For MTFTP "get file si= ze" > 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 i= s 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 ar= e UTC. > For > - an MTFTP read directory command, there is additionally a null-terminat= ed > multicast > - IP address preceding the filename of the form %d.%d.%d.%d for IP v4. T= he > 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_PROTOCO= L > 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, *BufferSiz= e returns the > size of the > - requested file. > - @param BlockSize The requested block size to be used duri= ng a TFTP > transfer. > - @param ServerIp The TFTP / MTFTP server IP address. > - @param Filename A Null-terminated ASCII string that spec= ifies a > directory name or a file > - name. > - @param Info Pointer to the MTFTP information. > - @param DontUseBuffer Set to FALSE for normal TFTP and MTFTP r= ead > file operation. > - > - @retval EFI_SUCCESS The TFTP/MTFTP operation was completed. > - @retval EFI_NOT_STARTED The PXE Base Code Protocol is in the sto= pped > 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 comple= te > the read operation. > - @retval EFI_ABORTED The callback function aborted the TFTP/M= TFTP > 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 =3D=3D NULL) = || > - (Filename =3D=3D NULL) = || > - (BufferSize =3D=3D NULL) = || > - ((ServerIp =3D=3D NULL) || > - (IP4_IS_UNSPECIFIED (NTOHL (ServerIp->Addr[0])) || > - IP4_IS_LOCAL_BROADCAST (NTOHL (ServerIp->Addr[0])))) = || > - ((BufferPtr =3D=3D NULL) && DontUseBuffer) = || > - ((BlockSize !=3D NULL) && (*BlockSize < 512))) { > - > - return EFI_INVALID_PARAMETER; > - } > - > - Status =3D EFI_DEVICE_ERROR; > - Private =3D PXEBC_PRIVATE_DATA_FROM_PXEBC (This); > - Mode =3D &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 =3D FALSE; > - Mode->IcmpErrorReceived =3D FALSE; > - > - Mtftp4Config.UseDefaultSetting =3D FALSE; > - Mtftp4Config.TimeoutValue =3D PXEBC_MTFTP_TIMEOUT; > - Mtftp4Config.TryCount =3D 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 =3D PxeBcTftpGetFileSize ( > - Private, > - &Mtftp4Config, > - Filename, > - BlockSize, > - BufferSize > - ); > - > - break; > - > - case EFI_PXE_BASE_CODE_TFTP_READ_FILE: > - > - Status =3D PxeBcTftpReadFile ( > - Private, > - &Mtftp4Config, > - Filename, > - BlockSize, > - BufferPtr, > - BufferSize, > - DontUseBuffer > - ); > - > - break; > - > - case EFI_PXE_BASE_CODE_TFTP_WRITE_FILE: > - > - Status =3D PxeBcTftpWriteFile ( > - Private, > - &Mtftp4Config, > - Filename, > - Overwrite, > - BlockSize, > - BufferPtr, > - BufferSize > - ); > - > - break; > - > - case EFI_PXE_BASE_CODE_TFTP_READ_DIRECTORY: > - > - Status =3D 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 =3D EFI_UNSUPPORTED; > - break; > - > - default: > - > - Status =3D EFI_INVALID_PARAMETER; > - break; > - } > - > - if (Status =3D=3D EFI_ICMP_ERROR) { > - Mode->IcmpErrorReceived =3D 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 =3D 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, DestPor= t, > 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 re= turned. > - If a timeout occurs during the transmission of the packet, then EFI_TI= MEOUT > will > - be returned. If an ICMP error occurs during the transmission of the pa= cket, > then > - the IcmpErrorReceived field is set to TRUE, the IcmpError field is fil= led in and > - EFI_ICMP_ERROR will be returned. If the Callback Protocol does not ret= urn > - EFI_PXE_BASE_CODE_CALLBACK_STATUS_CONTINUE, then EFI_ABORTED will > be returned. > - > - @param This Pointer to the EFI_PXE_BASE_CODE_PROTOCO= L > 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 th= e 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 Buf= ferPtr. > - @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 sto= pped > 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 Wr= ite > 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 =3D FALSE; > - > - if ((This =3D=3D NULL) || (DestIp =3D=3D NULL) || (DestPort =3D=3D NUL= L)) { > - return EFI_INVALID_PARAMETER; > - } > - > - if ((GatewayIp !=3D 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 !=3D NULL) && ((*HeaderSize =3D=3D 0) || (HeaderPtr = =3D=3D NULL))) { > - // > - // The HeaderSize ptr isn't NULL and: 1. the value is zero; or 2. th= e HeaderPtr > - // is NULL. > - // > - return EFI_INVALID_PARAMETER; > - } > - > - if ((BufferSize =3D=3D NULL) || ((*BufferSize !=3D 0) && (BufferPtr = =3D=3D NULL))) { > - return EFI_INVALID_PARAMETER; > - } > - > - Private =3D PXEBC_PRIVATE_DATA_FROM_PXEBC (This); > - Udp4 =3D Private->Udp4Write; > - Mode =3D &Private->Mode; > - if (!Mode->Started) { > - return EFI_NOT_STARTED; > - } > - > - if (!Private->AddressIsOk && (SrcIp =3D=3D 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 =3D FALSE; > - > - if ((Private->CurrentUdpSrcPort =3D=3D 0) || > - ((SrcPort !=3D NULL) && (*SrcPort !=3D Private->CurrentUdpSrcPort)= )) { > - // > - // Port is changed, (re)configure the Udp4Write instance > - // > - if (SrcPort !=3D NULL) { > - Private->CurrentUdpSrcPort =3D *SrcPort; > - } > - } > - > - Status =3D 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 =3D 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 =3D *DestPort; > - if (SrcIp !=3D NULL) { > - CopyMem (&Udp4Session.SourceAddress, SrcIp, sizeof (EFI_IPv4_ADDRESS= )); > - } > - if (SrcPort !=3D NULL) { > - Udp4Session.SourcePort =3D *SrcPort; > - } > - > - FragCount =3D (HeaderSize !=3D NULL) ? 2 : 1; > - Udp4TxData =3D (EFI_UDP4_TRANSMIT_DATA *) AllocateZeroPool (sizeof > (EFI_UDP4_TRANSMIT_DATA) + (FragCount - 1) * sizeof > (EFI_UDP4_FRAGMENT_DATA)); > - if (Udp4TxData =3D=3D NULL) { > - return EFI_OUT_OF_RESOURCES; > - } > - > - Udp4TxData->FragmentCount =3D FragCount; > - Udp4TxData->FragmentTable[FragCount - 1].FragmentLength =3D (UINT32) > *BufferSize; > - Udp4TxData->FragmentTable[FragCount - 1].FragmentBuffer =3D BufferPtr; > - DataLength =3D (UINT32) *BufferSize; > - > - if (FragCount =3D=3D 2) { > - > - Udp4TxData->FragmentTable[0].FragmentLength =3D (UINT32) *HeaderSize= ; > - Udp4TxData->FragmentTable[0].FragmentBuffer =3D HeaderPtr; > - DataLength +=3D (UINT32) *HeaderSize; > - } > - > - if (GatewayIp !=3D NULL) { > - Udp4TxData->GatewayAddress =3D (EFI_IPv4_ADDRESS *) GatewayIp; > - } > - Udp4TxData->UdpSessionData =3D &Udp4Session; > - Udp4TxData->DataLength =3D DataLength; > - Token.Packet.TxData =3D Udp4TxData; > - > - Status =3D gBS->CreateEvent ( > - EVT_NOTIFY_SIGNAL, > - TPL_NOTIFY, > - PxeBcCommonNotify, > - &IsDone, > - &Token.Event > - ); > - if (EFI_ERROR (Status)) { > - goto ON_EXIT; > - } > - > - Status =3D Udp4->Transmit (Udp4, &Token); > - if (EFI_ERROR (Status)) { > - if (Status =3D=3D EFI_ICMP_ERROR) { > - Mode->IcmpErrorReceived =3D TRUE; > - } > - goto ON_EXIT; > - } > - > - while (!IsDone) { > - > - Udp4->Poll (Udp4); > - } > - > - Status =3D Token.Status; > - > -ON_EXIT: > - > - if (Token.Event !=3D 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 set= tings > - 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) !=3D 0) { > - return TRUE; > - } > - > - CopyMem (&DestIp4Address, &Session->DestinationAddress, sizeof > (DestIp4Address)); > - if (((PxeBcMode->IpFilter.Filters & > EFI_PXE_BASE_CODE_IP_FILTER_PROMISCUOUS_MULTICAST) !=3D 0) && > - IP4_IS_MULTICAST (EFI_NTOHL (DestIp4Address)) > - ) { > - return TRUE; > - } > - > - if (((PxeBcMode->IpFilter.Filters & > EFI_PXE_BASE_CODE_IP_FILTER_BROADCAST) !=3D 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) !=3D 0) && > - EFI_IP4_EQUAL (&Ip4Address, &DestIp4Address) > - ) { > - return TRUE; > - } > - > - ASSERT (PxeBcMode->IpFilter.IpCnt < EFI_PXE_BASE_CODE_MAX_IPCNT); > - > - for (Index =3D 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 co= ntents > - are returned in (the optional HeaderPtr and) BufferPtr, and the size o= f the > - buffer received is returned in BufferSize . If the input BufferSize is= smaller > - than the UDP packet received (less optional HeaderSize), it will be se= t 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 info= rmation > - from the UDP header will be returned in DestIp, DestPort, SrcIp, and S= rcPort 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_PROTOCO= L > 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 th= e 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 Buf= ferPtr. > - @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 sto= pped > 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 hol= d. > - @retval EFI_ABORTED The callback function aborted the UDP Re= ad > 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 =3D=3D NULL || DestIp =3D=3D NULL || DestPort =3D=3D NULL) { > - return EFI_INVALID_PARAMETER; > - } > - > - if (((OpFlags & EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_DEST_PORT) =3D=3D 0 > && (DestPort =3D=3D NULL)) || > - ((OpFlags & EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_DEST_PORT) =3D=3D 0 > && (SrcIp =3D=3D NULL)) || > - ((OpFlags & EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_SRC_PORT) =3D=3D 0 &= & > (SrcPort =3D=3D NULL))) { > - return EFI_INVALID_PARAMETER; > - } > - > - if (((HeaderSize !=3D NULL) && (*HeaderSize =3D=3D 0)) || ((HeaderSize= !=3D NULL) && > (HeaderPtr =3D=3D NULL))) { > - return EFI_INVALID_PARAMETER; > - } > - > - if ((BufferSize =3D=3D NULL) || (BufferPtr =3D=3D NULL)) { > - return EFI_INVALID_PARAMETER; > - } > - > - Private =3D PXEBC_PRIVATE_DATA_FROM_PXEBC (This); > - Mode =3D Private->PxeBc.Mode; > - Udp4 =3D Private->Udp4Read; > - > - if (!Mode->Started) { > - return EFI_NOT_STARTED; > - } > - > - Mode->IcmpErrorReceived =3D FALSE; > - > - Status =3D gBS->CreateEvent ( > - EVT_NOTIFY_SIGNAL, > - TPL_NOTIFY, > - PxeBcCommonNotify, > - &IsDone, > - &Token.Event > - ); > - if (EFI_ERROR (Status)) { > - return EFI_OUT_OF_RESOURCES; > - } > - > -TRY_AGAIN: > - > - IsDone =3D FALSE; > - Status =3D Udp4->Receive (Udp4, &Token); > - if (EFI_ERROR (Status)) { > - if (Status =3D=3D EFI_ICMP_ERROR) { > - Mode->IcmpErrorReceived =3D TRUE; > - } > - goto ON_EXIT; > - } > - > - Udp4->Poll (Udp4); > - > - if (!IsDone) { > - Status =3D EFI_TIMEOUT; > - } else { > - > - // > - // check whether this packet matches the filters > - // > - if (EFI_ERROR (Token.Status)){ > - goto ON_EXIT; > - } > - > - RxData =3D Token.Packet.RxData; > - Session =3D &RxData->UdpSession; > - > - Matched =3D TRUE; > - > - if ((OpFlags & EFI_PXE_BASE_CODE_UDP_OPFLAGS_USE_FILTER) !=3D 0) { > - Matched =3D FALSE; > - // > - // Check UDP package by IP filter settings > - // > - if (CheckIpByFilter (Mode, Session)) { > - Matched =3D TRUE; > - } > - } > - > - if (Matched) { > - Matched =3D FALSE; > - > - // > - // Match the destination ip of the received udp dgram > - // > - if ((OpFlags & EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_DEST_IP) !=3D 0) = { > - Matched =3D TRUE; > - > - if (DestIp !=3D NULL) { > - CopyMem (DestIp, &Session->DestinationAddress, sizeof > (EFI_IPv4_ADDRESS)); > - } > - } else { > - if (DestIp !=3D NULL) { > - if (EFI_IP4_EQUAL (DestIp, &Session->DestinationAddress)) { > - Matched =3D TRUE; > - } > - } else { > - if (EFI_IP4_EQUAL (&Private->StationIp, &Session->DestinationA= ddress)) { > - Matched =3D TRUE; > - } > - } > - } > - } > - > - if (Matched) { > - // > - // Match the destination port of the received udp dgram > - // > - if ((OpFlags & EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_DEST_PORT) !=3D 0= ) > { > - > - if (DestPort !=3D NULL) { > - *DestPort =3D Session->DestinationPort; > - } > - } else { > - > - if (*DestPort !=3D Session->DestinationPort) { > - Matched =3D FALSE; > - } > - } > - } > - > - if (Matched) { > - // > - // Match the source ip of the received udp dgram > - // > - if ((OpFlags & EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_SRC_IP) !=3D 0) { > - > - if (SrcIp !=3D NULL) { > - CopyMem (SrcIp, &Session->SourceAddress, sizeof (EFI_IPv4_ADDR= ESS)); > - } > - } else { > - > - if (!EFI_IP4_EQUAL (SrcIp, &Session->SourceAddress)) { > - Matched =3D FALSE; > - } > - } > - } > - > - if (Matched) { > - // > - // Match the source port of the received udp dgram > - // > - if ((OpFlags & EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_SRC_PORT) !=3D 0)= { > - > - if (SrcPort !=3D NULL) { > - *SrcPort =3D Session->SourcePort; > - } > - } else { > - > - if (*SrcPort !=3D Session->SourcePort) { > - Matched =3D FALSE; > - } > - } > - } > - > - if (Matched) { > - ASSERT (RxData !=3D NULL); > - > - HeaderLen =3D 0; > - if (HeaderSize !=3D NULL) { > - HeaderLen =3D MIN (*HeaderSize, RxData->DataLength); > - } > - > - if (RxData->DataLength - HeaderLen > *BufferSize) { > - Status =3D EFI_BUFFER_TOO_SMALL; > - } else { > - *HeaderSize =3D HeaderLen; > - *BufferSize =3D RxData->DataLength - HeaderLen; > - > - HeaderCopiedLen =3D 0; > - BufferCopiedLen =3D 0; > - for (FragmentIndex =3D 0; FragmentIndex < RxData->FragmentCount; > FragmentIndex++) { > - FragmentLength =3D RxData- > >FragmentTable[FragmentIndex].FragmentLength; > - FragmentBuffer =3D RxData- > >FragmentTable[FragmentIndex].FragmentBuffer; > - if (HeaderCopiedLen + FragmentLength < HeaderLen) { > - // > - // Copy the header part of received data. > - // > - CopyMem ((UINT8 *) HeaderPtr + HeaderCopiedLen, FragmentBuff= er, > FragmentLength); > - HeaderCopiedLen +=3D FragmentLength; > - } else if (HeaderCopiedLen < HeaderLen) { > - // > - // Copy the header part of received data. > - // > - CopiedLen =3D HeaderLen - HeaderCopiedLen; > - CopyMem ((UINT8 *) HeaderPtr + HeaderCopiedLen, FragmentBuff= er, > CopiedLen); > - HeaderCopiedLen +=3D CopiedLen; > - > - // > - // Copy the other part of received data. > - // > - CopyMem ((UINT8 *) BufferPtr + BufferCopiedLen, FragmentBuff= er + > CopiedLen, FragmentLength - CopiedLen); > - BufferCopiedLen +=3D (FragmentLength - CopiedLen); > - } else { > - // > - // Copy the other part of received data. > - // > - CopyMem ((UINT8 *) BufferPtr + BufferCopiedLen, FragmentBuff= er, > FragmentLength); > - BufferCopiedLen +=3D FragmentLength; > - } > - } > - } > - } else { > - > - Status =3D 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 softwar= e > 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 U= dpRead(). > - The current hardware filter remains in effect no matter what the setti= ngs 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 (u= nicast), > - 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 s= ettings, > - it will have to preserve the IP receive filter settings before these c= alls, and > - use SetIpFilter() to restore them after the calls. If incompatible fil= tering is > - requested (for example, PROMISCUOUS with anything else) or if the devi= ce > does not > - support a requested filter setting and it cannot be accommodated in so= ftware > - (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_PROTOCO= L > instance. > - @param NewFilter Pointer to the new set of IP receive fil= ters. > - > - @retval EFI_SUCCESS The IP receive filter settings were upda= ted. > - @retval EFI_NOT_STARTED The PXE Base Code Protocol is in the sto= pped > 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 =3D=3D NULL) { > - DEBUG ((EFI_D_ERROR, "This =3D=3D NULL.\n")); > - return EFI_INVALID_PARAMETER; > - } > - > - Private =3D PXEBC_PRIVATE_DATA_FROM_PXEBC (This); > - Mode =3D Private->PxeBc.Mode; > - > - if (NewFilter =3D=3D NULL) { > - DEBUG ((EFI_D_ERROR, "NewFilter =3D=3D 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 =3D FALSE; > - > - for (Index =3D 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) !=3D 0) && > - (EFI_NTOHL(Mode->SubnetMask) !=3D 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_NTOH= L(Mode- > >SubnetMask)) && > - ((NewFilter->Filters & EFI_PXE_BASE_CODE_IP_FILTER_STATION_IP) != =3D 0)) { > - // > - // If EFI_PXE_BASE_CODE_IP_FILTER_STATION_IP is set and IP4 addres= s is in > IpList, > - // promiscuous mode is needed. > - // > - PromiscuousNeed =3D TRUE; > - } > - } > - > - AcceptPromiscuous =3D FALSE; > - AcceptBroadcast =3D FALSE; > - MultiCastUpdate =3D FALSE; > - > - if (PromiscuousNeed || > - ((NewFilter->Filters & EFI_PXE_BASE_CODE_IP_FILTER_PROMISCUOUS) != =3D 0) > || > - ((NewFilter->Filters & > EFI_PXE_BASE_CODE_IP_FILTER_PROMISCUOUS_MULTICAST) !=3D 0) > - ) { > - // > - // Configure the udp4 filter to receive all packages. > - // > - AcceptPromiscuous =3D TRUE; > - } else if ((NewFilter->Filters & > EFI_PXE_BASE_CODE_IP_FILTER_BROADCAST) !=3D 0) { > - // > - // Configure the udp4 filter to receive all broadcast packages. > - // > - AcceptBroadcast =3D TRUE; > - } > - > - // > - // In multicast condition when Promiscuous FALSE and IpCnt no-zero. > - // Here check if there is any update of the multicast ip address. If y= es, > - // we need leave the old multicast group (by Config UDP instance to NU= LL), > - // and join the new multicast group. > - // > - if (!AcceptPromiscuous) { > - if ((NewFilter->Filters & EFI_PXE_BASE_CODE_IP_FILTER_STATION_IP) != =3D 0) { > - if (Mode->IpFilter.IpCnt !=3D NewFilter->IpCnt) { > - MultiCastUpdate =3D TRUE; > - } else if (CompareMem (Mode->IpFilter.IpList, NewFilter->IpList, N= ewFilter- > >IpCnt * sizeof (EFI_IP_ADDRESS)) !=3D 0 ) { > - MultiCastUpdate =3D TRUE; > - } > - } > - } > - > - // > - // Check whether we need reconfigure the UDP instance. > - // > - Udp4Cfg =3D &Private->Udp4CfgData; > - if ((AcceptPromiscuous !=3D Udp4Cfg->AcceptPromiscuous) || > - (AcceptBroadcast !=3D Udp4Cfg->AcceptBroadcast) || MultiCastUp= date) { > - // > - // Clear the UDP instance configuration, all joined groups will be l= eft > - // during the operation. > - // > - Private->Udp4Read->Configure (Private->Udp4Read, NULL); > - > - // > - // Configure the UDP instance with the new configuration. > - // > - Udp4Cfg->AcceptPromiscuous =3D AcceptPromiscuous; > - Udp4Cfg->AcceptBroadcast =3D AcceptBroadcast; > - Status =3D 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 =3D 0; Index < NewFilter->IpCnt; ++Index) { > - if (IP4_IS_MULTICAST (EFI_NTOHL (NewFilter->IpList[Index].v4))) = { > - // > - // Join the mutilcast group. > - // > - Status =3D 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 Usin= gIpv6 > field > - of the EFI_PXE_BASE_CODE_MODE structure is used to determine if IPv4 o= r > IPv6 > - addresses are being used. The IP address specified by IpAddr is used t= o 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_PROTOCO= L > instance. > - @param IpAddr Pointer to the IP address that is used t= o resolve a > MAC address. > - @param MacAddr If not NULL, a pointer to the MAC addres= s 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 sto= pped > 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 pack= et > 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 =3D=3D NULL || IpAddr =3D=3D NULL) { > - return EFI_INVALID_PARAMETER; > - } > - > - Private =3D PXEBC_PRIVATE_DATA_FROM_PXEBC (This); > - Mode =3D 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 =3D 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 =3D Private->Arp->Request (Private->Arp, &IpAddr->v4, NULL, > &TempMacAddr); > - if (EFI_ERROR (Status)) { > - if (Status =3D=3D EFI_ICMP_ERROR) { > - Mode->IcmpErrorReceived =3D TRUE; > - } > - return Status; > - } > - } > - > - if (MacAddr !=3D 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 Bas= e Code > Protocol. > - The parameter specified by NewAutoArp is used to control the generatio= n of > ARP > - protocol packets. If NewAutoArp is TRUE, then ARP Protocol packets wil= l be > generated > - as required by the PXE Base Code Protocol. If NewAutoArp is FALSE, the= n no > ARP > - Protocol packets will be generated. In this case, the only mappings th= at are > - available are those stored in the ArpCache of the EFI_PXE_BASE_CODE_MO= DE > 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_PROTOCO= L > instance. > - @param NewAutoArp If not NULL, a pointer to a value that s= pecifies > whether to replace the > - current value of AutoARP. > - @param NewSendGUID If not NULL, a pointer to a value that s= pecifies > whether to replace the > - current value of SendGUID. > - @param NewTTL If not NULL, a pointer to be used in pla= ce of the > current value of TTL, > - the "time to live" field of the IP heade= r. > - @param NewToS If not NULL, a pointer to be used in pla= ce of the > current value of ToS, > - the "type of service" field of the IP he= ader. > - @param NewMakeCallback If not NULL, a pointer to a value that s= pecifies > 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 sto= pped > 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 =3D EFI_SUCCESS; > - > - if (This =3D=3D NULL) { > - Status =3D EFI_INVALID_PARAMETER; > - goto ON_EXIT; > - } > - > - Private =3D PXEBC_PRIVATE_DATA_FROM_PXEBC (This); > - Mode =3D Private->PxeBc.Mode; > - > - if (NewSendGUID !=3D NULL && *NewSendGUID) { > - // > - // FixMe, cann't locate SendGuid > - // > - } > - > - if (NewMakeCallback !=3D NULL && *NewMakeCallback) { > - > - Status =3D gBS->HandleProtocol ( > - Private->Controller, > - &gEfiPxeBaseCodeCallbackProtocolGuid, > - (VOID **) &Private->PxeBcCallback > - ); > - if (EFI_ERROR (Status) || (Private->PxeBcCallback->Callback =3D=3D N= ULL)) { > - > - Status =3D EFI_INVALID_PARAMETER; > - goto ON_EXIT; > - } > - } > - > - if (!Mode->Started) { > - Status =3D EFI_NOT_STARTED; > - goto ON_EXIT; > - } > - > - if (NewMakeCallback !=3D NULL) { > - > - if (*NewMakeCallback) { > - // > - // Update the Callback protocol. > - // > - Status =3D gBS->HandleProtocol ( > - Private->Controller, > - &gEfiPxeBaseCodeCallbackProtocolGuid, > - (VOID **) &Private->PxeBcCallback > - ); > - > - if (EFI_ERROR (Status) || (Private->PxeBcCallback->Callback =3D=3D= NULL)) { > - Status =3D EFI_INVALID_PARAMETER; > - goto ON_EXIT; > - } > - } else { > - Private->PxeBcCallback =3D NULL; > - } > - > - Mode->MakeCallbacks =3D *NewMakeCallback; > - } > - > - if (NewAutoArp !=3D NULL) { > - Mode->AutoArp =3D *NewAutoArp; > - } > - > - if (NewSendGUID !=3D NULL) { > - Mode->SendGUID =3D *NewSendGUID; > - } > - > - if (NewTTL !=3D NULL) { > - Mode->TTL =3D *NewTTL; > - } > - > - if (NewToS !=3D NULL) { > - Mode->ToS =3D *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 modif= ied. > Otherwise, > - this function updates the StationIp field of the EFI_PXE_BASE_CODE_MOD= E > structure > - with NewStationIp. The NewSubnetMask field is used to modify the netwo= rk > 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_PROTOCO= L > 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 use= d 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 sto= pped > 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 =3D=3D NULL) { > - return EFI_INVALID_PARAMETER; > - } > - > - if (NewSubnetMask !=3D NULL && !IP4_IS_VALID_NETMASK (NTOHL > (NewSubnetMask->Addr[0]))) { > - return EFI_INVALID_PARAMETER; > - } > - > - if (NewStationIp !=3D NULL) { > - if (IP4_IS_UNSPECIFIED(NTOHL (NewStationIp->Addr[0])) || > - IP4_IS_LOCAL_BROADCAST(NTOHL (NewStationIp->Addr[0])) || > - (NewSubnetMask !=3D NULL && NewSubnetMask->Addr[0] !=3D 0 > && !NetIp4IsUnicast (NTOHL (NewStationIp->Addr[0]), NTOHL > (NewSubnetMask->Addr[0])))) { > - return EFI_INVALID_PARAMETER; > - } > - } > - > - Private =3D PXEBC_PRIVATE_DATA_FROM_PXEBC (This); > - Mode =3D Private->PxeBc.Mode; > - > - if (!Mode->Started) { > - return EFI_NOT_STARTED; > - } > - > - if (NewStationIp !=3D NULL) { > - CopyMem (&Mode->StationIp, NewStationIp, sizeof (EFI_IP_ADDRESS)); > - CopyMem (&Private->StationIp, NewStationIp, sizeof (EFI_IP_ADDRESS))= ; > - } > - > - if (NewSubnetMask !=3D NULL) { > - CopyMem (&Mode->SubnetMask, NewSubnetMask, sizeof > (EFI_IP_ADDRESS)); > - CopyMem (&Private->SubnetMask ,NewSubnetMask, sizeof > (EFI_IP_ADDRESS)); > - } > - > - Private->AddressIsOk =3D 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 =3D 0x0800; > - ArpConfigData.SwAddressLength =3D (UINT8) sizeof (EFI_IPv4_ADDRESS); > - ArpConfigData.StationAddress =3D &Private->StationIp.v4; > - > - Private->Arp->Configure (Private->Arp, NULL); > - Private->Arp->Configure (Private->Arp, &ArpConfigData); > - > - // > - // Update the route table. > - // > - Mode->RouteTableEntries =3D 1; > - Mode->RouteTable[0].IpAddr.Addr[0] =3D Private->StationIp.Addr[0= ] & > Private->SubnetMask.Addr[0]; > - Mode->RouteTable[0].SubnetMask.Addr[0] =3D Private->SubnetMask.Addr[= 0]; > - Mode->RouteTable[0].GwAddr.Addr[0] =3D 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_PROTOC= OL > instance. > - @param NewDhcpDiscoverValid Pointer to a value that will replace th= e > current > - DhcpDiscoverValid field. > - @param NewDhcpAckReceived Pointer to a value that will replace th= e > current > - DhcpAckReceived field. > - @param NewProxyOfferReceived Pointer to a value that will replace th= e > current > - ProxyOfferReceived field. > - @param NewPxeDiscoverValid Pointer to a value that will replace th= e > current > - ProxyOfferReceived field. > - @param NewPxeReplyReceived Pointer to a value that will replace th= e > current > - PxeReplyReceived field. > - @param NewPxeBisReplyReceived Pointer to a value that will replace th= e > current > - PxeBisReplyReceived field. > - @param NewDhcpDiscover Pointer to the new cached DHCP Discover > packet contents. > - @param NewDhcpAck Pointer to the new cached DHCP Ack pack= et > contents. > - @param NewProxyOffer Pointer to the new cached Proxy Offer p= acket > contents. > - @param NewPxeDiscover Pointer to the new cached PXE Discover = packet > contents. > - @param NewPxeReply Pointer to the new cached PXE Reply pac= ket > 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 st= opped > 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 =3D=3D NULL) { > - return EFI_INVALID_PARAMETER; > - } > - > - Private =3D PXEBC_PRIVATE_DATA_FROM_PXEBC (This); > - Mode =3D Private->PxeBc.Mode; > - > - if (!Mode->Started) { > - return EFI_NOT_STARTED; > - } > - > - if (NewDhcpDiscoverValid !=3D NULL) { > - Mode->DhcpDiscoverValid =3D *NewDhcpDiscoverValid; > - } > - > - if (NewDhcpAckReceived !=3D NULL) { > - Mode->DhcpAckReceived =3D *NewDhcpAckReceived; > - } > - > - if (NewProxyOfferReceived !=3D NULL) { > - Mode->ProxyOfferReceived =3D *NewProxyOfferReceived; > - } > - > - if (NewPxeDiscoverValid !=3D NULL) { > - Mode->PxeDiscoverValid =3D *NewPxeDiscoverValid; > - } > - > - if (NewPxeReplyReceived !=3D NULL) { > - Mode->PxeReplyReceived =3D *NewPxeReplyReceived; > - } > - > - if (NewPxeBisReplyReceived !=3D NULL) { > - Mode->PxeBisReplyReceived =3D *NewPxeBisReplyReceived; > - } > - > - if (NewDhcpDiscover !=3D NULL) { > - CopyMem (&Mode->DhcpDiscover, NewDhcpDiscover, sizeof > (EFI_PXE_BASE_CODE_PACKET)); > - } > - > - if (NewDhcpAck !=3D NULL) { > - CopyMem (&Mode->DhcpAck, NewDhcpAck, sizeof > (EFI_PXE_BASE_CODE_PACKET)); > - } > - > - if (NewProxyOffer !=3D NULL) { > - CopyMem (&Mode->ProxyOffer, NewProxyOffer, sizeof > (EFI_PXE_BASE_CODE_PACKET)); > - } > - > - if (NewPxeDiscover !=3D NULL) { > - CopyMem (&Mode->PxeDiscover, NewPxeDiscover, sizeof > (EFI_PXE_BASE_CODE_PACKET)); > - } > - > - if (NewPxeReply !=3D NULL) { > - CopyMem (&Mode->PxeReply, NewPxeReply, sizeof > (EFI_PXE_BASE_CODE_PACKET)); > - } > - > - if (NewPxeBisReply !=3D NULL) { > - CopyMem (&Mode->PxeBisReply, NewPxeBisReply, sizeof > (EFI_PXE_BASE_CODE_PACKET)); > - } > - > - return EFI_SUCCESS; > -} > - > -EFI_PXE_BASE_CODE_PROTOCOL mPxeBcProtocolTemplate =3D { > - 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 a= bout to > transmit, has > - received, or is waiting to receive a packet. > - > - This function is invoked when the PXE Base Code Protocol is about to t= ransmit, > has received, > - or is waiting to receive a packet. Parameters Function and Received sp= ecify > 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 du= e to a > receive event. FALSE if > - the callback is being invoked due to a t= ransmit event. > - @param PacketLength The length, in bytes, of Packet. This fi= eld will have > a value of zero if > - this is a wait for receive event. > - @param PacketPtr If Received is TRUE, a pointer to the pa= cket that > was just received; > - otherwise a pointer to the packet that i= s 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 =3D gST->ConIn->ReadKeyStroke (gST->ConIn, &Key); > - > - if (!EFI_ERROR (Status)) { > - > - if (Key.ScanCode =3D=3D SCAN_ESC || Key.UnicodeChar =3D=3D (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 !=3D 0 && PacketPtr !=3D NULL) { > - if (PacketPtr->Raw[0x1C] !=3D 0x00 || PacketPtr->Raw[0x1D] !=3D 0x= 01) { > - 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 !=3D 0 && PacketPtr !=3D NULL) { > - // > - // Print '.' when transmit a packet > - // > - AsciiPrint ("."); > - > - } > - > - return EFI_PXE_BASE_CODE_CALLBACK_STATUS_CONTINUE; > -} > - > -EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL mPxeBcCallBackTemplate =3D { > - 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 =3D &Private->PxeBc; > - Mode =3D PxeBc->Mode; > - Type =3D EFI_PXE_BASE_CODE_BOOT_TYPE_BOOTSTRAP; > - Layer =3D EFI_PXE_BASE_CODE_BOOT_LAYER_INITIAL; > - > - // > - // do DHCP. > - // > - Status =3D PxeBc->Dhcp (PxeBc, TRUE); > - if (EFI_ERROR (Status)) { > - return Status; > - } > - > - // > - // Select a boot server > - // > - Status =3D PxeBcSelectBootPrompt (Private); > - > - if (Status =3D=3D EFI_SUCCESS) { > - Status =3D PxeBcSelectBootMenu (Private, &Type, TRUE); > - } else if (Status =3D=3D EFI_TIMEOUT) { > - Status =3D PxeBcSelectBootMenu (Private, &Type, FALSE); > - } > - > - if (!EFI_ERROR (Status)) { > - > - if (Type =3D=3D EFI_PXE_BASE_CODE_BOOT_TYPE_BOOTSTRAP) { > - // > - // Local boot(PXE bootstrap server) need abort > - // > - return EFI_ABORTED; > - } > - > - UseBis =3D (BOOLEAN) (Mode->BisSupported && Mode->BisDetected); > - Status =3D PxeBc->Discover (PxeBc, Type, &Layer, UseBis, NULL); > - if (EFI_ERROR (Status)) { > - return Status; > - } > - } > - > - *BufferSize =3D 0; > - > - // > - // Get bootfile name and (m)tftp server ip addresss > - // > - if (Mode->PxeReplyReceived) { > - Packet =3D &Private->PxeReply; > - } else if (Mode->ProxyOfferReceived) { > - Packet =3D &Private->ProxyOffer; > - } else { > - Packet =3D &Private->Dhcp4Ack; > - } > - > - // > - // Use siaddr(next server) in DHCPOFFER packet header, if zero, use op= tion > 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] =3D=3D 0) { > - return EFI_DEVICE_ERROR; > - } > - > - ASSERT (Packet->Dhcp4Option[PXEBC_DHCP4_TAG_INDEX_BOOTFILE] !=3D > NULL); > - > - // > - // bootlfile name > - // > - Private->BootFileName =3D (CHAR8 *) (Packet- > >Dhcp4Option[PXEBC_DHCP4_TAG_INDEX_BOOTFILE]->Data); > - > - if (Packet->Dhcp4Option[PXEBC_DHCP4_TAG_INDEX_BOOTFILE_LEN] !=3D 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 =3D NTOHS (Value); > - *BufferSize =3D 512 * Value; > - Status =3D EFI_BUFFER_TOO_SMALL; > - } else { > - // > - // Get the bootfile size from tftp > - // > - Status =3D 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 =3D (UINTN) *BufferSize; > - > - // > - // Display all the information: boot server address, boot file name an= d 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 orig= inates from > the > - boot manager is attempting to load FileP= ath 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 t= o. IF Buffer is > NULL, > - then no the size of the requested file i= s returned in > - BufferSize. > - > - @retval EFI_SUCCESS The file was loaded. > - @retval EFI_UNSUPPORTED The device does not support the pr= ovided > BootPolicy > - @retval EFI_INVALID_PARAMETER FilePath is not a valid device pat= h, 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 d= evice > 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 =3D=3D NULL || !IsDevicePathEnd (FilePath)) { > - return EFI_INVALID_PARAMETER; > - } > - > - Private =3D PXEBC_PRIVATE_DATA_FROM_LOADFILE (This); > - PxeBc =3D &Private->PxeBc; > - NewMakeCallback =3D FALSE; > - Status =3D EFI_DEVICE_ERROR; > - > - if (This =3D=3D NULL || BufferSize =3D=3D NULL) { > - > - return EFI_INVALID_PARAMETER; > - } > - > - // > - // Only support BootPolicy > - // > - if (!BootPolicy) { > - return EFI_UNSUPPORTED; > - } > - > - // > - // Check media status before PXE start > - // > - MediaStatus =3D EFI_SUCCESS; > - NetLibDetectMediaWaitTimeout (Private->Controller, > PXEBC_CHECK_MEDIA_WAITING_TIME, &MediaStatus); > - if (MediaStatus !=3D EFI_SUCCESS) { > - return EFI_NO_MEDIA; > - } > - > - Status =3D PxeBc->Start (PxeBc, FALSE); > - if (EFI_ERROR (Status) && (Status !=3D EFI_ALREADY_STARTED)) { > - return Status; > - } > - > - Status =3D gBS->HandleProtocol ( > - Private->Controller, > - &gEfiPxeBaseCodeCallbackProtocolGuid, > - (VOID **) &Private->PxeBcCallback > - ); > - if (Status =3D=3D EFI_UNSUPPORTED) { > - > - CopyMem (&Private->LoadFileCallback, &mPxeBcCallBackTemplate, sizeof > (Private->LoadFileCallback)); > - > - Status =3D gBS->InstallProtocolInterface ( > - &Private->Controller, > - &gEfiPxeBaseCodeCallbackProtocolGuid, > - EFI_NATIVE_INTERFACE, > - &Private->LoadFileCallback > - ); > - > - NewMakeCallback =3D (BOOLEAN) (Status =3D=3D EFI_SUCCESS); > - > - Status =3D PxeBc->SetParameters (PxeBc, NULL, NULL, NULL, N= ULL, > &NewMakeCallback); > - if (EFI_ERROR (Status)) { > - PxeBc->Stop (PxeBc); > - return Status; > - } > - } > - > - if (Private->FileSize =3D=3D 0) { > - TmpBufSize =3D 0; > - Status =3D DiscoverBootFile (Private, &TmpBufSize, Buffer); > - > - if (sizeof (UINTN) < sizeof (UINT64) && (TmpBufSize > 0xFFFFFFFF)) { > - Status =3D EFI_DEVICE_ERROR; > - } else if (TmpBufSize > 0 && *BufferSize >=3D (UINTN) TmpBufSize && = Buffer !=3D > NULL) { > - AsciiPrint ("\n Downloading NBP file...\n"); > - *BufferSize =3D (UINTN) TmpBufSize; > - Status =3D 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 =3D (UINTN) TmpBufSize; > - Status =3D EFI_BUFFER_TOO_SMALL; > - } > - } else if (Buffer =3D=3D NULL || Private->FileSize > *BufferSize) { > - *BufferSize =3D Private->FileSize; > - Status =3D EFI_BUFFER_TOO_SMALL; > - } else { > - // > - // Download the file. > - // > - AsciiPrint ("\n Downloading NBP file...\n"); > - TmpBufSize =3D (UINT64) (*BufferSize); > - Status =3D 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 =3D FALSE; > - > - PxeBc->SetParameters (PxeBc, NULL, NULL, NULL, NULL, > &NewMakeCallback); > - > - gBS->UninstallProtocolInterface ( > - Private->Controller, > - &gEfiPxeBaseCodeCallbackProtocolGuid, > - &Private->LoadFileCallback > - ); > - } > - > - // > - // Check download status > - // > - if (Status =3D=3D 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 progr= ams > 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 =3D=3D EFI_BUFFER_TOO_SMALL) { > - if (Buffer !=3D NULL) { > - AsciiPrint ("PXE-E05: Download buffer is smaller than requested fi= le.\n"); > - } else { > - // > - // The functionality of PXE Base Code protocol will not be stopped= . > - // > - return Status; > - } > - > - } else if (Status =3D=3D EFI_DEVICE_ERROR) { > - AsciiPrint ("PXE-E07: Network device error.\n"); > - > - } else if (Status =3D=3D EFI_OUT_OF_RESOURCES) { > - AsciiPrint ("PXE-E09: Could not allocate I/O buffers.\n"); > - > - } else if (Status =3D=3D EFI_NO_MEDIA) { > - AsciiPrint ("PXE-E12: Could not detect network connection.\n"); > - > - } else if (Status =3D=3D EFI_NO_RESPONSE) { > - AsciiPrint ("PXE-E16: No offer received.\n"); > - > - } else if (Status =3D=3D EFI_TIMEOUT) { > - AsciiPrint ("PXE-E18: Server response timeout.\n"); > - > - } else if (Status =3D=3D EFI_ABORTED) { > - AsciiPrint ("PXE-E21: Remote boot cancelled.\n"); > - > - } else if (Status =3D=3D EFI_ICMP_ERROR) { > - AsciiPrint ("PXE-E22: Client received ICMP error from server.\n"); > - > - } else if (Status =3D=3D 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 =3D { 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.
> -This program and the accompanying materials > -are licensed and made available under the terms and conditions of the BS= D > License > -which accompanies this distribution. The full text of the license may b= e 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] =3D { > - "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 intercep= t > - 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 =3D (PXEBC_PRIVATE_DATA *) Token->Context; > - Callback =3D Private->PxeBcCallback; > - Status =3D EFI_SUCCESS; > - > - if (Packet->OpCode =3D=3D EFI_MTFTP4_OPCODE_ERROR) { > - Private->Mode.TftpErrorReceived =3D TRUE; > - Private->Mode.TftpError.ErrorCode =3D (UINT8) Packet->Error.ErrorCod= e; > - 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] =3D '\0'; > - } > - > - if (Callback !=3D NULL) { > - > - Status =3D Callback->Callback ( > - Callback, > - Private->Function, > - TRUE, > - PacketLen, > - (EFI_PXE_BASE_CODE_PACKET *) Packet > - ); > - if (Status !=3D EFI_PXE_BASE_CODE_CALLBACK_STATUS_CONTINUE) { > - > - Status =3D EFI_ABORTED; > - } else { > - > - Status =3D 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 dur= ing > 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 =3D 0; > - Status =3D EFI_DEVICE_ERROR; > - Mtftp4 =3D Private->Mtftp4; > - Packet =3D NULL; > - Option =3D NULL; > - PktLen =3D 0; > - OptCnt =3D 1; > - Config->InitialServerPort =3D PXEBC_BS_DOWNLOAD_PORT; > - > - Status =3D Mtftp4->Configure (Mtftp4, Config); > - if (EFI_ERROR (Status)) { > - > - return Status; > - } > - > - ReqOpt[0].OptionStr =3D > (UINT8*)mMtftpOptions[PXE_MTFTP_OPTION_TSIZE_INDEX]; > - UtoA10 (0, (CHAR8 *) OptBuf, PXE_MTFTP_OPTBUF_MAXNUM_INDEX); > - ReqOpt[0].ValueStr =3D OptBuf; > - > - if (BlockSize !=3D NULL) { > - ReqOpt[1].OptionStr =3D > (UINT8*)mMtftpOptions[PXE_MTFTP_OPTION_BLKSIZE_INDEX]; > - ReqOpt[1].ValueStr =3D 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 =3D Mtftp4->GetInfo ( > - Mtftp4, > - NULL, > - Filename, > - NULL, > - (UINT8) OptCnt, > - ReqOpt, > - &PktLen, > - &Packet > - ); > - > - if (EFI_ERROR (Status)) { > - if (Status =3D=3D EFI_TFTP_ERROR) { > - Private->Mode.TftpErrorReceived =3D TRUE; > - Private->Mode.TftpError.ErrorCode =3D (UINT8) Packet->Error.ErrorC= ode; > - 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] =3D '\0'; > - } > - goto ON_ERROR; > - } > - > - OptCnt =3D 0; > - > - Status =3D Mtftp4->ParseOptions ( > - Mtftp4, > - PktLen, > - Packet, > - (UINT32 *) &OptCnt, > - &Option > - ); > - > - if (EFI_ERROR (Status)) { > - > - goto ON_ERROR; > - } > - > - Status =3D EFI_NOT_FOUND; > - > - while (OptCnt !=3D 0) { > - > - if (AsciiStrnCmp ((CHAR8 *) Option[OptCnt - 1].OptionStr, "tsize", 5= ) =3D=3D 0) { > - > - *BufferSize =3D AtoU64 (Option[OptCnt - 1].ValueStr); > - Status =3D EFI_SUCCESS; > - } > - > - OptCnt--; > - } > - > - FreePool (Option); > - > -ON_ERROR: > - > - if (Packet !=3D 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 dur= ing > 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 =3D EFI_DEVICE_ERROR; > - Mtftp4 =3D Private->Mtftp4; > - OptCnt =3D 0; > - Config->InitialServerPort =3D PXEBC_BS_DOWNLOAD_PORT; > - > - Status =3D Mtftp4->Configure (Mtftp4, Config); > - if (EFI_ERROR (Status)) { > - > - return Status; > - } > - > - if (BlockSize !=3D NULL) { > - > - ReqOpt[0].OptionStr =3D (UINT8*) > mMtftpOptions[PXE_MTFTP_OPTION_BLKSIZE_INDEX]; > - ReqOpt[0].ValueStr =3D OptBuf; > - UtoA10 (*BlockSize, (CHAR8 *) ReqOpt[0].ValueStr, > PXE_MTFTP_OPTBUF_MAXNUM_INDEX); > - OptCnt++; > - } > - > - Token.Event =3D NULL; > - Token.OverrideData =3D NULL; > - Token.Filename =3D Filename; > - Token.ModeStr =3D NULL; > - Token.OptionCount =3D OptCnt; > - Token.OptionList =3D ReqOpt; > - Token.Context =3D Private; > - > - if (DontUseBuffer) { > - Token.BufferSize =3D 0; > - Token.Buffer =3D NULL; > - } else { > - Token.BufferSize =3D *BufferSize; > - Token.Buffer =3D BufferPtr; > - } > - > - Token.CheckPacket =3D PxeBcCheckPacket; > - Token.TimeoutCallback =3D NULL; > - Token.PacketNeeded =3D NULL; > - > - Status =3D Mtftp4->ReadFile (Mtftp4, &Token); > - > - *BufferSize =3D 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 fil= e. > - @retval EFI_DEVICE_ERROR The network device encountered an error dur= ing > 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 =3D EFI_DEVICE_ERROR; > - Mtftp4 =3D Private->Mtftp4; > - OptCnt =3D 0; > - Config->InitialServerPort =3D PXEBC_BS_DOWNLOAD_PORT; > - > - Status =3D Mtftp4->Configure (Mtftp4, Config); > - if (EFI_ERROR (Status)) { > - > - return Status; > - } > - > - if (BlockSize !=3D NULL) { > - > - ReqOpt[0].OptionStr =3D (UINT8*) > mMtftpOptions[PXE_MTFTP_OPTION_BLKSIZE_INDEX]; > - ReqOpt[0].ValueStr =3D OptBuf; > - UtoA10 (*BlockSize, (CHAR8 *) ReqOpt[0].ValueStr, > PXE_MTFTP_OPTBUF_MAXNUM_INDEX); > - OptCnt++; > - } > - > - Token.Event =3D NULL; > - Token.OverrideData =3D NULL; > - Token.Filename =3D Filename; > - Token.ModeStr =3D NULL; > - Token.OptionCount =3D OptCnt; > - Token.OptionList =3D ReqOpt; > - Token.BufferSize =3D *BufferSize; > - Token.Buffer =3D BufferPtr; > - Token.CheckPacket =3D PxeBcCheckPacket; > - Token.TimeoutCallback =3D NULL; > - Token.PacketNeeded =3D NULL; > - > - Status =3D Mtftp4->WriteFile (Mtftp4, &Token); > - *BufferSize =3D Token.BufferSize; > - > - Mtftp4->Configure (Mtftp4, NULL); > - > - return Status; > -} > - > - > -/** > - This function is to get data(file) from a directory(may be a server) b= y 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 dire= ctory > success. > - @retval EFI_DEVICE_ERROR The network device encountered an error dur= ing > 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 =3D EFI_DEVICE_ERROR; > - Mtftp4 =3D Private->Mtftp4; > - OptCnt =3D 0; > - Config->InitialServerPort =3D PXEBC_BS_DOWNLOAD_PORT; > - > - Status =3D Mtftp4->Configure (Mtftp4, Config); > - if (EFI_ERROR (Status)) { > - > - return Status; > - } > - > - if (BlockSize !=3D NULL) { > - > - ReqOpt[0].OptionStr =3D (UINT8*) > mMtftpOptions[PXE_MTFTP_OPTION_BLKSIZE_INDEX]; > - ReqOpt[0].ValueStr =3D OptBuf; > - UtoA10 (*BlockSize, (CHAR8 *) ReqOpt[0].ValueStr, > PXE_MTFTP_OPTBUF_MAXNUM_INDEX); > - OptCnt++; > - } > - > - Token.Event =3D NULL; > - Token.OverrideData =3D NULL; > - Token.Filename =3D Filename; > - Token.ModeStr =3D NULL; > - Token.OptionCount =3D OptCnt; > - Token.OptionList =3D ReqOpt; > - Token.Context =3D Private; > - > - if (DontUseBuffer) { > - Token.BufferSize =3D 0; > - Token.Buffer =3D NULL; > - } else { > - Token.BufferSize =3D *BufferSize; > - Token.Buffer =3D BufferPtr; > - } > - > - Token.CheckPacket =3D PxeBcCheckPacket; > - Token.TimeoutCallback =3D NULL; > - Token.PacketNeeded =3D NULL; > - > - Status =3D Mtftp4->ReadDirectory (Mtftp4, &Token); > - > - *BufferSize =3D 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.
> -This program and the accompanying materials > -are licensed and made available under the terms and conditions of the BS= D > License > -which accompanies this distribution. The full text of the license may b= e 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) =3D 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, cha= nged, or > reset successfully. > - @retval EFI_NO_MAPPING When using a default address, configurat= ion > (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 alrea= dy > started/configured > - and must be stopped/reset before it can = be reconfigured. > - @retval EFI_ACCESS_DENIED UdpConfigData. AllowDuplicatePort is FAL= SE > - 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 =3D PXEBC_DEFAULT_LIFETIME; > - Udp4CfgData.TypeOfService =3D ToS; > - Udp4CfgData.TimeToLive =3D Ttl; > - Udp4CfgData.AllowDuplicatePort =3D TRUE; > - > - CopyMem (&Udp4CfgData.StationAddress, StationIp, sizeof (*StationIp)); > - CopyMem (&Udp4CfgData.SubnetMask, SubnetMask, sizeof (*SubnetMask)); > - > - Udp4CfgData.StationPort =3D *SrcPort; > - > - // > - // Reset the instance. > - // > - Udp4->Configure (Udp4, NULL); > - > - Status =3D Udp4->Configure (Udp4, &Udp4CfgData); > - if (!EFI_ERROR (Status) && (Gateway->Addr[0] !=3D 0)) { > - // > - // basic configuration OK, need to add the default route entry > - // > - Status =3D Udp4->Routes (Udp4, FALSE, &mZeroIp4Addr, &mZeroIp4Addr, > Gateway); > - if (EFI_ERROR (Status)) { > - // > - // roll back > - // > - Udp4->Configure (Udp4, NULL); > - } > - } > - > - if (!EFI_ERROR (Status) && (*SrcPort =3D=3D 0)) { > - Udp4->GetModeData (Udp4, &Udp4CfgData, NULL, NULL, NULL); > - *SrcPort =3D 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 =3D 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 Numbe= r. > - @param Length Length of Buffer. > - > -**/ > -VOID > -CvtNum ( > - IN UINTN Number, > - IN UINT8 *Buffer, > - IN UINTN Length > - ) > -{ > - UINTN Remainder; > - > - for (; Length > 0; Length--) { > - Remainder =3D Number % 10; > - Number /=3D 10; > - Buffer[Length - 1] =3D (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 =3D 63; > - TempStr[Index] =3D 0; > - > - do { > - Index--; > - TempStr[Index] =3D (CHAR8) ('0' + (Number % 10)); > - Number =3D Number / 10; > - } while (Number !=3D 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 =3D 0; > - while ((Character =3D *Buffer++) !=3D '\0') { > - Value =3D 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 >=20 > [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.
> -This program and the accompanying materials > -are licensed and made available under the terms and conditions of the BS= D > License > -which accompanies this distribution. The full text of the license may b= e 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 or= der > - > -// > -// 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 p= riority. > -// > -#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_SERV= ERS) | \ > - BIT (PXEBC_VENDOR_TAG_BOOT_MENU= ) | \ > - BIT (PXEBC_VENDOR_TAG_MENU_PROM= PT)) > - > -#define IS_VALID_BOOT_PROMPT(x) \ > - ((((x)[0]) & BIT (PXEBC_VENDOR_TAG_MENU_PROMPT)) =3D=3D BIT > (PXEBC_VENDOR_TAG_MENU_PROMPT)) > - > -#define IS_VALID_BOOT_MENU(x) \ > - ((((x)[0]) & BIT (PXEBC_VENDOR_TAG_BOOT_MENU)) =3D=3D BIT > (PXEBC_VENDOR_TAG_BOOT_MENU)) > - > -#define IS_VALID_MTFTP_VENDOR_OPTION(x) \ > - (((UINT32) ((x)[0]) & MTFTP_VENDOR_OPTION_BIT_MAP) =3D=3D > MTFTP_VENDOR_OPTION_BIT_MAP) > - > -#define IS_VALID_DISCOVER_VENDOR_OPTION(x) (((UINT32) ((x)[0]) & > DISCOVER_VENDOR_OPTION_BIT_MAP) !=3D 0) > - > -#define IS_VALID_CREDENTIAL_VENDOR_OPTION(x) \ > - (((UINT32) ((x)[0]) & BIT (PXEBC_VENDOR_TAG_CREDENTIAL_TYPES)) =3D= =3D 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)) \ > - =3D=3D BIT (PXEBC_VENDOR_TAG_BOOT_ITEM % 32)) > - > -#define IS_DISABLE_BCAST_DISCOVER(x) (((x) & BIT (0)) =3D=3D BIT (0)) > -#define IS_DISABLE_MCAST_DISCOVER(x) (((x) & BIT (1)) =3D=3D BIT (1)) > -#define IS_ENABLE_USE_SERVER_LIST(x) (((x) & BIT (2)) =3D=3D BIT (2)) > -#define IS_DISABLE_PROMPT_MENU(x) (((x) & BIT (3)) =3D=3D BIT (3)) > - > -#define SET_VENDOR_OPTION_BIT_MAP(x, y) (((x)[(y) / 32]) =3D (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)->Ip= Cnt - 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 Px= e > 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 ba= se > 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 s= tructure > - provides advanced control of each state transition of the DHCP process= . The > - returned status code determines the behavior of the EFI DHCPv4 Protoco= l > driver. > - There are three possible returned values, which are described in the f= ollowing > - table. > - > - @param This Pointer to the EFI DHCPv4 Protocol insta= nce that is > used to > - configure this callback function. > - @param Context Pointer to the context that is initializ= ed 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 sta= te, 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 a= bove > 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. T= he EFI > DHCPv4 Protocol > - driver will continue to wait for more DH= CPOFFER 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 Dhcp4InitRebo= ot 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 st= atic. > - @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 exist= s. > - > - @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 f= inish. > - > -**/ > -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.
> -This program and the accompanying materials > -are licensed and made available under the terms and conditions of the BS= D > License > -which accompanies this distribution. The full text of the license may b= e 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 dev= ice > - @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.
> -This program and the accompanying materials > -are licensed and made available under the terms and conditions of the BS= D > License > -which accompanies this distribution. The full text of the license may b= e 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 > - > -#include > -#include > -#include > -#include > -#include > -#include > -#include > -#include > -#include > -#include > -#include > -#include > -#include > - > -#include > -#include > -#include > -#include > -#include > -#include > -#include > -#include > -#include > -#include > -#include > - > -#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 micro= second > -#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 inde= xed by > ServerCount. > - // > - UINT32 ServerCount[DHCP4_PACKET_TYP= E_MAX]; > - UINT32 > OfferIndex[DHCP4_PACKET_TYPE_MAX][PXEBC_MAX_OFFER_NUM]; > - UINT32 BootpIndex; > - UINT32 ProxyIndex[DHCP4_PACKET_TYPE= _MAX]; > - UINT32 BinlIndex[PXEBC_MAX_OFFER_NU= M]; > - > - 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 orig= inates from > the > - boot manager is attempting to load FileP= ath 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 t= o. IF Buffer is > NULL, > - then no the size of the requested file i= s returned in > - BufferSize. > - > - @retval EFI_SUCCESS The file was loaded. > - @retval EFI_UNSUPPORTED The device does not support the pr= ovided > BootPolicy > - @retval EFI_INVALID_PARAMETER FilePath is not a valid device pat= h, 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 d= evice > 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.
> -This program and the accompanying materials > -are licensed and made available under the terms and conditions of the BS= D > License > -which accompanies this distribution. The full text of the license may b= e 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 dur= ing > 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 dur= ing > 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 fil= e. > - @retval EFI_DEVICE_ERROR The network device encountered an error dur= ing > 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) b= y 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 dire= ctory > success. > - @retval EFI_DEVICE_ERROR The network device encountered an error dur= ing > 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.
> -This program and the accompanying materials > -are licensed and made available under the terms and conditions of the BS= D > License > -which accompanies this distribution. The full text of the license may b= e 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, cha= nged, or > reset successfully. > - @retval EFI_NO_MAPPING When using a default address, configurat= ion > (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 alrea= dy > started/configured > - and must be stopped/reset before it can = be reconfigured. > - @retval EFI_ACCESS_DENIED UdpConfigData. AllowDuplicatePort is FAL= SE > - 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 Numbe= r. > - @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 Cod= e > 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 EF= I Load > File > -// Protocol to provide one clean way to otain control from the boot mana= ger if > the > -// boot patch is from the remote device. > -// > -// Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved. > -// > -// This program and the accompanying materials > -// are licensed and made available under the terms and conditions of the= BSD > License > -// which accompanies this distribution. The full text of the license may= be found > at > -// 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 IPv= 4 > 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 t= he > 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. > -// > -// 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 Cod= e > 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 EF= I Load > File > -# Protocol to provide one clean way to otain control from the boot mana= ger 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 NetworkP= kg. > -# 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 i= n > NetworkPkg > -# (e.g. IPv6, MTFTP windowsize). > -# 4) UefiPxeBcDxe driver in NetworkPkg is recommended for use instead o= f this > one even > -# though both of them can be used. > -# > -# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved. > -# This program and the accompanying materials > -# are licensed and made available under the terms and conditions of the= BSD > License > -# which accompanies this distribution. The full text of the license may= be found > at > -# 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 =3D 0x00010005 > - BASE_NAME =3D UefiPxe4BcDxe > - MODULE_UNI_FILE =3D UefiPxe4BcDxe.uni > - FILE_GUID =3D 3B1DEAB5-C75D-442e-9238-8E2FFB62B0B= B > - MODULE_TYPE =3D UEFI_DRIVER > - VERSION_STRING =3D 1.0 > - ENTRY_POINT =3D PxeBcDriverEntryPoint > - UNLOAD_IMAGE =3D NetLibDefaultUnload > - > -# > -# The following information is for reference only and not required by th= e build > tools. > -# > -# VALID_ARCHITECTURES =3D IA32 X64 > -# > -# DRIVER_BINDING =3D gPxeBcDriverBinding > -# COMPONENT_NAME =3D gPxeBcComponentName > -# COMPONENT_NAME2 =3D 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