1. Import UEFI PxeBc module in MdeModulePkg

2. Remove some SMBIOS definitions defined in PxeBc module, use those who are defined in MdePkg.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@4495 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
vanjeff 2008-01-04 02:29:30 +00:00
parent 822360ee34
commit dc361cc5a0
19 changed files with 6205 additions and 113 deletions

View File

@ -267,6 +267,7 @@
MdeModulePkg/Universal/Network/MnpDxe/MnpDxe.inf
MdeModulePkg/Universal/Network/Mtftp4Dxe/Mtftp4Dxe.inf
MdeModulePkg/Universal/Network/PxeBcDxe/PxeBcDxe.inf
MdeModulePkg/Universal/Network/UefiPxeBcDxe/UefiPxeBcDxe.inf
MdeModulePkg/Universal/Network/PxeDhcp4Dxe/PxeDhcp4Dxe.inf
MdeModulePkg/Universal/Network/SnpDxe/SnpDxe.inf
MdeModulePkg/Universal/Network/Tcp4Dxe/Tcp4Dxe.inf

View File

@ -23,6 +23,7 @@ Abstract:
#include <PiDxe.h>
#include <Guid/SmBios.h>
#include <IndustryStandard/Smbios.h>
#include <Protocol/Bis.h>
#include <Protocol/PxeBaseCode.h>
#include <Protocol/PxeBaseCodeCallBack.h>
@ -437,117 +438,6 @@ PxeBcLibGetSmbiosSystemGuidAndSerialNumber (
)
;
//
// Define SMBIOS tables.
//
#pragma pack(1)
typedef struct {
UINT8 AnchorString[4];
UINT8 EntryPointStructureChecksum;
UINT8 EntryPointLength;
UINT8 MajorVersion;
UINT8 MinorVersion;
UINT16 MaxStructureSize;
UINT8 EntryPointRevision;
UINT8 FormattedArea[5];
UINT8 IntermediateAnchorString[5];
UINT8 IntermediateChecksum;
UINT16 TableLength;
UINT32 TableAddress;
UINT16 NumberOfSmbiosStructures;
UINT8 SmbiosBcdRevision;
} SMBIOS_STRUCTURE_TABLE;
//
// Please note that SMBIOS structures can be odd byte aligned since the
// unformated section of each record is a set of arbitrary size strings.
//
typedef struct {
UINT8 Type;
UINT8 Length;
UINT8 Handle[2];
} SMBIOS_HEADER;
typedef UINT8 SMBIOS_STRING;
typedef struct {
SMBIOS_HEADER Hdr;
SMBIOS_STRING Vendor;
SMBIOS_STRING BiosVersion;
UINT8 BiosSegment[2];
SMBIOS_STRING BiosReleaseDate;
UINT8 BiosSize;
UINT8 BiosCharacteristics[8];
} SMBIOS_TYPE0;
typedef struct {
SMBIOS_HEADER Hdr;
SMBIOS_STRING Manufacturer;
SMBIOS_STRING ProductName;
SMBIOS_STRING Version;
SMBIOS_STRING SerialNumber;
//
// always byte copy this data to prevent alignment faults!
//
EFI_GUID Uuid;
UINT8 WakeUpType;
} SMBIOS_TYPE1;
typedef struct {
SMBIOS_HEADER Hdr;
SMBIOS_STRING Manufacturer;
SMBIOS_STRING ProductName;
SMBIOS_STRING Version;
SMBIOS_STRING SerialNumber;
} SMBIOS_TYPE2;
typedef struct {
SMBIOS_HEADER Hdr;
SMBIOS_STRING Manufacturer;
UINT8 Type;
SMBIOS_STRING Version;
SMBIOS_STRING SerialNumber;
SMBIOS_STRING AssetTag;
UINT8 BootupState;
UINT8 PowerSupplyState;
UINT8 ThermalState;
UINT8 SecurityStatus;
UINT8 OemDefined[4];
} SMBIOS_TYPE3;
typedef struct {
SMBIOS_HEADER Hdr;
UINT8 Socket;
UINT8 ProcessorType;
UINT8 ProcessorFamily;
SMBIOS_STRING ProcessorManufacture;
UINT8 ProcessorId[8];
SMBIOS_STRING ProcessorVersion;
UINT8 Voltage;
UINT8 ExternalClock[2];
UINT8 MaxSpeed[2];
UINT8 CurrentSpeed[2];
UINT8 Status;
UINT8 ProcessorUpgrade;
UINT8 L1CacheHandle[2];
UINT8 L2CacheHandle[2];
UINT8 L3CacheHandle[2];
} SMBIOS_TYPE4;
typedef union {
SMBIOS_HEADER *Hdr;
SMBIOS_TYPE0 *Type0;
SMBIOS_TYPE1 *Type1;
SMBIOS_TYPE2 *Type2;
SMBIOS_TYPE3 *Type3;
SMBIOS_TYPE4 *Type4;
UINT8 *Raw;
} SMBIOS_STRUCTURE_POINTER;
#pragma pack()
#include "ip.h"
#include "dhcp.h"
#include "tftp.h"

View File

