iPXE
pxe.h File Reference
#include "pxe_types.h"
#include "pxe_error.h"
#include "pxe_api.h"
#include <ipxe/device.h>
#include <ipxe/tables.h>

Go to the source code of this file.

Data Structures

struct  s_PXENV_UNKNOWN
 Parameter block for pxenv_unknown() More...
union  u_PXENV_ANY
struct  pxe_api_call
 A PXE API call. More...
struct  undi_rom_header
 An UNDI expansion ROM header. More...
struct  undi_rom_id
 An UNDI ROM ID structure. More...
struct  pcir_header
 A PCI expansion header. More...

Macros

#define PXENV_UNKNOWN   0xffff
 PXE API invalid function code.
#define PXE_API_CALLS   __table ( struct pxe_api_call, "pxe_api_calls" )
 PXE API call table.
#define __pxe_api_call   __table_entry ( PXE_API_CALLS, 01 )
 Declare a PXE API call.
#define PXE_API_CALL(_opcode, _entry, _params_type)
 Define a PXE API call.
#define ROM_SIGNATURE   0xaa55
 Signature for an expansion ROM.
#define UNDI_ROM_ID_SIGNATURE    ( ( 'U' << 0 ) + ( 'N' << 8 ) + ( 'D' << 16 ) + ( 'I' << 24 ) )
 Signature for an UNDI ROM ID structure.
#define PCIR_SIGNATURE    ( ( 'P' << 0 ) + ( 'C' << 8 ) + ( 'I' << 16 ) + ( 'R' << 24 ) )
 Signature for an UNDI ROM ID structure.

Typedefs

typedef struct s_PXENV_UNKNOWN PXENV_UNKNOWN_t
typedef union u_PXENV_ANY PXENV_ANY_t

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
void pxe_set_netdev (struct net_device *netdev)
 Set network device as current PXE network device.
void pxe_fake_cached_info (void)
 Construct cached DHCP packets.
PXENV_EXIT_t pxenv_tftp_read_file (struct s_PXENV_TFTP_READ_FILE *tftp_read_file)
 TFTP/MTFTP read file.
PXENV_EXIT_t undi_loader (struct s_UNDI_LOADER *undi_loader)

Variables

struct net_devicepxe_netdev
const char * pxe_cmdline
 PXE command line.

Macro Definition Documentation

◆ PXENV_UNKNOWN

#define PXENV_UNKNOWN   0xffff

PXE API invalid function code.

Definition at line 13 of file pxe.h.

Referenced by pxe_api_profiler(), and undinet_profiler().

◆ PXE_API_CALLS

#define PXE_API_CALLS   __table ( struct pxe_api_call, "pxe_api_calls" )

PXE API call table.

Definition at line 93 of file pxe.h.

Referenced by find_pxe_api_call(), and pxenv_file_api_check().

◆ __pxe_api_call

#define __pxe_api_call   __table_entry ( PXE_API_CALLS, 01 )

Declare a PXE API call.

Definition at line 96 of file pxe.h.

◆ PXE_API_CALL

#define PXE_API_CALL ( _opcode,
_entry,
_params_type )
Value:
{ \
.entry = ( ( ( ( PXENV_EXIT_t ( * ) ( _params_type *params ) ) NULL ) \
== ( ( typeof ( _entry ) * ) NULL ) ) \
? ( ( PXENV_EXIT_t ( * ) \
( union u_PXENV_ANY *params ) ) _entry ) \
: ( ( PXENV_EXIT_t ( * ) \
( union u_PXENV_ANY *params ) ) _entry ) ), \
.opcode = _opcode, \
}
#define NULL
NULL pointer (VOID *)
Definition Base.h:322
typeof(acpi_finder=acpi_find)
ACPI table finder.
Definition acpi.c:48
UINT16_t PXENV_EXIT_t
A PXE exit code.
Definition pxe_types.h:44

Define a PXE API call.

Parameters
_opcodeOpcode
_entryEntry point
_params_typeType of parameter structure
Return values
callPXE API call

Definition at line 106 of file pxe.h.

106#define PXE_API_CALL( _opcode, _entry, _params_type ) { \
107 .entry = ( ( ( ( PXENV_EXIT_t ( * ) ( _params_type *params ) ) NULL ) \
108 == ( ( typeof ( _entry ) * ) NULL ) ) \
109 ? ( ( PXENV_EXIT_t ( * ) \
110 ( union u_PXENV_ANY *params ) ) _entry ) \
111 : ( ( PXENV_EXIT_t ( * ) \
112 ( union u_PXENV_ANY *params ) ) _entry ) ), \
113 .opcode = _opcode, \
114 }

◆ ROM_SIGNATURE

#define ROM_SIGNATURE   0xaa55

