Add NetworkPkg (P.UDK2010.UP3.Network.P1)

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10986 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
hhtian
2010-11-01 06:13:54 +00:00
parent 12873d5766
commit a3bcde70e6
142 changed files with 83988 additions and 0 deletions

View File

@@ -0,0 +1,312 @@
/** @file
UEFI Component Name(2) protocol implementation for UefiPxeBc driver.
Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php.
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include "PxeBcImpl.h"
/**
Retrieves a Unicode string that is the user-readable name of the driver.
This function retrieves the user-readable name of a driver in the form of a
Unicode string. If the driver specified by This has a user-readable name in
the language specified by Language, then a pointer to the driver name is
returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
by This does not support the language specified by Language,
then EFI_UNSUPPORTED is returned.
@param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
EFI_COMPONENT_NAME_PROTOCOL instance.
@param[in] Language A pointer to a Null-terminated ASCII string
array indicating the language. This is the
language of the driver name that the caller is
requesting, and it must match one of the
languages specified in SupportedLanguages. The
number of languages supported by a driver is up
to the driver writer. Language is specified
in RFC 4646 or ISO 639-2 language code format.
@param[out] DriverName A pointer to the Unicode string to return.
This Unicode string is the name of the
driver specified by This in the language
specified by Language.
@retval EFI_SUCCESS The Unicode string for the Driver specified by
This and the language specified by Language was
returned in DriverName.
@retval EFI_INVALID_PARAMETER Language is NULL.
@retval EFI_INVALID_PARAMETER DriverName is NULL.
@retval EFI_UNSUPPORTED The driver specified by This does not support
the language specified by Language.
**/
EFI_STATUS
EFIAPI
PxeBcComponentNameGetDriverName (
IN EFI_COMPONENT_NAME_PROTOCOL *This,
IN CHAR8 *Language,
OUT CHAR16 **DriverName
);
/**
Retrieves a Unicode string that is the user-readable name of the controller
that is being managed by a driver.
This function retrieves the user-readable name of the controller specified by
ControllerHandle and ChildHandle in the form of a Unicode string. If the
driver specified by This has a user-readable name in the language specified by
Language, then a pointer to the controller name is returned in ControllerName,
and EFI_SUCCESS is returned. If the driver specified by This is not currently
managing the controller specified by ControllerHandle and ChildHandle,
then EFI_UNSUPPORTED is returned. If the driver specified by This does not
support the language specified by Language, then EFI_UNSUPPORTED is returned.
@param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
EFI_COMPONENT_NAME_PROTOCOL instance.
@param[in] ControllerHandle The handle of a controller that the driver
specified by This is managing. This handle
specifies the controller whose name is to be
returned.
@param[in] ChildHandle The handle of the child controller to retrieve
the name of. This is an optional parameter that
may be NULL. It will be NULL for device
drivers. It will also be NULL for a bus drivers
that wish to retrieve the name of the bus
controller. It will not be NULL for a bus
driver that wishes to retrieve the name of a
child controller.
@param[in] Language A pointer to a Null-terminated ASCII string
array indicating the language. This is the
language of the driver name that the caller is
requesting, and it must match one of the
languages specified in SupportedLanguages. The
number of languages supported by a driver is up
to the driver writer. Language is specified in
RFC 4646 or ISO 639-2 language code format.
@param[out] ControllerName A pointer to the Unicode string to return.
This Unicode string is the name of the
controller specified by ControllerHandle and
ChildHandle in the language specified by
Language from the point of view of the driver
specified by This.
@retval EFI_SUCCESS The Unicode string for the user-readable name in
the language specified by Language for the
driver specified by This was returned in
DriverName.
@retval EFI_INVALID_PARAMETER ControllerHandle is 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 (
IN EFI_COMPONENT_NAME_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN EFI_HANDLE ChildHandle OPTIONAL,
IN CHAR8 *Language,
OUT CHAR16 **ControllerName
);
//
// EFI Component Name Protocol
//
GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gPxeBcComponentName = {
PxeBcComponentNameGetDriverName,
PxeBcComponentNameGetControllerName,
"eng"
};
//
// EFI Component Name 2 Protocol
//
GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gPxeBcComponentName2 = {
(EFI_COMPONENT_NAME2_GET_DRIVER_NAME) PxeBcComponentNameGetDriverName,
(EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) PxeBcComponentNameGetControllerName,
"en"
};
GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mPxeBcDriverNameTable[] = {
{
"eng;en",
L"UEFI PXE Base Code Driver"
},
{
NULL,
NULL
}
};
/**
Retrieves a Unicode string that is the user-readable name of the driver.
This function retrieves the user-readable name of a driver in the form of a
Unicode string. If the driver specified by This has a user-readable name in
the language specified by Language, then a pointer to the driver name is
returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
by This does not support the language specified by Language,
then EFI_UNSUPPORTED is returned.
@param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
EFI_COMPONENT_NAME_PROTOCOL instance.
@param[in] Language A pointer to a Null-terminated ASCII string
array indicating the language. This is the
language of the driver name that the caller is
requesting, and it must match one of the
languages specified in SupportedLanguages. The
number of languages supported by a driver is up
to the driver writer. Language is specified
in RFC 4646 or ISO 639-2 language code format.
@param[out] DriverName A pointer to the Unicode string to return.
This Unicode string is the name of the
driver specified by This in the language
specified by Language.
@retval EFI_SUCCESS The Unicode string for the Driver specified by
This and the language specified by Language was
returned in DriverName.
@retval EFI_INVALID_PARAMETER Language is NULL.
@retval EFI_INVALID_PARAMETER DriverName is NULL.
@retval EFI_UNSUPPORTED The driver specified by This does not support
the language specified by Language.
**/
EFI_STATUS
EFIAPI
PxeBcComponentNameGetDriverName (
IN EFI_COMPONENT_NAME_PROTOCOL *This,
IN CHAR8 *Language,
OUT CHAR16 **DriverName
)
{
return LookupUnicodeString2(
Language,
This->SupportedLanguages,
mPxeBcDriverNameTable,
DriverName,
(BOOLEAN)(This == &gPxeBcComponentName)
);
}
/**
Retrieves a Unicode string that is the user-readable name of the controller
that is being managed by a driver.
This function retrieves the user-readable name of the controller specified by
ControllerHandle and ChildHandle in the form of a Unicode string. If the
driver specified by This has a user-readable name in the language specified by
Language, then a pointer to the controller name is returned in ControllerName,
and EFI_SUCCESS is returned. If the driver specified by This is not currently
managing the controller specified by ControllerHandle and ChildHandle,
then EFI_UNSUPPORTED is returned. If the driver specified by This does not
support the language specified by Language, then EFI_UNSUPPORTED is returned.
@param[in] This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
EFI_COMPONENT_NAME_PROTOCOL instance.
@param[in] ControllerHandle The handle of a controller that the driver
specified by This is managing. This handle
specifies the controller whose name is to be
returned.
@param[in] ChildHandle The handle of the child controller to retrieve
the name of. This is an optional parameter that
may be NULL. It will be NULL for device
drivers. It will also be NULL for a bus drivers
that wish to retrieve the name of the bus
controller. It will not be NULL for a bus
driver that wishes to retrieve the name of a
child controller.
@param[in] Language A pointer to a Null-terminated ASCII string
array indicating the language. This is the
language of the driver name that the caller is
requesting, and it must match one of the
languages specified in SupportedLanguages. The
number of languages supported by a driver is up
to the driver writer. Language is specified in
RFC 4646 or ISO 639-2 language code format.
@param[out] ControllerName A pointer to the Unicode string to return.
This Unicode string is the name of the
controller specified by ControllerHandle and
ChildHandle in the language specified by
Language from the point of view of the driver
specified by This.
@retval EFI_SUCCESS The Unicode string for the user-readable name in
the language specified by Language for the
driver specified by This was returned in
DriverName.
@retval EFI_INVALID_PARAMETER ControllerHandle is 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 (
IN EFI_COMPONENT_NAME_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN EFI_HANDLE ChildHandle OPTIONAL,
IN CHAR8 *Language,
OUT CHAR16 **ControllerName
)
{
return EFI_UNSUPPORTED;
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,100 @@
/** @file
Boot functions declaration for UefiPxeBc Driver.
Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php.
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#ifndef __EFI_PXEBC_BOOT_H__
#define __EFI_PXEBC_BOOT_H__
#define PXEBC_DISPLAY_MAX_LINE 70
#define PXEBC_DEFAULT_UDP_OVERHEAD_SIZE 8
#define PXEBC_DEFAULT_TFTP_OVERHEAD_SIZE 4
#define PXEBC_IS_SIZE_OVERFLOWED(x) ((sizeof (UINTN) < sizeof (UINT64)) && ((x) > 0xFFFFFFFF))
/**
Extract the discover information and boot server entry from the
cached packets if unspecified.
@param[in] Private Pointer to PxeBc private data.
@param[in] Type The type of bootstrap to perform.
@param[in, out] Info Pointer to EFI_PXE_BASE_CODE_DISCOVER_INFO.
@param[out] BootEntry Pointer to PXEBC_BOOT_SVR_ENTRY.
@param[out] SrvList Pointer to EFI_PXE_BASE_CODE_SRVLIST.
@retval EFI_SUCCESS Successfully extracted the information.
@retval EFI_DEVICE_ERROR Failed to extract the information.
**/
EFI_STATUS
PxeBcExtractDiscoverInfo (
IN PXEBC_PRIVATE_DATA *Private,
IN UINT16 Type,
IN OUT EFI_PXE_BASE_CODE_DISCOVER_INFO *Info,
OUT PXEBC_BOOT_SVR_ENTRY **BootEntry,
OUT EFI_PXE_BASE_CODE_SRVLIST **SrvList
);
/**
Build the discover packet and send out for boot.
@param[in] Private Pointer to PxeBc private data.
@param[in] Type PxeBc option boot item type.
@param[in] Layer Pointer to option boot item layer.
@param[in] UseBis Use BIS or not.
@param[in] DestIp Pointer to the server address.
@param[in] IpCount The total count of the server address.
@param[in] SrvList Pointer to the server address list.
@retval EFI_SUCCESS Successfully discovered boot file.
@retval EFI_OUT_OF_RESOURCES Failed to allocate resources.
@retval EFI_NOT_FOUND Can't get the PXE reply packet.
@retval Others Failed to discover boot file.
**/
EFI_STATUS
PxeBcDiscoverBootServer (
IN PXEBC_PRIVATE_DATA *Private,
IN UINT16 Type,
IN UINT16 *Layer,
IN BOOLEAN UseBis,
IN EFI_IP_ADDRESS *DestIp,
IN UINT16 IpCount,
IN EFI_PXE_BASE_CODE_SRVLIST *SrvList
);
/**
Load boot file into user buffer.
@param[in] Private Pointer to PxeBc private data.
@param[in, out] BufferSize Size of user buffer for input;
required buffer size for output.
@param[in] Buffer Pointer to user buffer.
@retval EFI_SUCCESS Successfully obtained all the boot information.
@retval EFI_BUFFER_TOO_SMALL The buffer size is not enough for boot file.
@retval EFI_ABORTED User cancelled the current operation.
@retval Others Failed to parse out the boot information.
**/
EFI_STATUS
PxeBcLoadBootFile (
IN PXEBC_PRIVATE_DATA *Private,
IN OUT UINTN *BufferSize,
IN VOID *Buffer OPTIONAL
);
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,389 @@
/** @file
Functions declaration related with DHCPv4 for UefiPxeBc Driver.
Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php.
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#ifndef __EFI_PXEBC_DHCP4_H__
#define __EFI_PXEBC_DHCP4_H__
#define PXEBC_DHCP4_OPTION_MAX_NUM 16
#define PXEBC_DHCP4_OPTION_MAX_SIZE 312
#define PXEBC_DHCP4_PACKET_MAX_SIZE 1472
#define PXEBC_DHCP4_S_PORT 67
#define PXEBC_DHCP4_C_PORT 68
#define PXEBC_BS_DOWNLOAD_PORT 69
#define PXEBC_BS_DISCOVER_PORT 4011
#define PXEBC_DHCP4_OPCODE_REQUEST 1
#define PXEBC_DHCP4_OPCODE_REPLY 2
#define PXEBC_DHCP4_MSG_TYPE_REQUEST 3
#define PXEBC_DHCP4_MAGIC 0x63538263 // network byte order
//
// Dhcp Options
//
#define PXEBC_DHCP4_TAG_PAD 0 // Pad Option
#define PXEBC_DHCP4_TAG_EOP 255 // End Option
#define PXEBC_DHCP4_TAG_NETMASK 1 // Subnet Mask
#define PXEBC_DHCP4_TAG_TIME_OFFSET 2 // Time Offset from UTC
#define PXEBC_DHCP4_TAG_ROUTER 3 // Router option,
#define PXEBC_DHCP4_TAG_TIME_SERVER 4 // Time Server
#define PXEBC_DHCP4_TAG_NAME_SERVER 5 // Name Server
#define PXEBC_DHCP4_TAG_DNS_SERVER 6 // Domain Name Server
#define PXEBC_DHCP4_TAG_HOSTNAME 12 // Host Name
#define PXEBC_DHCP4_TAG_BOOTFILE_LEN 13 // Boot File Size
#define PXEBC_DHCP4_TAG_DUMP 14 // Merit Dump File
#define PXEBC_DHCP4_TAG_DOMAINNAME 15 // Domain Name
#define PXEBC_DHCP4_TAG_ROOTPATH 17 // Root path
#define PXEBC_DHCP4_TAG_EXTEND_PATH 18 // Extensions Path
#define PXEBC_DHCP4_TAG_EMTU 22 // Maximum Datagram Reassembly Size
#define PXEBC_DHCP4_TAG_TTL 23 // Default IP Time-to-live
#define PXEBC_DHCP4_TAG_BROADCAST 28 // Broadcast Address
#define PXEBC_DHCP4_TAG_NIS_DOMAIN 40 // Network Information Service Domain
#define PXEBC_DHCP4_TAG_NIS_SERVER 41 // Network Information Servers
#define PXEBC_DHCP4_TAG_NTP_SERVER 42 // Network Time Protocol Servers
#define PXEBC_DHCP4_TAG_VENDOR 43 // Vendor Specific Information
#define PXEBC_DHCP4_TAG_REQUEST_IP 50 // Requested IP Address
#define PXEBC_DHCP4_TAG_LEASE 51 // IP Address Lease Time
#define PXEBC_DHCP4_TAG_OVERLOAD 52 // Option Overload
#define PXEBC_DHCP4_TAG_MSG_TYPE 53 // DHCP Message Type
#define PXEBC_DHCP4_TAG_SERVER_ID 54 // Server Identifier
#define PXEBC_DHCP4_TAG_PARA_LIST 55 // Parameter Request List
#define PXEBC_DHCP4_TAG_MAXMSG 57 // Maximum DHCP Message Size
#define PXEBC_DHCP4_TAG_T1 58 // Renewal (T1) Time Value
#define PXEBC_DHCP4_TAG_T2 59 // Rebinding (T2) Time Value
#define PXEBC_DHCP4_TAG_CLASS_ID 60 // Vendor class identifier
#define PXEBC_DHCP4_TAG_CLIENT_ID 61 // Client-identifier
#define PXEBC_DHCP4_TAG_TFTP 66 // TFTP server name
#define PXEBC_DHCP4_TAG_BOOTFILE 67 // Bootfile name
#define PXEBC_PXE_DHCP4_TAG_ARCH 93
#define PXEBC_PXE_DHCP4_TAG_UNDI 94
#define PXEBC_PXE_DHCP4_TAG_UUID 97
//
// Sub-Options in Dhcp Vendor Option
//
#define PXEBC_VENDOR_TAG_MTFTP_IP 1
#define PXEBC_VENDOR_TAG_MTFTP_CPORT 2
#define PXEBC_VENDOR_TAG_MTFTP_SPORT 3
#define PXEBC_VENDOR_TAG_MTFTP_TIMEOUT 4
#define PXEBC_VENDOR_TAG_MTFTP_DELAY 5
#define PXEBC_VENDOR_TAG_DISCOVER_CTRL 6
#define PXEBC_VENDOR_TAG_DISCOVER_MCAST 7
#define PXEBC_VENDOR_TAG_BOOT_SERVERS 8
#define PXEBC_VENDOR_TAG_BOOT_MENU 9
#define PXEBC_VENDOR_TAG_MENU_PROMPT 10
#define PXEBC_VENDOR_TAG_MCAST_ALLOC 11
#define PXEBC_VENDOR_TAG_CREDENTIAL_TYPES 12
#define PXEBC_VENDOR_TAG_BOOT_ITEM 71
#define PXEBC_BOOT_REQUEST_TIMEOUT 1
#define PXEBC_BOOT_REQUEST_RETRIES 4
#define PXEBC_DHCP4_OVERLOAD_FILE 1
#define PXEBC_DHCP4_OVERLOAD_SERVER_NAME 2
//
// The array index of the DHCP4 option tag interested
//
#define PXEBC_DHCP4_TAG_INDEX_BOOTFILE_LEN 0
#define PXEBC_DHCP4_TAG_INDEX_VENDOR 1
#define PXEBC_DHCP4_TAG_INDEX_OVERLOAD 2
#define PXEBC_DHCP4_TAG_INDEX_MSG_TYPE 3
#define PXEBC_DHCP4_TAG_INDEX_SERVER_ID 4
#define PXEBC_DHCP4_TAG_INDEX_CLASS_ID 5
#define PXEBC_DHCP4_TAG_INDEX_BOOTFILE 6
#define PXEBC_DHCP4_TAG_INDEX_MAX 7
//
// Dhcp4 and Dhcp6 share this definition, and corresponding
// relatioinship is as follows:
//
// Dhcp4Discover <> Dhcp6Solicit
// Dhcp4Offer <> Dhcp6Advertise
// Dhcp4Request <> Dhcp6Request
// Dhcp4Ack <> DHcp6Reply
//
typedef enum {
PxeOfferTypeDhcpOnly,
PxeOfferTypeDhcpPxe10,
PxeOfferTypeDhcpWfm11a,
PxeOfferTypeDhcpBinl,
PxeOfferTypeProxyPxe10,
PxeOfferTypeProxyWfm11a,
PxeOfferTypeProxyBinl,
PxeOfferTypeBootp,
PxeOfferTypeMax
} PXEBC_OFFER_TYPE;
#define BIT(x) (1 << x)
#define CTRL(x) (0x1F & (x))
#define DEFAULT_CLASS_ID_DATA "PXEClient:Arch:?????:????:??????"
#define DEFAULT_UNDI_TYPE 1
#define DEFAULT_UNDI_MAJOR 3
#define DEFAULT_UNDI_MINOR 0
#define MTFTP_VENDOR_OPTION_BIT_MAP \
(BIT (PXEBC_VENDOR_TAG_MTFTP_IP) | \
BIT (PXEBC_VENDOR_TAG_MTFTP_CPORT) | \
BIT (PXEBC_VENDOR_TAG_MTFTP_SPORT) | \
BIT (PXEBC_VENDOR_TAG_MTFTP_TIMEOUT) | \
BIT (PXEBC_VENDOR_TAG_MTFTP_DELAY))
#define DISCOVER_VENDOR_OPTION_BIT_MAP \
(BIT (PXEBC_VENDOR_TAG_DISCOVER_CTRL) | \
BIT (PXEBC_VENDOR_TAG_DISCOVER_MCAST) | \
BIT (PXEBC_VENDOR_TAG_BOOT_SERVERS) | \
BIT (PXEBC_VENDOR_TAG_BOOT_MENU) | \
BIT (PXEBC_VENDOR_TAG_MENU_PROMPT))
#define IS_VALID_BOOT_PROMPT(x) \
((((x)[0]) & BIT (PXEBC_VENDOR_TAG_MENU_PROMPT)) \
== BIT (PXEBC_VENDOR_TAG_MENU_PROMPT))
#define IS_VALID_BOOT_MENU(x) \
((((x)[0]) & BIT (PXEBC_VENDOR_TAG_BOOT_MENU)) \
== BIT (PXEBC_VENDOR_TAG_BOOT_MENU))
#define IS_VALID_MTFTP_VENDOR_OPTION(x) \
(((UINT32) ((x)[0]) & MTFTP_VENDOR_OPTION_BIT_MAP) \
== MTFTP_VENDOR_OPTION_BIT_MAP)
#define IS_VALID_DISCOVER_VENDOR_OPTION(x) \
(((UINT32) ((x)[0]) & DISCOVER_VENDOR_OPTION_BIT_MAP) != 0)
#define IS_VALID_CREDENTIAL_VENDOR_OPTION(x) \
(((UINT32) ((x)[0]) & BIT (PXEBC_VENDOR_TAG_CREDENTIAL_TYPES)) \
== BIT (PXEBC_VENDOR_TAG_CREDENTIAL_TYPES))
#define IS_VALID_BOOTITEM_VENDOR_OPTION(x) \
(((UINT32) ((x)[PXEBC_VENDOR_TAG_BOOT_ITEM / 32]) & \
BIT (PXEBC_VENDOR_TAG_BOOT_ITEM % 32)) \
== BIT (PXEBC_VENDOR_TAG_BOOT_ITEM % 32))
#define SET_VENDOR_OPTION_BIT_MAP(x, y) \
(*(x + ((y) / 32)) = (UINT32) ((UINT32) ((x)[(y) / 32]) | BIT ((y) % 32)))
#define GET_NEXT_DHCP_OPTION(Opt) \
(EFI_DHCP4_PACKET_OPTION *) ((UINT8 *) (Opt) + \
sizeof (EFI_DHCP4_PACKET_OPTION) + (Opt)->Length - 1)
#define GET_OPTION_BUFFER_LEN(Pkt) \
((Pkt)->Length - sizeof (EFI_DHCP4_HEADER) - 4)
#define GET_NEXT_BOOT_SVR_ENTRY(Ent) \
(PXEBC_BOOT_SVR_ENTRY *) ((UINT8 *) Ent + sizeof (*(Ent)) + \
((Ent)->IpCnt - 1) * sizeof (EFI_IPv4_ADDRESS))
#define IS_PROXY_DHCP_OFFER(Offer) \
EFI_IP4_EQUAL (&(Offer)->Dhcp4.Header.YourAddr, &mZeroIp4Addr)
#define IS_DISABLE_BCAST_DISCOVER(x) \
(((x) & BIT (0)) == BIT (0))
#define IS_DISABLE_MCAST_DISCOVER(x) \
(((x) & BIT (1)) == BIT (1))
#define IS_ENABLE_USE_SERVER_LIST(x) \
(((x) & BIT (2)) == BIT (2))
#define IS_ENABLE_BOOT_FILE_NAME(x) \
(((x) & BIT (3)) == BIT (3))
#pragma pack(1)
typedef struct {
UINT8 ParaList[135];
} PXEBC_DHCP4_OPTION_PARA;
typedef struct {
UINT16 Size;
} PXEBC_DHCP4_OPTION_MAX_MESG_SIZE;
typedef struct {
UINT8 Type;
UINT8 MajorVer;
UINT8 MinorVer;
} PXEBC_DHCP4_OPTION_UNDI;
typedef struct {
UINT8 Type;
} PXEBC_DHCP4_OPTION_MESG;
typedef struct {
UINT16 Type;
} PXEBC_DHCP4_OPTION_ARCH;
typedef struct {
UINT8 ClassIdentifier[10];
UINT8 ArchitecturePrefix[5];
UINT8 ArchitectureType[5];
UINT8 Lit3[1];
UINT8 InterfaceName[4];
UINT8 Lit4[1];
UINT8 UndiMajor[3];
UINT8 UndiMinor[3];
} PXEBC_DHCP4_OPTION_CLID;
typedef struct {
UINT8 Type;
UINT8 Guid[16];
} PXEBC_DHCP4_OPTION_UUID;
typedef struct {
UINT16 Type;
UINT16 Layer;
} PXEBC_OPTION_BOOT_ITEM;
#pragma pack()
typedef union {
PXEBC_DHCP4_OPTION_PARA *Para;
PXEBC_DHCP4_OPTION_UNDI *Undi;
PXEBC_DHCP4_OPTION_ARCH *Arch;
PXEBC_DHCP4_OPTION_CLID *Clid;
PXEBC_DHCP4_OPTION_UUID *Uuid;
PXEBC_DHCP4_OPTION_MESG *Mesg;
PXEBC_DHCP4_OPTION_MAX_MESG_SIZE *MaxMesgSize;
} PXEBC_DHCP4_OPTION_ENTRY;
typedef struct {
UINT16 Type;
UINT8 IpCnt;
EFI_IPv4_ADDRESS IpAddr[1];
} PXEBC_BOOT_SVR_ENTRY;
typedef struct {
UINT16 Type;
UINT8 DescLen;
UINT8 DescStr[1];
} PXEBC_BOOT_MENU_ENTRY;
typedef struct {
UINT8 Timeout;
UINT8 Prompt[1];
} PXEBC_MENU_PROMPT;
typedef struct {
UINT32 BitMap[8];
EFI_IPv4_ADDRESS MtftpIp;
UINT16 MtftpCPort;
UINT16 MtftpSPort;
UINT8 MtftpTimeout;
UINT8 MtftpDelay;
UINT8 DiscoverCtrl;
EFI_IPv4_ADDRESS DiscoverMcastIp;
EFI_IPv4_ADDRESS McastIpBase;
UINT16 McastIpBlock;
UINT16 McastIpRange;
UINT16 BootSrvType;
UINT16 BootSrvLayer;
PXEBC_BOOT_SVR_ENTRY *BootSvr;
UINT8 BootSvrLen;
PXEBC_BOOT_MENU_ENTRY *BootMenu;
UINT8 BootMenuLen;
PXEBC_MENU_PROMPT *MenuPrompt;
UINT8 MenuPromptLen;
UINT32 *CredType;
UINT8 CredTypeLen;
} PXEBC_VENDOR_OPTION;
typedef union {
EFI_DHCP4_PACKET Offer;
EFI_DHCP4_PACKET Ack;
UINT8 Buffer[PXEBC_DHCP4_PACKET_MAX_SIZE];
} PXEBC_DHCP4_PACKET;
typedef struct {
PXEBC_DHCP4_PACKET Packet;
PXEBC_OFFER_TYPE OfferType;
EFI_DHCP4_PACKET_OPTION *OptList[PXEBC_DHCP4_TAG_INDEX_MAX];
PXEBC_VENDOR_OPTION VendorOpt;
} PXEBC_DHCP4_PACKET_CACHE;
/**
Create a template DHCPv4 packet as a seed.
@param[out] Seed Pointer to the seed packet.
@param[in] Udp4 Pointer to EFI_UDP4_PROTOCOL.
**/
VOID
PxeBcSeedDhcp4Packet (
OUT EFI_DHCP4_PACKET *Seed,
IN EFI_UDP4_PROTOCOL *Udp4
);
/**
Parse the cached DHCPv4 packet, including all the options.
@param[in] Cache4 Pointer to cached DHCPv4 packet.
@retval EFI_SUCCESS Parsed the DHCPv4 packet successfully.
@retval EFI_DEVICE_ERROR Failed to parse and invalid packet.
**/
EFI_STATUS
PxeBcParseDhcp4Packet (
IN PXEBC_DHCP4_PACKET_CACHE *Cache4
);
/**
Build and send out the request packet for the bootfile, and parse the reply.
@param[in] Private Pointer to PxeBc private data.
@param[in] Type PxeBc option boot item type.
@param[in] Layer Pointer to option boot item layer.
@param[in] UseBis Use BIS or not.
@param[in] DestIp Pointer to the server address.
@param[in] IpCount The total count of the server address.
@param[in] SrvList Pointer to EFI_PXE_BASE_CODE_SRVLIST.
@retval EFI_SUCCESS Successfully discovered boot file.
@retval EFI_OUT_OF_RESOURCES Failed to allocate resource.
@retval EFI_NOT_FOUND Can't get the PXE reply packet.
@retval Others Failed to discover boot file.
**/
EFI_STATUS
PxeBcDhcp4Discover (
IN PXEBC_PRIVATE_DATA *Private,
IN UINT16 Type,
IN UINT16 *Layer,
IN BOOLEAN UseBis,
IN EFI_IP_ADDRESS *DestIp,
IN UINT16 IpCount,
IN EFI_PXE_BASE_CODE_SRVLIST *SrvList
);
/**
Start the D.O.R.A DHCPv4 process to acquire the IPv4 address and other PXE boot information.
@param[in] Private Pointer to PxeBc private data.
@param[in] Dhcp4 Pointer to the EFI_DHCP4_PROTOCOL
@retval EFI_SUCCESS The D.O.R.A process successfully finished.
@retval Others Failed to finish the D.O.R.A process.
**/
EFI_STATUS
PxeBcDhcp4Dora (
IN PXEBC_PRIVATE_DATA *Private,
IN EFI_DHCP4_PROTOCOL *Dhcp4
);
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,277 @@
/** @file
Functions declaration related with DHCPv6 for UefiPxeBc Driver.
Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php.
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#ifndef __EFI_PXEBC_DHCP6_H__
#define __EFI_PXEBC_DHCP6_H__
#define PXEBC_DHCP6_OPTION_MAX_NUM 16
#define PXEBC_DHCP6_OPTION_MAX_SIZE 312
#define PXEBC_DHCP6_PACKET_MAX_SIZE 1472
#define PXEBC_DHCP6_MAPPING_TIMEOUT 50000000 // 5 seconds, unit is 10nanosecond.
#define PXEBC_IP6_POLICY_MAX 0xff
#define PXEBC_DHCP6_S_PORT 547
#define PXEBC_DHCP6_C_PORT 546
#define PXEBC_DHCP6_OPT_CLIENT_ID 1
#define PXEBC_DHCP6_OPT_SERVER_ID 2
#define PXEBC_DHCP6_OPT_IA_NA 3
#define PXEBC_DHCP6_OPT_IA_TA 4
#define PXEBC_DHCP6_OPT_IAADDR 5
#define PXEBC_DHCP6_OPT_ORO 6
#define PXEBC_DHCP6_OPT_PREFERENCE 7
#define PXEBC_DHCP6_OPT_ELAPSED_TIME 8
#define PXEBC_DHCP6_OPT_REPLAY_MSG 9
#define PXEBC_DHCP6_OPT_AUTH 11
#define PXEBC_DHCP6_OPT_UNICAST 12
#define PXEBC_DHCP6_OPT_STATUS_CODE 13
#define PXEBC_DHCP6_OPT_RAPID_COMMIT 14
#define PXEBC_DHCP6_OPT_USER_CLASS 15
#define PXEBC_DHCP6_OPT_VENDOR_CLASS 16
#define PXEBC_DHCP6_OPT_VENDOR_OPTS 17
#define PXEBC_DHCP6_OPT_INTERFACE_ID 18
#define PXEBC_DHCP6_OPT_RECONFIG_MSG 19
#define PXEBC_DHCP6_OPT_RECONFIG_ACCEPT 20
#define PXEBC_DHCP6_OPT_BOOT_FILE_URL 59 // Assigned by IANA, RFC 5970
#define PXEBC_DHCP6_OPT_BOOT_FILE_PARAM 60 // Assigned by IANA, RFC 5970
#define PXEBC_DHCP6_OPT_ARCH 61 // Assigned by IANA, RFC 5970
#define PXEBC_DHCP6_OPT_UNDI 62 // Assigned by IANA, RFC 5970
#define PXEBC_DHCP6_ENTERPRISE_NUM 343 // TODO: IANA TBD: temporarily using Intel's
#define PXEBC_DHCP6_MAX_BOOT_FILE_SIZE 65535 // It's a limitation of bit length, 65535*512 bytes.
#define PXEBC_DHCP6_IDX_IA_NA 0
#define PXEBC_DHCP6_IDX_BOOT_FILE_URL 1
#define PXEBC_DHCP6_IDX_BOOT_FILE_PARAM 2
#define PXEBC_DHCP6_IDX_VENDOR_CLASS 3
#define PXEBC_DHCP6_IDX_MAX 4
#define PXEBC_DHCP6_BOOT_FILE_URL_PREFIX "tftp://"
#define PXEBC_TFTP_URL_SEPARATOR '/'
#define PXEBC_ADDR_START_DELIMITER '['
#define PXEBC_ADDR_END_DELIMITER ']'
#define GET_NEXT_DHCP6_OPTION(Opt) \
(EFI_DHCP6_PACKET_OPTION *) ((UINT8 *) (Opt) + \
sizeof (EFI_DHCP6_PACKET_OPTION) + (NTOHS ((Opt)->OpLen)) - 1)
#define GET_DHCP6_OPTION_SIZE(Pkt) \
((Pkt)->Length - sizeof (EFI_DHCP6_HEADER))
#define IS_PROXY_OFFER(Type) \
((Type) == PxeOfferTypeProxyBinl || \
(Type) == PxeOfferTypeProxyPxe10 || \
(Type) == PxeOfferTypeProxyWfm11a)
#pragma pack(1)
typedef struct {
UINT16 OpCode[256];
} PXEBC_DHCP6_OPTION_ORO;
typedef struct {
UINT8 Type;
UINT8 MajorVer;
UINT8 MinorVer;
UINT8 Reserved;
} PXEBC_DHCP6_OPTION_UNDI;
typedef struct {
UINT16 Type;
} PXEBC_DHCP6_OPTION_ARCH;
typedef struct {
UINT8 ClassIdentifier[10];
UINT8 ArchitecturePrefix[5];
UINT8 ArchitectureType[5];
UINT8 Lit3[1];
UINT8 InterfaceName[4];
UINT8 Lit4[1];
UINT8 UndiMajor[3];
UINT8 UndiMinor[3];
} PXEBC_CLASS_ID;
typedef struct {
UINT32 Vendor;
UINT16 ClassLen;
PXEBC_CLASS_ID ClassId;
} PXEBC_DHCP6_OPTION_VENDOR_CLASS;
#pragma pack()
typedef union {
PXEBC_DHCP6_OPTION_ORO *Oro;
PXEBC_DHCP6_OPTION_UNDI *Undi;
PXEBC_DHCP6_OPTION_ARCH *Arch;
PXEBC_DHCP6_OPTION_VENDOR_CLASS *VendorClass;
} PXEBC_DHCP6_OPTION_ENTRY;
typedef struct {
LIST_ENTRY Link;
EFI_DHCP6_PACKET_OPTION *Option;
UINT8 Precedence;
} PXEBC_DHCP6_OPTION_NODE;
typedef union {
EFI_DHCP6_PACKET Offer;
EFI_DHCP6_PACKET Ack;
UINT8 Buffer[PXEBC_DHCP6_PACKET_MAX_SIZE];
} PXEBC_DHCP6_PACKET;
typedef struct {
PXEBC_DHCP6_PACKET Packet;
PXEBC_OFFER_TYPE OfferType;
EFI_DHCP6_PACKET_OPTION *OptList[PXEBC_DHCP6_IDX_MAX];
} PXEBC_DHCP6_PACKET_CACHE;
/**
Free all the nodes in the boot file list.
@param[in] Head The pointer to the head of the list.
**/
VOID
PxeBcFreeBootFileOption (
IN LIST_ENTRY *Head
);
/**
Parse the Boot File URL option.
@param[out] FileName The pointer to the boot file name.
@param[in, out] SrvAddr The pointer to the boot server address.
@param[in] BootFile The pointer to the boot file URL option data.
@param[in] Length Length of the boot file URL option data.
@retval EFI_ABORTED User canceled the operation.
@retval EFI_SUCCESS Selected the boot menu successfully.
@retval EFI_NOT_READY Read the input key from the keybroad has not finish.
**/
EFI_STATUS
PxeBcExtractBootFileUrl (
OUT UINT8 **FileName,
IN OUT EFI_IPv6_ADDRESS *SrvAddr,
IN CHAR8 *BootFile,
IN UINT16 Length
);
/**
Parse the Boot File Parameter option.
@param[in] BootFilePara The pointer to the boot file parameter option data.
@param[out] BootFileSize The pointer to the parsed boot file size.
@retval EFI_SUCCESS Successfully obtained the boot file size from parameter option.
@retval EFI_NOT_FOUND Failed to extract the boot file size from parameter option.
**/
EFI_STATUS
PxeBcExtractBootFileParam (
IN CHAR8 *BootFilePara,
OUT UINT16 *BootFileSize
);
/**
Parse the cached DHCPv6 packet, including all the options.
@param[in] Cache6 The pointer to a cached DHCPv6 packet.
@retval EFI_SUCCESS Parsed the DHCPv6 packet successfully.
@retval EFI_DEVICE_ERROR Failed to parse and invalid packet.
**/
EFI_STATUS
PxeBcParseDhcp6Packet (
IN PXEBC_DHCP6_PACKET_CACHE *Cache6
);
/**
Register the ready address by Ip6Config protocol.
@param[in] Private The pointer to the PxeBc private data.
@param[in] Address The pointer to the ready address.
@retval EFI_SUCCESS Registered the address succesfully.
@retval Others Failed to register the address.
**/
EFI_STATUS
PxeBcRegisterIp6Address (
IN PXEBC_PRIVATE_DATA *Private,
IN EFI_IPv6_ADDRESS *Address
);
/**
Unregister the address by Ip6Config protocol.
@param[in] Private The pointer to the PxeBc private data.
**/
VOID
PxeBcUnregisterIp6Address (
IN PXEBC_PRIVATE_DATA *Private
);
/**
Build and send out the request packet for the bootfile, and parse the reply.
@param[in] Private The pointer to the PxeBc private data.
@param[in] Type PxeBc option boot item type.
@param[in] Layer The pointer to the option boot item layer.
@param[in] UseBis Use BIS or not.
@param[in] DestIp The pointer to the server address.
@retval EFI_SUCCESS Successfully discovered theboot file.
@retval EFI_OUT_OF_RESOURCES Failed to allocate resource.
@retval EFI_NOT_FOUND Can't get the PXE reply packet.
@retval Others Failed to discover boot file.
**/
EFI_STATUS
PxeBcDhcp6Discover (
IN PXEBC_PRIVATE_DATA *Private,
IN UINT16 Type,
IN UINT16 *Layer,
IN BOOLEAN UseBis,
IN EFI_IP_ADDRESS *DestIp
);
/**
Start the DHCPv6 S.A.R.R. process to acquire the IPv6 address and other PXE boot information.
@param[in] Private The pointer to the PxeBc private data.
@param[in] Dhcp6 The pointer to EFI_DHCP6_PROTOCOL.
@retval EFI_SUCCESS The S.A.R.R. process successfully finished.
@retval Others Failed to finish the S.A.R.R. process.
**/
EFI_STATUS
PxeBcDhcp6Sarr (
IN PXEBC_PRIVATE_DATA *Private,
IN EFI_DHCP6_PROTOCOL *Dhcp6
);
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,104 @@
/** @file
Driver Binding functions declaration for UefiPxeBc Driver.
Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php.
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#ifndef __EFI_PXEBC_DRIVER_H__
#define __EFI_PXEBC_DRIVER_H__
extern EFI_COMPONENT_NAME_PROTOCOL gPxeBcComponentName;
extern EFI_COMPONENT_NAME2_PROTOCOL gPxeBcComponentName2;
/**
Test to see if this driver supports ControllerHandle. This service
is called by the EFI boot service ConnectController(). In
order to make drivers as small as possible, there are a few calling
restrictions for this service. ConnectController() must
follow these calling restrictions. If any other agent wishes to call
Supported() it must also follow these calling restrictions.
@param[in] This The pointer to the driver binding protocol.
@param[in] ControllerHandle The handle of device to be tested.
@param[in] RemainingDevicePath Optional parameter use to pick a specific child
device to be started.
@retval EFI_SUCCESS This driver supports this device.
@retval EFI_UNSUPPORTED This driver does not support this device.
**/
EFI_STATUS
EFIAPI
PxeBcDriverBindingSupported (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
);
/**
Start this driver on ControllerHandle. This service is called by the
EFI boot service ConnectController(). In order to make
drivers as small as possible, there are a few calling restrictions for
this service. ConnectController() must follow these
calling restrictions. If any other agent wishes to call Start() it
must also follow these calling restrictions.
@param[in] This The pointer to the driver binding protocol.
@param[in] ControllerHandle The handle of device to be started.
@param[in] RemainingDevicePath Optional parameter used to pick a specific child
device to be started.
@retval EFI_SUCCESS This driver is installed to ControllerHandle.
@retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle.
@retval other This driver does not support this device.
**/
EFI_STATUS
EFIAPI
PxeBcDriverBindingStart (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
);
/**
Stop this driver on ControllerHandle. This service is called by the
EFI boot service DisconnectController(). In order to
make drivers as small as possible, there are a few calling
restrictions for this service. DisconnectController()
must follow these calling restrictions. If any other agent wishes
to call Stop() it must also follow these calling restrictions.
@param[in] This Protocol instance pointer.
@param[in] ControllerHandle Handle of device to stop driver on
@param[in] NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
children is zero stop the entire bus driver.
@param[in] ChildHandleBuffer List of Child Handles to Stop.
@retval EFI_SUCCESS This driver is removed ControllerHandle
@retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
@retval Others This driver was not removed from this device.
**/
EFI_STATUS
EFIAPI
PxeBcDriverBindingStop (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN UINTN NumberOfChildren,
IN EFI_HANDLE *ChildHandleBuffer
);
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,207 @@
/** @file
This EFI_PXE_BASE_CODE_PROTOCOL and EFI_LOAD_FILE_PROTOCOL.
interfaces declaration.
Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php.
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#ifndef __EFI_PXEBC_IMPL_H__
#define __EFI_PXEBC_IMPL_H__
#include <Uefi.h>
#include <Guid/SmBios.h>
#include <IndustryStandard/SmBios.h>
#include <Protocol/NetworkInterfaceIdentifier.h>
#include <Protocol/Arp.h>
#include <Protocol/Ip4.h>
#include <Protocol/Ip6.h>
#include <Protocol/Ip6Config.h>
#include <Protocol/Udp4.h>
#include <Protocol/Udp6.h>
#include <Protocol/Dhcp4.h>
#include <Protocol/Dhcp6.h>
#include <Protocol/Mtftp4.h>
#include <Protocol/Mtftp6.h>
#include <Protocol/PxeBaseCode.h>
#include <Protocol/LoadFile.h>
#include <Protocol/PxeBaseCodeCallBack.h>
#include <Protocol/ServiceBinding.h>
#include <Protocol/DriverBinding.h>
#include <Library/DebugLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/UefiDriverEntryPoint.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiLib.h>
#include <Library/BaseLib.h>
#include <Library/NetLib.h>
#include <Library/DpcLib.h>
#include <Library/DevicePathLib.h>
#include <Library/PcdLib.h>
typedef struct _PXEBC_PRIVATE_DATA PXEBC_PRIVATE_DATA;
typedef struct _PXEBC_VIRTUAL_NIC PXEBC_VIRTUAL_NIC;
#include "PxeBcDriver.h"
#include "PxeBcDhcp4.h"
#include "PxeBcDhcp6.h"
#include "PxeBcMtftp.h"
#include "PxeBcBoot.h"
#include "PxeBcSupport.h"
#define PXEBC_DEFAULT_HOPLIMIT 64
#define PXEBC_DEFAULT_LIFETIME 50000 // 50 ms, unit is microsecond
#define PXEBC_UDP_TIMEOUT 30000000 // 3 seconds, unit is 100nanosecond
#define PXEBC_MTFTP_TIMEOUT 4
#define PXEBC_MTFTP_RETRIES 6
#define PXEBC_DHCP_RETRIES 4 // refers to mPxeDhcpTimeout, also by PXE2.1 spec.
#define PXEBC_MENU_MAX_NUM 24
#define PXEBC_OFFER_MAX_NUM 16
#define PXEBC_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('P', 'X', 'E', 'P')
#define PXEBC_VIRTUAL_NIC_SIGNATURE SIGNATURE_32 ('P', 'X', 'E', 'V')
#define PXEBC_PRIVATE_DATA_FROM_PXEBC(a) CR (a, PXEBC_PRIVATE_DATA, PxeBc, PXEBC_PRIVATE_DATA_SIGNATURE)
#define PXEBC_VIRTUAL_NIC_FROM_LOADFILE(a) CR (a, PXEBC_VIRTUAL_NIC, LoadFile, PXEBC_VIRTUAL_NIC_SIGNATURE)
typedef union {
PXEBC_DHCP4_PACKET_CACHE Dhcp4;
PXEBC_DHCP6_PACKET_CACHE Dhcp6;
} PXEBC_DHCP_PACKET_CACHE;
struct _PXEBC_VIRTUAL_NIC {
UINT32 Signature;
EFI_HANDLE Controller;
EFI_LOAD_FILE_PROTOCOL LoadFile;
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
PXEBC_PRIVATE_DATA *Private;
};
struct _PXEBC_PRIVATE_DATA {
UINT32 Signature;
EFI_HANDLE Controller;
EFI_HANDLE Image;
PXEBC_VIRTUAL_NIC *Ip4Nic;
PXEBC_VIRTUAL_NIC *Ip6Nic;
EFI_HANDLE ArpChild;
EFI_HANDLE Ip4Child;
EFI_HANDLE Dhcp4Child;
EFI_HANDLE Mtftp4Child;
EFI_HANDLE Udp4ReadChild;
EFI_HANDLE Udp4WriteChild;
EFI_ARP_PROTOCOL *Arp;
EFI_IP4_PROTOCOL *Ip4;
EFI_DHCP4_PROTOCOL *Dhcp4;
EFI_MTFTP4_PROTOCOL *Mtftp4;
EFI_UDP4_PROTOCOL *Udp4Read;
EFI_UDP4_PROTOCOL *Udp4Write;
EFI_HANDLE Ip6Child;
EFI_HANDLE Dhcp6Child;
EFI_HANDLE Mtftp6Child;
EFI_HANDLE Udp6ReadChild;
EFI_HANDLE Udp6WriteChild;
EFI_IP6_PROTOCOL *Ip6;
EFI_IP6_CONFIG_PROTOCOL *Ip6Cfg;
EFI_DHCP6_PROTOCOL *Dhcp6;
EFI_MTFTP6_PROTOCOL *Mtftp6;
EFI_UDP6_PROTOCOL *Udp6Read;
EFI_UDP6_PROTOCOL *Udp6Write;
EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL *Nii;
EFI_PXE_BASE_CODE_PROTOCOL PxeBc;
EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL LoadFileCallback;
EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL *PxeBcCallback;
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
EFI_PXE_BASE_CODE_MODE Mode;
EFI_PXE_BASE_CODE_FUNCTION Function;
UINT32 Ip6Policy;
EFI_UDP4_CONFIG_DATA Udp4CfgData;
EFI_UDP6_CONFIG_DATA Udp6CfgData;
EFI_IP4_CONFIG_DATA Ip4CfgData;
EFI_IP6_CONFIG_DATA Ip6CfgData;
EFI_EVENT UdpTimeOutEvent;
EFI_EVENT ArpUpdateEvent;
EFI_IP4_COMPLETION_TOKEN IcmpToken;
EFI_IP6_COMPLETION_TOKEN Icmp6Token;
BOOLEAN IsAddressOk;
BOOLEAN IsOfferSorted;
BOOLEAN IsProxyRecved;
BOOLEAN IsDoDiscover;
EFI_IP_ADDRESS StationIp;
EFI_IP_ADDRESS SubnetMask;
EFI_IP_ADDRESS GatewayIp;
EFI_IP_ADDRESS ServerIp;
UINT16 CurSrcPort;
UINT32 Ip4MaxPacketSize;
UINT32 Ip6MaxPacketSize;
UINT8 *BootFileName;
UINTN BootFileSize;
UINTN BlockSize;
PXEBC_DHCP_PACKET_CACHE ProxyOffer;
PXEBC_DHCP_PACKET_CACHE DhcpAck;
PXEBC_DHCP_PACKET_CACHE PxeReply;
EFI_DHCP6_PACKET *Dhcp6Request;
EFI_DHCP4_PACKET SeedPacket;
//
// OfferIndex records the index of DhcpOffer[] buffer, and OfferCount records the num of each type of offer.
//
// It supposed that
//
// OfferNum: 8
// OfferBuffer: [ProxyBinl, ProxyBinl, DhcpOnly, ProxyPxe10, DhcpOnly, DhcpPxe10, DhcpBinl, ProxyBinl]
// (OfferBuffer is 0-based.)
//
// And assume that (DhcpPxe10 is the first priority actually.)
//
// SelectIndex: 2
// SelectProxyType: PXEBC_OFFER_TYPE_PROXY_BINL
// (SelectIndex is 1-based, and 0 means no one is selected.)
//
// So it should be
//
// DhcpOnly DhcpPxe10 DhcpWfm11a DhcpBinl ProxyPxe10 ProxyWfm11a ProxyBinl Bootp
// OfferCount: [ 2(n), 1(n), 0(n), 1(n), 1(1), 0(1), 3(n), 1(1)]
//
// OfferIndex: {[ 2, 5, 0, 6, 3, 0, *0, 0]
// [ 4, 0, 0, 0, 0, 0, 1, 0]
// [ 0, 0, 0, 0, 0, 0, 7, 0]
// ... ]}
// (OfferIndex is 0-based.)
//
//
UINT32 SelectIndex;
UINT32 SelectProxyType;
PXEBC_DHCP_PACKET_CACHE OfferBuffer[PXEBC_OFFER_MAX_NUM];
UINT32 OfferNum;
UINT32 OfferCount[PxeOfferTypeMax];
UINT32 OfferIndex[PxeOfferTypeMax][PXEBC_OFFER_MAX_NUM];
};
extern EFI_PXE_BASE_CODE_PROTOCOL gPxeBcProtocolTemplate;
extern EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL gPxeBcCallBackTemplate;
extern EFI_LOAD_FILE_PROTOCOL gLoadFileProtocolTemplate;
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,136 @@
/** @file
Functions declaration related with Mtftp for UefiPxeBc Driver.
Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php.
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#ifndef __EFI_PXEBC_MTFTP_H__
#define __EFI_PXEBC_MTFTP_H__
#define PXE_MTFTP_OPTION_BLKSIZE_INDEX 0
#define PXE_MTFTP_OPTION_TIMEOUT_INDEX 1
#define PXE_MTFTP_OPTION_TSIZE_INDEX 2
#define PXE_MTFTP_OPTION_MULTICAST_INDEX 3
#define PXE_MTFTP_OPTION_MAXIMUM_INDEX 4
#define PXE_MTFTP_ERROR_STRING_LENGTH 127 // refer to definition of struct EFI_PXE_BASE_CODE_TFTP_ERROR.
#define PXE_MTFTP_DEFAULT_BLOCK_SIZE 512 // refer to rfc-1350.
/**
This function is wrapper to get the file size using TFTP.
@param[in] Private Pointer to PxeBc private data.
@param[in] Config Pointer to configure data.
@param[in] Filename Pointer to boot file name.
@param[in] BlockSize Pointer to required block size.
@param[in, out] BufferSize Pointer to buffer size.
@retval EFI_SUCCESS Successfully obtained the size of file.
@retval EFI_NOT_FOUND Parse the tftp ptions failed.
@retval EFI_DEVICE_ERROR The network device encountered an error during this operation.
@retval Others Did not obtain the size of the file.
**/
EFI_STATUS
PxeBcTftpGetFileSize (
IN PXEBC_PRIVATE_DATA *Private,
IN VOID *Config,
IN UINT8 *Filename,
IN UINTN *BlockSize,
IN OUT UINT64 *BufferSize
);
/**
This function is a wrapper to get a file using TFTP.
@param[in] Private Pointer to PxeBc private data.
@param[in] Config Pointer to config data.
@param[in] Filename Pointer to boot file name.
@param[in] BlockSize Pointer to required block size.
@param[in] BufferPtr Pointer to buffer.
@param[in, out] BufferSize Pointer to buffer size.
@param[in] DontUseBuffer Indicates whether to use a receive buffer.
@retval EFI_SUCCESS Successfully read the data from the special file.
@retval EFI_DEVICE_ERROR The network device encountered an error during this operation.
@retval Others Read data from file failed.
**/
EFI_STATUS
PxeBcTftpReadFile (
IN PXEBC_PRIVATE_DATA *Private,
IN VOID *Config,
IN UINT8 *Filename,
IN UINTN *BlockSize,
IN UINT8 *BufferPtr,
IN OUT UINT64 *BufferSize,
IN BOOLEAN DontUseBuffer
);
/**
This function is a wrapper to put file with TFTP.
@param[in] Private Pointer to PxeBc private data.
@param[in] Config Pointer to config data.
@param[in] Filename Pointer to boot file name.
@param[in] Overwrite Indicates whether to use an overwrite attribute.
@param[in] BlockSize Pointer to required block size.
@param[in] BufferPtr Pointer to buffer.
@param[in, out] BufferSize Pointer to buffer size.
@retval EFI_SUCCESS Successfully wrote the data into the special file.
@retval EFI_DEVICE_ERROR The network device encountered an error during this operation.
@retval other Write data into file failed.
**/
EFI_STATUS
PxeBcTftpWriteFile (
IN PXEBC_PRIVATE_DATA *Private,
IN VOID *Config,
IN UINT8 *Filename,
IN BOOLEAN Overwrite,
IN UINTN *BlockSize,
IN UINT8 *BufferPtr,
IN OUT UINT64 *BufferSize
);
/**
This function is a wrapper to get the data (file) from a directory using TFTP.
@param[in] Private Pointer to PxeBc private data.
@param[in] Config Pointer to config data.
@param[in] Filename Pointer to boot file name.
@param[in] BlockSize Pointer to required block size.
@param[in] BufferPtr Pointer to buffer.
@param[in, out] BufferSize Pointer to buffer size.
@param[in] DontUseBuffer Indicates whether with a receive buffer.
@retval EFI_SUCCES Successfully obtained the data from the file included in directory.
@retval EFI_DEVICE_ERROR The network device encountered an error during this operation.
@retval Others Operation failed.
**/
EFI_STATUS
PxeBcTftpReadDirectory (
IN PXEBC_PRIVATE_DATA *Private,
IN VOID *Config,
IN UINT8 *Filename,
IN UINTN *BlockSize,
IN UINT8 *BufferPtr,
IN OUT UINT64 *BufferSize,
IN BOOLEAN DontUseBuffer
);
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,491 @@
/** @file
Support functions declaration for UefiPxeBc Driver.
Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php.
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#ifndef __EFI_PXEBC_SUPPORT_H__
#define __EFI_PXEBC_SUPPORT_H__
#define ICMP_DEST_UNREACHABLE 3
#define ICMP_SOURCE_QUENCH 4
#define ICMP_REDIRECT 5
#define ICMP_ECHO_REQUEST 8
#define ICMP_TIME_EXCEEDED 11
#define ICMP_PARAMETER_PROBLEM 12
/**
This function obtain the system guid and serial number from the smbios table.
@param[out] SystemGuid The pointer of returned system guid.
@retval EFI_SUCCESS Successfully obtained the system guid.
@retval EFI_NOT_FOUND Did not find the SMBIOS table.
**/
EFI_STATUS
PxeBcGetSystemGuid (
OUT EFI_GUID *SystemGuid
);
/**
Flush the previous configration using the new station Ip address.
@param[in] Private Pointer to PxeBc private data.
@param[in] StationIp Pointer to the station Ip address.
@param[in] SubnetMask Pointer to the subnet mask address for v4.
@retval EFI_SUCCESS Successfully flushed the previous config.
@retval Others Failed to flush using the new station Ip.
**/
EFI_STATUS
PxeBcFlushStaionIp (
PXEBC_PRIVATE_DATA *Private,
EFI_IP_ADDRESS *StationIp,
EFI_IP_ADDRESS *SubnetMask OPTIONAL
);
/**
Notify callback function when an event is triggered.
@param[in] Event The triggered event.
@param[in] Context The opaque parameter to the function.
**/
VOID
EFIAPI
PxeBcCommonNotify (
IN EFI_EVENT Event,
IN VOID *Context
);
/**
Perform arp resolution from the arp cache in PxeBcMode.
@param Mode Pointer to EFI_PXE_BASE_CODE_MODE.
@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 Found a matched entry.
@retval FALSE Did not find a matched entry.
**/
BOOLEAN
PxeBcCheckArpCache (
IN EFI_PXE_BASE_CODE_MODE *Mode,
IN EFI_IPv4_ADDRESS *Ip4Addr,
OUT EFI_MAC_ADDRESS *MacAddress
);
/**
Update arp cache periodically.
@param Event Pointer to EFI_PXE_BC_PROTOCOL.
@param Context Context of the timer event.
**/
VOID
EFIAPI
PxeBcArpCacheUpdate (
IN EFI_EVENT Event,
IN VOID *Context
);
/**
xxx
@param Event The event signaled.
@param Context The context passed in by the event notifier.
**/
VOID
EFIAPI
PxeBcIcmpErrorUpdate (
IN EFI_EVENT Event,
IN VOID *Context
);
/**
xxx
@param Event The event signaled.
@param Context The context passed in by the event notifier.
**/
VOID
EFIAPI
PxeBcIcmp6ErrorUpdate (
IN EFI_EVENT Event,
IN VOID *Context
);
/**
This function is to configure a UDPv4 instance for UdpWrite.
@param[in] Udp4 Pointer to EFI_UDP4_PROTOCOL.
@param[in] StationIp Pointer to the station address.
@param[in] SubnetMask Pointer to the subnet mask.
@param[in] Gateway Pointer to the gateway address.
@param[in, out] SrcPort Pointer to the source port.
@param[in] DoNotFragment The flag of DoNotFragment bit in the IPv4
packet.
@retval EFI_SUCCESS Successfully configured this instance.
@retval Others Failed to configure this instance.
**/
EFI_STATUS
PxeBcConfigUdp4Write (
IN EFI_UDP4_PROTOCOL *Udp4,
IN EFI_IPv4_ADDRESS *StationIp,
IN EFI_IPv4_ADDRESS *SubnetMask,
IN EFI_IPv4_ADDRESS *Gateway,
IN OUT UINT16 *SrcPort,
IN BOOLEAN DoNotFragment
);
/**
This function is to configure a UDPv6 instance for UdpWrite.
@param[in] Udp6 Pointer to EFI_UDP6_PROTOCOL.
@param[in] StationIp Pointer to the station address.
@param[in, out] SrcPort Pointer to the source port.
@retval EFI_SUCCESS Successfuly configured this instance.
@retval Others Failed to configure this instance.
**/
EFI_STATUS
PxeBcConfigUdp6Write (
IN EFI_UDP6_PROTOCOL *Udp6,
IN EFI_IPv6_ADDRESS *StationIp,
IN OUT UINT16 *SrcPort
);
/**
This function is to configure a UDPv4 instance for UdpWrite.
@param[in] Udp4 Pointer to EFI_UDP4_PROTOCOL.
@param[in] Session Pointer to the UDP4 session data.
@param[in] TimeoutEvent The event for timeout.
@param[in] Gateway Pointer to the gateway address.
@param[in] 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[in] HeaderPtr If HeaderSize is not NULL, a pointer to a header to be
prefixed to the data at BufferPtr.
@param[in] BufferSize A pointer to the size of the data at BufferPtr.
@param[in] BufferPtr A pointer to the data to be written.
@retval EFI_SUCCESS Successfully sent out data with Udp4Write.
@retval Others Failed to send out data.
**/
EFI_STATUS
PxeBcUdp4Write (
IN EFI_UDP4_PROTOCOL *Udp4,
IN EFI_UDP4_SESSION_DATA *Session,
IN EFI_EVENT TimeoutEvent,
IN EFI_IPv4_ADDRESS *Gateway OPTIONAL,
IN UINTN *HeaderSize OPTIONAL,
IN VOID *HeaderPtr OPTIONAL,
IN UINTN *BufferSize,
IN VOID *BufferPtr
);
/**
This function is to configure a UDPv6 instance for UdpWrite.
@param[in] Udp6 Pointer to EFI_UDP6_PROTOCOL.
@param[in] Session Pointer to the UDP6 session data.
@param[in] TimeoutEvent The event for timeout.
@param[in] 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[in] HeaderPtr If HeaderSize is not NULL, a pointer to a header to be
prefixed to the data at BufferPtr.
@param[in] BufferSize A pointer to the size of the data at BufferPtr.
@param[in] BufferPtr A pointer to the data to be written.
@retval EFI_SUCCESS Successfully to send out data with Udp6Write.
@retval Others Failed to send out data.
**/
EFI_STATUS
PxeBcUdp6Write (
IN EFI_UDP6_PROTOCOL *Udp6,
IN EFI_UDP6_SESSION_DATA *Session,
IN EFI_EVENT TimeoutEvent,
IN UINTN *HeaderSize OPTIONAL,
IN VOID *HeaderPtr OPTIONAL,
IN UINTN *BufferSize,
IN VOID *BufferPtr
);
/**
Check the received packet with the Ip filter.
@param[in] Mode Pointer to mode data of PxeBc.
@param[in] Session Pointer to the current UDPv4 session.
@param[in] OpFlags Operation flag for UdpRead/UdpWrite.
@retval TRUE Succesfully passed the Ip filter.
@retval FALSE Failed to pass the Ip filter.
**/
BOOLEAN
PxeBcCheckByIpFilter (
IN EFI_PXE_BASE_CODE_MODE *Mode,
IN VOID *Session,
IN UINT16 OpFlags
);
/**
Filter the received packet with the destination Ip.
@param[in] Mode Pointer to mode data of PxeBc.
@param[in] Session Pointer to the current UDPv4 session.
@param[in, out] DestIp Pointer to the dest Ip address.
@param[in] OpFlags Operation flag for UdpRead/UdpWrite.
@retval TRUE Succesfully passed the IPv4 filter.
@retval FALSE Failed to pass the IPv4 filter.
**/
BOOLEAN
PxeBcCheckByDestIp (
IN EFI_PXE_BASE_CODE_MODE *Mode,
IN VOID *Session,
IN OUT EFI_IP_ADDRESS *DestIp,
IN UINT16 OpFlags
);
/**
Check the received packet with the destination port.
@param[in] PxeBcMode Pointer to mode data of PxeBc.
@param[in] Session Pointer to the current UDPv4 session.
@param[in, out] DestPort Pointer to the destination port.
@param[in] OpFlags Operation flag for UdpRead/UdpWrite.
@retval TRUE Succesfully passed the IPv4 filter.
@retval FALSE Failed to pass the IPv4 filter.
**/
BOOLEAN
PxeBcCheckByDestPort (
IN EFI_PXE_BASE_CODE_MODE *Mode,
IN VOID *Session,
IN OUT UINT16 *DestPort,
IN UINT16 OpFlags
);
/**
Filter the received packet with the source Ip.
@param[in] Mode Pointer to mode data of PxeBc.
@param[in] Session Pointer to the current UDPv4 session.
@param[in, out] SrcIp Pointer to the source Ip address.
@param[in] OpFlags Operation flag for UdpRead/UdpWrite.
@retval TRUE Succesfully passed the IPv4 filter.
@retval FALSE Failed to pass the IPv4 filter.
**/
BOOLEAN
PxeBcFilterBySrcIp (
IN EFI_PXE_BASE_CODE_MODE *Mode,
IN VOID *Session,
IN OUT EFI_IP_ADDRESS *SrcIp,
IN UINT16 OpFlags
);
/**
Filter the received packet with the source port.
@param[in] Mode Pointer to mode data of PxeBc.
@param[in] Session Pointer to the current UDPv4 session.
@param[in, out] SrcPort Pointer to the source port.
@param[in] OpFlags Operation flag for UdpRead/UdpWrite.
@retval TRUE Succesfully passed the IPv4 filter.
@retval FALSE Failed to pass the IPv4 filter.
**/
BOOLEAN
PxeBcFilterBySrcPort (
IN EFI_PXE_BASE_CODE_MODE *Mode,
IN VOID *Session,
IN OUT UINT16 *SrcPort,
IN UINT16 OpFlags
);
/**
This function is to receive packet with Udp4Read.
@param[in] Udp4 Pointer to EFI_UDP4_PROTOCOL.
@param[in] Token Pointer to EFI_UDP4_COMPLETION_TOKEN.
@param[in] Mode Pointer to EFI_PXE_BASE_CODE_MODE.
@param[in] TimeoutEvent The event for timeout.
@param[in] OpFlags The UDP operation flags.
@param[in] IsDone Pointer to IsDone flag.
@param[out] IsMatched Pointer to IsMatched flag.
@param[in, out] DestIp Pointer to destination address.
@param[in, out] DestPort Pointer to destination port.
@param[in, out] SrcIp Pointer to source address.
@param[in, out] SrcPort Pointer to source port.
@retval EFI_SUCCESS Successfully read data with Udp4.
@retval Others Failed to send out data.
**/
EFI_STATUS
PxeBcUdp4Read (
IN EFI_UDP4_PROTOCOL *Udp4,
IN EFI_UDP4_COMPLETION_TOKEN *Token,
IN EFI_PXE_BASE_CODE_MODE *Mode,
IN EFI_EVENT TimeoutEvent,
IN UINT16 OpFlags,
IN BOOLEAN *IsDone,
OUT BOOLEAN *IsMatched,
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
);
/**
This function is to receive packet with Udp6Read.
@param[in] Udp6 Pointer to EFI_UDP6_PROTOCOL.
@param[in] Token Pointer to EFI_UDP6_COMPLETION_TOKEN.
@param[in] Mode Pointer to EFI_PXE_BASE_CODE_MODE.
@param[in] TimeoutEvent The event for timeout.
@param[in] OpFlags The UDP operation flags.
@param[in] IsDone Pointer to IsDone flag.
@param[out] IsMatched Pointer to IsMatched flag.
@param[in, out] DestIp Pointer to destination address.
@param[in, out] DestPort Pointer to destination port.
@param[in, out] SrcIp Pointer to source address.
@param[in, out] SrcPort Pointer to source port.
@retval EFI_SUCCESS Successfully read data with Udp6.
@retval Others Failed to send out data.
**/
EFI_STATUS
PxeBcUdp6Read (
IN EFI_UDP6_PROTOCOL *Udp6,
IN EFI_UDP6_COMPLETION_TOKEN *Token,
IN EFI_PXE_BASE_CODE_MODE *Mode,
IN EFI_EVENT TimeoutEvent,
IN UINT16 OpFlags,
IN BOOLEAN *IsDone,
OUT BOOLEAN *IsMatched,
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
);
/**
This function is to display the IPv4 address.
@param[in] Ip Pointer to the IPv4 address.
**/
VOID
PxeBcShowIp4Addr (
IN EFI_IPv4_ADDRESS *Ip
);
/**
This function is to display the IPv6 address.
@param[in] Ip Pointer to the IPv6 address.
**/
VOID
PxeBcShowIp6Addr (
IN EFI_IPv6_ADDRESS *Ip
);
/**
This function is to convert UINTN to ASCII string with required format.
@param[in] Number Numeric value to be converted.
@param[in] Buffer Pointer to the buffer for ASCII string.
@param[in] Length Length of the required format.
**/
VOID
PxeBcUintnToAscDecWithFormat (
IN UINTN Number,
IN UINT8 *Buffer,
IN INTN Length
);
/**
This function is to convert a UINTN to a ASCII string, and return the
actual length of the buffer.
@param[in] Number Numeric value to be converted.
@param[in] Buffer Pointer to the buffer for ASCII string.
@return Length The actual length of the ASCII string.
**/
UINTN
PxeBcUintnToAscDec (
IN UINTN Number,
IN UINT8 *Buffer
);
/**
This function is to convert unicode hex number to a UINT8.
@param[out] Digit The converted UINT8 for output.
@param[in] Char The unicode hex number to be converted.
@retval EFI_SUCCESS Successfully converted the unicode hex.
@retval EFI_INVALID_PARAMETER Failed to convert the unicode hex.
**/
EFI_STATUS
PxeBcUniHexToUint8 (
OUT UINT8 *Digit,
IN CHAR16 Char
);
#endif