@ -473,7 +473,7 @@ PxeBcLibGetSmbiosSystemGuidAndSerialNumber (
)
{
EFI_STATUS Status;
SMBIOS_STRUCTURE_TABLE *SmbiosTable;
SMBIOS_TABLE_ENTRY_POINT *SmbiosTable;
SMBIOS_STRUCTURE_POINTER Smbios;
SMBIOS_STRUCTURE_POINTER SmbiosEnd;
UINT16 Index;
@ -484,7 +484,7 @@ PxeBcLibGetSmbiosSystemGuidAndSerialNumber (
return EFI_NOT_FOUND;
}
Smbios.Hdr = (SMBIOS_HEADER *) (UINTN) SmbiosTable->TableAddress;
Smbios.Hdr = (SMBIOS_STRUCTURE *) (UINTN) SmbiosTable->TableAddress;
SmbiosEnd.Raw = (UINT8 *) (UINTN) (SmbiosTable->TableAddress + SmbiosTable->TableLength);
for (Index = 0; Index < SmbiosTable->TableLength; Index++) {

View File

@ -0,0 +1,168 @@
/** @file
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
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:
**/
#include "PxeBcImpl.h"
//
// EFI Component Name Functions
//
EFI_STATUS
EFIAPI
PxeBcComponentNameGetDriverName (
IN EFI_COMPONENT_NAME_PROTOCOL * This,
IN CHAR8 *Language,
OUT CHAR16 **DriverName
);
EFI_STATUS
EFIAPI
PxeBcComponentNameGetControllerName (
IN EFI_COMPONENT_NAME_PROTOCOL * This,
IN EFI_HANDLE ControllerHandle,
IN EFI_HANDLE ChildHandle OPTIONAL,
IN CHAR8 *Language,
OUT CHAR16 **ControllerName
);
//
// EFI Component Name Protocol
//
GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gPxeBcComponentName = {
PxeBcComponentNameGetDriverName,
PxeBcComponentNameGetControllerName,
"eng"
};
GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gPxeBcComponentName2 = {
(EFI_COMPONENT_NAME2_GET_DRIVER_NAME) PxeBcComponentNameGetDriverName,
(EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) PxeBcComponentNameGetControllerName,
"en"
};
GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mPxeBcDriverNameTable[] = {
{
"eng;en",
L"UEFI PXE Base Code Driver"
},
{
NULL,
NULL
}
};
EFI_STATUS
EFIAPI
PxeBcComponentNameGetDriverName (
IN EFI_COMPONENT_NAME_PROTOCOL * This,
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,
This->SupportedLanguages,
mPxeBcDriverNameTable,
DriverName,
(BOOLEAN)(This == &gPxeBcComponentName)
);
}
EFI_STATUS
EFIAPI
PxeBcComponentNameGetControllerName (
IN EFI_COMPONENT_NAME_PROTOCOL * This,
IN EFI_HANDLE ControllerHandle,
IN EFI_HANDLE ChildHandle OPTIONAL,
IN CHAR8 *Language,
OUT CHAR16 **ControllerNameString
)
/*++
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;
}

View File

@ -0,0 +1,26 @@
/** @file
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
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_
#define _EFI_PXE_ARCH_H_
#define SYS_ARCH 0x6
#endif

View File

@ -0,0 +1,26 @@
/** @file
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
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_
#define _EFI_PXE_ARCH_H_
#define SYS_ARCH 0x2
#endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,542 @@
/** @file
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
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 {
PXEBC_DHCP4_MAX_OPTION_NUM = 16,
PXEBC_DHCP4_MAX_OPTION_SIZE = 312,
PXEBC_DHCP4_MAX_PACKET_SIZE = 1472,
PXEBC_DHCP4_S_PORT = 67,
PXEBC_DHCP4_C_PORT = 68,
PXEBC_BS_DOWNLOAD_PORT = 69,
PXEBC_BS_DISCOVER_PORT = 4011,
PXEBC_DHCP4_OPCODE_REQUEST = 1,
PXEBC_DHCP4_OPCODE_REPLY = 2,
PXEBC_DHCP4_MSG_TYPE_REQUEST = 3,
PXEBC_DHCP4_MAGIC = 0x63538263, // network byte order
//
// Dhcp Options
//
PXEBC_DHCP4_TAG_PAD = 0, // Pad Option
PXEBC_DHCP4_TAG_EOP = 255, // End Option
PXEBC_DHCP4_TAG_NETMASK = 1, // Subnet Mask
PXEBC_DHCP4_TAG_TIME_OFFSET = 2, // Time Offset from UTC
PXEBC_DHCP4_TAG_ROUTER = 3, // Router option,
PXEBC_DHCP4_TAG_TIME_SERVER = 4, // Time Server
PXEBC_DHCP4_TAG_NAME_SERVER = 5, // Name Server
PXEBC_DHCP4_TAG_DNS_SERVER = 6, // Domain Name Server
PXEBC_DHCP4_TAG_HOSTNAME = 12, // Host Name
PXEBC_DHCP4_TAG_BOOTFILE_LEN = 13, // Boot File Size
PXEBC_DHCP4_TAG_DUMP = 14, // Merit Dump File
PXEBC_DHCP4_TAG_DOMAINNAME = 15, // Domain Name
PXEBC_DHCP4_TAG_ROOTPATH = 17, // Root path
PXEBC_DHCP4_TAG_EXTEND_PATH = 18, // Extensions Path
PXEBC_DHCP4_TAG_EMTU = 22, // Maximum Datagram Reassembly Size
PXEBC_DHCP4_TAG_TTL = 23, // Default IP Time-to-live
PXEBC_DHCP4_TAG_BROADCAST = 28, // Broadcast Address
PXEBC_DHCP4_TAG_NIS_DOMAIN = 40, // Network Information Service Domain
PXEBC_DHCP4_TAG_NIS_SERVER = 41, // Network Information Servers
PXEBC_DHCP4_TAG_NTP_SERVER = 42, // Network Time Protocol Servers
PXEBC_DHCP4_TAG_VENDOR = 43, // Vendor Specific Information
PXEBC_DHCP4_TAG_REQUEST_IP = 50, // Requested IP Address
PXEBC_DHCP4_TAG_LEASE = 51, // IP Address Lease Time
PXEBC_DHCP4_TAG_OVERLOAD = 52, // Option Overload
PXEBC_DHCP4_TAG_MSG_TYPE = 53, // DHCP Message Type
PXEBC_DHCP4_TAG_SERVER_ID = 54, // Server Identifier
PXEBC_DHCP4_TAG_PARA_LIST = 55, // Parameter Request List
PXEBC_DHCP4_TAG_MAXMSG = 57, // Maximum DHCP Message Size
PXEBC_DHCP4_TAG_T1 = 58, // Renewal (T1) Time Value
PXEBC_DHCP4_TAG_T2 = 59, // Rebinding (T2) Time Value
PXEBC_DHCP4_TAG_CLASS_ID = 60, // Vendor class identifier
PXEBC_DHCP4_TAG_CLIENT_ID = 61, // Client-identifier
PXEBC_DHCP4_TAG_TFTP = 66, // TFTP server name
PXEBC_DHCP4_TAG_BOOTFILE = 67, // Bootfile name
PXEBC_PXE_DHCP4_TAG_ARCH = 93,
PXEBC_PXE_DHCP4_TAG_UNDI = 94,
PXEBC_PXE_DHCP4_TAG_UUID = 97,
//
// Sub-Options in Dhcp Vendor Option
//
PXEBC_VENDOR_TAG_MTFTP_IP = 1,
PXEBC_VENDOR_TAG_MTFTP_CPORT = 2,
PXEBC_VENDOR_TAG_MTFTP_SPORT = 3,
PXEBC_VENDOR_TAG_MTFTP_TIMEOUT = 4,
PXEBC_VENDOR_TAG_MTFTP_DELAY = 5,
PXEBC_VENDOR_TAG_DISCOVER_CTRL = 6,
PXEBC_VENDOR_TAG_DISCOVER_MCAST = 7,
PXEBC_VENDOR_TAG_BOOT_SERVERS = 8,
PXEBC_VENDOR_TAG_BOOT_MENU = 9,
PXEBC_VENDOR_TAG_MENU_PROMPT = 10,
PXEBC_VENDOR_TAG_MCAST_ALLOC = 11,
PXEBC_VENDOR_TAG_CREDENTIAL_TYPES = 12,
PXEBC_VENDOR_TAG_BOOT_ITEM = 71,
PXEBC_DHCP4_DISCOVER_INIT_TIMEOUT = 4,
PXEBC_DHCP4_DISCOVER_RETRIES = 4,
PXEBC_MAX_MENU_NUM = 24,
PXEBC_MAX_OFFER_NUM = 16,
PXEBC_BOOT_REQUEST_TIMEOUT = 1,
PXEBC_BOOT_REQUEST_RETRIES = 4,
PXEBC_DHCP4_OVERLOAD_FILE = 1,
PXEBC_DHCP4_OVERLOAD_SERVER_NAME = 2
};
//
// The array index of the DHCP4 option tag interested
//
enum {
PXEBC_DHCP4_TAG_INDEX_BOOTFILE_LEN,
PXEBC_DHCP4_TAG_INDEX_VENDOR,
PXEBC_DHCP4_TAG_INDEX_OVERLOAD,
PXEBC_DHCP4_TAG_INDEX_MSG_TYPE,
PXEBC_DHCP4_TAG_INDEX_SERVER_ID,
PXEBC_DHCP4_TAG_INDEX_CLASS_ID,
PXEBC_DHCP4_TAG_INDEX_BOOTFILE,
PXEBC_DHCP4_TAG_INDEX_MAX
};
//
// The type of DHCP OFFER, arranged by priority, PXE10 has the highest priority.
//
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
};
#define BIT(x) (1 << x)
#define CTRL(x) (0x1F & (x))
//
// WfM11a options
//
#define MTFTP_VENDOR_OPTION_BIT_MAP (BIT (PXEBC_VENDOR_TAG_MTFTP_IP) | \
BIT (PXEBC_VENDOR_TAG_MTFTP_CPORT) | \
BIT (PXEBC_VENDOR_TAG_MTFTP_SPORT) | \
BIT (PXEBC_VENDOR_TAG_MTFTP_TIMEOUT) | \
BIT (PXEBC_VENDOR_TAG_MTFTP_DELAY))
//
// Discoverty options
//
#define DISCOVER_VENDOR_OPTION_BIT_MAP (BIT (PXEBC_VENDOR_TAG_DISCOVER_CTRL) | \
BIT (PXEBC_VENDOR_TAG_DISCOVER_MCAST) | \
BIT (PXEBC_VENDOR_TAG_BOOT_SERVERS) | \
BIT (PXEBC_VENDOR_TAG_BOOT_MENU) | \
BIT (PXEBC_VENDOR_TAG_MENU_PROMPT))
#define IS_VALID_BOOT_PROMPT(x) \
((((x)[0]) & BIT (PXEBC_VENDOR_TAG_MENU_PROMPT)) == BIT (PXEBC_VENDOR_TAG_MENU_PROMPT))
#define IS_VALID_BOOT_MENU(x) \
((((x)[0]) & BIT (PXEBC_VENDOR_TAG_BOOT_MENU)) == BIT (PXEBC_VENDOR_TAG_BOOT_MENU))
#define IS_VALID_MTFTP_VENDOR_OPTION(x) \
(((UINT32) ((x)[0]) & MTFTP_VENDOR_OPTION_BIT_MAP) == MTFTP_VENDOR_OPTION_BIT_MAP)
#define IS_VALID_DISCOVER_VENDOR_OPTION(x) (((UINT32) ((x)[0]) & DISCOVER_VENDOR_OPTION_BIT_MAP) != 0)
#define IS_VALID_CREDENTIAL_VENDOR_OPTION(x) \
(((UINT32) ((x)[0]) & BIT (PXEBC_VENDOR_TAG_CREDENTIAL_TYPES)) == BIT (PXEBC_VENDOR_TAG_CREDENTIAL_TYPES))
#define IS_VALID_BOOTITEM_VENDOR_OPTION(x) \
(((UINT32) ((x)[PXEBC_VENDOR_TAG_BOOT_ITEM / 32]) & BIT (PXEBC_VENDOR_TAG_BOOT_ITEM % 32)) \
== BIT (PXEBC_VENDOR_TAG_BOOT_ITEM % 32))
#define IS_DISABLE_BCAST_DISCOVER(x) (((x) & BIT (0)) == BIT (0))
#define IS_DISABLE_MCAST_DISCOVER(x) (((x) & BIT (1)) == BIT (1))
#define IS_ENABLE_USE_SERVER_LIST(x) (((x) & BIT (2)) == BIT (2))
#define IS_ENABLE_BOOT_FILE_NAME(x) (((x) & BIT (3)) == BIT (3))
#define SET_VENDOR_OPTION_BIT_MAP(x, y) ((UINT32) ((x)[(y) / 32]) = (UINT32) ((x)[(y) / 32]) | BIT ((y) % 32))
#pragma pack(1)
typedef struct {
UINT8 ParaList[135];
} PXEBC_DHCP4_OPTION_PARA;
typedef struct {
UINT16 Size;
} PXEBC_DHCP4_OPTION_MAX_MESG_SIZE;
typedef struct {
UINT8 Type;
UINT8 MajorVer;
UINT8 MinorVer;
} PXEBC_DHCP4_OPTION_UNDI;
typedef struct {
UINT8 Type;
} PXEBC_DHCP4_OPTION_MESG;
typedef struct {
UINT16 Type;
} PXEBC_DHCP4_OPTION_ARCH;
#define DEFAULT_CLASS_ID_DATA "PXEClient:Arch:?????:????:??????"
typedef struct {
UINT8 ClassIdentifier[10];
UINT8 ArchitecturePrefix[5];
UINT8 ArchitectureType[5];
UINT8 Lit3[1];
UINT8 InterfaceName[4];
UINT8 Lit4[1];
UINT8 UndiMajor[3];
UINT8 UndiMinor[3];
} PXEBC_DHCP4_OPTION_CLID;
typedef struct {
UINT8 Type;
UINT8 Guid[16];
} PXEBC_DHCP4_OPTION_UUID;
typedef struct {
UINT16 Type;
UINT16 Layer;
} PXEBC_OPTION_BOOT_ITEM;
#pragma pack()
typedef union {
PXEBC_DHCP4_OPTION_PARA *Para;
PXEBC_DHCP4_OPTION_UNDI *Undi;
PXEBC_DHCP4_OPTION_ARCH *Arch;
PXEBC_DHCP4_OPTION_CLID *Clid;
PXEBC_DHCP4_OPTION_UUID *Uuid;
PXEBC_DHCP4_OPTION_MESG *Mesg;
PXEBC_DHCP4_OPTION_MAX_MESG_SIZE *MaxMesgSize;
} PXEBC_DHCP4_OPTION_ENTRY;
typedef struct {
UINT16 Type;
UINT8 IpCnt;
EFI_IPv4_ADDRESS IpAddr[1];
} PXEBC_BOOT_SVR_ENTRY;
typedef struct {
UINT16 Type;
UINT8 DescLen;
UINT8 DescStr[1];
} PXEBC_BOOT_MENU_ENTRY;
typedef struct {
UINT8 Timeout;
UINT8 Prompt[1];
} PXEBC_MENU_PROMPT;
typedef struct {
UINT32 BitMap[8];
EFI_IPv4_ADDRESS MtftpIp;
UINT16 MtftpCPort;
UINT16 MtftpSPort;
UINT8 MtftpTimeout;
UINT8 MtftpDelay;
UINT8 DiscoverCtrl;
EFI_IPv4_ADDRESS DiscoverMcastIp;
EFI_IPv4_ADDRESS McastIpBase;
UINT16 McastIpBlock;
UINT16 McastIpRange;
UINT16 BootSrvType;
UINT16 BootSrvLayer;
PXEBC_BOOT_SVR_ENTRY *BootSvr;
UINT8 BootSvrLen;
PXEBC_BOOT_MENU_ENTRY *BootMenu;
UINT8 BootMenuLen;
PXEBC_MENU_PROMPT *MenuPrompt;
UINT8 MenuPromptLen;
UINT32 *CredType;
UINT8 CredTypeLen;
} PXEBC_VENDOR_OPTION;
#define PXEBC_CACHED_DHCP4_PACKET_MAX_SIZE (EFI_FIELD_OFFSET (EFI_DHCP4_PACKET, Dhcp4) + PXEBC_DHCP4_MAX_PACKET_SIZE)
typedef struct {
union {
EFI_DHCP4_PACKET Offer;
EFI_DHCP4_PACKET Ack;
UINT8 Buffer[PXEBC_CACHED_DHCP4_PACKET_MAX_SIZE];
} Packet;
BOOLEAN IsPxeOffer;
UINT8 OfferType;
EFI_DHCP4_PACKET_OPTION *Dhcp4Option[PXEBC_DHCP4_TAG_INDEX_MAX];
PXEBC_VENDOR_OPTION PxeVendorOption;
} PXEBC_CACHED_DHCP4_PACKET;
#define GET_NEXT_DHCP_OPTION(Opt) \
(EFI_DHCP4_PACKET_OPTION *) ((UINT8 *) (Opt) + sizeof (EFI_DHCP4_PACKET_OPTION) + (Opt)->Length - 1)
#define GET_OPTION_BUFFER_LEN(Pkt) ((Pkt)->Length - sizeof (EFI_DHCP4_HEADER) - 4)
#define IS_PROXY_DHCP_OFFER(Offer) EFI_IP4_EQUAL (&((Offer)->Dhcp4.Header.YourAddr), &mZeroIp4Addr)
#define GET_NEXT_BOOT_SVR_ENTRY(Ent) \
(PXEBC_BOOT_SVR_ENTRY *) ((UINT8 *) Ent + sizeof (*(Ent)) + ((Ent)->IpCnt - 1) * sizeof (EFI_IPv4_ADDRESS))
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
@param CachedPacket GC_NOTO: add argument description
@return GC_NOTO: add return values
**/
BOOLEAN
PxeBcParseCachedDhcpPacket (
IN PXEBC_CACHED_DHCP4_PACKET *CachedPacket
)
;
/**
GC_NOTO: Add function description
@param Private GC_NOTO: add argument description
@return GC_NOTO: add return values
**/
EFI_STATUS
PxeBcCheckSelectedOffer (
IN PXEBC_PRIVATE_DATA *Private
)
;
/**
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
**/
EFI_STATUS
PxeBcDhcpCallBack (
IN EFI_DHCP4_PROTOCOL * This,
IN VOID *Context,
IN EFI_DHCP4_STATE CurrentState,
IN EFI_DHCP4_EVENT Dhcp4Event,
IN EFI_DHCP4_PACKET * Packet OPTIONAL,
OUT EFI_DHCP4_PACKET **NewPacket OPTIONAL
)
;
/**
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
**/
EFI_STATUS
PxeBcDiscvBootService (
IN PXEBC_PRIVATE_DATA * Private,
IN UINT16 Type,
IN UINT16 *Layer,
IN BOOLEAN UseBis,
IN EFI_IP_ADDRESS * DestIp,
IN UINT16 IpCount,
IN EFI_PXE_BASE_CODE_SRVLIST * SrvList,
IN BOOLEAN IsDiscv,
OUT EFI_DHCP4_PACKET * Reply OPTIONAL
)
;
/**
GC_NOTO: Add function description
@param Private GC_NOTO: add argument description
@param OptList GC_NOTO: add argument description
@param IsDhcpDiscover GC_NOTO: add argument description
@return GC_NOTO: add return values
**/
UINT32
PxeBcBuildDhcpOptions (
IN PXEBC_PRIVATE_DATA *Private,
IN EFI_DHCP4_PACKET_OPTION **OptList,
IN BOOLEAN IsDhcpDiscover
)
;
/**
GC_NOTO: Add function description
@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
@return GC_NOTO: add return values
**/
VOID
PxeBcCreateBootOptions (
IN EFI_DHCP4_PACKET_OPTION *OptList,
IN UINT16 Type,
IN UINT16 *Layer,
OUT UINT32 *OptLen
)
;
/**
GC_NOTO: Add function description
@param Buffer GC_NOTO: add argument description
@param Length GC_NOTO: add argument description
@param OptTag GC_NOTO: add argument description
@return GC_NOTO: add return values
**/
EFI_DHCP4_PACKET_OPTION *
PxeBcParseExtendOptions (
IN UINT8 *Buffer,
IN UINT32 Length,
IN UINT8 OptTag
)
;
/**
GC_NOTO: Add function description
@param Dhcp4Option GC_NOTO: add argument description
@param VendorOption GC_NOTO: add argument description
@return GC_NOTO: add return values
**/
BOOLEAN
PxeBcParseVendorOptions (
IN EFI_DHCP4_PACKET_OPTION *Dhcp4Option,
IN PXEBC_VENDOR_OPTION *VendorOption
)
;
/**
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
@return GC_NOTO: add return values
**/
EFI_STATUS
PxeBcSelectBootPrompt (
IN PXEBC_PRIVATE_DATA *Private
)
;
/**
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
**/
EFI_STATUS
PxeBcSelectBootMenu (
IN PXEBC_PRIVATE_DATA *Private,
OUT UINT16 *Type,
IN BOOLEAN UseDefaultItem
)
;
#endif

View File

@ -0,0 +1,451 @@
/** @file
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
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"
/**
The entry point for PxeBc driver which install the driver
binding and component name protocol on its image.
@param ImageHandle The Image handle of the driver
@param SystemTable The system table
@return EFI_SUCCESS
@return Others
**/
EFI_STATUS
PxeBcDriverEntryPoint (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
return EfiLibInstallDriverBindingComponentName2 (
ImageHandle,
SystemTable,
&gPxeBcDriverBinding,
ImageHandle,
&gPxeBcComponentName,
&gPxeBcComponentName2
);
}
/**
Test to see if this driver supports ControllerHandle.
@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
**/
EFI_STATUS
EFIAPI
PxeBcDriverBindingSupported (
IN EFI_DRIVER_BINDING_PROTOCOL * This,
IN EFI_HANDLE ControllerHandle,
IN EFI_DEVICE_PATH_PROTOCOL * RemainingDevicePath OPTIONAL
)
{
EFI_PXE_BASE_CODE_PROTOCOL *PxeBc;
EFI_STATUS Status;
Status = gBS->OpenProtocol (
ControllerHandle,
&gEfiPxeBaseCodeProtocolGuid,
(VOID **) &PxeBc,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
if (!EFI_ERROR (Status)) {
return EFI_ALREADY_STARTED;
}
Status = gBS->OpenProtocol (
ControllerHandle,
&gEfiDhcp4ServiceBindingProtocolGuid,
NULL,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_TEST_PROTOCOL
);
if (!EFI_ERROR (Status)) {
Status = gBS->OpenProtocol (
ControllerHandle,
&gEfiMtftp4ServiceBindingProtocolGuid,
NULL,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_TEST_PROTOCOL
);
}
return Status;
}
/**
Start this driver on ControllerHandle.
@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
**/
EFI_STATUS
EFIAPI
PxeBcDriverBindingStart (
IN EFI_DRIVER_BINDING_PROTOCOL * This,
IN EFI_HANDLE ControllerHandle,
IN EFI_DEVICE_PATH_PROTOCOL * RemainingDevicePath OPTIONAL
)
{
PXEBC_PRIVATE_DATA *Private;
UINTN Index;
EFI_STATUS Status;
Private = NetAllocateZeroPool (sizeof (PXEBC_PRIVATE_DATA));
if (Private == NULL) {
return EFI_OUT_OF_RESOURCES;
}
Private->Signature = PXEBC_PRIVATE_DATA_SIGNATURE;
Private->Controller = ControllerHandle;
Private->Image = This->DriverBindingHandle;
CopyMem (&Private->PxeBc, &mPxeBcProtocolTemplate, sizeof (Private->PxeBc));
Private->PxeBc.Mode = &Private->Mode;
CopyMem (&Private->LoadFile, &mLoadFileProtocolTemplate, sizeof (Private->LoadFile));
Private->ProxyOffer.Packet.Offer.Size = PXEBC_CACHED_DHCP4_PACKET_MAX_SIZE;
Private->Dhcp4Ack.Packet.Ack.Size = PXEBC_CACHED_DHCP4_PACKET_MAX_SIZE;
Private->PxeReply.Packet.Ack.Size = PXEBC_CACHED_DHCP4_PACKET_MAX_SIZE;
for (Index = 0; Index < PXEBC_MAX_OFFER_NUM; Index++) {
Private->Dhcp4Offers[Index].Packet.Offer.Size = PXEBC_CACHED_DHCP4_PACKET_MAX_SIZE;
}
//
// Get the NII interface
//
Status = gBS->OpenProtocol (
ControllerHandle,
&gEfiNetworkInterfaceIdentifierProtocolGuid_31,
(VOID **) &Private->Nii,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
if (EFI_ERROR (Status)) {
goto ON_ERROR;
}
Status = NetLibCreateServiceChild (
ControllerHandle,
This->DriverBindingHandle,
&gEfiDhcp4ServiceBindingProtocolGuid,
&Private->Dhcp4Child
);
if (EFI_ERROR (Status)) {
goto ON_ERROR;
}
Status = gBS->OpenProtocol (
Private->Dhcp4Child,
&gEfiDhcp4ProtocolGuid,
(VOID **) &Private->Dhcp4,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER
);
if (EFI_ERROR (Status)) {
goto ON_ERROR;
}
Status = NetLibCreateServiceChild (
ControllerHandle,
This->DriverBindingHandle,
&gEfiMtftp4ServiceBindingProtocolGuid,
&Private->Mtftp4Child
);
if (EFI_ERROR (Status)) {
goto ON_ERROR;
}
Status = gBS->OpenProtocol (
Private->Mtftp4Child,
&gEfiMtftp4ProtocolGuid,
(VOID **) &Private->Mtftp4,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER
);
if (EFI_ERROR (Status)) {
goto ON_ERROR;
}
Status = NetLibCreateServiceChild (
ControllerHandle,
This->DriverBindingHandle,
&gEfiUdp4ServiceBindingProtocolGuid,
&Private->Udp4Child
);
if (EFI_ERROR (Status)) {
goto ON_ERROR;
}
Status = gBS->OpenProtocol (
Private->Udp4Child,
&gEfiUdp4ProtocolGuid,
(VOID **) &Private->Udp4,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_BY_DRIVER
);
if (EFI_ERROR (Status)) {
goto ON_ERROR;
}
NetZeroMem (&Private->Udp4CfgData, sizeof (EFI_UDP4_CONFIG_DATA));
Private->Udp4CfgData.AcceptBroadcast = TRUE;
Private->Udp4CfgData.AcceptPromiscuous = FALSE;
Private->Udp4CfgData.AcceptAnyPort = FALSE;
Private->Udp4CfgData.AllowDuplicatePort = TRUE;
Private->Udp4CfgData.TypeOfService = DEFAULT_ToS;
Private->Udp4CfgData.TimeToLive = DEFAULT_TTL;
Private->Udp4CfgData.DoNotFragment = FALSE;
Private->Udp4CfgData.ReceiveTimeout = 10000; // 10 milliseconds
Private->Udp4CfgData.UseDefaultAddress = FALSE;
PxeBcInitSeedPacket (&Private->SeedPacket, Private->Udp4);
Status = gBS->InstallMultipleProtocolInterfaces (
&ControllerHandle,
&gEfiPxeBaseCodeProtocolGuid,
&Private->PxeBc,
&gEfiLoadFileProtocolGuid,
&Private->LoadFile,
NULL
);
if (EFI_ERROR (Status)) {
goto ON_ERROR;
}
return EFI_SUCCESS;
ON_ERROR:
if (Private->Udp4Child != NULL) {
gBS->CloseProtocol (
Private->Udp4Child,
&gEfiUdp4ProtocolGuid,
This->DriverBindingHandle,
ControllerHandle
);
NetLibDestroyServiceChild (
ControllerHandle,
This->DriverBindingHandle,
&gEfiUdp4ProtocolGuid,
Private->Udp4Child
);
}
if (Private->Mtftp4Child != NULL) {
gBS->CloseProtocol (
Private->Mtftp4Child,
&gEfiMtftp4ProtocolGuid,
This->DriverBindingHandle,
ControllerHandle
);
NetLibDestroyServiceChild (
ControllerHandle,
This->DriverBindingHandle,
&gEfiMtftp4ProtocolGuid,
Private->Mtftp4Child
);
}
if (Private->Dhcp4Child != NULL) {
gBS->CloseProtocol (
Private->Dhcp4Child,
&gEfiDhcp4ProtocolGuid,
This->DriverBindingHandle,
ControllerHandle
);
NetLibDestroyServiceChild (
ControllerHandle,
This->DriverBindingHandle,
&gEfiDhcp4ProtocolGuid,
Private->Dhcp4Child
);
}
NetFreePool (Private);
return Status;
}
/**
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
**/
EFI_STATUS
EFIAPI
PxeBcDriverBindingStop (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE ControllerHandle,
IN UINTN NumberOfChildren,
IN EFI_HANDLE *ChildHandleBuffer
)
{
PXEBC_PRIVATE_DATA *Private;
EFI_PXE_BASE_CODE_PROTOCOL *PxeBc;
EFI_HANDLE NicHandle;
EFI_STATUS Status;
NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiDhcp4ProtocolGuid);
if (NicHandle == NULL) {
NicHandle = NetLibGetNicHandle (ControllerHandle, &gEfiMtftp4ProtocolGuid);
if (NicHandle == NULL) {
return EFI_DEVICE_ERROR;
}
}
Status = gBS->OpenProtocol (
NicHandle,
&gEfiPxeBaseCodeProtocolGuid,
(VOID **) &PxeBc,
This->DriverBindingHandle,
ControllerHandle,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
if (EFI_ERROR (Status)) {
return Status;
}
Private = PXEBC_PRIVATE_DATA_FROM_PXEBC (PxeBc);
Status = gBS->UninstallMultipleProtocolInterfaces (
NicHandle,
&gEfiPxeBaseCodeProtocolGuid,
&Private->PxeBc,
&gEfiLoadFileProtocolGuid,
&Private->LoadFile,
NULL
);
if (!EFI_ERROR (Status)) {
gBS->CloseProtocol (
Private->Udp4Child,
&gEfiUdp4ProtocolGuid,
This->DriverBindingHandle,
ControllerHandle
);
NetLibDestroyServiceChild (
ControllerHandle,
This->DriverBindingHandle,
&gEfiUdp4ServiceBindingProtocolGuid,
Private->Udp4Child
);
gBS->CloseProtocol (
Private->Dhcp4Child,
&gEfiDhcp4ProtocolGuid,
This->DriverBindingHandle,
ControllerHandle
);
NetLibDestroyServiceChild (
ControllerHandle,
This->DriverBindingHandle,
&gEfiDhcp4ServiceBindingProtocolGuid,
Private->Dhcp4Child
);
gBS->CloseProtocol (
Private->Mtftp4Child,
&gEfiMtftp4ProtocolGuid,
This->DriverBindingHandle,
ControllerHandle
);
NetLibDestroyServiceChild (
ControllerHandle,
This->DriverBindingHandle,
&gEfiMtftp4ServiceBindingProtocolGuid,
Private->Mtftp4Child
);
NetFreePool (Private);
}
return Status;
}
EFI_DRIVER_BINDING_PROTOCOL gPxeBcDriverBinding = {
PxeBcDriverBindingSupported,
PxeBcDriverBindingStart,
PxeBcDriverBindingStop,
0xa,
NULL,
NULL
};

View File

@ -0,0 +1,103 @@
/** @file
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
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__
EFI_STATUS
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
;
/**
Start this driver on ControllerHandle.
@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
**/
// GC_NOTO: Controller - add argument and description to function comment
EFI_STATUS
PxeBcDriverBindingStart (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE Controller,
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
)
;
/**
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
**/
// GC_NOTO: Controller - add argument and description to function comment
EFI_STATUS
PxeBcDriverBindingStop (
IN EFI_DRIVER_BINDING_PROTOCOL *This,
IN EFI_HANDLE Controller,
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

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,126 @@
/** @file
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
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__
#define __EFI_PXEBC_IMPL_H__
typedef struct _PXEBC_PRIVATE_DATA PXEBC_PRIVATE_DATA;
#include <PiDxe.h>
#include <Guid/SmBios.h>
#include <IndustryStandard/Smbios.h>
#include <Protocol/Dhcp4.h>
#include <Protocol/PxeBaseCode.h>
#include <Protocol/Mtftp4.h>
#include <Protocol/Udp4.h>
#include <Protocol/LoadFile.h>
#include <Protocol/NetworkInterfaceIdentifier.h>
#include <Protocol/PxeBaseCodeCallBack.h>
#include <Library/DebugLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/UefiDriverEntryPoint.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiLib.h>
#include <Library/BaseLib.h>
#include <Library/NetLib.h>
#include "PxeBcDriver.h"
#include "PxeArch.h"
#include "PxeBcDhcp.h"
#include "PxeBcMtftp.h"
#include "PxeBcSupport.h"
#define PXEBC_PRIVATE_DATA_SIGNATURE EFI_SIGNATURE_32 ('P', 'X', 'E', 'P')
#define PXEBC_MTFTP_TIMEOUT 4
#define PXEBC_MTFTP_RETRIES 6
struct _PXEBC_PRIVATE_DATA {
UINT32 Signature;
EFI_HANDLE Controller;
EFI_HANDLE Image;
EFI_HANDLE Dhcp4Child;
EFI_HANDLE Mtftp4Child;
EFI_HANDLE Udp4Child;
EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL *Nii;
EFI_PXE_BASE_CODE_PROTOCOL PxeBc;
EFI_LOAD_FILE_PROTOCOL LoadFile;
EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL LoadFileCallback;
EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL *PxeBcCallback;
EFI_DHCP4_PROTOCOL *Dhcp4;
EFI_MTFTP4_PROTOCOL *Mtftp4;
EFI_UDP4_PROTOCOL *Udp4;
EFI_UDP4_CONFIG_DATA Udp4CfgData;
EFI_PXE_BASE_CODE_MODE Mode;
EFI_PXE_BASE_CODE_FUNCTION Function;
CHAR8 *BootFileName;
EFI_IP_ADDRESS StationIp;
EFI_IP_ADDRESS SubnetMask;
EFI_IP_ADDRESS GatewayIp;
EFI_IP_ADDRESS ServerIp;
BOOLEAN AddressIsOk;
UINTN FileSize;
UINT8 OptionBuffer[PXEBC_DHCP4_MAX_OPTION_SIZE];
EFI_DHCP4_PACKET SeedPacket;
BOOLEAN SortOffers;
UINT32 NumOffers;
UINT32 SelectedOffer;
UINT32 ProxyOfferType;
//
// Cached packets as complements of pxe mode data
//
PXEBC_CACHED_DHCP4_PACKET ProxyOffer;
PXEBC_CACHED_DHCP4_PACKET Dhcp4Ack;
PXEBC_CACHED_DHCP4_PACKET PxeReply;
PXEBC_CACHED_DHCP4_PACKET Dhcp4Offers[PXEBC_MAX_OFFER_NUM];
//
// Arrays for different types of offers:
// ServerCount records the count of the servers we got the offers,
// OfferIndex records the index of the offer sent by the server indexed by ServerCount.
//
UINT32 ServerCount[DHCP4_PACKET_TYPE_MAX];
UINT32 OfferIndex[DHCP4_PACKET_TYPE_MAX][PXEBC_MAX_OFFER_NUM];
UINT32 BootpIndex;
UINT32 ProxyIndex[DHCP4_PACKET_TYPE_MAX];
UINT32 BinlIndex[PXEBC_MAX_OFFER_NUM];
};
#define PXEBC_PRIVATE_DATA_FROM_PXEBC(a) CR (a, PXEBC_PRIVATE_DATA, PxeBc, PXEBC_PRIVATE_DATA_SIGNATURE)
#define PXEBC_PRIVATE_DATA_FROM_LOADFILE(a) CR (a, PXEBC_PRIVATE_DATA, LoadFile, PXEBC_PRIVATE_DATA_SIGNATURE)
#define PXEBC_PRIVATE_DATA_FROM_PXEBCCALLBACK(a) CR (a, PXEBC_PRIVATE_DATA, PxeBcCallback, PXEBC_PRIVATE_DATA_SIGNATURE)
extern EFI_PXE_BASE_CODE_PROTOCOL mPxeBcProtocolTemplate;
extern EFI_LOAD_FILE_PROTOCOL mLoadFileProtocolTemplate;
#endif

View File

@ -0,0 +1,437 @@
/** @file
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
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"
VOID *TokenContext = NULL;
UINT8 *mMtftpOptions[PXE_MTFTP_OPTION_MAXIMUM_INDEX] = {
"blksize",
"timeout",
"tsize",
"multicast"
};
/**
This is a callback function when packets received/transmitted in Mtftp driver.
@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
**/
EFI_STATUS
PxeBcCheckPacket (
IN EFI_MTFTP4_PROTOCOL *This,
IN EFI_MTFTP4_TOKEN *Token,
IN UINT16 PacketLen,
IN EFI_MTFTP4_PACKET *Packet
)
{
PXEBC_PRIVATE_DATA *Private;
EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL *Callback;
EFI_STATUS Status;
Private = (PXEBC_PRIVATE_DATA *) TokenContext;
Callback = Private->PxeBcCallback;
Status = EFI_SUCCESS;
if (Callback != NULL) {
Status = Callback->Callback (
Callback,
Private->Function,
TRUE,
PacketLen,
(EFI_PXE_BASE_CODE_PACKET *) Packet
);
if (Status != EFI_PXE_BASE_CODE_CALLBACK_STATUS_CONTINUE) {
Status = EFI_ABORTED;
} else {
Status = EFI_SUCCESS;
}
}
return Status;
}
/**
This function is to get size of a file by Tftp.
@param Private Pointer to PxeBc private data
@param Config Pointer to Mtftp configuration data
@param Filename Pointer to file name
@param BlockSize Pointer to block size
@param BufferSize Pointer to buffer size
@return EFI_SUCCESS
@return EFI_NOT_FOUND
@return EFI_DEVICE_ERROR
**/
EFI_STATUS
PxeBcTftpGetFileSize (
IN PXEBC_PRIVATE_DATA *Private,
IN EFI_MTFTP4_CONFIG_DATA *Config,
IN UINT8 *Filename,
IN UINTN *BlockSize,
IN OUT UINT64 *BufferSize
)
{
EFI_MTFTP4_PROTOCOL *Mtftp4;
EFI_MTFTP4_OPTION ReqOpt[2];
EFI_MTFTP4_PACKET *Packet;
EFI_MTFTP4_OPTION *Option;
UINT32 PktLen;
UINT8 OptBuf[128];
UINT32 OptCnt;
EFI_STATUS Status;
*BufferSize = 0;
Status = EFI_DEVICE_ERROR;
Mtftp4 = Private->Mtftp4;
Packet = NULL;
Option = NULL;
PktLen = 0;
OptCnt = 1;
Config->InitialServerPort = PXEBC_BS_DOWNLOAD_PORT;
Status = Mtftp4->Configure (Mtftp4, Config);
if (EFI_ERROR (Status)) {
return Status;
}
ReqOpt[0].OptionStr = mMtftpOptions[PXE_MTFTP_OPTION_TSIZE_INDEX];
UtoA10 (0, (CHAR8 *) OptBuf);
ReqOpt[0].ValueStr = OptBuf;
if (BlockSize != NULL) {
ReqOpt[1].OptionStr = mMtftpOptions[PXE_MTFTP_OPTION_BLKSIZE_INDEX];
ReqOpt[1].ValueStr = ReqOpt[0].ValueStr + AsciiStrLen ((CHAR8 *) ReqOpt[0].ValueStr) + 1;
UtoA10 (*BlockSize, (CHAR8 *) ReqOpt[1].ValueStr);
OptCnt++;
}
Status = Mtftp4->GetInfo (
Mtftp4,
FALSE,
Filename,
NULL,
(UINT8) OptCnt,
ReqOpt,
&PktLen,
&Packet
);
if (EFI_ERROR (Status)) {
goto ON_ERROR;
}
OptCnt = 0;
Status = Mtftp4->ParseOptions (
Mtftp4,
PktLen,
Packet,
(UINT32 *) &OptCnt,
&Option
);
if (EFI_ERROR (Status)) {
goto ON_ERROR;
}
Status = EFI_NOT_FOUND;
while (OptCnt != 0) {
if (AsciiStrnCmp ((CHAR8 *) Option[OptCnt - 1].OptionStr, "tsize", 5) == 0) {
*BufferSize = AtoU64 (Option[OptCnt - 1].ValueStr);
Status = EFI_SUCCESS;
}
OptCnt--;
}
NetFreePool (Option);
ON_ERROR:
if (Packet != NULL) {
NetFreePool (Packet);
}
Mtftp4->Configure (Mtftp4, NULL);
return Status;
}
/**
This function is to get data of a file by Tftp.
@param Private Pointer to PxeBc private data
@param Config Pointer to Mtftp configuration data
@param Filename Pointer to file name
@param BlockSize Pointer to block size
@param BufferPtr Pointer to buffer
@param BufferSize Pointer to buffer size
@param DontUseBuffer Indicate whether with a receive buffer
@return EFI_SUCCESS
@return EFI_DEVICE_ERROR
**/
EFI_STATUS
PxeBcTftpReadFile (
IN PXEBC_PRIVATE_DATA *Private,
IN EFI_MTFTP4_CONFIG_DATA *Config,
IN UINT8 *Filename,
IN UINTN *BlockSize,
IN UINT8 *BufferPtr,
IN OUT UINT64 *BufferSize,
IN BOOLEAN DontUseBuffer
)
{
EFI_MTFTP4_PROTOCOL *Mtftp4;
EFI_MTFTP4_TOKEN Token;
EFI_MTFTP4_OPTION ReqOpt[1];
UINT32 OptCnt;
UINT8 OptBuf[128];
EFI_STATUS Status;
Status = EFI_DEVICE_ERROR;
Mtftp4 = Private->Mtftp4;
OptCnt = 0;
Config->InitialServerPort = PXEBC_BS_DOWNLOAD_PORT;
Status = Mtftp4->Configure (Mtftp4, Config);
if (EFI_ERROR (Status)) {
return Status;
}
if (BlockSize != NULL) {
ReqOpt[0].OptionStr = mMtftpOptions[PXE_MTFTP_OPTION_BLKSIZE_INDEX];
ReqOpt[0].ValueStr = OptBuf;
UtoA10 (*BlockSize, (CHAR8 *) ReqOpt[0].ValueStr);
OptCnt++;
}
Token.Event = NULL;
Token.OverrideData = NULL;
Token.Filename = Filename;
Token.ModeStr = NULL;
Token.OptionCount = OptCnt;
Token.OptionList = ReqOpt;
TokenContext = Private;
if (DontUseBuffer) {
Token.BufferSize = 0;
Token.Buffer = NULL;
} else {
Token.BufferSize = *BufferSize;
Token.Buffer = BufferPtr;
}
Token.CheckPacket = PxeBcCheckPacket;
Token.TimeoutCallback = NULL;
Token.PacketNeeded = NULL;
Status = Mtftp4->ReadFile (Mtftp4, &Token);
*BufferSize = Token.BufferSize;
Mtftp4->Configure (Mtftp4, NULL);
return Status;
}
/**
This function is put data of a file by Tftp.
@param Private Pointer to PxeBc private data
@param Config Pointer to Mtftp configuration data
@param Filename Pointer to file name
@param Overwrite Indicate whether with overwrite attribute
@param BlockSize Pointer to block size
@param BufferPtr Pointer to buffer
@param BufferSize Pointer to buffer size
@return EFI_SUCCESS
@return EFI_DEVICE_ERROR
**/
EFI_STATUS
PxeBcTftpWriteFile (
IN PXEBC_PRIVATE_DATA *Private,
IN EFI_MTFTP4_CONFIG_DATA *Config,
IN UINT8 *Filename,
IN BOOLEAN Overwrite,
IN UINTN *BlockSize,
IN UINT8 *BufferPtr,
IN OUT UINT64 *BufferSize
)
{
EFI_MTFTP4_PROTOCOL *Mtftp4;
EFI_MTFTP4_TOKEN Token;
EFI_MTFTP4_OPTION ReqOpt[1];
UINT32 OptCnt;
UINT8 OptBuf[128];
EFI_STATUS Status;
Status = EFI_DEVICE_ERROR;
Mtftp4 = Private->Mtftp4;
OptCnt = 0;
Config->InitialServerPort = PXEBC_BS_DOWNLOAD_PORT;
Status = Mtftp4->Configure (Mtftp4, Config);
if (EFI_ERROR (Status)) {
return Status;
}
if (BlockSize != NULL) {
ReqOpt[0].OptionStr = mMtftpOptions[PXE_MTFTP_OPTION_BLKSIZE_INDEX];
ReqOpt[0].ValueStr = OptBuf;
UtoA10 (*BlockSize, (CHAR8 *) ReqOpt[0].ValueStr);
OptCnt++;
}
Token.Event = NULL;
Token.OverrideData = NULL;
Token.Filename = Filename;
Token.ModeStr = NULL;
Token.OptionCount = OptCnt;
Token.OptionList = ReqOpt;
Token.BufferSize = *BufferSize;
Token.Buffer = BufferPtr;
Token.CheckPacket = PxeBcCheckPacket;
Token.TimeoutCallback = NULL;
Token.PacketNeeded = NULL;
Status = Mtftp4->WriteFile (Mtftp4, &Token);
*BufferSize = Token.BufferSize;
Mtftp4->Configure (Mtftp4, NULL);
return Status;
}
/**
This function is to get data 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
**/
// GC_NOTO: EFI_SUCCESS - add return value to function comment
EFI_STATUS
PxeBcTftpReadDirectory (
IN PXEBC_PRIVATE_DATA *Private,
IN EFI_MTFTP4_CONFIG_DATA *Config,
IN UINT8 *Filename,
IN UINTN *BlockSize,
IN UINT8 *BufferPtr,
IN OUT UINT64 *BufferSize,
IN BOOLEAN DontUseBuffer
)
{
EFI_MTFTP4_PROTOCOL *Mtftp4;
EFI_MTFTP4_TOKEN Token;
EFI_MTFTP4_OPTION ReqOpt[1];
UINT32 OptCnt;
UINT8 OptBuf[128];
EFI_STATUS Status;
Status = EFI_DEVICE_ERROR;
Mtftp4 = Private->Mtftp4;
OptCnt = 0;
Config->InitialServerPort = PXEBC_BS_DOWNLOAD_PORT;
Status = Mtftp4->Configure (Mtftp4, Config);
if (EFI_ERROR (Status)) {
return Status;
}
if (BlockSize != NULL) {
ReqOpt[0].OptionStr = mMtftpOptions[PXE_MTFTP_OPTION_BLKSIZE_INDEX];
ReqOpt[0].ValueStr = OptBuf;
UtoA10 (*BlockSize, (CHAR8 *) ReqOpt[0].ValueStr);
OptCnt++;
}
Token.Event = NULL;
Token.OverrideData = NULL;
Token.Filename = Filename;
Token.ModeStr = NULL;
Token.OptionCount = OptCnt;
Token.OptionList = ReqOpt;
TokenContext = Private;
if (DontUseBuffer) {
Token.BufferSize = 0;
Token.Buffer = NULL;
} else {
Token.BufferSize = *BufferSize;
Token.Buffer = BufferPtr;
}
Token.CheckPacket = PxeBcCheckPacket;
Token.TimeoutCallback = NULL;
Token.PacketNeeded = NULL;
Status = Mtftp4->ReadDirectory (Mtftp4, &Token);
*BufferSize = Token.BufferSize;
Mtftp4->Configure (Mtftp4, NULL);
return Status;
}

View File

@ -0,0 +1,144 @@
/** @file
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
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 {
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
};
/**
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
**/
EFI_STATUS
PxeBcTftpGetFileSize (
IN PXEBC_PRIVATE_DATA *Private,
IN EFI_MTFTP4_CONFIG_DATA *Config,
IN UINT8 *Filename,
IN UINTN *BlockSize,
IN OUT UINT64 *BufferSize
)
;
/**
This function is to get data of a file by Tftp.
@param Private Pointer to PxeBc private data
@param Config Pointer to Mtftp configuration data
@param Filename Pointer to file name
@param BlockSize Pointer to block size
@param BufferPtr Pointer to buffer
@param BufferSize Pointer to buffer size
@param DontUseBuffer Indicate whether with a receive buffer
@return EFI_SUCCESS
@return EFI_DEVICE_ERROR
**/
EFI_STATUS
PxeBcTftpReadFile (
IN PXEBC_PRIVATE_DATA *Private,
IN EFI_MTFTP4_CONFIG_DATA *Config,
IN UINT8 *Filename,
IN UINTN *BlockSize,
IN UINT8 *BufferPtr,
IN OUT UINT64 *BufferSize,
IN BOOLEAN DontUseBuffer
)
;
/**
This function is put data of a file by Tftp.
@param Private Pointer to PxeBc private data
@param Config Pointer to Mtftp configuration data
@param Filename Pointer to file name
@param Overwrite Indicate whether with overwrite attribute
@param BlockSize Pointer to block size
@param BufferPtr Pointer to buffer
@param BufferSize Pointer to buffer size
@return EFI_SUCCESS
@return EFI_DEVICE_ERROR
**/
EFI_STATUS
PxeBcTftpWriteFile (
IN PXEBC_PRIVATE_DATA *Private,
IN EFI_MTFTP4_CONFIG_DATA *Config,
IN UINT8 *Filename,
IN BOOLEAN Overwrite,
IN UINTN *BlockSize,
IN UINT8 *BufferPtr,
IN OUT UINT64 *BufferSize
)
;
/**
This function is to get data 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
**/
EFI_STATUS
PxeBcTftpReadDirectory (
IN PXEBC_PRIVATE_DATA *Private,
IN EFI_MTFTP4_CONFIG_DATA *Config,
IN UINT8 *Filename,
IN UINTN *BlockSize,
IN UINT8 *BufferPtr,
IN OUT UINT64 *BufferSize,
IN BOOLEAN DontUseBuffer
)
;
#endif

View File

@ -0,0 +1,250 @@
/** @file
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
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
**/
#include "PxeBcImpl.h"
/**
@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.
@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,
IN UINT16 StringNumber
)
{
UINT16 Index;
CHAR8 *String;
//
// Skip over formatted section
//
String = (CHAR8 *) (Smbios->Raw + Smbios->Hdr->Length);
//
// Look through unformated section
//
for (Index = 1; Index <= StringNumber || StringNumber == 0; Index++) {
if (StringNumber == Index) {
return String;
}
//
// Skip string
//
for (; *String != 0; String++)
;
String++;
if (*String == 0) {
//
// If double NULL then we are done.
// Return pointer to next structure in Smbios.
// if you pass in a 0 you will always get here
//
Smbios->Raw = (UINT8 *)++String;
return NULL;
}
}
return NULL;
}
/**
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
@retval EFI_SUCCESS Successfully get the system guid and system serial
number
@retval EFI_NOT_FOUND Not find the SMBIOS table
**/
EFI_STATUS
GetSmbiosSystemGuidAndSerialNumber (
IN EFI_GUID *SystemGuid,
OUT CHAR8 **SystemSerialNumber
)
{
EFI_STATUS Status;
SMBIOS_TABLE_ENTRY_POINT *SmbiosTable;
SMBIOS_STRUCTURE_POINTER Smbios;
SMBIOS_STRUCTURE_POINTER SmbiosEnd;
UINT16 Index;
Status = EfiGetSystemConfigurationTable (&gEfiSmbiosTableGuid, (VOID **) &SmbiosTable);
if (EFI_ERROR (Status)) {
return EFI_NOT_FOUND;
}
Smbios.Hdr = (SMBIOS_STRUCTURE *) (UINTN) SmbiosTable->TableAddress;
SmbiosEnd.Raw = (UINT8 *) (UINTN) (SmbiosTable->TableAddress + SmbiosTable->TableLength);
for (Index = 0; Index < SmbiosTable->TableLength; Index++) {
if (Smbios.Hdr->Type == 1) {
if (Smbios.Hdr->Length < 0x19) {
//
// Older version did not support Guid and Serial number
//
continue;
}
//
// SMBIOS tables are byte packed so we need to do a byte copy to
// prevend alignment faults on Itanium-based platform.
//
CopyMem (SystemGuid, &Smbios.Type1->Uuid, sizeof (EFI_GUID));
*SystemSerialNumber = GetSmbiosString (&Smbios, Smbios.Type1->SerialNumber);
return EFI_SUCCESS;
}
//
// Make Smbios point to the next record
//
GetSmbiosString (&Smbios, 0);
if (Smbios.Raw >= SmbiosEnd.Raw) {
//
// SMBIOS 2.1 incorrectly stated the length of SmbiosTable as 0x1e.
// given this we must double check against the length of the structure.
//
return EFI_SUCCESS;
}
}
return EFI_SUCCESS;
}
/**
GC_NOTO: Add function description
@param Event GC_NOTO: add argument description
@param Context GC_NOTO: add argument description
@return GC_NOTO: add return values
**/
VOID
PxeBcCommonNotify (
IN EFI_EVENT Event,
IN VOID *Context
)
{
*((BOOLEAN *) Context) = TRUE;
}
/**
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.
@retval none none
**/
VOID
CvtNum (
IN UINTN Number,
IN UINT8 *Buffer,
IN INTN Length
)
{
UINTN Remainder;
while (Length--) {
Remainder = Number % 10;
Number /= 10;
Buffer[Length] = (UINT8) ('0' + Remainder);
}
}
/**
GC_NOTO: Add function description
@param Number GC_NOTO: add argument description
@param Buffer GC_NOTO: add argument description
@return GC_NOTO: add return values
**/
UINTN
UtoA10 (
IN UINTN Number,
IN CHAR8 *Buffer
)
{
UINTN Index;
CHAR8 TempStr[64];
Index = 63;
TempStr[Index] = 0;
do {
Index--;
TempStr[Index] = (CHAR8) ('0' + (Number % 10));
Number = Number / 10;
} while (Number != 0);
AsciiStrCpy (Buffer, &TempStr[Index]);
return AsciiStrLen (Buffer);
}
/**
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
@retval Value UINTN value of the ASCII string.
**/
UINT64
AtoU64 (
IN UINT8 *Buffer
)
{
UINT64 Value;
UINT8 Character;
Value = 0;
while ((Character = *Buffer++) != '\0') {
Value = MultU64x32 (Value, 10) + (Character - '0');
}
return Value;
}

View File

@ -0,0 +1,89 @@
/** @file
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
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
Abstract:
Support routines for PxeBc
**/
#ifndef __EFI_PXEBC_SUPPORT_H__
#define __EFI_PXEBC_SUPPORT_H__
EFI_STATUS
GetSmbiosSystemGuidAndSerialNumber (
IN EFI_GUID *SystemGuid,
OUT CHAR8 **SystemSerialNumber
);
/**
GC_NOTO: Add function description
@param Event GC_NOTO: add argument description
@param Context GC_NOTO: add argument description
@return GC_NOTO: add return values
**/
VOID
PxeBcCommonNotify (
IN EFI_EVENT Event,
IN VOID *Context
)
;
VOID
CvtNum (
IN UINTN Number,
IN UINT8 *Buffer,
IN INTN Length
);
/**
GC_NOTO: Add function description
@param Number GC_NOTO: add argument description
@param BufferPtr GC_NOTO: add argument description
@return GC_NOTO: add return values
**/
UINTN
UtoA10 (
UINTN Number,
CHAR8 *BufferPtr
)
;
/**
GC_NOTO: Add function description
@param BufferPtr GC_NOTO: add argument description
@return GC_NOTO: add return values
**/
UINT64
AtoU64 (
UINT8 *BufferPtr
)
;
#endif

View File

@ -0,0 +1,93 @@
#/** @file
# Component name for module UefiPxeBc
#
# FIX ME!
# Copyright (c) 2007, Intel Corporation. All rights reserved.
#
# All rights reserved. This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
# http://opensource.org/licenses/bsd-license.php
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
#
#**/
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = UefiPxeBcDxe
FILE_GUID = 3B1DEAB5-C75D-442e-9238-8E2FFB62B0BB
MODULE_TYPE = DXE_DRIVER
VERSION_STRING = 1.0
EDK_RELEASE_VERSION = 0x00020000
EFI_SPECIFICATION_VERSION = 0x00020000
ENTRY_POINT = PxeBcDriverEntryPoint
#
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = IA32 X64 IPF
#
[Sources.common]
PxeBcMtftp.c
PxeBcSupport.h
PxeBcSupport.c
PxeBcDriver.c
PxeBcDhcp.h
ComponentName.c
PxeBcImpl.c
PxeBcImpl.h
PxeBcDhcp.c
PxeBcMtftp.h
PxeBcDriver.h
[Sources.IA32]
Ia32\PxeArch.h
[Sources.X64]
X64\PxeArch.h
[Sources.IPF]
Ipf\PxeArch.h
[Packages]
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec
[LibraryClasses]
BaseLib
UefiLib
UefiBootServicesTableLib
UefiDriverEntryPoint
BaseMemoryLib
DebugLib
NetLib
[Guids]
gEfiSmbiosTableGuid # ALWAYS_CONSUMED
[Protocols]
gEfiMtftp4ServiceBindingProtocolGuid # PROTOCOL ALWAYS_CONSUMED
gEfiMtftp4ProtocolGuid # PROTOCOL ALWAYS_CONSUMED
gEfiUdp4ServiceBindingProtocolGuid # PROTOCOL ALWAYS_CONSUMED
gEfiDhcp4ServiceBindingProtocolGuid # PROTOCOL ALWAYS_CONSUMED
gEfiPxeBaseCodeCallbackProtocolGuid # PROTOCOL ALWAYS_CONSUMED
gEfiPxeBaseCodeProtocolGuid # PROTOCOL ALWAYS_CONSUMED
gEfiLoadFileProtocolGuid # PROTOCOL ALWAYS_CONSUMED
gEfiDhcp4ProtocolGuid # PROTOCOL ALWAYS_CONSUMED
gEfiUdp4ProtocolGuid # PROTOCOL ALWAYS_CONSUMED
gEfiNetworkInterfaceIdentifierProtocolGuid_31 # PROTOCOL ALWAYS_CONSUMED

View File

@ -0,0 +1,108 @@
<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<MsaHeader>
<ModuleName>UefiPxeBcDxe</ModuleName>
<ModuleType>DXE_DRIVER</ModuleType>
<GuidValue>3B1DEAB5-C75D-442e-9238-8E2FFB62B0BB</GuidValue>
<Version>1.0</Version>
<Abstract>Component name for module UefiPxeBc</Abstract>
<Description>FIX ME!</Description>
<Copyright>Copyright (c) 2007, Intel Corporation. All rights reserved.</Copyright>
<License>All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.</License>
<Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052</Specification>
</MsaHeader>
<ModuleDefinitions>
<SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>
<BinaryModule>false</BinaryModule>
<OutputFileBasename>UefiPxeBcDxe</OutputFileBasename>
</ModuleDefinitions>
<LibraryClassDefinitions>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>DebugLib</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>BaseMemoryLib</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>UefiDriverEntryPoint</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>UefiBootServicesTableLib</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>UefiLib</Keyword>
</LibraryClass>
<LibraryClass Usage="ALWAYS_CONSUMED">
<Keyword>BaseLib</Keyword>
</LibraryClass>
</LibraryClassDefinitions>
<SourceFiles>
<Filename>PxeBcDriver.h</Filename>
<Filename>PxeBcMtftp.h</Filename>
<Filename>PxeBcDhcp.c</Filename>
<Filename>PxeBcImpl.h</Filename>
<Filename>PxeBcImpl.c</Filename>
<Filename>ComponentName.c</Filename>
<Filename>PxeBcDhcp.h</Filename>
<Filename>ipf\PxeArch.h</Filename>
<Filename>PxeBcDriver.c</Filename>
<Filename SupArchList="X64">x64\PxeArch.h</Filename>
<Filename>PxeBcSupport.c</Filename>
<Filename>PxeBcSupport.h</Filename>
<Filename>ia32\PxeArch.h</Filename>
<Filename>PxeBcMtftp.c</Filename>
</SourceFiles>
<PackageDependencies>
<Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>
<Package PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>
</PackageDependencies>
<Protocols>
<Protocol Usage="ALWAYS_CONSUMED">
<ProtocolCName>gEfiNetworkInterfaceIdentifierProtocolGuid_31</ProtocolCName>
</Protocol>
<Protocol Usage="ALWAYS_CONSUMED">
<ProtocolCName>gEfiUdp4ProtocolGuid</ProtocolCName>
</Protocol>
<Protocol Usage="ALWAYS_CONSUMED">
<ProtocolCName>gEfiDhcp4ProtocolGuid</ProtocolCName>
</Protocol>
<Protocol Usage="ALWAYS_CONSUMED">
<ProtocolCName>gEfiLoadFileProtocolGuid</ProtocolCName>
</Protocol>
<Protocol Usage="ALWAYS_CONSUMED">
<ProtocolCName>gEfiPxeBaseCodeProtocolGuid</ProtocolCName>
</Protocol>
<Protocol Usage="ALWAYS_CONSUMED">
<ProtocolCName>gEfiPxeBaseCodeCallbackProtocolGuid</ProtocolCName>
</Protocol>
<Protocol Usage="ALWAYS_CONSUMED">
<ProtocolCName>gEfiDhcp4ServiceBindingProtocolGuid</ProtocolCName>
</Protocol>
<Protocol Usage="ALWAYS_CONSUMED">
<ProtocolCName>gEfiUdp4ServiceBindingProtocolGuid</ProtocolCName>
</Protocol>
<Protocol Usage="ALWAYS_CONSUMED">
<ProtocolCName>gEfiMtftp4ProtocolGuid</ProtocolCName>
</Protocol>
<Protocol Usage="ALWAYS_CONSUMED">
<ProtocolCName>gEfiMtftp4ServiceBindingProtocolGuid</ProtocolCName>
</Protocol>
</Protocols>
<Guids>
<GuidCNames Usage="ALWAYS_CONSUMED">
<GuidCName>gEfiSmbiosTableGuid</GuidCName>
</GuidCNames>
</Guids>
<Externs>
<Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>
<Specification>EDK_RELEASE_VERSION 0x00020000</Specification>
<Extern>
<ModuleEntryPoint>PxeBcDriverEntryPoint</ModuleEntryPoint>
</Extern>
</Externs>
</ModuleSurfaceArea>

View File

@ -0,0 +1,26 @@
/** @file
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
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_
#define _EFI_PXE_ARCH_H_
#define SYS_ARCH 0x7
#endif