Signature for an expansion ROM.

Definition at line 134 of file pxe.h.

Referenced by undirom_probe().

◆ UNDI_ROM_ID_SIGNATURE

#define UNDI_ROM_ID_SIGNATURE    ( ( 'U' << 0 ) + ( 'N' << 8 ) + ( 'D' << 16 ) + ( 'I' << 24 ) )

Signature for an UNDI ROM ID structure.

Definition at line 168 of file pxe.h.

168#define UNDI_ROM_ID_SIGNATURE \
169 ( ( 'U' << 0 ) + ( 'N' << 8 ) + ( 'D' << 16 ) + ( 'I' << 24 ) )

Referenced by undirom_parse_pxeromid().

◆ PCIR_SIGNATURE

#define PCIR_SIGNATURE    ( ( 'P' << 0 ) + ( 'C' << 8 ) + ( 'I' << 16 ) + ( 'R' << 24 ) )

Signature for an UNDI ROM ID structure.

Definition at line 185 of file pxe.h.

185#define PCIR_SIGNATURE \
186 ( ( 'P' << 0 ) + ( 'C' << 8 ) + ( 'I' << 16 ) + ( 'R' << 24 ) )

Referenced by undirom_parse_pcirheader().

Typedef Documentation

◆ PXENV_UNKNOWN_t

Definition at line 20 of file pxe.h.

◆ PXENV_ANY_t

typedef union u_PXENV_ANY PXENV_ANY_t

Definition at line 78 of file pxe.h.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )

◆ pxe_set_netdev()

void pxe_set_netdev ( struct net_device * netdev)
extern

Set network device as current PXE network device.

Parameters
netdevNetwork device, or NULL

Definition at line 69 of file pxe_undi.c.

69 {
70
71 if ( pxe_netdev ) {
74 }
75
77
78 if ( netdev )
80}
static struct net_device * netdev
Definition gdbudp.c:53
void netdev_rx_unfreeze(struct net_device *netdev)
Unfreeze network device receive queue processing.
Definition netdevice.c:193
static struct net_device * netdev_get(struct net_device *netdev)
Get reference to network device.
Definition netdevice.h:565
static void netdev_put(struct net_device *netdev)
Drop reference to network device.
Definition netdevice.h:576
struct net_device * pxe_netdev
Definition pxe_undi.c:59

References netdev, netdev_get(), netdev_put(), netdev_rx_unfreeze(), NULL, and pxe_netdev.

Referenced by pxe_activate(), and pxe_deactivate().

◆ pxe_fake_cached_info()

void pxe_fake_cached_info ( void )
extern

Construct cached DHCP packets.

Definition at line 134 of file pxe_preboot.c.

134 {
135 struct pxe_dhcp_packet_creator *creator;
136 union pxe_cached_info *info;
137 unsigned int i;
138 int rc;
139
140 /* Sanity check */
141 assert ( pxe_netdev != NULL );
142
143 /* Erase any stale packets */
144 memset ( cached_info, 0, sizeof ( cached_info ) );
145
146 /* Construct all DHCP packets */
147 for ( i = 0 ; i < ( sizeof ( pxe_dhcp_packet_creators ) /
148 sizeof ( pxe_dhcp_packet_creators[0] ) ) ; i++ ) {
149
150 /* Construct DHCP packet */
151 creator = &pxe_dhcp_packet_creators[i];
152 info = &cached_info[i];
153 if ( ( rc = creator->create ( pxe_netdev, info,
154 sizeof ( *info ) ) ) != 0 ) {
155 DBGC ( &pxe_netdev, " failed to build packet: %s\n",
156 strerror ( rc ) );
157 /* Continue constructing remaining packets */
158 }
159 }
160}
u32 info
Definition ar9003_mac.h:0
struct arbelprm_rc_send_wqe rc
Definition arbel.h:3
#define assert(condition)
Assert a condition at run-time.
Definition assert.h:50
#define DBGC(...)
Definition compiler.h:505
void * memset(void *dest, int character, size_t len) __nonnull
#define cached_info
static struct pxe_dhcp_packet_creator pxe_dhcp_packet_creators[]
PXE DHCP packet creators.
Definition pxe_preboot.c:90
char * strerror(int errno)
Retrieve string representation of error number.
Definition strerror.c:79
A PXE DHCP packet creator.
Definition pxe_preboot.c:77
int(* create)(struct net_device *netdev, void *data, size_t max_len)
Create DHCP packet.
Definition pxe_preboot.c:85
A cached DHCP packet.
Definition pxe_preboot.c:61

References assert, cached_info, pxe_dhcp_packet_creator::create, DBGC, info, memset(), NULL, pxe_dhcp_packet_creators, pxe_netdev, rc, and strerror().

