From f737cfb953905f42f3324e8e53ec324a15314210 Mon Sep 17 00:00:00 2001 From: jgong5 Date: Fri, 6 Feb 2009 05:07:34 +0000 Subject: [PATCH] code scrub for UefiPxeBcDxe. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@7452 6f19259b-4bc3-4df7-8a09-765794883524 --- .../Network/UefiPxeBcDxe/ComponentName.c | 295 +++-- .../Network/UefiPxeBcDxe/Ebc/PxeArch.c | 17 +- .../Network/UefiPxeBcDxe/Ebc/PxeArch.h | 18 +- .../Network/UefiPxeBcDxe/Ia32/PxeArch.h | 12 +- .../Network/UefiPxeBcDxe/Ipf/PxeArch.h | 5 +- .../Network/UefiPxeBcDxe/PxeBcDhcp.c | 227 ++-- .../Network/UefiPxeBcDxe/PxeBcDhcp.h | 224 ++-- .../Network/UefiPxeBcDxe/PxeBcDriver.c | 110 +- .../Network/UefiPxeBcDxe/PxeBcDriver.h | 129 +- .../Network/UefiPxeBcDxe/PxeBcImpl.c | 1106 ++++++++++------- .../Network/UefiPxeBcDxe/PxeBcImpl.h | 47 +- .../Network/UefiPxeBcDxe/PxeBcMtftp.c | 83 +- .../Network/UefiPxeBcDxe/PxeBcMtftp.h | 67 +- .../Network/UefiPxeBcDxe/PxeBcSupport.c | 87 +- .../Network/UefiPxeBcDxe/PxeBcSupport.h | 90 +- .../Network/UefiPxeBcDxe/X64/PxeArch.h | 12 +- MdePkg/Include/Protocol/PxeBaseCode.h | 217 +++- MdePkg/Include/Protocol/PxeBaseCodeCallBack.h | 10 + 18 files changed, 1732 insertions(+), 1024 deletions(-) diff --git a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/ComponentName.c b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/ComponentName.c index 8deac91eab..887b1c3381 100644 --- a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/ComponentName.c +++ b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/ComponentName.c @@ -1,6 +1,6 @@ /** @file -Copyright (c) 2007, Intel Corporation +Copyright (c) 2007, 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 @@ -9,12 +9,6 @@ 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. -Module Name: - ComponentName.c - -Abstract: - - **/ @@ -23,6 +17,45 @@ Abstract: // // EFI Component Name Functions // +/** + Retrieves a Unicode string that is the user readable name of the driver. + + This function retrieves the user readable name of a driver in the form of a + Unicode string. If the driver specified by This has a user readable name in + the language specified by Language, then a pointer to the driver name is + returned in DriverName, and EFI_SUCCESS is returned. If the driver specified + by This does not support the language specified by Language, + then EFI_UNSUPPORTED is returned. + + @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or + EFI_COMPONENT_NAME_PROTOCOL instance. + + @param[in] Language A pointer to a Null-terminated ASCII string + array indicating the language. This is the + language of the driver name that the caller is + requesting, and it must match one of the + languages specified in SupportedLanguages. The + number of languages supported by a driver is up + to the driver writer. Language is specified + in RFC 3066 or ISO 639-2 language code format. + + @param[out] DriverName A pointer to the Unicode string to return. + This Unicode string is the name of the + driver specified by This in the language + specified by Language. + + @retval EFI_SUCCESS The Unicode string for the Driver specified by + This and the language specified by Language was + returned in DriverName. + + @retval EFI_INVALID_PARAMETER Language is NULL. + + @retval EFI_INVALID_PARAMETER DriverName is NULL. + + @retval EFI_UNSUPPORTED The driver specified by This does not support + the language specified by Language. + +**/ EFI_STATUS EFIAPI PxeBcComponentNameGetDriverName ( @@ -31,6 +64,74 @@ PxeBcComponentNameGetDriverName ( OUT CHAR16 **DriverName ); +/** + Retrieves a Unicode string that is the user readable name of the controller + that is being managed by a driver. + + This function retrieves the user readable name of the controller specified by + ControllerHandle and ChildHandle in the form of a Unicode string. If the + driver specified by This has a user readable name in the language specified by + Language, then a pointer to the controller name is returned in ControllerName, + and EFI_SUCCESS is returned. If the driver specified by This is not currently + managing the controller specified by ControllerHandle and ChildHandle, + then EFI_UNSUPPORTED is returned. If the driver specified by This does not + support the language specified by Language, then EFI_UNSUPPORTED is returned. + + @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or + EFI_COMPONENT_NAME_PROTOCOL instance. + + @param[in] ControllerHandle The handle of a controller that the driver + specified by This is managing. This handle + specifies the controller whose name is to be + returned. + + @param[in] ChildHandle The handle of the child controller to retrieve + the name of. This is an optional parameter that + may be NULL. It will be NULL for device + drivers. It will also be NULL for a bus drivers + that wish to retrieve the name of the bus + controller. It will not be NULL for a bus + driver that wishes to retrieve the name of a + child controller. + + @param[in] Language A pointer to a Null-terminated ASCII string + array indicating the language. This is the + language of the driver name that the caller is + requesting, and it must match one of the + languages specified in SupportedLanguages. The + number of languages supported by a driver is up + to the driver writer. Language is specified in + RFC 3066 or ISO 639-2 language code format. + + @param[out] ControllerName A pointer to the Unicode string to return. + This Unicode string is the name of the + controller specified by ControllerHandle and + ChildHandle in the language specified by + Language from the point of view of the driver + specified by This. + + @retval EFI_SUCCESS The Unicode string for the user readable name in + the language specified by Language for the + driver specified by This was returned in + DriverName. + + @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE. + + @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid + EFI_HANDLE. + + @retval EFI_INVALID_PARAMETER Language is NULL. + + @retval EFI_INVALID_PARAMETER ControllerName is NULL. + + @retval EFI_UNSUPPORTED The driver specified by This is not currently + managing the controller specified by + ControllerHandle and ChildHandle. + + @retval EFI_UNSUPPORTED The driver specified by This does not support + the language specified by Language. + +**/ EFI_STATUS EFIAPI PxeBcComponentNameGetControllerName ( @@ -49,6 +150,7 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gPxeBcComponentNam PxeBcComponentNameGetControllerName, "eng" }; + GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gPxeBcComponentName2 = { (EFI_COMPONENT_NAME2_GET_DRIVER_NAME) PxeBcComponentNameGetDriverName, (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) PxeBcComponentNameGetControllerName, @@ -66,6 +168,45 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mPxeBcDriverNameTable[] = } }; +/** + Retrieves a Unicode string that is the user readable name of the driver. + + This function retrieves the user readable name of a driver in the form of a + Unicode string. If the driver specified by This has a user readable name in + the language specified by Language, then a pointer to the driver name is + returned in DriverName, and EFI_SUCCESS is returned. If the driver specified + by This does not support the language specified by Language, + then EFI_UNSUPPORTED is returned. + + @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or + EFI_COMPONENT_NAME_PROTOCOL instance. + + @param[in] Language A pointer to a Null-terminated ASCII string + array indicating the language. This is the + language of the driver name that the caller is + requesting, and it must match one of the + languages specified in SupportedLanguages. The + number of languages supported by a driver is up + to the driver writer. Language is specified + in RFC 3066 or ISO 639-2 language code format. + + @param[out] DriverName A pointer to the Unicode string to return. + This Unicode string is the name of the + driver specified by This in the language + specified by Language. + + @retval EFI_SUCCESS The Unicode string for the Driver specified by + This and the language specified by Language was + returned in DriverName. + + @retval EFI_INVALID_PARAMETER Language is NULL. + + @retval EFI_INVALID_PARAMETER DriverName is NULL. + + @retval EFI_UNSUPPORTED The driver specified by This does not support + the language specified by Language. + +**/ EFI_STATUS EFIAPI PxeBcComponentNameGetDriverName ( @@ -73,32 +214,6 @@ PxeBcComponentNameGetDriverName ( IN CHAR8 *Language, OUT CHAR16 **DriverName ) -/*++ - - Routine Description: - Retrieves a Unicode string that is the user readable name of the EFI Driver. - - Arguments: - This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance. - Language - A pointer to a three character ISO 639-2 language identifier. - This is the language of the driver name that that the caller - is requesting, and it must match one of the languages specified - in SupportedLanguages. The number of languages supported by a - driver is up to the driver writer. - DriverName - A pointer to the Unicode string to return. This Unicode string - is the name of the driver specified by This in the language - specified by Language. - - Returns: - EFI_SUCCESS - The Unicode string for the Driver specified by This - and the language specified by Language was returned - in DriverName. - EFI_INVALID_PARAMETER - Language is NULL. - EFI_INVALID_PARAMETER - DriverName is NULL. - EFI_UNSUPPORTED - The driver specified by This does not support the - language specified by Language. - ---*/ { return LookupUnicodeString2 ( Language, @@ -109,6 +224,74 @@ PxeBcComponentNameGetDriverName ( ); } +/** + Retrieves a Unicode string that is the user readable name of the controller + that is being managed by a driver. + + This function retrieves the user readable name of the controller specified by + ControllerHandle and ChildHandle in the form of a Unicode string. If the + driver specified by This has a user readable name in the language specified by + Language, then a pointer to the controller name is returned in ControllerName, + and EFI_SUCCESS is returned. If the driver specified by This is not currently + managing the controller specified by ControllerHandle and ChildHandle, + then EFI_UNSUPPORTED is returned. If the driver specified by This does not + support the language specified by Language, then EFI_UNSUPPORTED is returned. + + @param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or + EFI_COMPONENT_NAME_PROTOCOL instance. + + @param[in] ControllerHandle The handle of a controller that the driver + specified by This is managing. This handle + specifies the controller whose name is to be + returned. + + @param[in] ChildHandle The handle of the child controller to retrieve + the name of. This is an optional parameter that + may be NULL. It will be NULL for device + drivers. It will also be NULL for a bus drivers + that wish to retrieve the name of the bus + controller. It will not be NULL for a bus + driver that wishes to retrieve the name of a + child controller. + + @param[in] Language A pointer to a Null-terminated ASCII string + array indicating the language. This is the + language of the driver name that the caller is + requesting, and it must match one of the + languages specified in SupportedLanguages. The + number of languages supported by a driver is up + to the driver writer. Language is specified in + RFC 3066 or ISO 639-2 language code format. + + @param[out] ControllerName A pointer to the Unicode string to return. + This Unicode string is the name of the + controller specified by ControllerHandle and + ChildHandle in the language specified by + Language from the point of view of the driver + specified by This. + + @retval EFI_SUCCESS The Unicode string for the user readable name in + the language specified by Language for the + driver specified by This was returned in + DriverName. + + @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE. + + @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid + EFI_HANDLE. + + @retval EFI_INVALID_PARAMETER Language is NULL. + + @retval EFI_INVALID_PARAMETER ControllerName is NULL. + + @retval EFI_UNSUPPORTED The driver specified by This is not currently + managing the controller specified by + ControllerHandle and ChildHandle. + + @retval EFI_UNSUPPORTED The driver specified by This does not support + the language specified by Language. + +**/ EFI_STATUS EFIAPI PxeBcComponentNameGetControllerName ( @@ -116,52 +299,8 @@ PxeBcComponentNameGetControllerName ( IN EFI_HANDLE ControllerHandle, IN EFI_HANDLE ChildHandle OPTIONAL, IN CHAR8 *Language, - OUT CHAR16 **ControllerNameString + OUT CHAR16 **ControllerName ) -/*++ - - Routine Description: - Retrieves a Unicode string that is the user readable name of the controller - that is being managed by an EFI Driver. - - Arguments: - This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance. - ControllerHandle - The handle of a controller that the driver specified by - This is managing. This handle specifies the controller - whose name is to be returned. - ChildHandle - The handle of the child controller to retrieve the name - of. This is an optional parameter that may be NULL. It - will be NULL for device drivers. It will also be NULL - for a bus drivers that wish to retrieve the name of the - bus controller. It will not be NULL for a bus driver - that wishes to retrieve the name of a child controller. - Language - A pointer to a three character ISO 639-2 language - identifier. This is the language of the controller name - that that the caller is requesting, and it must match one - of the languages specified in SupportedLanguages. The - number of languages supported by a driver is up to the - driver writer. - ControllerName - A pointer to the Unicode string to return. This Unicode - string is the name of the controller specified by - ControllerHandle and ChildHandle in the language specified - by Language from the point of view of the driver specified - by This. - - Returns: - EFI_SUCCESS - The Unicode string for the user readable name in the - language specified by Language for the driver - specified by This was returned in DriverName. - EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE. - EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid EFI_HANDLE. - EFI_INVALID_PARAMETER - Language is NULL. - EFI_INVALID_PARAMETER - ControllerName is NULL. - EFI_UNSUPPORTED - The driver specified by This is not currently managing - the controller specified by ControllerHandle and - ChildHandle. - EFI_UNSUPPORTED - The driver specified by This does not support the - language specified by Language. - ---*/ { return EFI_UNSUPPORTED; } diff --git a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/Ebc/PxeArch.c b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/Ebc/PxeArch.c index 026dd249e0..9aa5aa483c 100644 --- a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/Ebc/PxeArch.c +++ b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/Ebc/PxeArch.c @@ -1,6 +1,7 @@ /** @file - -Copyright (c) 2007, Intel Corporation + Defines PXE Arch type. + +Copyright (c) 2007, 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 @@ -9,20 +10,18 @@ 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. -Module Name: - PxeArch.c - -Abstract: - Defines PXE Arch type - - **/ #include "PxeArch.h" UINT16 mSysArch = 0; +/** + Get the system architecture type. + + @return system architecture type. +**/ UINT16 GetSysArch ( VOID diff --git a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/Ebc/PxeArch.h b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/Ebc/PxeArch.h index 89350674b1..9d0b4306dd 100644 --- a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/Ebc/PxeArch.h +++ b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/Ebc/PxeArch.h @@ -1,6 +1,7 @@ /** @file - -Copyright (c) 2007, Intel Corporation + Defines PXE Arch type. + +Copyright (c) 2007, 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 @@ -9,13 +10,6 @@ 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. -Module Name: - PxeArch.h - -Abstract: - Defines PXE Arch type - - **/ #ifndef _EFI_PXE_ARCH_H_ @@ -28,6 +22,12 @@ Abstract: #define SYS_ARCH GetSysArch() +/** + Get the system architecture type. + + @return system architecture type. + +**/ UINT16 GetSysArch ( VOID diff --git a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/Ia32/PxeArch.h b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/Ia32/PxeArch.h index d032f62a91..0d34191b19 100644 --- a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/Ia32/PxeArch.h +++ b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/Ia32/PxeArch.h @@ -1,6 +1,7 @@ /** @file - -Copyright (c) 2006, Intel Corporation + Defines PXE Arch type. + +Copyright (c) 2006, 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 @@ -9,13 +10,6 @@ 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. -Module Name: - PxeArch.h - -Abstract: - Defines PXE Arch type - - **/ #ifndef _EFI_PXE_ARCH_H_ diff --git a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/Ipf/PxeArch.h b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/Ipf/PxeArch.h index 866f486226..4e5c806b7b 100644 --- a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/Ipf/PxeArch.h +++ b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/Ipf/PxeArch.h @@ -1,6 +1,7 @@ /** @file - -Copyright (c) 2006, Intel Corporation + Defines PXE Arch type. + +Copyright (c) 2006, 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 diff --git a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDhcp.c b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDhcp.c index b5ba22f491..db19d15ead 100644 --- a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDhcp.c +++ b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDhcp.c @@ -1,6 +1,7 @@ /** @file - -Copyright (c) 2007 - 2008, Intel Corporation + Support for PxeBc dhcp functions. + +Copyright (c) 2007 - 2008, 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 @@ -9,15 +10,6 @@ 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. -Module Name: - - PxeBcDhcp.c - -Abstract: - - Support for PxeBc dhcp functions - - **/ @@ -38,12 +30,14 @@ UINT8 mInterestedDhcp4Tags[PXEBC_DHCP4_TAG_INDEX_MAX] = { /** - GC_NOTO: Add function description + This function initialize the DHCP4 message instance. - @param Seed GC_NOTO: add argument description - @param Udp4 GC_NOTO: add argument description + 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. - @return GC_NOTO: add return values + @return none. **/ VOID @@ -74,12 +68,12 @@ PxeBcInitSeedPacket ( /** - GC_NOTO: Add function description + Copy the DCHP4 packet from srouce to destination. - @param Dst GC_NOTO: add argument description - @param Src GC_NOTO: add argument description + @param Dst Pointer to the EFI_DHCP4_PROTOCOL instance. + @param Src Pointer to the EFI_DHCP4_PROTOCOL instance. - @return GC_NOTO: add return values + @return None. **/ VOID @@ -96,12 +90,13 @@ PxeBcCopyEfiDhcp4Packet ( /** - GC_NOTO: Add function description + Copy the dhcp4 packet to the PxeBc private data and parse the dhcp4 packet. - @param Private GC_NOTO: add argument description - @param OfferIndex GC_NOTO: add argument description + @param Private Pointer to PxeBc private data. + @param OfferIndex Index of cached packets as complements of pxe mode data, + the index is maximum offer number. - @return GC_NOTO: add return values + @return None. **/ VOID @@ -129,10 +124,10 @@ PxeBcCopyProxyOffer ( /** Parse the cached dhcp packet. - @param CachedPacket Pointer to cached dhcp packet + @param CachedPacket Pointer to cached dhcp packet. - @return TRUE : Success to parse and validation - @return FALSE : Fail to parse or validation + @retval TRUE Succeed to parse and validation. + @retval FALSE Fail to parse or validation. **/ BOOLEAN @@ -256,13 +251,16 @@ PxeBcParseCachedDhcpPacket ( /** - GC_NOTO: Add function description + Offer dhcp service with a BINL dhcp offer. - @param Private GC_NOTO: add argument description - @param Index GC_NOTO: add argument description - - @return GC_NOTO: add return values + @param Private Pointer to PxeBc private data. + @param Index Index of cached packets as complements of pxe mode data, + the index is maximum offer number. + @retval TRUE Offer the service successfully under priority BINL. + @retval FALSE Boot Service failed, parse cached dhcp packet failed or this + BINL ack cannot find options set or bootfile name specified. + **/ BOOLEAN PxeBcTryBinl ( @@ -334,12 +332,13 @@ PxeBcTryBinl ( /** - GC_NOTO: Add function description + Offer dhcp service for each proxy with a BINL dhcp offer. - @param Private GC_NOTO: add argument description - @param OfferIndex GC_NOTO: add argument description + @param Private Pointer to PxeBc private data + @param OfferIndex Pointer to the index of cached packets as complements of + pxe mode data, the index is maximum offer number. - @return GC_NOTO: add return values + @return If there is no service needed offer return FALSE, otherwise TRUE. **/ BOOLEAN @@ -366,11 +365,14 @@ PxeBcTryBinlProxy ( /** - GC_NOTO: Add function description + This function is to check the selected proxy offer (include BINL dhcp offer and + DHCP_ONLY offer ) and set the flag and copy the DHCP packets to the Pxe base code + mode structure. - @param Private GC_NOTO: add argument description + @param Private Pointer to PxeBc private data. - @return GC_NOTO: add return values + @retval EFI_SUCCESS Operational successful. + @retval EFI_NO_RESPONSE Offer dhcp service failed. **/ EFI_STATUS @@ -518,12 +520,12 @@ PxeBcCheckSelectedOffer ( /** - GC_NOTO: Add function description + Cache the Dhcp4 packet offer, Parse and validate each option of the packet. - @param Private GC_NOTO: add argument description - @param RcvdOffer GC_NOTO: add argument description + @param Private Pointer to PxeBc private data. + @param RcvdOffer Pointer to the received Dhcp proxy offer packet. - @return GC_NOTO: add return values + @return None. **/ VOID @@ -608,11 +610,12 @@ PxeBcCacheDhcpOffer ( /** - GC_NOTO: Add function description - - @param Private GC_NOTO: add argument description + 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. - @return GC_NOTO: add return values + @return None **/ VOID @@ -728,17 +731,32 @@ PxeBcSelectOffer ( /** - GC_NOTO: Add function description - - @param This GC_NOTO: add argument description - @param Context GC_NOTO: add argument description - @param CurrentState GC_NOTO: add argument description - @param Dhcp4Event GC_NOTO: add argument description - @param Packet GC_NOTO: add argument description - @param NewPacket GC_NOTO: add argument description - - @retval EFI_SUCCESS GC_NOTO: Add description for return value - @retval EFI_ABORTED GC_NOTO: Add description for return value + Callback routine. + + EFI_DHCP4_CALLBACK is provided by the consumer of the EFI DHCPv4 Protocol driver + to intercept events that occurred in the configuration process. This structure + provides advanced control of each state transition of the DHCP process. The + returned status code determines the behavior of the EFI DHCPv4 Protocol driver. + There are three possible returned values, which are described in the following + table. + + @param This Pointer to the EFI DHCPv4 Protocol instance that is used to + configure this callback function. + @param Context Pointer to the context that is initialized by + EFI_DHCP4_PROTOCOL.Configure(). + @param CurrentState The current operational state of the EFI DHCPv4 Protocol + driver. + @param Dhcp4Event The event that occurs in the current state, which usually means a + state transition. + @param Packet The DHCP packet that is going to be sent or already received. + @param NewPacket The packet that is used to replace the above Packet. + + @retval EFI_SUCCESS Tells the EFI DHCPv4 Protocol driver to continue the DHCP process. + @retval EFI_NOT_READY Only used in the Dhcp4Selecting state. The EFI DHCPv4 Protocol + driver will continue to wait for more DHCPOFFER packets until the retry + timeout expires. + @retval EFI_ABORTED Tells the EFI DHCPv4 Protocol driver to abort the current process and + return to the Dhcp4Init or Dhcp4InitReboot state. **/ EFI_STATUS @@ -878,13 +896,14 @@ PxeBcDhcpCallBack ( /** - GC_NOTO: Add function description + Initialize the DHCP options and build the option list. - @param Private GC_NOTO: add argument description - @param OptList GC_NOTO: add argument description - @param IsDhcpDiscover GC_NOTO: add argument description + @param Private Pointer to PxeBc private data. + @param OptList Pointer to a DHCP option list. + + @param IsDhcpDiscover Discover dhcp option or not. - @return GC_NOTO: add return values + @return The index item number of the option list. **/ UINT32 @@ -1029,20 +1048,23 @@ PxeBcBuildDhcpOptions ( /** - GC_NOTO: Add function description - - @param Private GC_NOTO: add argument description - @param Type GC_NOTO: add argument description - @param Layer GC_NOTO: add argument description - @param UseBis GC_NOTO: add argument description - @param DestIp GC_NOTO: add argument description - @param IpCount GC_NOTO: add argument description - @param SrvList GC_NOTO: add argument description - @param IsDiscv GC_NOTO: add argument description - @param Reply GC_NOTO: add argument description - - @retval EFI_OUT_OF_RESOURCES GC_NOTO: Add description for return value - + Discover the boot of service and initialize the vendor option if exists. + + @param Private Pointer to PxeBc private data. + @param Type PxeBc option boot item type + @param Layer PxeBc option boot item layer + @param UseBis Use BIS or not + @param DestIp Ip address for server + @param IpCount The total count of the server ip address + @param SrvList Server list + @param IsDiscv Discover the vendor or not + @param Reply The dhcp4 packet of Pxe reply + + @retval EFI_SUCCESS Operation succeeds. + @retval EFI_OUT_OF_RESOURCES Allocate memory pool failed. + @retval EFI_NOT_FOUND There is no vendor option exists. + @retval EFI_TIMEOUT Send Pxe Discover time out. + **/ EFI_STATUS PxeBcDiscvBootService ( @@ -1242,13 +1264,14 @@ PxeBcDiscvBootService ( /** - GC_NOTO: Add function description + Parse interested dhcp options. - @param Buffer GC_NOTO: add argument description - @param Length GC_NOTO: add argument description - @param OptTag GC_NOTO: add argument description + @param Buffer Pointer to the dhcp options packet. + @param Length The length of the dhcp options. + @param OptTag The option OpCode. - @return GC_NOTO: add return values + @return NULL if the buffer length is 0 and OpCode is not + PXEBC_DHCP4_TAG_EOP, or the pointer to the buffer. **/ EFI_DHCP4_PACKET_OPTION * @@ -1290,8 +1313,7 @@ PxeBcParseExtendOptions ( @param Dhcp4Option Pointer to dhcp options @param VendorOption Pointer to vendor options - @return TRUE : Valid vendor options - @return FALSE : Invalid vendor options + @return TRUE if valid for vendor options, or FALSE. **/ BOOLEAN @@ -1409,12 +1431,14 @@ PxeBcParseVendorOptions ( /** - GC_NOTO: Add function description + This function display boot item detail. - @param Str GC_NOTO: add argument description - @param Len GC_NOTO: add argument description + If the length of the boot item string over 70 Char, just display 70 Char. + + @param Str Pointer to a string (boot item string). + @param Len The length of string. - @return GC_NOTO: add return values + @return None. **/ VOID @@ -1434,13 +1458,16 @@ PxeBcDisplayBootItem ( /** - GC_NOTO: Add function description - - @param Private GC_NOTO: add argument description + Choose the boot prompt. - @retval EFI_SUCCESS GC_NOTO: Add description for return value - @retval EFI_TIMEOUT GC_NOTO: Add description for return value + @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 ( @@ -1609,13 +1636,15 @@ ON_EXIT: /** - GC_NOTO: Add function description - - @param Private GC_NOTO: add argument description - @param Type GC_NOTO: add argument description + Select the boot menu. - @retval EFI_ABORTED GC_NOTO: Add description for return value - @retval EFI_SUCCESS GC_NOTO: Add description for return value + @param Private Pointer to PxeBc private data. + @param Type The type of the menu. + @param UseDefaultItem Use default item or not. + + @retval EFI_ABORTED User cancel operation. + @retval EFI_SUCCESS Select the boot menu success. + @retval EFI_NOT_READY Read the input key from the keybroad has not finish. **/ EFI_STATUS @@ -1734,7 +1763,7 @@ PxeBcSelectBootMenu ( switch (InputKey.ScanCode) { case SCAN_LEFT: case SCAN_UP: - if (Select) { + if (Select > 0) { --Select; } diff --git a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDhcp.h b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDhcp.h index b3438d0e14..76ebaca143 100644 --- a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDhcp.h +++ b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDhcp.h @@ -1,6 +1,7 @@ /** @file + Dhcp and Discover routines for PxeBc. -Copyright (c) 2007, Intel Corporation +Copyright (c) 2007, 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 @@ -9,21 +10,12 @@ 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. -Module Name: - - PxeBcDhcp.h - -Abstract: - - Dhcp and Discover routines for PxeBc - - **/ #ifndef __EFI_PXEBC_DHCP_H__ #define __EFI_PXEBC_DHCP_H__ -enum { +typedef enum { PXEBC_DHCP4_MAX_OPTION_NUM = 16, PXEBC_DHCP4_MAX_OPTION_SIZE = 312, PXEBC_DHCP4_MAX_PACKET_SIZE = 1472, @@ -105,12 +97,12 @@ enum { PXEBC_DHCP4_OVERLOAD_FILE = 1, PXEBC_DHCP4_OVERLOAD_SERVER_NAME = 2 -}; +} PXEBC_ENUM_TYPES; // // The array index of the DHCP4 option tag interested // -enum { +typedef enum { PXEBC_DHCP4_TAG_INDEX_BOOTFILE_LEN, PXEBC_DHCP4_TAG_INDEX_VENDOR, PXEBC_DHCP4_TAG_INDEX_OVERLOAD, @@ -119,19 +111,19 @@ enum { PXEBC_DHCP4_TAG_INDEX_CLASS_ID, PXEBC_DHCP4_TAG_INDEX_BOOTFILE, PXEBC_DHCP4_TAG_INDEX_MAX -}; +} PXEBC_DHCP4_TAG_INDEX_ENUM_TYPES; // // The type of DHCP OFFER, arranged by priority, PXE10 has the highest priority. // -enum { +typedef enum { DHCP4_PACKET_TYPE_PXE10, DHCP4_PACKET_TYPE_WFM11A, DHCP4_PACKET_TYPE_BINL, DHCP4_PACKET_TYPE_DHCP_ONLY, DHCP4_PACKET_TYPE_MAX, DHCP4_PACKET_TYPE_BOOTP = DHCP4_PACKET_TYPE_MAX -}; +} DHCP4_PACKET_TYPE_ENUM_TYPES; #define BIT(x) (1 << x) #define CTRL(x) (0x1F & (x)) @@ -301,36 +293,33 @@ typedef struct { #define GET_NEXT_BOOT_SVR_ENTRY(Ent) \ (PXEBC_BOOT_SVR_ENTRY *) ((UINT8 *) Ent + sizeof (*(Ent)) + ((Ent)->IpCnt - 1) * sizeof (EFI_IPv4_ADDRESS)) + +/** + This function initialize the DHCP4 message instance. + + This function will pad each item of dhcp4 message packet. + + @param Seed Pointer to the message instance of the DHCP4 packet. + @param Udp4 Pointer to the EFI_UDP4_PROTOCOL instance. + + @return none. + +**/ VOID PxeBcInitSeedPacket ( IN EFI_DHCP4_PACKET *Seed, IN EFI_UDP4_PROTOCOL *Udp4 ) -/*++ - -Routine Description: - - GC_NOTO: Add function description - -Arguments: - - Seed - GC_NOTO: add argument description - Udp4 - GC_NOTO: add argument description - -Returns: - - GC_NOTO: add return values - ---*/ ; /** - GC_NOTO: Add function description + Parse the cached dhcp packet. - @param CachedPacket GC_NOTO: add argument description + @param CachedPacket Pointer to cached dhcp packet. - @return GC_NOTO: add return values + @retval TRUE Success to parse and validation. + @retval FALSE Fail to parse or validation. **/ BOOLEAN @@ -339,13 +328,15 @@ PxeBcParseCachedDhcpPacket ( ) ; - /** - GC_NOTO: Add function description + This function is to check the selected proxy offer(include BINL dhcp offer and + DHCP_ONLY offer ) and set the flag and copy the DHCP packets to the Pxe base code + mode structure. - @param Private GC_NOTO: add argument description + @param Private Pointer to PxeBc private data. - @return GC_NOTO: add return values + @retval EFI_SUCCESS Operational successful. + @retval EFI_NO_RESPONSE Offer dhcp service failed. **/ EFI_STATUS @@ -356,16 +347,32 @@ PxeBcCheckSelectedOffer ( /** - GC_NOTO: Add function description - - @param This GC_NOTO: add argument description - @param Context GC_NOTO: add argument description - @param CurrentState GC_NOTO: add argument description - @param Dhcp4Event GC_NOTO: add argument description - @param Packet GC_NOTO: add argument description - @param NewPacket GC_NOTO: add argument description - - @return GC_NOTO: add return values + Callback routine. + + EFI_DHCP4_CALLBACK is provided by the consumer of the EFI DHCPv4 Protocol driver + to intercept events that occurred in the configuration process. This structure + provides advanced control of each state transition of the DHCP process. The + returned status code determines the behavior of the EFI DHCPv4 Protocol driver. + There are three possible returned values, which are described in the following + table. + + @param This Pointer to the EFI DHCPv4 Protocol instance that is used to + configure this callback function. + @param Context Pointer to the context that is initialized by + EFI_DHCP4_PROTOCOL.Configure(). + @param CurrentState The current operational state of the EFI DHCPv4 Protocol + driver. + @param Dhcp4Event The event that occurs in the current state, which usually means a + state transition. + @param Packet The DHCP packet that is going to be sent or already received. + @param NewPacket The packet that is used to replace the above Packet. + + @retval EFI_SUCCESS Tells the EFI DHCPv4 Protocol driver to continue the DHCP process. + @retval EFI_NOT_READY Only used in the Dhcp4Selecting state. The EFI DHCPv4 Protocol + driver will continue to wait for more DHCPOFFER packets until the retry + timeout expires. + @retval EFI_ABORTED Tells the EFI DHCPv4 Protocol driver to abort the current process and + return to the Dhcp4Init or Dhcp4InitReboot state. **/ EFI_STATUS @@ -381,20 +388,23 @@ PxeBcDhcpCallBack ( /** - GC_NOTO: Add function description - - @param Private GC_NOTO: add argument description - @param Type GC_NOTO: add argument description - @param Layer GC_NOTO: add argument description - @param UseBis GC_NOTO: add argument description - @param DestIp GC_NOTO: add argument description - @param IpCount GC_NOTO: add argument description - @param SrvList GC_NOTO: add argument description - @param IsDiscv GC_NOTO: add argument description - @param Reply GC_NOTO: add argument description - - @return GC_NOTO: add return values - + Discover the boot of service and initialize the vendor option if exists. + + @param Private Pointer to PxeBc private data. + @param Type PxeBc option boot item type + @param Layer PxeBc option boot item layer + @param UseBis use bios or not + @param DestIp ip address for server + @param IpCount the total 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 operational success. + @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 ( @@ -412,13 +422,14 @@ PxeBcDiscvBootService ( /** - GC_NOTO: Add function description + Initialize the DHCP options and build the option list. - @param Private GC_NOTO: add argument description - @param OptList GC_NOTO: add argument description - @param IsDhcpDiscover GC_NOTO: add argument description + @param Private Pointer to PxeBc private data. + @param OptList Pointer to a DHCP option list. + + @param IsDhcpDiscover Discover dhcp option or not. - @return GC_NOTO: add return values + @return The index item number of the option list. **/ UINT32 @@ -431,14 +442,14 @@ PxeBcBuildDhcpOptions ( /** - GC_NOTO: Add function description + Create the boot options - @param OptList GC_NOTO: add argument description - @param Type GC_NOTO: add argument description - @param Layer GC_NOTO: add argument description - @param OptLen GC_NOTO: add argument description + @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 - @return GC_NOTO: add return values + @return None. **/ VOID @@ -452,13 +463,14 @@ PxeBcCreateBootOptions ( /** - GC_NOTO: Add function description + Parse interested dhcp options. - @param Buffer GC_NOTO: add argument description - @param Length GC_NOTO: add argument description - @param OptTag GC_NOTO: add argument description + @param Buffer Pointer to the dhcp options packet. + @param Length the length of the dhcp options. + @param OptTag the option OpCode. - @return GC_NOTO: add return values + @return Return NULL if the buffer length is 0 and OpCode is not + PXEBC_DHCP4_TAG_EOP, or the pointer to the buffer. **/ EFI_DHCP4_PACKET_OPTION * @@ -471,12 +483,12 @@ PxeBcParseExtendOptions ( /** - GC_NOTO: Add function description + This function is to parse and check vendor options. - @param Dhcp4Option GC_NOTO: add argument description - @param VendorOption GC_NOTO: add argument description + @param Dhcp4Option Pointer to dhcp options + @param VendorOption Pointer to vendor options - @return GC_NOTO: add return values + @return Return TRUE if valid for vendor options, or FALSE. **/ BOOLEAN @@ -488,31 +500,16 @@ PxeBcParseVendorOptions ( /** - GC_NOTO: Add function description - - @param Private GC_NOTO: add argument description - @param Info GC_NOTO: add argument description - @param Type GC_NOTO: add argument description - - @return GC_NOTO: add return values - -**/ -EFI_STATUS -PxeBcSelectBootServers ( - IN PXEBC_PRIVATE_DATA *Private, - OUT EFI_PXE_BASE_CODE_DISCOVER_INFO **Info, - OUT UINT16 *Type - ) -; - - -/** - GC_NOTO: Add function description - - @param Private GC_NOTO: add argument description + Choose the boot prompt. - @return GC_NOTO: add return values + @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 ( @@ -522,12 +519,15 @@ PxeBcSelectBootPrompt ( /** - GC_NOTO: Add function description - - @param Private GC_NOTO: add argument description - @param Type GC_NOTO: add argument description - - @return GC_NOTO: add return values + Select the boot menu. + + @param Private Pointer to PxeBc private data. + @param Type The type of the menu. + @param UseDefaultItem Use default item or not. + + @retval EFI_ABORTED User cancel operation. + @retval EFI_SUCCESS Select the boot menu success. + @retval EFI_NOT_READY Read the input key from the keybroad has not finish. **/ EFI_STATUS diff --git a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDriver.c b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDriver.c index e228aca093..f6845bfb35 100644 --- a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDriver.c +++ b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDriver.c @@ -1,6 +1,7 @@ /** @file - -Copyright (c) 2007 - 2008, Intel Corporation + The driver binding for IP4 CONFIG protocol. + +Copyright (c) 2007 - 2008, 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 @@ -9,30 +10,30 @@ 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. -Module Name: - - PxeBcDriver.c - -Abstract: - - The driver binding for IP4 CONFIG protocol. - - **/ #include "PxeBcImpl.h" +EFI_DRIVER_BINDING_PROTOCOL gPxeBcDriverBinding = { + PxeBcDriverBindingSupported, + PxeBcDriverBindingStart, + PxeBcDriverBindingStop, + 0xa, + NULL, + NULL +}; /** - The entry point for PxeBc driver which install the driver - binding and component name protocol on its image. + This is the declaration of an EFI image entry point. This entry point is + the same for UEFI Applications, UEFI OS Loaders, and UEFI Drivers including + both device drivers and bus drivers. - @param ImageHandle The Image handle of the driver - @param SystemTable The system table + @param ImageHandle The firmware allocated handle for the UEFI image. + @param SystemTable A pointer to the EFI System Table. - @return EFI_SUCCESS - @return Others + @retval EFI_SUCCESS The operation completed successfully. + @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources. **/ EFI_STATUS @@ -53,16 +54,22 @@ PxeBcDriverEntryPoint ( /** - Test to see if this driver supports ControllerHandle. - - @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. - - @return EFI_SUCCES - @return EFI_ALREADY_STARTED - @return Others + Test to see if this driver supports ControllerHandle. This service + is called by the EFI boot service ConnectController(). In + order to make drivers as small as possible, there are a few calling + restrictions for this service. ConnectController() must + follow these calling restrictions. If any other agent wishes to call + Supported() it must also follow these calling restrictions. + PxeBc requires DHCP4 and MTFTP4 protocols. + + @param This Protocol instance pointer. + @param ControllerHandle Handle of device to test + @param RemainingDevicePath Optional parameter use to pick a specific child + device to start. + + @retval EFI_SUCCESS This driver supports this device + @retval EFI_ALREADY_STARTED This driver is already running on this device + @retval other This driver does not support this device **/ EFI_STATUS @@ -116,17 +123,21 @@ PxeBcDriverBindingSupported ( /** - Start this driver on ControllerHandle. + 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. - @return EFI_SUCCES - @return EFI_ALREADY_STARTED - @return EFI_OUT_OF_RESOURCES - @return Others + @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 @@ -458,17 +469,21 @@ ON_ERROR: /** - Stop this driver on ControllerHandle. - - @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. - - @return EFI_SUCCESS - @return EFI_DEVICE_ERROR - @return Others + 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 @@ -616,13 +631,4 @@ PxeBcDriverBindingStop ( return Status; } -EFI_DRIVER_BINDING_PROTOCOL gPxeBcDriverBinding = { - PxeBcDriverBindingSupported, - PxeBcDriverBindingStart, - PxeBcDriverBindingStop, - 0xa, - NULL, - NULL -}; - diff --git a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDriver.h b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDriver.h index 8e5bc7dd6d..333dd76870 100644 --- a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDriver.h +++ b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcDriver.h @@ -1,6 +1,6 @@ /** @file -Copyright (c) 2007, Intel Corporation +Copyright (c) 2007, 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 @@ -9,95 +9,94 @@ 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. -Module Name: - - PxeBcDriver.h - -Abstract: - - **/ #ifndef __EFI_PXEBC_DRIVER_H__ #define __EFI_PXEBC_DRIVER_H__ +/** + Test to see if this driver supports ControllerHandle. This service + is called by the EFI boot service ConnectController(). In + order to make drivers as small as possible, there are a few calling + restrictions for this service. ConnectController() must + follow these calling restrictions. If any other agent wishes to call + Supported() it must also follow these calling restrictions. + PxeBc requires DHCP4 and MTFTP4 protocols. + + @param This Protocol instance pointer. + @param ControllerHandle Handle of device to test + @param RemainingDevicePath Optional parameter use to pick a specific child + device to start. + + @retval EFI_SUCCESS This driver supports this device + @retval EFI_ALREADY_STARTED This driver is already running on this device + @retval other This driver does not support this device + +**/ EFI_STATUS +EFIAPI PxeBcDriverBindingSupported ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE Controller, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath - ) -/*++ - - Routine Description: - Test to see if this driver supports ControllerHandle. - - Arguments: - This - Protocol instance pointer. - ControllerHandle - Handle of device to test - RemainingDevicePath - Optional parameter use to pick a specific child - device to start. - - Returns: - EFI_SUCCES - EFI_ALREADY_STARTED - Others - ---*/ -// GC_NOTO: Controller - add argument and description to function comment -; - - + IN EFI_DRIVER_BINDING_PROTOCOL * This, + IN EFI_HANDLE ControllerHandle, + IN EFI_DEVICE_PATH_PROTOCOL * RemainingDevicePath OPTIONAL + ); + /** - Start this driver on ControllerHandle. + 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. - @return EFI_SUCCES - @return EFI_ALREADY_STARTED - @return EFI_OUT_OF_RESOURCES - @return Others + @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 **/ -// GC_NOTO: Controller - add argument and description to function comment EFI_STATUS +EFIAPI PxeBcDriverBindingStart ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE Controller, - IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath - ) -; - - + IN EFI_DRIVER_BINDING_PROTOCOL * This, + IN EFI_HANDLE ControllerHandle, + IN EFI_DEVICE_PATH_PROTOCOL * RemainingDevicePath OPTIONAL + ); + /** - Stop this driver on ControllerHandle. - - @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. - - @return EFI_SUCCESS - @return EFI_DEVICE_ERROR - @return Others + 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 **/ -// GC_NOTO: Controller - add argument and description to function comment EFI_STATUS +EFIAPI PxeBcDriverBindingStop ( - IN EFI_DRIVER_BINDING_PROTOCOL *This, - IN EFI_HANDLE Controller, - IN UINTN NumberOfChildren, - IN EFI_HANDLE *ChildHandleBuffer - ) -; - + 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.c b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.c index 40f7277a67..bed82ae21c 100644 --- a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.c +++ b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.c @@ -1,6 +1,7 @@ /** @file - -Copyright (c) 2007 - 2008, Intel Corporation + Interface routines for PxeBc. + +Copyright (c) 2007 - 2008, 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 @@ -9,27 +10,20 @@ 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. -Module Name: - - PxeBcImpl.c - -Abstract: - - Interface routines for PxeBc - - **/ #include "PxeBcImpl.h" +EFI_LOAD_FILE_PROTOCOL mLoadFileProtocolTemplate = { EfiPxeLoadFile }; + /** - Get and record the arp cache + 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 updating arp cache + @retval others If error occurs when getting arp cache **/ EFI_STATUS @@ -48,29 +42,50 @@ UpdateArpCache ( Private = PXEBC_PRIVATE_DATA_FROM_PXEBC (This); Mode = Private->PxeBc.Mode; - Status = Private->Arp->Find (Private->Arp, TRUE, NULL, &EntryLength, &EntryCount, &Entries, TRUE); + Status = Private->Arp->Find ( + Private->Arp, + TRUE, + NULL, + &EntryLength, + &EntryCount, + &Entries, + TRUE + ); if (EFI_ERROR (Status)) { return Status; } - Mode->ArpCacheEntries = MIN (EntryCount, EFI_PXE_BASE_CODE_MAX_ARP_ENTRIES); + Mode->ArpCacheEntries = MIN ( + EntryCount, + EFI_PXE_BASE_CODE_MAX_ARP_ENTRIES + ); for (Index = 0; Index < Mode->ArpCacheEntries; Index ++) { - CopyMem (&Mode->ArpCache[Index].IpAddr, Entries + 1, Entries->SwAddressLength); - CopyMem (&Mode->ArpCache[Index].MacAddr, (UINT8 *)(Entries + 1) + Entries->SwAddressLength, Entries->HwAddressLength); + CopyMem ( + &Mode->ArpCache[Index].IpAddr, + Entries + 1, + Entries->SwAddressLength + ); + CopyMem ( + &Mode->ArpCache[Index].MacAddr, + (UINT8 *) (Entries + 1) + Entries->SwAddressLength, + Entries->HwAddressLength + ); // // Slip to the next FindData. // - Entries = (EFI_ARP_FIND_DATA *)((UINT8 *)Entries + EntryLength); + Entries = (EFI_ARP_FIND_DATA *) ((UINT8 *) Entries + EntryLength); } return EFI_SUCCESS; } /** - Timeout routine to catch arp cache. + Timeout routine to update arp cache. @param Event Pointer to EFI_PXE_BC_PROTOCOL @param Context Context of the timer event + + @return None. **/ VOID @@ -84,24 +99,33 @@ ArpCacheUpdateTimeout ( } /** - Timeout routine to catch arp cache. - - @param Event Pointer to EFI_PXE_BC_PROTOCOL - @param 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 ( - EFI_PXE_BASE_CODE_MODE *PxeBcMode, - EFI_IPv4_ADDRESS *Ip4Addr, - EFI_MAC_ADDRESS *MacAddress + IN EFI_PXE_BASE_CODE_MODE *PxeBcMode, + IN EFI_IPv4_ADDRESS *Ip4Addr, + OUT EFI_MAC_ADDRESS *MacAddress ) { UINT32 Index; for (Index = 0; Index < PxeBcMode->ArpCacheEntries; Index ++) { if (EFI_IP4_EQUAL (&PxeBcMode->ArpCache[Index].IpAddr.v4, Ip4Addr)) { - CopyMem (MacAddress, &PxeBcMode->ArpCache[Index].MacAddr, sizeof (EFI_MAC_ADDRESS)); + CopyMem ( + MacAddress, + &PxeBcMode->ArpCache[Index].MacAddr, + sizeof (EFI_MAC_ADDRESS) + ); return TRUE; } } @@ -113,7 +137,7 @@ FindInArpCache ( Notify function for the ICMP receive token, used to process the received ICMP packets. - @param Context The context passed in by the event notifier. + @param Context The PXEBC private data. @return None. @@ -139,14 +163,14 @@ IcmpErrorListenHandlerDpc ( RxData = Private->IcmpErrorRcvToken.Packet.RxData; Ip4 = Private->Ip4; - if (EFI_ABORTED == Status) { + if (Status == EFI_ABORTED) { // // The reception is actively aborted by the consumer, directly return. // return; } - if ((EFI_SUCCESS != Status) || (NULL == RxData)) { + if (EFI_ERROR (Status) || (RxData == NULL)) { // // Only process the normal packets and the icmp error packets, if RxData is NULL // with Status == EFI_SUCCESS or EFI_ICMP_ERROR, just resume the receive although @@ -155,8 +179,8 @@ IcmpErrorListenHandlerDpc ( goto Resume; } - if ((EFI_IP4 (RxData->Header->SourceAddress) != 0) && - !Ip4IsUnicast (EFI_NTOHL (RxData->Header->SourceAddress), 0)) { + if (EFI_IP4 (RxData->Header->SourceAddress) != 0 && + !Ip4IsUnicast (EFI_NTOHL (RxData->Header->SourceAddress), 0)) { // // The source address is not zero and it's not a unicast IP address, discard it. // @@ -179,9 +203,17 @@ IcmpErrorListenHandlerDpc ( for (Index = 0; Index < RxData->FragmentCount; Index ++) { CopiedLen += RxData->FragmentTable[Index].FragmentLength; if (CopiedLen <= sizeof (EFI_PXE_BASE_CODE_ICMP_ERROR)) { - CopyMem (CopiedPointer, RxData->FragmentTable[Index].FragmentBuffer, RxData->FragmentTable[Index].FragmentLength); + 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)); + CopyMem ( + CopiedPointer, + RxData->FragmentTable[Index].FragmentBuffer, + CopiedLen - sizeof (EFI_PXE_BASE_CODE_ICMP_ERROR) + ); } CopiedPointer += CopiedLen; } @@ -217,23 +249,69 @@ IcmpErrorListenHandler ( NetLibQueueDpc (TPL_CALLBACK, IcmpErrorListenHandlerDpc, Context); } -/** - GC_NOTO: Add function description - - @param This GC_NOTO: add argument - description - @param UseIpv6 GC_NOTO: add argument - description - - @retval EFI_INVALID_PARAMETER GC_NOTO: Add description for - return value - @retval EFI_ALREADY_STARTED GC_NOTO: Add description for - return value - @retval EFI_UNSUPPORTED GC_NOTO: Add description for - return value - @retval EFI_SUCCESS GC_NOTO: Add description for - return value - +/** + Enables the use of the PXE Base Code Protocol functions. + + This function enables the use of the PXE Base Code Protocol functions. If the + Started field of the EFI_PXE_BASE_CODE_MODE structure is already TRUE, then + EFI_ALREADY_STARTED will be returned. If UseIpv6 is TRUE, then IPv6 formatted + addresses will be used in this session. If UseIpv6 is FALSE, then IPv4 formatted + addresses will be used in this session. If UseIpv6 is TRUE, and the Ipv6Supported + field of the EFI_PXE_BASE_CODE_MODE structure is FALSE, then EFI_UNSUPPORTED will + be returned. If there is not enough memory or other resources to start the PXE + Base Code Protocol, then EFI_OUT_OF_RESOURCES will be returned. Otherwise, the + PXE Base Code Protocol will be started, and all of the fields of the EFI_PXE_BASE_CODE_MODE + structure will be initialized as follows: + StartedSet to TRUE. + Ipv6SupportedUnchanged. + Ipv6AvailableUnchanged. + UsingIpv6Set to UseIpv6. + BisSupportedUnchanged. + BisDetectedUnchanged. + AutoArpSet to TRUE. + SendGUIDSet to FALSE. + TTLSet to DEFAULT_TTL. + ToSSet to DEFAULT_ToS. + DhcpCompletedSet to FALSE. + ProxyOfferReceivedSet to FALSE. + StationIpSet to an address of all zeros. + SubnetMaskSet to a subnet mask of all zeros. + DhcpDiscoverZero-filled. + DhcpAckZero-filled. + ProxyOfferZero-filled. + PxeDiscoverValidSet to FALSE. + PxeDiscoverZero-filled. + PxeReplyValidSet to FALSE. + PxeReplyZero-filled. + PxeBisReplyValidSet to FALSE. + PxeBisReplyZero-filled. + IpFilterSet the Filters field to 0 and the IpCnt field to 0. + ArpCacheEntriesSet to 0. + ArpCacheZero-filled. + RouteTableEntriesSet to 0. + RouteTableZero-filled. + IcmpErrorReceivedSet to FALSE. + IcmpErrorZero-filled. + TftpErroReceivedSet to FALSE. + TftpErrorZero-filled. + MakeCallbacksSet to TRUE if the PXE Base Code Callback Protocol is available. + Set to FALSE if the PXE Base Code Callback Protocol is not available. + + @param This Pointer to the EFI_PXE_BASE_CODE_PROTOCOL instance. + @param UseIpv6 Specifies the type of IP addresses that are to be used during the session + that is being started. Set to TRUE for IPv6 addresses, and FALSE for + IPv4 addresses. + + @retval EFI_SUCCESS The PXE Base Code Protocol was started. + @retval EFI_DEVICE_ERROR The network device encountered an error during this oper + @retval EFI_UNSUPPORTED UseIpv6 is TRUE, but the Ipv6Supported field of the + EFI_PXE_BASE_CODE_MODE structure is FALSE. + @retval EFI_ALREADY_STARTED The PXE Base Code Protocol is already in the started state. + @retval EFI_INVALID_PARAMETER The This parameter is NULL or does not point to a valid + EFI_PXE_BASE_CODE_PROTOCOL structure. + @retval EFI_OUT_OF_RESOURCES Could not allocate enough memory or other resources to start the + PXE Base Code Protocol. + **/ EFI_STATUS EFIAPI @@ -267,7 +345,10 @@ EfiPxeBcStart ( // // Configure the udp4 instance to let it receive data // - Status = Private->Udp4Read->Configure (Private->Udp4Read, &Private->Udp4CfgData); + Status = Private->Udp4Read->Configure ( + Private->Udp4Read, + &Private->Udp4CfgData + ); if (EFI_ERROR (Status)) { return Status; } @@ -356,19 +437,22 @@ ON_EXIT: } -/** - GC_NOTO: Add function description - - @param This GC_NOTO: add argument - description - - @retval EFI_INVALID_PARAMETER GC_NOTO: Add description for - return value - @retval EFI_NOT_STARTED GC_NOTO: Add description for - return value - @retval EFI_SUCCESS GC_NOTO: Add description for - return value - +/** + Disables the use of the PXE Base Code Protocol functions. + + This function stops all activity on the network device. All the resources allocated + in Start() are released, the Started field of the EFI_PXE_BASE_CODE_MODE structure is + set to FALSE and EFI_SUCCESS is returned. If the Started field of the EFI_PXE_BASE_CODE_MODE + structure is already FALSE, then EFI_NOT_STARTED will be returned. + + @param This Pointer to the EFI_PXE_BASE_CODE_PROTOCOL instance. + + @retval EFI_SUCCESS The PXE Base Code Protocol was stopped. + @retval EFI_NOT_STARTED The PXE Base Code Protocol is already in the stopped state. + @retval EFI_INVALID_PARAMETER The This parameter is NULL or does not point to a valid + EFI_PXE_BASE_CODE_PROTOCOL structure. + @retval EFI_DEVICE_ERROR The network device encountered an error during this operation. + **/ EFI_STATUS EFIAPI @@ -429,19 +513,38 @@ EfiPxeBcStop ( } -/** - GC_NOTO: Add function description - - @param This GC_NOTO: add argument - description - @param SortOffers GC_NOTO: add argument - description - - @retval EFI_INVALID_PARAMETER GC_NOTO: Add description for - return value - @retval EFI_NOT_STARTED GC_NOTO: Add description for - return value - +/** + Attempts to complete a DHCPv4 D.O.R.A. (discover / offer / request / acknowledge) or DHCPv6 + S.A.R.R (solicit / advertise / request / reply) sequence. + + This function attempts to complete the DHCP sequence. If this sequence is completed, + then EFI_SUCCESS is returned, and the DhcpCompleted, ProxyOfferReceived, StationIp, + SubnetMask, DhcpDiscover, DhcpAck, and ProxyOffer fields of the EFI_PXE_BASE_CODE_MODE + structure are filled in. + If SortOffers is TRUE, then the cached DHCP offer packets will be sorted before + they are tried. If SortOffers is FALSE, then the cached DHCP offer packets will + be tried in the order in which they are received. Please see the Preboot Execution + Environment (PXE) Specification for additional details on the implementation of DHCP. + This function can take at least 31 seconds to timeout and return control to the + caller. If the DHCP sequence does not complete, then EFI_TIMEOUT will be returned. + If the Callback Protocol does not return EFI_PXE_BASE_CODE_CALLBACK_STATUS_CONTINUE, + then the DHCP sequence will be stopped and EFI_ABORTED will be returned. + + @param This Pointer to the EFI_PXE_BASE_CODE_PROTOCOL instance. + @param SortOffers TRUE if the offers received should be sorted. Set to FALSE to try the + offers in the order that they are received. + + @retval EFI_SUCCESS Valid DHCP has completed. + @retval EFI_NOT_STARTED The PXE Base Code Protocol is in the stopped state. + @retval EFI_INVALID_PARAMETER The This parameter is NULL or does not point to a valid + EFI_PXE_BASE_CODE_PROTOCOL structure. + @retval EFI_DEVICE_ERROR The network device encountered an error during this operation. + @retval EFI_OUT_OF_RESOURCES Could not allocate enough memory to complete the DHCP Protocol. + @retval EFI_ABORTED The callback function aborted the DHCP Protocol. + @retval EFI_TIMEOUT The DHCP Protocol timed out. + @retval EFI_ICMP_ERROR An ICMP error packet was received during the DHCP session. + @retval EFI_NO_RESPONSE Valid PXE offer was not received. + **/ EFI_STATUS EFIAPI @@ -539,9 +642,21 @@ EfiPxeBcDhcp ( ASSERT (Dhcp4Mode.State == Dhcp4Bound); - CopyMem (&Private->StationIp, &Dhcp4Mode.ClientAddress, sizeof (EFI_IPv4_ADDRESS)); - CopyMem (&Private->SubnetMask, &Dhcp4Mode.SubnetMask, sizeof (EFI_IPv4_ADDRESS)); - CopyMem (&Private->GatewayIp, &Dhcp4Mode.RouterAddress, sizeof (EFI_IPv4_ADDRESS)); + CopyMem ( + &Private->StationIp, + &Dhcp4Mode.ClientAddress, + sizeof (EFI_IPv4_ADDRESS) + ); + CopyMem ( + &Private->SubnetMask, + &Dhcp4Mode.SubnetMask, + sizeof (EFI_IPv4_ADDRESS) + ); + CopyMem ( + &Private->GatewayIp, + &Dhcp4Mode.RouterAddress, + sizeof (EFI_IPv4_ADDRESS) + ); // // Check the selected offer to see whether BINL is required, if no or BINL is @@ -603,33 +718,48 @@ EfiPxeBcDhcp ( } -/** - GC_NOTO: Add function description - - @param This GC_NOTO: add argument - description - @param Type GC_NOTO: add argument - description - @param Layer GC_NOTO: add argument - description - @param UseBis GC_NOTO: add argument - description - @param Info GC_NOTO: add argument - description - - @retval EFI_INVALID_PARAMETER GC_NOTO: Add description for - return value - @retval EFI_NOT_STARTED GC_NOTO: Add description for - return value - @retval EFI_INVALID_PARAMETER GC_NOTO: Add description for - return value - @retval EFI_INVALID_PARAMETER GC_NOTO: Add description for - return value - @retval EFI_INVALID_PARAMETER GC_NOTO: Add description for - return value - @retval EFI_INVALID_PARAMETER GC_NOTO: Add description for - return value - +/** + Attempts to complete the PXE Boot Server and/or boot image discovery sequence. + + This function attempts to complete the PXE Boot Server and/or boot image discovery + sequence. If this sequence is completed, then EFI_SUCCESS is returned, and the + PxeDiscoverValid, PxeDiscover, PxeReplyReceived, and PxeReply fields of the + EFI_PXE_BASE_CODE_MODE structure are filled in. If UseBis is TRUE, then the + PxeBisReplyReceived and PxeBisReply fields of the EFI_PXE_BASE_CODE_MODE structure + will also be filled in. If UseBis is FALSE, then PxeBisReplyValid will be set to FALSE. + In the structure referenced by parameter Info, the PXE Boot Server list, SrvList[], + has two uses: It is the Boot Server IP address list used for unicast discovery + (if the UseUCast field is TRUE), and it is the list used for Boot Server verification + (if the MustUseList field is TRUE). Also, if the MustUseList field in that structure + is TRUE and the AcceptAnyResponse field in the SrvList[] array is TRUE, any Boot + Server reply of that type will be accepted. If the AcceptAnyResponse field is + FALSE, only responses from Boot Servers with matching IP addresses will be accepted. + This function can take at least 10 seconds to timeout and return control to the + caller. If the Discovery sequence does not complete, then EFI_TIMEOUT will be + returned. Please see the Preboot Execution Environment (PXE) Specification for + additional details on the implementation of the Discovery sequence. + If the Callback Protocol does not return EFI_PXE_BASE_CODE_CALLBACK_STATUS_CONTINUE, + then the Discovery sequence is stopped and EFI_ABORTED will be returned. + + @param This Pointer to the EFI_PXE_BASE_CODE_PROTOCOL instance. + @param Type The type of bootstrap to perform. + @param Layer Pointer to the boot server layer number to discover, which must be + PXE_BOOT_LAYER_INITIAL when a new server type is being + discovered. + @param UseBis TRUE if Boot Integrity Services are to be used. FALSE otherwise. + @param Info Pointer to a data structure that contains additional information on the + type of discovery operation that is to be performed. + + @retval EFI_SUCCESS The Discovery sequence has been completed. + @retval EFI_NOT_STARTED The PXE Base Code Protocol is in the stopped state. + @retval EFI_INVALID_PARAMETER One or more parameters are invalid. + @retval EFI_DEVICE_ERROR The network device encountered an error during this operation. + @retval EFI_OUT_OF_RESOURCES Could not allocate enough memory to complete Discovery. + @retval EFI_ABORTED The callback function aborted the Discovery sequence. + @retval EFI_TIMEOUT The Discovery sequence timed out. + @retval EFI_ICMP_ERROR An ICMP error packet was received during the PXE discovery + session. + **/ EFI_STATUS EFIAPI @@ -647,7 +777,7 @@ EfiPxeBcDiscover ( EFI_PXE_BASE_CODE_SRVLIST *SrvList; EFI_PXE_BASE_CODE_SRVLIST DefaultSrvList; PXEBC_CACHED_DHCP4_PACKET *Packet; - PXEBC_VENDOR_OPTION *VendorOpt; + PXEBC_VENDOR_OPTION *VendorOpt; UINT16 Index; EFI_STATUS Status; PXEBC_BOOT_SVR_ENTRY *BootSvrEntry; @@ -718,7 +848,11 @@ EfiPxeBcDiscover ( // // Get the multicast discover ip address from vendor option. // - CopyMem (&DefaultInfo.ServerMCastIp.Addr, &VendorOpt->DiscoverMcastIp, sizeof (EFI_IPv4_ADDRESS)); + CopyMem ( + &DefaultInfo.ServerMCastIp.Addr, + &VendorOpt->DiscoverMcastIp, + sizeof (EFI_IPv4_ADDRESS) + ); } DefaultInfo.IpCnt = 0; @@ -777,7 +911,11 @@ EfiPxeBcDiscover ( if (BootSvrEntry == NULL) { Private->ServerIp.Addr[0] = SrvList[Index].IpAddr.Addr[0]; } else { - CopyMem (&Private->ServerIp, &BootSvrEntry->IpAddr[Index], sizeof (EFI_IPv4_ADDRESS)); + CopyMem ( + &Private->ServerIp, + &BootSvrEntry->IpAddr[Index], + sizeof (EFI_IPv4_ADDRESS) + ); } Status = PxeBcDiscvBootService ( @@ -833,40 +971,87 @@ EfiPxeBcDiscover ( } if (Mode->PxeBisReplyReceived) { - CopyMem (&Private->ServerIp, &Mode->PxeReply.Dhcpv4.BootpSiAddr, sizeof (EFI_IPv4_ADDRESS)); + CopyMem ( + &Private->ServerIp, + &Mode->PxeReply.Dhcpv4.BootpSiAddr, + sizeof (EFI_IPv4_ADDRESS) + ); } return Status; } -/** - GC_NOTO: Add function description - - @param This GC_NOTO: add argument - description - @param Operation GC_NOTO: add argument - description - @param BufferPtr GC_NOTO: add argument - description - @param Overwrite GC_NOTO: add argument - description - @param BufferSize GC_NOTO: add argument - description - @param BlockSize GC_NOTO: add argument - description - @param ServerIp GC_NOTO: add argument - description - @param Filename GC_NOTO: add argument - description - @param Info GC_NOTO: add argument - description - @param DontUseBuffer GC_NOTO: add argument - description - - @retval EFI_INVALID_PARAMETER GC_NOTO: Add description for - return value - +/** + Used to perform TFTP and MTFTP services. + + This function is used to perform TFTP and MTFTP services. This includes the + TFTP operations to get the size of a file, read a directory, read a file, and + write a file. It also includes the MTFTP operations to get the size of a file, + read a directory, and read a file. The type of operation is specified by Operation. + If the callback function that is invoked during the TFTP/MTFTP operation does + not return EFI_PXE_BASE_CODE_CALLBACK_STATUS_CONTINUE, then EFI_ABORTED will + be returned. + For read operations, the return data will be placed in the buffer specified by + BufferPtr. If BufferSize is too small to contain the entire downloaded file, + then EFI_BUFFER_TOO_SMALL will be returned and BufferSize will be set to zero + or the size of the requested file (the size of the requested file is only returned + if the TFTP server supports TFTP options). If BufferSize is large enough for the + read operation, then BufferSize will be set to the size of the downloaded file, + and EFI_SUCCESS will be returned. Applications using the PxeBc.Mtftp() services + should use the get-file-size operations to determine the size of the downloaded + file prior to using the read-file operations-especially when downloading large + (greater than 64 MB) files-instead of making two calls to the read-file operation. + Following this recommendation will save time if the file is larger than expected + and the TFTP server does not support TFTP option extensions. Without TFTP option + extension support, the client has to download the entire file, counting and discarding + the received packets, to determine the file size. + For write operations, the data to be sent is in the buffer specified by BufferPtr. + BufferSize specifies the number of bytes to send. If the write operation completes + successfully, then EFI_SUCCESS will be returned. + For TFTP "get file size" operations, the size of the requested file or directory + is returned in BufferSize, and EFI_SUCCESS will be returned. If the TFTP server + does not support options, the file will be downloaded into a bit bucket and the + length of the downloaded file will be returned. For MTFTP "get file size" operations, + if the MTFTP server does not support the "get file size" option, EFI_UNSUPPORTED + will be returned. + This function can take up to 10 seconds to timeout and return control to the caller. + If the TFTP sequence does not complete, EFI_TIMEOUT will be returned. + If the Callback Protocol does not return EFI_PXE_BASE_CODE_CALLBACK_STATUS_CONTINUE, + then the TFTP sequence is stopped and EFI_ABORTED will be returned. + The format of the data returned from a TFTP read directory operation is a null-terminated + filename followed by a null-terminated information string, of the form + "size year-month-day hour:minute:second" (i.e. %d %d-%d-%d %d:%d:%f - note that + the seconds field can be a decimal number), where the date and time are UTC. For + an MTFTP read directory command, there is additionally a null-terminated multicast + IP address preceding the filename of the form %d.%d.%d.%d for IP v4. The final + entry is itself null-terminated, so that the final information string is terminated + with two null octets. + + @param This Pointer to the EFI_PXE_BASE_CODE_PROTOCOL instance. + @param Operation The type of operation to perform. + @param BufferPtr A pointer to the data buffer. + @param Overwrite Only used on write file operations. TRUE if a file on a remote server can + be overwritten. + @param BufferSize For get-file-size operations, *BufferSize returns the size of the + requested file. + @param BlockSize The requested block size to be used during a TFTP transfer. + @param ServerIp The TFTP / MTFTP server IP address. + @param Filename A Null-terminated ASCII string that specifies a directory name or a file + name. + @param Info Pointer to the MTFTP information. + @param DontUseBuffer Set to FALSE for normal TFTP and MTFTP read file operation. + + @retval EFI_SUCCESS The TFTP/MTFTP operation was completed. + @retval EFI_NOT_STARTED The PXE Base Code Protocol is in the stopped state. + @retval EFI_INVALID_PARAMETER One or more parameters are invalid. + @retval EFI_DEVICE_ERROR The network device encountered an error during this operation. + @retval EFI_BUFFER_TOO_SMALL The buffer is not large enough to complete the read operation. + @retval EFI_ABORTED The callback function aborted the TFTP/MTFTP operation. + @retval EFI_TIMEOUT The TFTP/MTFTP operation timed out. + @retval EFI_ICMP_ERROR An ICMP error packet was received during the MTFTP session. + @retval EFI_TFTP_ERROR A TFTP error packet was received during the MTFTP session. + **/ EFI_STATUS EFIAPI @@ -889,11 +1074,11 @@ EfiPxeBcMtftp ( EFI_PXE_BASE_CODE_MODE *Mode; EFI_MAC_ADDRESS TempMacAddr; - if ((This == NULL) || - (Filename == NULL) || - (BufferSize == NULL) || + if ((This == NULL) || + (Filename == NULL) || + (BufferSize == NULL) || ((ServerIp == NULL) || !Ip4IsUnicast (NTOHL (ServerIp->Addr[0]), 0)) || - ((BufferPtr == NULL) && DontUseBuffer) || + ((BufferPtr == NULL) && DontUseBuffer) || ((BlockSize != NULL) && (*BlockSize < 512))) { return EFI_INVALID_PARAMETER; @@ -920,10 +1105,26 @@ EfiPxeBcMtftp ( Mtftp4Config.TimeoutValue = PXEBC_MTFTP_TIMEOUT; Mtftp4Config.TryCount = PXEBC_MTFTP_RETRIES; - CopyMem (&Mtftp4Config.StationIp, &Private->StationIp, sizeof (EFI_IPv4_ADDRESS)); - CopyMem (&Mtftp4Config.SubnetMask, &Private->SubnetMask, sizeof (EFI_IPv4_ADDRESS)); - CopyMem (&Mtftp4Config.GatewayIp, &Private->GatewayIp, sizeof (EFI_IPv4_ADDRESS)); - CopyMem (&Mtftp4Config.ServerIp, ServerIp, sizeof (EFI_IPv4_ADDRESS)); + 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) { @@ -1005,43 +1206,42 @@ EfiPxeBcMtftp ( } -/** - GC_NOTO: Add function description - - @param This GC_NOTO: add argument - description - @param OpFlags GC_NOTO: add argument - description - @param DestIp GC_NOTO: add argument - description - @param DestPort GC_NOTO: add argument - description - @param GatewayIp GC_NOTO: add argument - description - @param SrcIp GC_NOTO: add argument - description - @param SrcPort GC_NOTO: add argument - description - @param HeaderSize GC_NOTO: add argument - description - @param HeaderPtr GC_NOTO: add argument - description - @param BufferSize GC_NOTO: add argument - description - @param BufferPtr GC_NOTO: add argument - description - - @retval EFI_INVALID_PARAMETER GC_NOTO: Add description for - return value - @retval EFI_INVALID_PARAMETER GC_NOTO: Add description for - return value - @retval EFI_INVALID_PARAMETER GC_NOTO: Add description for - return value - @retval EFI_INVALID_PARAMETER GC_NOTO: Add description for - return value - @retval EFI_OUT_OF_RESOURCES GC_NOTO: Add description for - return value - +/** + Writes a UDP packet to the network interface. + + This function writes a UDP packet specified by the (optional HeaderPtr and) + BufferPtr parameters to the network interface. The UDP header is automatically + built by this routine. It uses the parameters OpFlags, DestIp, DestPort, GatewayIp, + SrcIp, and SrcPort to build this header. If the packet is successfully built and + transmitted through the network interface, then EFI_SUCCESS will be returned. + If a timeout occurs during the transmission of the packet, then EFI_TIMEOUT will + be returned. If an ICMP error occurs during the transmission of the packet, then + the IcmpErrorReceived field is set to TRUE, the IcmpError field is filled in and + EFI_ICMP_ERROR will be returned. If the Callback Protocol does not return + EFI_PXE_BASE_CODE_CALLBACK_STATUS_CONTINUE, then EFI_ABORTED will be returned. + + @param This Pointer to the EFI_PXE_BASE_CODE_PROTOCOL instance. + @param OpFlags The UDP operation flags. + @param DestIp The destination IP address. + @param DestPort The destination UDP port number. + @param GatewayIp The gateway IP address. + @param SrcIp The source IP address. + @param SrcPort The source UDP port number. + @param HeaderSize An optional field which may be set to the length of a header at + HeaderPtr to be prefixed to the data at BufferPtr. + @param HeaderPtr If HeaderSize is not NULL, a pointer to a header to be prefixed to the + data at BufferPtr. + @param BufferSize A pointer to the size of the data at BufferPtr. + @param BufferPtr A pointer to the data to be written. + + @retval EFI_SUCCESS The UDP Write operation was completed. + @retval EFI_NOT_STARTED The PXE Base Code Protocol is in the stopped state. + @retval EFI_INVALID_PARAMETER One or more parameters are invalid. + @retval EFI_BAD_BUFFER_SIZE The buffer is too long to be transmitted. + @retval EFI_ABORTED The callback function aborted the UDP Write operation. + @retval EFI_TIMEOUT The UDP Write operation timed out. + @retval EFI_ICMP_ERROR An ICMP error packet was received during the UDP write session. + **/ EFI_STATUS EFIAPI @@ -1120,7 +1320,7 @@ EfiPxeBcUdpWrite ( Mode->IcmpErrorReceived = FALSE; if ((Private->CurrentUdpSrcPort == 0) || - ((SrcPort != NULL) && (*SrcPort != Private->CurrentUdpSrcPort))) { + ((SrcPort != NULL) && (*SrcPort != Private->CurrentUdpSrcPort))) { // // Port is changed, (re)configure the Udp4Write instance // @@ -1216,28 +1416,27 @@ ON_EXIT: } /** - Validate IP packages by IP filter settings - - @param PxeBcMode Pointer to EFI_PXEBC_MODE - - @param Session Received UDP session + Decide whether the incoming UDP packet is acceptable per IP filter settings + in provided PxeBcMode. - @retval TRUE The UDP package matches IP filters + @param PxeBcMode Pointer to EFI_PXE_BASE_CODE_MODE. + @param Session Received UDP session. - @retval FLASE The UDP package doesn't matches IP filters + @retval TRUE The UDP package matches IP filters. + @retval FALSE The UDP package doesn't matches IP filters. **/ BOOLEAN CheckIpByFilter ( - EFI_PXE_BASE_CODE_MODE *PxeBcMode, - EFI_UDP4_SESSION_DATA *Session + 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) { + if ((PxeBcMode->IpFilter.Filters & EFI_PXE_BASE_CODE_IP_FILTER_PROMISCUOUS) != 0) { return TRUE; } @@ -1261,8 +1460,12 @@ CheckIpByFilter ( return TRUE; } - for (Index = 0; Index < PxeBcMode->IpFilter.IpCnt; ++Index) { - CopyMem (&Ip4Address, &PxeBcMode->IpFilter.IpList[Index].v4, sizeof (Ip4Address)); + for (Index = 0; Index < PxeBcMode->IpFilter.IpCnt; Index++) { + CopyMem ( + &Ip4Address, + &PxeBcMode->IpFilter.IpList[Index].v4, + sizeof (Ip4Address) + ); if (EFI_IP4_EQUAL (&Ip4Address, &DestIp4Address)) { return TRUE; } @@ -1271,57 +1474,56 @@ CheckIpByFilter ( return FALSE; } -/** - GC_NOTO: Add function description - - @param This GC_NOTO: add argument - description - @param OpFlags GC_NOTO: add argument - description - @param DestIp GC_NOTO: add argument - description - @param DestPort GC_NOTO: add argument - description - @param SrcIp GC_NOTO: add argument - description - @param SrcPort GC_NOTO: add argument - description - @param HeaderSize GC_NOTO: add argument - description - @param HeaderPtr GC_NOTO: add argument - description - @param BufferSize GC_NOTO: add argument - description - @param BufferPtr GC_NOTO: add argument - description - - @retval EFI_INVALID_PARAMETER GC_NOTO: Add description for - return value - @retval EFI_INVALID_PARAMETER GC_NOTO: Add description for - return value - @retval EFI_INVALID_PARAMETER GC_NOTO: Add description for - return value - @retval EFI_INVALID_PARAMETER GC_NOTO: Add description for - return value - @retval EFI_NOT_STARTED GC_NOTO: Add description for - return value - @retval EFI_OUT_OF_RESOURCES GC_NOTO: Add description for - return value - +/** + Reads a UDP packet from the network interface. + + This function reads a UDP packet from a network interface. The data contents + are returned in (the optional HeaderPtr and) BufferPtr, and the size of the + buffer received is returned in BufferSize . If the input BufferSize is smaller + than the UDP packet received (less optional HeaderSize), it will be set to the + required size, and EFI_BUFFER_TOO_SMALL will be returned. In this case, the + contents of BufferPtr are undefined, and the packet is lost. If a UDP packet is + successfully received, then EFI_SUCCESS will be returned, and the information + from the UDP header will be returned in DestIp, DestPort, SrcIp, and SrcPort if + they are not NULL. Depending on the values of OpFlags and the DestIp, DestPort, + SrcIp, and SrcPort input values, different types of UDP packet receive filtering + will be performed. The following tables summarize these receive filter operations. + + @param This Pointer to the EFI_PXE_BASE_CODE_PROTOCOL instance. + @param OpFlags The UDP operation flags. + @param DestIp The destination IP address. + @param DestPort The destination UDP port number. + @param SrcIp The source IP address. + @param SrcPort The source UDP port number. + @param HeaderSize An optional field which may be set to the length of a header at + HeaderPtr to be prefixed to the data at BufferPtr. + @param HeaderPtr If HeaderSize is not NULL, a pointer to a header to be prefixed to the + data at BufferPtr. + @param BufferSize A pointer to the size of the data at BufferPtr. + @param BufferPtr A pointer to the data to be read. + + @retval EFI_SUCCESS The UDP Read operation was completed. + @retval EFI_NOT_STARTED The PXE Base Code Protocol is in the stopped state. + @retval EFI_INVALID_PARAMETER One or more parameters are invalid. + @retval EFI_DEVICE_ERROR The network device encountered an error during this operation. + @retval EFI_BUFFER_TOO_SMALL The packet is larger than Buffer can hold. + @retval EFI_ABORTED The callback function aborted the UDP Read operation. + @retval EFI_TIMEOUT The UDP Read operation timed out. + **/ EFI_STATUS EFIAPI EfiPxeBcUdpRead ( - IN EFI_PXE_BASE_CODE_PROTOCOL *This, - IN UINT16 OpFlags, - IN OUT EFI_IP_ADDRESS *DestIp, OPTIONAL - IN OUT EFI_PXE_BASE_CODE_UDP_PORT *DestPort, OPTIONAL - IN OUT EFI_IP_ADDRESS *SrcIp, OPTIONAL - IN OUT EFI_PXE_BASE_CODE_UDP_PORT *SrcPort, OPTIONAL - IN UINTN *HeaderSize, OPTIONAL - IN VOID *HeaderPtr, OPTIONAL - IN OUT UINTN *BufferSize, - IN VOID *BufferPtr + 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; @@ -1339,9 +1541,9 @@ EfiPxeBcUdpRead ( return EFI_INVALID_PARAMETER; } - if ((!(OpFlags & EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_DEST_PORT) && (DestPort == NULL)) || - (!(OpFlags & EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_DEST_PORT) && (SrcIp == NULL)) || - (!(OpFlags & EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_SRC_PORT) && (SrcPort == NULL))) { + if (((OpFlags & EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_DEST_PORT) == 0 && (DestPort == NULL)) || + ((OpFlags & EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_DEST_PORT) == 0 && (SrcIp == NULL)) || + ((OpFlags & EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_SRC_PORT) == 0 && (SrcPort == NULL))) { return EFI_INVALID_PARAMETER; } @@ -1403,7 +1605,7 @@ TRY_AGAIN: Matched = FALSE; - if (OpFlags & EFI_PXE_BASE_CODE_UDP_OPFLAGS_USE_FILTER) { + if ((OpFlags & EFI_PXE_BASE_CODE_UDP_OPFLAGS_USE_FILTER) != 0) { // // Check UDP package by IP filter settings // @@ -1418,7 +1620,7 @@ TRY_AGAIN: // // Match the destination ip of the received udp dgram // - if (OpFlags & EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_DEST_IP) { + if ((OpFlags & EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_DEST_IP) != 0) { Matched = TRUE; if (DestIp != NULL) { @@ -1441,7 +1643,7 @@ TRY_AGAIN: // // Match the destination port of the received udp dgram // - if (OpFlags & EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_DEST_PORT) { + if ((OpFlags & EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_DEST_PORT) != 0) { if (DestPort != NULL) { *DestPort = Session->DestinationPort; @@ -1458,7 +1660,7 @@ TRY_AGAIN: // // Match the source ip of the received udp dgram // - if (OpFlags & EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_SRC_IP) { + if ((OpFlags & EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_SRC_IP) != 0) { if (SrcIp != NULL) { CopyMem (SrcIp, &Session->SourceAddress, sizeof (EFI_IPv4_ADDRESS)); @@ -1475,7 +1677,7 @@ TRY_AGAIN: // // Match the source port of the received udp dgram // - if (OpFlags & EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_SRC_PORT) { + if ((OpFlags & EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_SRC_PORT) != 0) { if (SrcPort != NULL) { *SrcPort = Session->SourcePort; @@ -1504,7 +1706,11 @@ TRY_AGAIN: } else { *BufferSize = RxData->DataLength - CopyLen; - CopyMem (BufferPtr, (UINT8 *) RxData->FragmentTable[0].FragmentBuffer + CopyLen, *BufferSize); + CopyMem ( + BufferPtr, + (UINT8 *) RxData->FragmentTable[0].FragmentBuffer + CopyLen, + *BufferSize + ); } } else { @@ -1530,18 +1736,37 @@ ON_EXIT: return Status; } - -/** - GC_NOTO: Add function description - - @param This GC_NOTO: add argument - description - @param NewFilter GC_NOTO: add argument - description - - @retval EFI_UNSUPPORTED GC_NOTO: Add description for - return value - +/** + Updates the IP receive filters of a network device and enables software filtering. + + The NewFilter field is used to modify the network device's current IP receive + filter settings and to enable a software filter. This function updates the IpFilter + field of the EFI_PXE_BASE_CODE_MODE structure with the contents of NewIpFilter. + The software filter is used when the USE_FILTER in OpFlags is set to UdpRead(). + The current hardware filter remains in effect no matter what the settings of OpFlags + are, so that the meaning of ANY_DEST_IP set in OpFlags to UdpRead() is from those + packets whose reception is enabled in hardware-physical NIC address (unicast), + broadcast address, logical address or addresses (multicast), or all (promiscuous). + UdpRead() does not modify the IP filter settings. + Dhcp(), Discover(), and Mtftp() set the IP filter, and return with the IP receive + filter list emptied and the filter set to EFI_PXE_BASE_CODE_IP_FILTER_STATION_IP. + If an application or driver wishes to preserve the IP receive filter settings, + it will have to preserve the IP receive filter settings before these calls, and + use SetIpFilter() to restore them after the calls. If incompatible filtering is + requested (for example, PROMISCUOUS with anything else) or if the device does not + support a requested filter setting and it cannot be accommodated in software + (for example, PROMISCUOUS not supported), EFI_INVALID_PARAMETER will be returned. + The IPlist field is used to enable IPs other than the StationIP. They may be + multicast or unicast. If IPcnt is set as well as EFI_PXE_BASE_CODE_IP_FILTER_STATION_IP, + then both the StationIP and the IPs from the IPlist will be used. + + @param This Pointer to the EFI_PXE_BASE_CODE_PROTOCOL instance. + @param NewFilter Pointer to the new set of IP receive filters. + + @retval EFI_SUCCESS The IP receive filter settings were updated. + @retval EFI_NOT_STARTED The PXE Base Code Protocol is in the stopped state. + @retval EFI_INVALID_PARAMETER One or more parameters are invalid. + **/ EFI_STATUS EFIAPI @@ -1667,19 +1892,32 @@ EfiPxeBcSetIpFilter ( } -/** - GC_NOTO: Add function description - - @param This GC_NOTO: add argument - description - @param IpAddr GC_NOTO: add argument - description - @param MacAddr GC_NOTO: add argument - description - - @retval EFI_UNSUPPORTED GC_NOTO: Add description for - return value - +/** + Uses the ARP protocol to resolve a MAC address. + + This function uses the ARP protocol to resolve a MAC address. The UsingIpv6 field + of the EFI_PXE_BASE_CODE_MODE structure is used to determine if IPv4 or IPv6 + addresses are being used. The IP address specified by IpAddr is used to resolve + a MAC address. If the ARP protocol succeeds in resolving the specified address, + then the ArpCacheEntries and ArpCache fields of the EFI_PXE_BASE_CODE_MODE structure + are updated, and EFI_SUCCESS is returned. If MacAddr is not NULL, the resolved + MAC address is placed there as well. If the PXE Base Code protocol is in the + stopped state, then EFI_NOT_STARTED is returned. If the ARP protocol encounters + a timeout condition while attempting to resolve an address, then EFI_TIMEOUT is + returned. If the Callback Protocol does not return EFI_PXE_BASE_CODE_CALLBACK_STATUS_CONTINUE, + then EFI_ABORTED is returned. + + @param This Pointer to the EFI_PXE_BASE_CODE_PROTOCOL instance. + @param IpAddr Pointer to the IP address that is used to resolve a MAC address. + @param MacAddr If not NULL, a pointer to the MAC address that was resolved with the + ARP protocol. + + @retval EFI_SUCCESS The IP or MAC address was resolved. + @retval EFI_NOT_STARTED The PXE Base Code Protocol is in the stopped state. + @retval EFI_INVALID_PARAMETER One or more parameters are invalid. + @retval EFI_DEVICE_ERROR The network device encountered an error during this operation. + @retval EFI_ICMP_ERROR Something error occur with the ICMP packet message. + **/ EFI_STATUS EFIAPI @@ -1740,35 +1978,46 @@ EfiPxeBcArp ( return EFI_SUCCESS; } - - -/** - GC_NOTO: Add function description - - @param This GC_NOTO: add argument - description - @param NewAutoArp GC_NOTO: add argument - description - @param NewSendGUID GC_NOTO: add argument - description - @param NewTTL GC_NOTO: add argument - description - @param NewToS GC_NOTO: add argument - description - @param NewMakeCallback GC_NOTO: add argument - description - - @return GC_NOTO: add return values - +/** + Updates the parameters that affect the operation of the PXE Base Code Protocol. + + This function sets parameters that affect the operation of the PXE Base Code Protocol. + The parameter specified by NewAutoArp is used to control the generation of ARP + protocol packets. If NewAutoArp is TRUE, then ARP Protocol packets will be generated + as required by the PXE Base Code Protocol. If NewAutoArp is FALSE, then no ARP + Protocol packets will be generated. In this case, the only mappings that are + available are those stored in the ArpCache of the EFI_PXE_BASE_CODE_MODE structure. + If there are not enough mappings in the ArpCache to perform a PXE Base Code Protocol + service, then the service will fail. This function updates the AutoArp field of + the EFI_PXE_BASE_CODE_MODE structure to NewAutoArp. + The SetParameters() call must be invoked after a Callback Protocol is installed + to enable the use of callbacks. + + @param This Pointer to the EFI_PXE_BASE_CODE_PROTOCOL instance. + @param NewAutoArp If not NULL, a pointer to a value that specifies whether to replace the + current value of AutoARP. + @param NewSendGUID If not NULL, a pointer to a value that specifies whether to replace the + current value of SendGUID. + @param NewTTL If not NULL, a pointer to be used in place of the current value of TTL, + the "time to live" field of the IP header. + @param NewToS If not NULL, a pointer to be used in place of the current value of ToS, + the "type of service" field of the IP header. + @param NewMakeCallback If not NULL, a pointer to a value that specifies whether to replace the + current value of the MakeCallback field of the Mode structure. + + @retval EFI_SUCCESS The new parameters values were updated. + @retval EFI_NOT_STARTED The PXE Base Code Protocol is in the stopped state. + @retval EFI_INVALID_PARAMETER One or more parameters are invalid. + **/ EFI_STATUS EFIAPI EfiPxeBcSetParameters ( IN EFI_PXE_BASE_CODE_PROTOCOL *This, - IN BOOLEAN *NewAutoArp, OPTIONAL - IN BOOLEAN *NewSendGUID, OPTIONAL - IN UINT8 *NewTTL, OPTIONAL - IN UINT8 *NewToS, OPTIONAL + IN BOOLEAN *NewAutoArp OPTIONAL, + IN BOOLEAN *NewSendGUID OPTIONAL, + IN UINT8 *NewTTL OPTIONAL, + IN UINT8 *NewToS OPTIONAL, IN BOOLEAN *NewMakeCallback // OPTIONAL ) { @@ -1786,13 +2035,13 @@ EfiPxeBcSetParameters ( Private = PXEBC_PRIVATE_DATA_FROM_PXEBC (This); Mode = Private->PxeBc.Mode; - if (NewSendGUID != NULL && *NewSendGUID == TRUE) { + if (NewSendGUID != NULL && *NewSendGUID) { // // FixMe, cann't locate SendGuid // } - if (NewMakeCallback != NULL && *NewMakeCallback == TRUE) { + if (NewMakeCallback != NULL && *NewMakeCallback) { Status = gBS->HandleProtocol ( Private->Controller, @@ -1854,34 +2103,32 @@ ON_EXIT: return Status; } - -/** - GC_NOTO: Add function description - - @param This GC_NOTO: add argument - description - @param NewStationIp GC_NOTO: add argument - description - @param NewSubnetMask GC_NOTO: add argument - description - - @retval EFI_INVALID_PARAMETER GC_NOTO: Add description for - return value - @retval EFI_INVALID_PARAMETER GC_NOTO: Add description for - return value - @retval EFI_INVALID_PARAMETER GC_NOTO: Add description for - return value - @retval EFI_NOT_STARTED GC_NOTO: Add description for - return value - @retval EFI_SUCCESS GC_NOTO: Add description for - return value - +/** + Updates the station IP address and/or subnet mask values of a network device. + + This function updates the station IP address and/or subnet mask values of a network + device. The NewStationIp field is used to modify the network device's current IP address. + If NewStationIP is NULL, then the current IP address will not be modified. Otherwise, + this function updates the StationIp field of the EFI_PXE_BASE_CODE_MODE structure + with NewStationIp. The NewSubnetMask field is used to modify the network device's current subnet + mask. If NewSubnetMask is NULL, then the current subnet mask will not be modified. + Otherwise, this function updates the SubnetMask field of the EFI_PXE_BASE_CODE_MODE + structure with NewSubnetMask. + + @param This Pointer to the EFI_PXE_BASE_CODE_PROTOCOL instance. + @param NewStationIp Pointer to the new IP address to be used by the network device. + @param NewSubnetMask Pointer to the new subnet mask to be used by the network device. + + @retval EFI_SUCCESS The new station IP address and/or subnet mask were updated. + @retval EFI_NOT_STARTED The PXE Base Code Protocol is in the stopped state. + @retval EFI_INVALID_PARAMETER One or more parameters are invalid. + **/ EFI_STATUS EFIAPI EfiPxeBcSetStationIP ( IN EFI_PXE_BASE_CODE_PROTOCOL * This, - IN EFI_IP_ADDRESS * NewStationIp, OPTIONAL + IN EFI_IP_ADDRESS * NewStationIp OPTIONAL, IN EFI_IP_ADDRESS * NewSubnetMask OPTIONAL ) { @@ -1946,60 +2193,52 @@ EfiPxeBcSetStationIP ( return EFI_SUCCESS; } - -/** - GC_NOTO: Add function description - - @param This GC_NOTO: add argument - description - @param NewDhcpDiscoverValid GC_NOTO: add argument - description - @param NewDhcpAckReceived GC_NOTO: add argument - description - @param NewProxyOfferReceived GC_NOTO: add argument - description - @param NewPxeDiscoverValid GC_NOTO: add argument - description - @param NewPxeReplyReceived GC_NOTO: add argument - description - @param NewPxeBisReplyReceived GC_NOTO: add argument - description - @param NewDhcpDiscover GC_NOTO: add argument - description - @param NewDhcpAck GC_NOTO: add argument - description - @param NewProxyOffer GC_NOTO: add argument - description - @param NewPxeDiscover GC_NOTO: add argument - description - @param NewPxeReply GC_NOTO: add argument - description - @param NewPxeBisReply GC_NOTO: add argument - description - - @retval EFI_INVALID_PARAMETER GC_NOTO: Add description for - return value - @retval EFI_NOT_STARTED GC_NOTO: Add description for - return value - @retval EFI_SUCCESS GC_NOTO: Add description for - return value - +/** + Updates the contents of the cached DHCP and Discover packets. + + The pointers to the new packets are used to update the contents of the cached + packets in the EFI_PXE_BASE_CODE_MODE structure. + + @param This Pointer to the EFI_PXE_BASE_CODE_PROTOCOL instance. + @param NewDhcpDiscoverValid Pointer to a value that will replace the current + DhcpDiscoverValid field. + @param NewDhcpAckReceived Pointer to a value that will replace the current + DhcpAckReceived field. + @param NewProxyOfferReceived Pointer to a value that will replace the current + ProxyOfferReceived field. + @param NewPxeDiscoverValid Pointer to a value that will replace the current + ProxyOfferReceived field. + @param NewPxeReplyReceived Pointer to a value that will replace the current + PxeReplyReceived field. + @param NewPxeBisReplyReceived Pointer to a value that will replace the current + PxeBisReplyReceived field. + @param NewDhcpDiscover Pointer to the new cached DHCP Discover packet contents. + @param NewDhcpAck Pointer to the new cached DHCP Ack packet contents. + @param NewProxyOffer Pointer to the new cached Proxy Offer packet contents. + @param NewPxeDiscover Pointer to the new cached PXE Discover packet contents. + @param NewPxeReply Pointer to the new cached PXE Reply packet contents. + @param NewPxeBisReply Pointer to the new cached PXE BIS Reply packet contents. + + @retval EFI_SUCCESS The cached packet contents were updated. + @retval EFI_NOT_STARTED The PXE Base Code Protocol is in the stopped state. + @retval EFI_INVALID_PARAMETER This is NULL or not point to a valid EFI_PXE_BASE_CODE_PROTOCOL structure. + **/ EFI_STATUS EFIAPI EfiPxeBcSetPackets ( IN EFI_PXE_BASE_CODE_PROTOCOL * This, - IN BOOLEAN * NewDhcpDiscoverValid, OPTIONAL - IN BOOLEAN * NewDhcpAckReceived, OPTIONAL - IN BOOLEAN * NewProxyOfferReceived, OPTIONAL - IN BOOLEAN * NewPxeDiscoverValid, OPTIONAL - IN BOOLEAN * NewPxeReplyReceived, OPTIONAL - IN BOOLEAN * NewPxeBisReplyReceived, OPTIONAL - IN EFI_PXE_BASE_CODE_PACKET * NewDhcpDiscover, OPTIONAL - IN EFI_PXE_BASE_CODE_PACKET * NewDhcpAck, OPTIONAL - IN EFI_PXE_BASE_CODE_PACKET * NewProxyOffer, OPTIONAL - IN EFI_PXE_BASE_CODE_PACKET * NewPxeDiscover, OPTIONAL - IN EFI_PXE_BASE_CODE_PACKET * NewPxeReply, OPTIONAL + IN 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 ) { @@ -2087,32 +2326,32 @@ EFI_PXE_BASE_CODE_PROTOCOL mPxeBcProtocolTemplate = { NULL }; - -/** - GC_NOTO: Add function description - - @param This GC_NOTO: add argument - description - @param Function GC_NOTO: add argument - description - @param Received GC_NOTO: add argument - description - @param PacketLength GC_NOTO: add argument - description - @param PacketPtr GC_NOTO: add argument - description - - @retval EFI_PXE_BASE_CODE_CALLBACK_STATUS_ABORT GC_NOTO: Add description for - return value - @retval EFI_PXE_BASE_CODE_CALLBACK_STATUS_CONTINUE GC_NOTO: Add description for - return value - @retval EFI_PXE_BASE_CODE_CALLBACK_STATUS_CONTINUE GC_NOTO: Add description for - return value - @retval EFI_PXE_BASE_CODE_CALLBACK_STATUS_CONTINUE GC_NOTO: Add description for - return value - @retval EFI_PXE_BASE_CODE_CALLBACK_STATUS_CONTINUE GC_NOTO: Add description for - return value - +/** + Callback function that is invoked when the PXE Base Code Protocol is about to transmit, has + received, or is waiting to receive a packet. + + This function is invoked when the PXE Base Code Protocol is about to transmit, has received, + or is waiting to receive a packet. Parameters Function and Received specify the type of event. + Parameters PacketLen and Packet specify the packet that generated the event. If these fields + are zero and NULL respectively, then this is a status update callback. If the operation specified + by Function is to continue, then CALLBACK_STATUS_CONTINUE should be returned. If the operation + specified by Function should be aborted, then CALLBACK_STATUS_ABORT should be returned. Due to + the polling nature of UEFI device drivers, a callback function should not execute for more than 5 ms. + The SetParameters() function must be called after a Callback Protocol is installed to enable the + use of callbacks. + + @param This Pointer to the EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL instance. + @param Function The PXE Base Code Protocol function that is waiting for an event. + @param Received TRUE if the callback is being invoked due to a receive event. FALSE if + the callback is being invoked due to a transmit event. + @param PacketLength The length, in bytes, of Packet. This field will have a value of zero if + this is a wait for receive event. + @param PacketPtr If Received is TRUE, a pointer to the packet that was just received; + otherwise a pointer to the packet that is about to be transmitted. + + @retval EFI_PXE_BASE_CODE_CALLBACK_STATUS_CONTINUE if Function specifies a continue operation + @retval EFI_PXE_BASE_CODE_CALLBACK_STATUS_ABORT if Function specifies an abort operation + **/ EFI_PXE_BASE_CODE_CALLBACK_STATUS EFIAPI @@ -2187,17 +2426,17 @@ EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL mPxeBcCallBackTemplate = { /** - GC_NOTO: Add function description - - @param Private GC_NOTO: add argument - description - @param BufferSize GC_NOTO: add argument - description - @param Buffer GC_NOTO: add argument - description + Find the boot file. - @return GC_NOTO: add return values + @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 ( @@ -2320,25 +2559,32 @@ DiscoverBootFile ( return Status; } - /** - GC_NOTO: Add function description - - @param This GC_NOTO: add argument - description - @param FilePath GC_NOTO: add argument - description - @param BootPolicy GC_NOTO: add argument - description - @param BufferSize GC_NOTO: add argument - description - @param Buffer GC_NOTO: add argument - description - - @retval EFI_INVALID_PARAMETER GC_NOTO: Add description for - return value - @retval EFI_UNSUPPORTED GC_NOTO: Add description for - return value + Causes the driver to load a specified file. + + @param This Protocol instance pointer. + @param FilePath The device specific path of the file to load. + @param BootPolicy If TRUE, indicates that the request originates from the + boot manager is attempting to load FilePath as a boot + selection. If FALSE, then FilePath must match as exact file + to be loaded. + @param BufferSize On input the size of Buffer in bytes. On output with a return + code of EFI_SUCCESS, the amount of data transferred to + Buffer. On output with a return code of EFI_BUFFER_TOO_SMALL, + the size of Buffer required to retrieve the requested file. + @param Buffer The memory buffer to transfer the file to. IF Buffer is NULL, + then no the size of the requested file is returned in + BufferSize. + + @retval EFI_SUCCESS The file was loaded. + @retval EFI_UNSUPPORTED The device does not support the provided BootPolicy + @retval EFI_INVALID_PARAMETER FilePath is not a valid device path, or + BufferSize is NULL. + @retval EFI_NO_MEDIA No medium was present to load the file. + @retval EFI_DEVICE_ERROR The file was not loaded due to a device error. + @retval EFI_NO_RESPONSE The remote system did not respond. + @retval EFI_NOT_FOUND The file was not found. + @retval EFI_ABORTED The file load process was manually cancelled. **/ EFI_STATUS @@ -2498,5 +2744,3 @@ EfiPxeLoadFile ( return Status; } -EFI_LOAD_FILE_PROTOCOL mLoadFileProtocolTemplate = { EfiPxeLoadFile }; - diff --git a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.h b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.h index 075a19617a..0a65f1383a 100644 --- a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.h +++ b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcImpl.h @@ -1,6 +1,6 @@ /** @file -Copyright (c) 2007 - 2008, Intel Corporation +Copyright (c) 2007 - 2008, 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 @@ -9,13 +9,6 @@ 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. -Module Name: - - PxeBcImpl.h - -Abstract: - - **/ #ifndef __EFI_PXEBC_IMPL_H__ @@ -143,4 +136,42 @@ struct _PXEBC_PRIVATE_DATA { extern EFI_PXE_BASE_CODE_PROTOCOL mPxeBcProtocolTemplate; extern EFI_LOAD_FILE_PROTOCOL mLoadFileProtocolTemplate; +/** + Causes the driver to load a specified file. + + @param This Protocol instance pointer. + @param FilePath The device specific path of the file to load. + @param BootPolicy If TRUE, indicates that the request originates from the + boot manager is attempting to load FilePath as a boot + selection. If FALSE, then FilePath must match as exact file + to be loaded. + @param BufferSize On input the size of Buffer in bytes. On output with a return + code of EFI_SUCCESS, the amount of data transferred to + Buffer. On output with a return code of EFI_BUFFER_TOO_SMALL, + the size of Buffer required to retrieve the requested file. + @param Buffer The memory buffer to transfer the file to. IF Buffer is NULL, + then no the size of the requested file is returned in + BufferSize. + + @retval EFI_SUCCESS The file was loaded. + @retval EFI_UNSUPPORTED The device does not support the provided BootPolicy + @retval EFI_INVALID_PARAMETER FilePath is not a valid device path, or + BufferSize is NULL. + @retval EFI_NO_MEDIA No medium was present to load the file. + @retval EFI_DEVICE_ERROR The file was not loaded due to a device error. + @retval EFI_NO_RESPONSE The remote system did not respond. + @retval EFI_NOT_FOUND The file was not found. + @retval EFI_ABORTED The file load process was manually cancelled. + +**/ +EFI_STATUS +EFIAPI +EfiPxeLoadFile ( + IN EFI_LOAD_FILE_PROTOCOL * This, + IN EFI_DEVICE_PATH_PROTOCOL * FilePath, + IN BOOLEAN BootPolicy, + IN OUT UINTN *BufferSize, + IN VOID *Buffer OPTIONAL + ); + #endif diff --git a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcMtftp.c b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcMtftp.c index b49ff2d52c..928b99a820 100644 --- a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcMtftp.c +++ b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcMtftp.c @@ -1,6 +1,7 @@ /** @file - -Copyright (c) 2007, Intel Corporation + PxeBc MTFTP functions. + +Copyright (c) 2007, 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 @@ -9,15 +10,6 @@ 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. -Module Name: - - PxeBcMtftp.c - -Abstract: - - PxeBc MTFTP functions - - **/ #include "PxeBcImpl.h" @@ -35,13 +27,19 @@ CHAR8 *mMtftpOptions[PXE_MTFTP_OPTION_MAXIMUM_INDEX] = { /** This is a callback function when packets received/transmitted in Mtftp driver. + A callback function that is provided by the caller to intercept + the EFI_MTFTP4_OPCODE_DATA or EFI_MTFTP4_OPCODE_DATA8 packets processed in the + EFI_MTFTP4_PROTOCOL.ReadFile() function, and alternatively to intercept + EFI_MTFTP4_OPCODE_OACK or EFI_MTFTP4_OPCODE_ERROR packets during a call to + EFI_MTFTP4_PROTOCOL.ReadFile(), WriteFile() or ReadDirectory(). + @param This Pointer to Mtftp protocol instance @param Token Pointer to Mtftp token @param PacketLen Length of Mtftp packet @param Packet Pointer to Mtftp packet - @return EFI_SUCCESS - @return EFI_ABORTED + @retval EFI_SUCCESS Operation sucess + @retval EFI_ABORTED Abort transfer process **/ EFI_STATUS @@ -90,17 +88,18 @@ PxeBcCheckPacket ( /** 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 - @return EFI_SUCCESS - @return EFI_NOT_FOUND - @return EFI_DEVICE_ERROR - + @retval EFI_SUCCESS Get the size of file success + @retval EFI_NOT_FOUND Parse the tftp ptions failed. + @retval EFI_DEVICE_ERROR The network device encountered an error during this operation. + @retval Other Has not get the size of the file. + **/ EFI_STATUS PxeBcTftpGetFileSize ( @@ -161,7 +160,11 @@ PxeBcTftpGetFileSize ( if (Packet->OpCode == EFI_MTFTP4_OPCODE_ERROR) { Private->Mode.TftpErrorReceived = TRUE; Private->Mode.TftpError.ErrorCode = (UINT8) Packet->Error.ErrorCode; - AsciiStrnCpy (Private->Mode.TftpError.ErrorString, (CHAR8 *) Packet->Error.ErrorMessage, 127); + AsciiStrnCpy ( + Private->Mode.TftpError.ErrorString, + (CHAR8 *) Packet->Error.ErrorMessage, + 127 + ); } goto ON_ERROR; } @@ -219,9 +222,10 @@ ON_ERROR: @param BufferSize Pointer to buffer size @param DontUseBuffer Indicate whether with a receive buffer - @return EFI_SUCCESS - @return EFI_DEVICE_ERROR - + @retval EFI_SUCCESS Read the data success from the special file. + @retval EFI_DEVICE_ERROR The network device encountered an error during this operation. + @retval other Read data from file failed. + **/ EFI_STATUS PxeBcTftpReadFile ( @@ -301,9 +305,10 @@ PxeBcTftpReadFile ( @param BufferPtr Pointer to buffer @param BufferSize Pointer to buffer size - @return EFI_SUCCESS - @return EFI_DEVICE_ERROR - + @retval EFI_SUCCESS Write the data success into the special file. + @retval EFI_DEVICE_ERROR The network device encountered an error during this operation. + @retval other Write data into file failed. + **/ EFI_STATUS PxeBcTftpWriteFile ( @@ -364,21 +369,21 @@ PxeBcTftpWriteFile ( /** - This function is to get data of a directory 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 - - @return EFI_SUCCES - @return EFI_DEVICE_ERROR - + This function is to get data(file) from a directory(may be a server) by Tftp. + + @param Private Pointer to PxeBc private data. + @param Config Pointer to Mtftp configuration data. + @param Filename Pointer to file name. + @param BlockSize Pointer to block size. + @param BufferPtr Pointer to buffer. + @param BufferSize Pointer to buffer size. + @param DontUseBuffer Indicate whether with a receive buffer. + + @retval EFI_SUCCES Get the data from the file included in directory success. + @retval EFI_DEVICE_ERROR The network device encountered an error during this operation. + @retval other Operation failed. + **/ -// GC_NOTO: EFI_SUCCESS - add return value to function comment EFI_STATUS PxeBcTftpReadDirectory ( IN PXEBC_PRIVATE_DATA *Private, diff --git a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcMtftp.h b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcMtftp.h index 85598cb6ab..8c2ce37e1e 100644 --- a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcMtftp.h +++ b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcMtftp.h @@ -1,6 +1,7 @@ /** @file - -Copyright (c) 2007, Intel Corporation + Mtftp routines for PxeBc. + +Copyright (c) 2007, 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 @@ -9,42 +10,34 @@ 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. -Module Name: - - PxeBcMtftp.h - -Abstract: - - Mtftp routines for PxeBc - - **/ #ifndef __EFI_PXEBC_MTFTP_H__ #define __EFI_PXEBC_MTFTP_H__ -enum { +typedef enum { PXE_MTFTP_OPTION_BLKSIZE_INDEX, PXE_MTFTP_OPTION_TIMEOUT_INDEX, PXE_MTFTP_OPTION_TSIZE_INDEX, PXE_MTFTP_OPTION_MULTICAST_INDEX, PXE_MTFTP_OPTION_MAXIMUM_INDEX -}; +} PXE_MTFTP_OPTION_ENUM_TYPES; /** 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 - @return EFI_SUCCESS - @return EFI_NOT_FOUND - @return EFI_DEVICE_ERROR - + @retval EFI_SUCCESS Get the size of file success + @retval EFI_NOT_FOUND Parse the tftp ptions failed. + @retval EFI_DEVICE_ERROR The network device encountered an error during this operation. + @retval Other Has not get the size of the file. + **/ EFI_STATUS PxeBcTftpGetFileSize ( @@ -68,9 +61,9 @@ PxeBcTftpGetFileSize ( @param BufferSize Pointer to buffer size @param DontUseBuffer Indicate whether with a receive buffer - @return EFI_SUCCESS - @return EFI_DEVICE_ERROR - + @retval EFI_SUCCESS Read the data success from the special file. + @retval EFI_DEVICE_ERROR The network device encountered an error during this operation. + @retval other Read data from file failed. **/ EFI_STATUS PxeBcTftpReadFile ( @@ -96,8 +89,9 @@ PxeBcTftpReadFile ( @param BufferPtr Pointer to buffer @param BufferSize Pointer to buffer size - @return EFI_SUCCESS - @return EFI_DEVICE_ERROR + @retval EFI_SUCCESS Write the data success into the special file. + @retval EFI_DEVICE_ERROR The network device encountered an error during this operation. + @retval other Write data into file failed. **/ EFI_STATUS @@ -114,19 +108,20 @@ PxeBcTftpWriteFile ( /** - This function is to get data of a directory 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 - - @return EFI_SUCCES - @return EFI_DEVICE_ERROR - + This function is to get data(file) from a directory(may be a server) by Tftp. + + @param Private Pointer to PxeBc private data. + @param Config Pointer to Mtftp configuration data. + @param Filename Pointer to file name. + @param BlockSize Pointer to block size. + @param BufferPtr Pointer to buffer. + @param BufferSize Pointer to buffer size. + @param DontUseBuffer Indicate whether with a receive buffer. + + @retval EFI_SUCCES Get the data from the file included in directory success. + @retval EFI_DEVICE_ERROR The network device encountered an error during this operation. + @retval other Operation failed. + **/ EFI_STATUS PxeBcTftpReadDirectory ( diff --git a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcSupport.c b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcSupport.c index 0e42b5c69b..296861f12d 100644 --- a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcSupport.c +++ b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcSupport.c @@ -1,6 +1,7 @@ /** @file - -Copyright (c) 2007 - 2008, Intel Corporation + Support routines for PxeBc. + +Copyright (c) 2007 - 2008, 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 @@ -9,15 +10,6 @@ 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. -Module Name: - - PxeBcSupport.c - -Abstract: - - Support routines for PxeBc - - **/ @@ -25,7 +17,8 @@ Abstract: /** - + This function returns SMBIOS string given the string number. + @param Smbios Pointer to SMBIOS structure @param StringNumber String number to return. 0 is used to skip all strings and point to the next SMBIOS structure. @@ -33,7 +26,6 @@ Abstract: @return Pointer to string, or pointer to next SMBIOS strcuture if StringNumber == 0 **/ -// GC_NOTO: function comment is missing 'Routine Description:' CHAR8 * GetSmbiosString ( IN SMBIOS_STRUCTURE_POINTER *Smbios, @@ -78,14 +70,14 @@ GetSmbiosString ( /** - This function gets system guid and serial number from the smbios table + This function gets system guid and serial number from the smbios table. - @param SystemGuid The pointer of returned system guid - @param SystemSerialNumber The pointer of returned system serial number + @param SystemGuid The pointer of returned system guid. + @param SystemSerialNumber The pointer of returned system serial number. @retval EFI_SUCCESS Successfully get the system guid and system serial - number - @retval EFI_NOT_FOUND Not find the SMBIOS table + number. + @retval EFI_NOT_FOUND Not find the SMBIOS table. **/ EFI_STATUS @@ -145,12 +137,12 @@ GetSmbiosSystemGuidAndSerialNumber ( /** - GC_NOTO: Add function description + The common notify function associated with various PxeBc events. - @param Event GC_NOTO: add argument description - @param Context GC_NOTO: add argument description + @param Event The event signaled. + @param Context The context. - @return GC_NOTO: add return values + @return None **/ VOID @@ -162,6 +154,32 @@ PxeBcCommonNotify ( *((BOOLEAN *) Context) = TRUE; } + +/** + This function initialize(or configure) the Udp4Write instance. + + @param Udp4 Pointer to the EFI_UDP4_PROTOCOL instance. + @param StationIp Pointer to the station ip address. + @param SubnetMask Pointer to the subnetmask of the station ip address. + @param Gateway Pointer to the gateway ip address. + @param SrcPort Pointer to the srouce port of the station. + + @retval EFI_SUCCESS The configuration settings were set, changed, or reset successfully. + @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, BOOTP, + RARP, etc.) is not finished yet. + @retval EFI_INVALID_PARAMETER One or more following conditions are TRUE: + @retval EFI_ALREADY_STARTED The EFI UDPv4 Protocol instance is already started/configured + and must be stopped/reset before it can be reconfigured. + @retval EFI_ACCESS_DENIED UdpConfigData. AllowDuplicatePort is FALSE + and UdpConfigData.StationPort is already used by + other instance. + @retval EFI_OUT_OF_RESOURCES The EFI UDPv4 Protocol driver cannot allocate memory for this + EFI UDPv4 Protocol instance. + @retval EFI_DEVICE_ERROR An unexpected network or system error occurred and this instance + was not opened. + @retval Others Please examine the function Udp4->Routes(Udp4, FALSE, &mZeroIp4Addr, &mZeroIp4Addr, Gateway) returns. + +**/ EFI_STATUS PxeBcConfigureUdpWriteInstance ( IN EFI_UDP4_PROTOCOL *Udp4, @@ -214,25 +232,23 @@ PxeBcConfigureUdpWriteInstance ( /** - Convert number to ASCII value + Convert number to ASCII value. @param Number Numeric value to convert to decimal ASCII value. - @param Buffer Buffer to place ASCII version of the Number + @param Buffer Buffer to place ASCII version of the Number. @param Length Length of Buffer. - @retval none none - **/ VOID CvtNum ( IN UINTN Number, IN UINT8 *Buffer, - IN INTN Length + IN UINTN Length ) { UINTN Remainder; - while (Length--) { + while (Length-- > 0) { Remainder = Number % 10; Number /= 10; Buffer[Length] = (UINT8) ('0' + Remainder); @@ -241,12 +257,12 @@ CvtNum ( /** - GC_NOTO: Add function description + Convert unsigned int number to decimal number. - @param Number GC_NOTO: add argument description - @param Buffer GC_NOTO: add argument description + @param Number The unsigned int number will be converted. + @param Buffer Pointer to the buffer to store the decimal number after transform. - @return GC_NOTO: add return values + @return the length of the number after transform. **/ UINTN @@ -274,12 +290,11 @@ UtoA10 ( /** - Convert ASCII numeric string to a UINTN value + Convert ASCII numeric string to a UINTN value. - @param Number Numeric value to convert to decimal ASCII value. - @param Buffer Buffer to place ASCII version of the Number + @param Buffer Pointer to the 8-byte unsigned int value. - @retval Value UINTN value of the ASCII string. + @return UINTN value of the ASCII string. **/ UINT64 diff --git a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcSupport.h b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcSupport.h index 6ca661ea0f..1458fde2bb 100644 --- a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcSupport.h +++ b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/PxeBcSupport.h @@ -1,6 +1,6 @@ /** @file - -Copyright (c) 2007 - 2008, Intel Corporation + Support routines for PxeBc. +Copyright (c) 2007 - 2008, 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 @@ -9,20 +9,22 @@ 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. -Module Name: +**/ - PxeBcSupport.h +#ifndef __EFI_PXEBC_SUPPORT_H__ +#define __EFI_PXEBC_SUPPORT_H__ -Abstract: +/** + This function gets system guid and serial number from the smbios table. - Support routines for PxeBc + @param SystemGuid The pointer of returned system guid. + @param SystemSerialNumber The pointer of returned system serial number. + @retval EFI_SUCCESS Successfully get the system guid and system serial + number. + @retval EFI_NOT_FOUND Not find the SMBIOS table. **/ - -#ifndef __EFI_PXEBC_SUPPORT_H__ -#define __EFI_PXEBC_SUPPORT_H__ - EFI_STATUS GetSmbiosSystemGuidAndSerialNumber ( IN EFI_GUID *SystemGuid, @@ -31,12 +33,12 @@ GetSmbiosSystemGuidAndSerialNumber ( /** - GC_NOTO: Add function description + The common notify function associated with various PxeBc events. - @param Event GC_NOTO: add argument description - @param Context GC_NOTO: add argument description + @param Event The event signaled. + @param Context The context. - @return GC_NOTO: add return values + @return None **/ VOID @@ -46,6 +48,32 @@ PxeBcCommonNotify ( ) ; + +/** + 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. + + @retval EFI_SUCCESS The configuration settings were set, changed, or reset successfully. + @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, BOOTP, + RARP, etc.) is not finished yet. + @retval EFI_INVALID_PARAMETER One or more following conditions are TRUE: + @retval EFI_ALREADY_STARTED The EFI UDPv4 Protocol instance is already started/configured + and must be stopped/reset before it can be reconfigured. + @retval EFI_ACCESS_DENIED UdpConfigData. AllowDuplicatePort is FALSE + and UdpConfigData.StationPort is already used by + other instance. + @retval EFI_OUT_OF_RESOURCES The EFI UDPv4 Protocol driver cannot allocate memory for this + EFI UDPv4 Protocol instance. + @retval EFI_DEVICE_ERROR An unexpected network or system error occurred and this instance + was not opened. + @retval Others Please examine the function Udp4->Routes(Udp4, FALSE, &mZeroIp4Addr, &mZeroIp4Addr, Gateway) returns. + +**/ EFI_STATUS PxeBcConfigureUdpWriteInstance ( IN EFI_UDP4_PROTOCOL *Udp4, @@ -54,42 +82,52 @@ PxeBcConfigureUdpWriteInstance ( IN EFI_IPv4_ADDRESS *Gateway, IN OUT UINT16 *SrcPort ); +/** + Convert number to ASCII value. + + @param Number Numeric value to convert to decimal ASCII value. + @param Buffer Buffer to place ASCII version of the Number + @param Length Length of Buffer. + + @return None. + +**/ VOID CvtNum ( IN UINTN Number, IN UINT8 *Buffer, - IN INTN Length + IN UINTN Length ); /** - GC_NOTO: Add function description + Convert unsigned int number to decimal number. - @param Number GC_NOTO: add argument description - @param BufferPtr GC_NOTO: add argument description + @param Number The unsigned int number will be converted. + @param Buffer Pointer to the buffer to store the decimal number after transform. - @return GC_NOTO: add return values + @return the length of the number after transform. **/ UINTN UtoA10 ( - UINTN Number, - CHAR8 *BufferPtr + IN UINTN Number, + IN CHAR8 *Buffer ) ; /** - GC_NOTO: Add function description - - @param BufferPtr GC_NOTO: add argument description + Convert ASCII numeric string to a UINTN value. - @return GC_NOTO: add return values + @param Buffer Pointer to the 8-byte unsigned int value. + + @return UINTN value of the ASCII string. **/ UINT64 AtoU64 ( - UINT8 *BufferPtr + IN UINT8 *Buffer ) ; diff --git a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/X64/PxeArch.h b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/X64/PxeArch.h index 33a7b2696f..3024d0e925 100644 --- a/MdeModulePkg/Universal/Network/UefiPxeBcDxe/X64/PxeArch.h +++ b/MdeModulePkg/Universal/Network/UefiPxeBcDxe/X64/PxeArch.h @@ -1,6 +1,7 @@ /** @file - -Copyright (c) 2006, Intel Corporation + Defines PXE Arch type. + +Copyright (c) 2006, 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 @@ -9,13 +10,6 @@ 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. -Module Name: - PxeArch.h - -Abstract: - Defines PXE Arch type - - **/ #ifndef _EFI_PXE_ARCH_H_ diff --git a/MdePkg/Include/Protocol/PxeBaseCode.h b/MdePkg/Include/Protocol/PxeBaseCode.h index 4085726f64..e893fa1606 100644 --- a/MdePkg/Include/Protocol/PxeBaseCode.h +++ b/MdePkg/Include/Protocol/PxeBaseCode.h @@ -281,6 +281,51 @@ typedef struct { /** Enables the use of the PXE Base Code Protocol functions. + + This function enables the use of the PXE Base Code Protocol functions. If the + Started field of the EFI_PXE_BASE_CODE_MODE structure is already TRUE, then + EFI_ALREADY_STARTED will be returned. If UseIpv6 is TRUE, then IPv6 formatted + addresses will be used in this session. If UseIpv6 is FALSE, then IPv4 formatted + addresses will be used in this session. If UseIpv6 is TRUE, and the Ipv6Supported + field of the EFI_PXE_BASE_CODE_MODE structure is FALSE, then EFI_UNSUPPORTED will + be returned. If there is not enough memory or other resources to start the PXE + Base Code Protocol, then EFI_OUT_OF_RESOURCES will be returned. Otherwise, the + PXE Base Code Protocol will be started, and all of the fields of the EFI_PXE_BASE_CODE_MODE + structure will be initialized as follows: + StartedSet to TRUE. + Ipv6SupportedUnchanged. + Ipv6AvailableUnchanged. + UsingIpv6Set to UseIpv6. + BisSupportedUnchanged. + BisDetectedUnchanged. + AutoArpSet to TRUE. + SendGUIDSet to FALSE. + TTLSet to DEFAULT_TTL. + ToSSet to DEFAULT_ToS. + DhcpCompletedSet to FALSE. + ProxyOfferReceivedSet to FALSE. + StationIpSet to an address of all zeros. + SubnetMaskSet to a subnet mask of all zeros. + DhcpDiscoverZero-filled. + DhcpAckZero-filled. + ProxyOfferZero-filled. + PxeDiscoverValidSet to FALSE. + PxeDiscoverZero-filled. + PxeReplyValidSet to FALSE. + PxeReplyZero-filled. + PxeBisReplyValidSet to FALSE. + PxeBisReplyZero-filled. + IpFilterSet the Filters field to 0 and the IpCnt field to 0. + ArpCacheEntriesSet to 0. + ArpCacheZero-filled. + RouteTableEntriesSet to 0. + RouteTableZero-filled. + IcmpErrorReceivedSet to FALSE. + IcmpErrorZero-filled. + TftpErroReceivedSet to FALSE. + TftpErrorZero-filled. + MakeCallbacksSet to TRUE if the PXE Base Code Callback Protocol is available. + Set to FALSE if the PXE Base Code Callback Protocol is not available. @param This Pointer to the EFI_PXE_BASE_CODE_PROTOCOL instance. @param UseIpv6 Specifies the type of IP addresses that are to be used during the session @@ -307,7 +352,12 @@ EFI_STATUS /** Disables the use of the PXE Base Code Protocol functions. - + + This function stops all activity on the network device. All the resources allocated + in Start() are released, the Started field of the EFI_PXE_BASE_CODE_MODE structure is + set to FALSE and EFI_SUCCESS is returned. If the Started field of the EFI_PXE_BASE_CODE_MODE + structure is already FALSE, then EFI_NOT_STARTED will be returned. + @param This Pointer to the EFI_PXE_BASE_CODE_PROTOCOL instance. @retval EFI_SUCCESS The PXE Base Code Protocol was stopped. @@ -326,6 +376,19 @@ EFI_STATUS /** Attempts to complete a DHCPv4 D.O.R.A. (discover / offer / request / acknowledge) or DHCPv6 S.A.R.R (solicit / advertise / request / reply) sequence. + + This function attempts to complete the DHCP sequence. If this sequence is completed, + then EFI_SUCCESS is returned, and the DhcpCompleted, ProxyOfferReceived, StationIp, + SubnetMask, DhcpDiscover, DhcpAck, and ProxyOffer fields of the EFI_PXE_BASE_CODE_MODE + structure are filled in. + If SortOffers is TRUE, then the cached DHCP offer packets will be sorted before + they are tried. If SortOffers is FALSE, then the cached DHCP offer packets will + be tried in the order in which they are received. Please see the Preboot Execution + Environment (PXE) Specification for additional details on the implementation of DHCP. + This function can take at least 31 seconds to timeout and return control to the + caller. If the DHCP sequence does not complete, then EFI_TIMEOUT will be returned. + If the Callback Protocol does not return EFI_PXE_BASE_CODE_CALLBACK_STATUS_CONTINUE, + then the DHCP sequence will be stopped and EFI_ABORTED will be returned. @param This Pointer to the EFI_PXE_BASE_CODE_PROTOCOL instance. @param SortOffers TRUE if the offers received should be sorted. Set to FALSE to try the @@ -352,6 +415,26 @@ EFI_STATUS /** Attempts to complete the PXE Boot Server and/or boot image discovery sequence. + + This function attempts to complete the PXE Boot Server and/or boot image discovery + sequence. If this sequence is completed, then EFI_SUCCESS is returned, and the + PxeDiscoverValid, PxeDiscover, PxeReplyReceived, and PxeReply fields of the + EFI_PXE_BASE_CODE_MODE structure are filled in. If UseBis is TRUE, then the + PxeBisReplyReceived and PxeBisReply fields of the EFI_PXE_BASE_CODE_MODE structure + will also be filled in. If UseBis is FALSE, then PxeBisReplyValid will be set to FALSE. + In the structure referenced by parameter Info, the PXE Boot Server list, SrvList[], + has two uses: It is the Boot Server IP address list used for unicast discovery + (if the UseUCast field is TRUE), and it is the list used for Boot Server verification + (if the MustUseList field is TRUE). Also, if the MustUseList field in that structure + is TRUE and the AcceptAnyResponse field in the SrvList[] array is TRUE, any Boot + Server reply of that type will be accepted. If the AcceptAnyResponse field is + FALSE, only responses from Boot Servers with matching IP addresses will be accepted. + This function can take at least 10 seconds to timeout and return control to the + caller. If the Discovery sequence does not complete, then EFI_TIMEOUT will be + returned. Please see the Preboot Execution Environment (PXE) Specification for + additional details on the implementation of the Discovery sequence. + If the Callback Protocol does not return EFI_PXE_BASE_CODE_CALLBACK_STATUS_CONTINUE, + then the Discovery sequence is stopped and EFI_ABORTED will be returned. @param This Pointer to the EFI_PXE_BASE_CODE_PROTOCOL instance. @param Type The type of bootstrap to perform. @@ -385,6 +468,49 @@ EFI_STATUS /** Used to perform TFTP and MTFTP services. + + This function is used to perform TFTP and MTFTP services. This includes the + TFTP operations to get the size of a file, read a directory, read a file, and + write a file. It also includes the MTFTP operations to get the size of a file, + read a directory, and read a file. The type of operation is specified by Operation. + If the callback function that is invoked during the TFTP/MTFTP operation does + not return EFI_PXE_BASE_CODE_CALLBACK_STATUS_CONTINUE, then EFI_ABORTED will + be returned. + For read operations, the return data will be placed in the buffer specified by + BufferPtr. If BufferSize is too small to contain the entire downloaded file, + then EFI_BUFFER_TOO_SMALL will be returned and BufferSize will be set to zero + or the size of the requested file (the size of the requested file is only returned + if the TFTP server supports TFTP options). If BufferSize is large enough for the + read operation, then BufferSize will be set to the size of the downloaded file, + and EFI_SUCCESS will be returned. Applications using the PxeBc.Mtftp() services + should use the get-file-size operations to determine the size of the downloaded + file prior to using the read-file operations--especially when downloading large + (greater than 64 MB) files--instead of making two calls to the read-file operation. + Following this recommendation will save time if the file is larger than expected + and the TFTP server does not support TFTP option extensions. Without TFTP option + extension support, the client has to download the entire file, counting and discarding + the received packets, to determine the file size. + For write operations, the data to be sent is in the buffer specified by BufferPtr. + BufferSize specifies the number of bytes to send. If the write operation completes + successfully, then EFI_SUCCESS will be returned. + For TFTP “get file size” operations, the size of the requested file or directory + is returned in BufferSize, and EFI_SUCCESS will be returned. If the TFTP server + does not support options, the file will be downloaded into a bit bucket and the + length of the downloaded file will be returned. For MTFTP “get file size” operations, + if the MTFTP server does not support the “get file size” option, EFI_UNSUPPORTED + will be returned. + This function can take up to 10 seconds to timeout and return control to the caller. + If the TFTP sequence does not complete, EFI_TIMEOUT will be returned. + If the Callback Protocol does not return EFI_PXE_BASE_CODE_CALLBACK_STATUS_CONTINUE, + then the TFTP sequence is stopped and EFI_ABORTED will be returned. + The format of the data returned from a TFTP read directory operation is a null-terminated + filename followed by a null-terminated information string, of the form + “size year-month-day hour:minute:second” (i.e. %d %d-%d-%d %d:%d:%f - note that + the seconds field can be a decimal number), where the date and time are UTC. For + an MTFTP read directory command, there is additionally a null-terminated multicast + IP address preceding the filename of the form %d.%d.%d.%d for IP v4. The final + entry is itself null-terminated, so that the final information string is terminated + with two null octets. @param This Pointer to the EFI_PXE_BASE_CODE_PROTOCOL instance. @param Operation The type of operation to perform. @@ -428,6 +554,17 @@ EFI_STATUS /** Writes a UDP packet to the network interface. + + This function writes a UDP packet specified by the (optional HeaderPtr and) + BufferPtr parameters to the network interface. The UDP header is automatically + built by this routine. It uses the parameters OpFlags, DestIp, DestPort, GatewayIp, + SrcIp, and SrcPort to build this header. If the packet is successfully built and + transmitted through the network interface, then EFI_SUCCESS will be returned. + If a timeout occurs during the transmission of the packet, then EFI_TIMEOUT will + be returned. If an ICMP error occurs during the transmission of the packet, then + the IcmpErrorReceived field is set to TRUE, the IcmpError field is filled in and + EFI_ICMP_ERROR will be returned. If the Callback Protocol does not return + EFI_PXE_BASE_CODE_CALLBACK_STATUS_CONTINUE, then EFI_ABORTED will be returned. @param This Pointer to the EFI_PXE_BASE_CODE_PROTOCOL instance. @param OpFlags The UDP operation flags. @@ -470,12 +607,24 @@ EFI_STATUS /** Reads a UDP packet from the network interface. + + This function reads a UDP packet from a network interface. The data contents + are returned in (the optional HeaderPtr and) BufferPtr, and the size of the + buffer received is returned in BufferSize . If the input BufferSize is smaller + than the UDP packet received (less optional HeaderSize), it will be set to the + required size, and EFI_BUFFER_TOO_SMALL will be returned. In this case, the + contents of BufferPtr are undefined, and the packet is lost. If a UDP packet is + successfully received, then EFI_SUCCESS will be returned, and the information + from the UDP header will be returned in DestIp, DestPort, SrcIp, and SrcPort if + they are not NULL. + Depending on the values of OpFlags and the DestIp, DestPort, SrcIp, and SrcPort + input values, different types of UDP packet receive filtering will be performed. + The following tables summarize these receive filter operations. @param This Pointer to the EFI_PXE_BASE_CODE_PROTOCOL instance. @param OpFlags The UDP operation flags. @param DestIp The destination IP address. - @param DestPort The destination UDP port number. - @param GatewayIp The gateway IP address. + @param DestPort The destination UDP port number. @param SrcIp The source IP address. @param SrcPort The source UDP port number. @param HeaderSize An optional field which may be set to the length of a header at @@ -485,7 +634,7 @@ EFI_STATUS @param BufferSize A pointer to the size of the data at BufferPtr. @param BufferPtr A pointer to the data to be read. - @retval EFI_SUCCESS The UDP Write operation was completed. + @retval EFI_SUCCESS The UDP Read operation was completed. @retval EFI_NOT_STARTED The PXE Base Code Protocol is in the stopped state. @retval EFI_INVALID_PARAMETER One or more parameters are invalid. @retval EFI_DEVICE_ERROR The network device encountered an error during this operation. @@ -511,6 +660,27 @@ EFI_STATUS /** Updates the IP receive filters of a network device and enables software filtering. + + The NewFilter field is used to modify the network device's current IP receive + filter settings and to enable a software filter. This function updates the IpFilter + field of the EFI_PXE_BASE_CODE_MODE structure with the contents of NewIpFilter. + The software filter is used when the USE_FILTER in OpFlags is set to UdpRead(). + The current hardware filter remains in effect no matter what the settings of OpFlags + are, so that the meaning of ANY_DEST_IP set in OpFlags to UdpRead() is from those + packets whose reception is enabled in hardware – physical NIC address (unicast), + broadcast address, logical address or addresses (multicast), or all (promiscuous). + UdpRead() does not modify the IP filter settings. + Dhcp(), Discover(), and Mtftp() set the IP filter, and return with the IP receive + filter list emptied and the filter set to EFI_PXE_BASE_CODE_IP_FILTER_STATION_IP. + If an application or driver wishes to preserve the IP receive filter settings, + it will have to preserve the IP receive filter settings before these calls, and + use SetIpFilter() to restore them after the calls. If incompatible filtering is + requested (for example, PROMISCUOUS with anything else) or if the device does not + support a requested filter setting and it cannot be accommodated in software + (for example, PROMISCUOUS not supported), EFI_INVALID_PARAMETER will be returned. + The IPlist field is used to enable IPs other than the StationIP. They may be + multicast or unicast. If IPcnt is set as well as EFI_PXE_BASE_CODE_IP_FILTER_STATION_IP, + then both the StationIP and the IPs from the IPlist will be used. @param This Pointer to the EFI_PXE_BASE_CODE_PROTOCOL instance. @param NewFilter Pointer to the new set of IP receive filters. @@ -529,6 +699,19 @@ EFI_STATUS /** Uses the ARP protocol to resolve a MAC address. + + This function uses the ARP protocol to resolve a MAC address. The UsingIpv6 field + of the EFI_PXE_BASE_CODE_MODE structure is used to determine if IPv4 or IPv6 + addresses are being used. The IP address specified by IpAddr is used to resolve + a MAC address. If the ARP protocol succeeds in resolving the specified address, + then the ArpCacheEntries and ArpCache fields of the EFI_PXE_BASE_CODE_MODE structure + are updated, and EFI_SUCCESS is returned. If MacAddr is not NULL, the resolved + MAC address is placed there as well. + If the PXE Base Code protocol is in the stopped state, then EFI_NOT_STARTED is + returned. If the ARP protocol encounters a timeout condition while attempting + to resolve an address, then EFI_TIMEOUT is returned. If the Callback Protocol + does not return EFI_PXE_BASE_CODE_CALLBACK_STATUS_CONTINUE, then EFI_ABORTED is + returned. @param This Pointer to the EFI_PXE_BASE_CODE_PROTOCOL instance. @param IpAddr Pointer to the IP address that is used to resolve a MAC address. @@ -553,6 +736,18 @@ EFI_STATUS /** Updates the parameters that affect the operation of the PXE Base Code Protocol. + + This function sets parameters that affect the operation of the PXE Base Code Protocol. + The parameter specified by NewAutoArp is used to control the generation of ARP + protocol packets. If NewAutoArp is TRUE, then ARP Protocol packets will be generated + as required by the PXE Base Code Protocol. If NewAutoArp is FALSE, then no ARP + Protocol packets will be generated. In this case, the only mappings that are + available are those stored in the ArpCache of the EFI_PXE_BASE_CODE_MODE structure. + If there are not enough mappings in the ArpCache to perform a PXE Base Code Protocol + service, then the service will fail. This function updates the AutoArp field of + the EFI_PXE_BASE_CODE_MODE structure to NewAutoArp. + The SetParameters() call must be invoked after a Callback Protocol is installed + to enable the use of callbacks. @param This Pointer to the EFI_PXE_BASE_CODE_PROTOCOL instance. @param NewAutoArp If not NULL, a pointer to a value that specifies whether to replace the @@ -584,6 +779,17 @@ EFI_STATUS /** Updates the station IP address and/or subnet mask values of a network device. + + This function updates the station IP address and/or subnet mask values of a network + device. + The NewStationIp field is used to modify the network device's current IP address. + If NewStationIP is NULL, then the current IP address will not be modified. Otherwise, + this function updates the StationIp field of the EFI_PXE_BASE_CODE_MODE structure + with NewStationIp. + The NewSubnetMask field is used to modify the network device's current subnet + mask. If NewSubnetMask is NULL, then the current subnet mask will not be modified. + Otherwise, this function updates the SubnetMask field of the EFI_PXE_BASE_CODE_MODE + structure with NewSubnetMask. @param This Pointer to the EFI_PXE_BASE_CODE_PROTOCOL instance. @param NewStationIp Pointer to the new IP address to be used by the network device. @@ -604,6 +810,9 @@ EFI_STATUS /** Updates the contents of the cached DHCP and Discover packets. + + The pointers to the new packets are used to update the contents of the cached + packets in the EFI_PXE_BASE_CODE_MODE structure. @param This Pointer to the EFI_PXE_BASE_CODE_PROTOCOL instance. @param NewDhcpDiscoverValid Pointer to a value that will replace the current diff --git a/MdePkg/Include/Protocol/PxeBaseCodeCallBack.h b/MdePkg/Include/Protocol/PxeBaseCodeCallBack.h index 26b1503582..5f6fd7cb54 100644 --- a/MdePkg/Include/Protocol/PxeBaseCodeCallBack.h +++ b/MdePkg/Include/Protocol/PxeBaseCodeCallBack.h @@ -75,6 +75,16 @@ typedef enum { Callback function that is invoked when the PXE Base Code Protocol is about to transmit, has received, or is waiting to receive a packet. + This function is invoked when the PXE Base Code Protocol is about to transmit, has received, + or is waiting to receive a packet. Parameters Function and Received specify the type of event. + Parameters PacketLen and Packet specify the packet that generated the event. If these fields + are zero and NULL respectively, then this is a status update callback. If the operation specified + by Function is to continue, then CALLBACK_STATUS_CONTINUE should be returned. If the operation + specified by Function should be aborted, then CALLBACK_STATUS_ABORT should be returned. Due to + the polling nature of UEFI device drivers, a callback function should not execute for more than 5 ms. + The SetParameters() function must be called after a Callback Protocol is installed to enable the + use of callbacks. + @param This Pointer to the EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL instance. @param Function The PXE Base Code Protocol function that is waiting for an event. @param Received TRUE if the callback is being invoked due to a receive event. FALSE if -- 2.39.2