View File

@@ -0,0 +1,98 @@
## @file
# Component name for module PxeBc
#
# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php.
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
##
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = UefiPxeBcDxe
FILE_GUID = B95E9FDA-26DE-48d2-8807-1F9107AC5E3A
MODULE_TYPE = UEFI_DRIVER
VERSION_STRING = 1.0
ENTRY_POINT = PxeBcDriverEntryPoint
UNLOAD_IMAGE = NetLibDefaultUnload
#
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = IA32 X64 IPF
#
[Sources]
ComponentName.c
PxeBcDriver.c
PxeBcDriver.h
PxeBcImpl.c
PxeBcImpl.h
PxeBcBoot.c
PxeBcBoot.h
PxeBcDhcp6.c
PxeBcDhcp6.h
PxeBcDhcp4.c
PxeBcDhcp4.h
PxeBcMtftp.c
PxeBcMtftp.h
PxeBcSupport.c
PxeBcSupport.h
[Packages]
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec
[LibraryClasses]
BaseLib
UefiLib
UefiBootServicesTableLib
UefiDriverEntryPoint
BaseMemoryLib
MemoryAllocationLib
DebugLib
NetLib
DpcLib
DevicePathLib
PcdLib
[Guids]
gEfiSmbiosTableGuid
[Protocols]
gEfiDevicePathProtocolGuid
gEfiNetworkInterfaceIdentifierProtocolGuid_31
gEfiArpServiceBindingProtocolGuid
gEfiArpProtocolGuid
gEfiIp4ServiceBindingProtocolGuid
gEfiIp4ProtocolGuid
gEfiIp6ServiceBindingProtocolGuid
gEfiIp6ProtocolGuid
gEfiIp6ConfigProtocolGuid
gEfiUdp4ServiceBindingProtocolGuid
gEfiUdp4ProtocolGuid
gEfiMtftp4ServiceBindingProtocolGuid
gEfiMtftp4ProtocolGuid
gEfiDhcp4ServiceBindingProtocolGuid
gEfiDhcp4ProtocolGuid
gEfiUdp6ServiceBindingProtocolGuid
gEfiUdp6ProtocolGuid
gEfiMtftp6ServiceBindingProtocolGuid
gEfiMtftp6ProtocolGuid
gEfiDhcp6ServiceBindingProtocolGuid
gEfiDhcp6ProtocolGuid
gEfiPxeBaseCodeCallbackProtocolGuid
gEfiPxeBaseCodeProtocolGuid
gEfiLoadFileProtocolGuid
[Pcd]
gEfiMdeModulePkgTokenSpaceGuid.PcdTftpBlockSize ## CONSUMES