Referenced by pxe_exec().

◆ pxenv_tftp_read_file()

PXENV_EXIT_t pxenv_tftp_read_file ( struct s_PXENV_TFTP_READ_FILE * tftp_read_file)
extern

TFTP/MTFTP read file.

Parameters
tftp_read_filePointer to a struct s_PXENV_TFTP_READ_FILE
s_PXENV_TFTP_READ_FILE::FileNameFile name
s_PXENV_TFTP_READ_FILE::BufferSizeSize of the receive buffer
s_PXENV_TFTP_READ_FILE::BufferAddress of the receive buffer
s_PXENV_TFTP_READ_FILE::ServerIPAddressTFTP server IP address
s_PXENV_TFTP_READ_FILE::GatewayIPAddressRelay agent IP address
s_PXENV_TFTP_READ_FILE::McastIPAddressFile's multicast IP address
s_PXENV_TFTP_READ_FILE::TFTPClntPortClient multicast UDP port
s_PXENV_TFTP_READ_FILE::TFTPSrvPortServer multicast UDP port
s_PXENV_TFTP_READ_FILE::TFTPOpenTimeOutTime to wait for first packet
s_PXENV_TFTP_READ_FILE::TFTPReopenDelayMTFTP inactivity timeout
Return values
PXENV_EXIT_SUCCESSFile downloaded successfully
PXENV_EXIT_FAILUREFile not downloaded
s_PXENV_TFTP_READ_FILE::StatusPXE status code
s_PXENV_TFTP_READ_FILE::BufferSizeLength of downloaded file

Downloads an entire file via either TFTP or MTFTP into the buffer pointed to by s_PXENV_TFTP_READ_FILE::Buffer.

The PXE specification does not make it clear how the caller requests that MTFTP be used rather than TFTP (or vice versa). One reasonable guess is that setting s_PXENV_TFTP_READ_FILE::McastIPAddress to 0.0.0.0 would cause TFTP to be used instead of MTFTP, though it is conceivable that some PXE stacks would interpret that as "use the DHCP-provided multicast IP address" instead. Some PXE stacks will not implement MTFTP at all, and will always use TFTP.

It is not specified whether or not s_PXENV_TFTP_READ_FILE::TFTPSrvPort will be used as the TFTP server port for TFTP (rather than MTFTP) downloads. Callers should assume that the only way to access a TFTP server on a non-standard port is to use pxenv_tftp_open() and pxenv_tftp_read().

If s_PXENV_TFTP_READ_FILE::GatewayIPAddress is 0.0.0.0, normal IP routing will take place. See the relevant implementation note for more details.

It is interesting to note that s_PXENV_TFTP_READ_FILE::Buffer is an ADDR32_t type, i.e. nominally a flat physical address. Some PXE NBPs (e.g. NTLDR) are known to call pxenv_tftp_read_file() in real mode with s_PXENV_TFTP_READ_FILE::Buffer set to an address above 1MB. This means that PXE stacks must be prepared to write to areas outside base memory. Exactly how this is to be achieved is not specified, though using INT 15,87 is as close to a standard method as any, and should probably be used. Switching to protected-mode in order to access high memory will fail if pxenv_tftp_read_file() is called in V86 mode; it is reasonably to expect that a V86 monitor would intercept the relatively well-defined INT 15,87 if it wants the PXE stack to be able to write to high memory.

Things get even more interesting if pxenv_tftp_read_file() is called in protected mode, because there is then absolutely no way for the PXE stack to write to an absolute physical address. You can't even get around the problem by creating a special "access everything" segment in the s_PXE data structure, because the #SEGDESC_t descriptors are limited to 64kB in size.

Previous versions of the PXE specification (e.g. WfM 1.1a) provide a separate API call, pxenv_tftp_read_file_pmode(), specifically to work around this problem. The s_PXENV_TFTP_READ_FILE_PMODE parameter block splits s_PXENV_TFTP_READ_FILE::Buffer into s_PXENV_TFTP_READ_FILE_PMODE::BufferSelector and s_PXENV_TFTP_READ_FILE_PMODE::BufferOffset, i.e. it provides a protected-mode segment:offset address for the data buffer. This API call is no longer present in version 2.1 of the PXE specification.

Etherboot makes the assumption that s_PXENV_TFTP_READ_FILE::Buffer is an offset relative to the caller's data segment, when pxenv_tftp_read_file() is called in protected mode.

On x86, you must set the s_PXE::StatusCallout field to a nonzero value before calling this function in protected mode. You cannot call this function with a 32-bit stack segment. (See the relevant implementation note for more details.)

Definition at line 478 of file pxe_tftp.c.

479 {
480 int rc;
481
482 DBG ( "PXENV_TFTP_READ_FILE to %08x+%x", tftp_read_file->Buffer,
483 tftp_read_file->BufferSize );
484
485 /* Open TFTP file */
486 if ( ( rc = pxe_tftp_open ( tftp_read_file->ServerIPAddress, 0,
487 tftp_read_file->FileName, 0 ) ) != 0 ) {
488 tftp_read_file->Status = PXENV_STATUS ( rc );
489 return PXENV_EXIT_FAILURE;
490 }
491
492 /* Read entire file */
493 pxe_tftp.buffer = phys_to_virt ( tftp_read_file->Buffer );
494 pxe_tftp.size = tftp_read_file->BufferSize;
495 while ( ( rc = pxe_tftp.rc ) == -EINPROGRESS )
496 step();
497 pxe_tftp.buffer = NULL;
498 tftp_read_file->BufferSize = pxe_tftp.max_offset;
499
500 /* Close TFTP file */
502
503 tftp_read_file->Status = PXENV_STATUS ( rc );
505}
#define DBG(...)
Print a debugging message.
Definition compiler.h:498
#define EINPROGRESS
Operation in progress.
Definition errno.h:419
#define PXENV_EXIT_FAILURE
An error occurred.
Definition pxe_types.h:46
#define PXENV_EXIT_SUCCESS
No error occurred.
Definition pxe_types.h:45
void step(void)
Single-step a single process.
Definition process.c:99
#define PXENV_STATUS(rc)
Derive PXENV_STATUS code from iPXE error number.
Definition pxe_error.h:121
static void pxe_tftp_close(struct pxe_tftp_connection *pxe_tftp, int rc)
Close PXE TFTP connection.
Definition pxe_tftp.c:74
static struct pxe_tftp_connection pxe_tftp
The PXE TFTP connection.
Definition pxe_tftp.c:156
static int pxe_tftp_open(IP4_t ipaddress, UDP_PORT_t port, UINT8_t *filename, UINT16_t blksize)
Open PXE TFTP connection.
Definition pxe_tftp.c:169
IP4_t ServerIPAddress
TFTP server IP address.
Definition pxe_api.h:650
UINT8_t FileName[128]
File name.
Definition pxe_api.h:647
ADDR32_t Buffer
Address of data buffer.
Definition pxe_api.h:649
PXENV_STATUS_t Status
PXE status code.
Definition pxe_api.h:646
UINT32_t BufferSize
Size of data buffer.
Definition pxe_api.h:648

References s_PXENV_TFTP_READ_FILE::Buffer, s_PXENV_TFTP_READ_FILE::BufferSize, DBG, EINPROGRESS, s_PXENV_TFTP_READ_FILE::FileName, NULL, pxe_tftp, pxe_tftp_close(), pxe_tftp_open(), PXENV_EXIT_FAILURE, PXENV_EXIT_SUCCESS, PXENV_STATUS, rc, s_PXENV_TFTP_READ_FILE::ServerIPAddress, s_PXENV_TFTP_READ_FILE::Status, and step().

Referenced by pxenv_restart_tftp().

◆ undi_loader()

PXENV_EXIT_t undi_loader ( struct s_UNDI_LOADER * undi_loader)
extern

Definition at line 39 of file pxe_loader.c.

39 {
40
41 /* Perform one-time initialisation (e.g. heap) */
42 initialise();
43
44 DBG ( "[PXENV_UNDI_LOADER to CS %04x DS %04x]",
45 undi_loader->UNDI_CS, undi_loader->UNDI_DS );
46
47 /* Fill in UNDI loader structure */
48 undi_loader->PXEptr.segment = rm_cs;
49 undi_loader->PXEptr.offset = __from_text16 ( &ppxe );
50 undi_loader->PXENVptr.segment = rm_cs;
51 undi_loader->PXENVptr.offset = __from_text16 ( &pxenv );
52
54 return PXENV_EXIT_SUCCESS;
55}
#define PXENV_STATUS_SUCCESS
Definition pxe_error.h:19
void initialise(void)
Initialise iPXE.
Definition init.c:53
#define __from_text16(pointer)
Definition libkir.h:23
#define rm_cs
Definition libkir.h:38
#define ppxe
Definition pxe_call.h:28
#define pxenv
Definition pxe_call.h:32
#define undi_loader
Definition undiload.c:53

References __from_text16, DBG, initialise(), ppxe, pxenv, PXENV_EXIT_SUCCESS, PXENV_STATUS_SUCCESS, rm_cs, and undi_loader.

Variable Documentation

◆ pxe_netdev

◆ pxe_cmdline

const char* pxe_cmdline
extern

PXE command line.

Definition at line 48 of file pxe_image.c.

Referenced by pxe_exec(), and pxenv_file_cmdline().