iPXE
pxe.h
Go to the documentation of this file.
1 #ifndef PXE_H
2 #define PXE_H
3 
4 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
5 
6 #include "pxe_types.h"
7 #include "pxe_error.h"
8 #include "pxe_api.h"
9 #include <ipxe/device.h>
10 #include <ipxe/tables.h>
11 
12 /** PXE API invalid function code */
13 #define PXENV_UNKNOWN 0xffff
14 
15 /** Parameter block for pxenv_unknown() */
17  PXENV_STATUS_t Status; /**< PXE status code */
18 } __attribute__ (( packed ));
19 
21 
22 /* Union used for PXE API calls; we don't know the type of the
23  * structure until we interpret the opcode. Also, Status is available
24  * in the same location for any opcode, and it's convenient to have
25  * non-specific access to it.
26  */
27 union u_PXENV_ANY {
28  /* Make it easy to read status for any operation */
76 };
77 
78 typedef union u_PXENV_ANY PXENV_ANY_t;
79 
80 /** A PXE API call */
81 struct pxe_api_call {
82  /** Entry point
83  *
84  * @v params PXE API call parameters
85  * @ret exit PXE API call exit code
86  */
87  PXENV_EXIT_t ( * entry ) ( union u_PXENV_ANY *params );
88  /** Length of parameters */
90  /** Opcode */
92 };
93 
94 /** PXE API call table */
95 #define PXE_API_CALLS __table ( struct pxe_api_call, "pxe_api_calls" )
96 
97 /** Declare a PXE API call */
98 #define __pxe_api_call __table_entry ( PXE_API_CALLS, 01 )
99 
100 /**
101  * Define a PXE API call
102  *
103  * @v _opcode Opcode
104  * @v _entry Entry point
105  * @v _params_type Type of parameter structure
106  * @ret call PXE API call
107  */
108 #define PXE_API_CALL( _opcode, _entry, _params_type ) { \
109  .entry = ( ( ( ( PXENV_EXIT_t ( * ) ( _params_type *params ) ) NULL ) \
110  == ( ( typeof ( _entry ) * ) NULL ) ) \
111  ? ( ( PXENV_EXIT_t ( * ) \
112  ( union u_PXENV_ANY *params ) ) _entry ) \
113  : ( ( PXENV_EXIT_t ( * ) \
114  ( union u_PXENV_ANY *params ) ) _entry ) ), \
115  .params_len = sizeof ( _params_type ), \
116  .opcode = _opcode, \
117  }
118 
119 /** An UNDI expansion ROM header */
121  /** Signature
122  *
123  * Must be equal to @c ROM_SIGNATURE
124  */
126  /** ROM length in 512-byte blocks */
128  /** Unused */
130  /** Offset of the PXE ROM ID structure */
132  /** Offset of the PCI ROM structure */
134 } __attribute__ (( packed ));
135 
136 /** Signature for an expansion ROM */
137 #define ROM_SIGNATURE 0xaa55
138 
139 /** An UNDI ROM ID structure */
140 struct undi_rom_id {
141  /** Signature
142  *
143  * Must be equal to @c UNDI_ROM_ID_SIGNATURE
144  */
146  /** Length of structure */
148  /** Checksum */
150  /** Structure revision
151  *
152  * Must be zero.
153  */
155  /** UNDI revision
156  *
157  * Version 2.1.0 is encoded as the byte sequence 0x00, 0x01, 0x02.
158  */
160  /** Offset to UNDI loader */
162  /** Minimum required stack segment size */
164  /** Minimum required data segment size */
166  /** Minimum required code segment size */
168 } __attribute__ (( packed ));
169 
170 /** Signature for an UNDI ROM ID structure */
171 #define UNDI_ROM_ID_SIGNATURE \
172  ( ( 'U' << 0 ) + ( 'N' << 8 ) + ( 'D' << 16 ) + ( 'I' << 24 ) )
173 
174 /** A PCI expansion header */
175 struct pcir_header {
176  /** Signature
177  *
178  * Must be equal to @c PCIR_SIGNATURE
179  */
181  /** PCI vendor ID */
183  /** PCI device ID */
185 } __attribute__ (( packed ));
186 
187 /** Signature for an UNDI ROM ID structure */
188 #define PCIR_SIGNATURE \
189  ( ( 'P' << 0 ) + ( 'C' << 8 ) + ( 'I' << 16 ) + ( 'R' << 24 ) )
190 
191 extern struct net_device *pxe_netdev;
192 extern const char *pxe_cmdline;
193 
194 extern void pxe_set_netdev ( struct net_device *netdev );
195 extern void pxe_fake_cached_info ( void );
197  *tftp_read_file );
199 
200 #endif /* PXE_H */
struct s_PXENV_UNDI_FORCE_INTERRUPT undi_force_interrupt
Definition: pxe.h:62
struct s_PXENV_UNDI_CLEAR_STATISTICS undi_clear_statistics
Definition: pxe.h:60
#define __attribute__(x)
Definition: compiler.h:10
Parameter block for pxenv_stop_base()
Definition: pxe_api.h:546
Parameter block for pxenv_undi_isr()
Definition: pxe_api.h:1479
unsigned short uint16_t
Definition: stdint.h:11
struct s_PXENV_UNDI_INITIATE_DIAGS undi_initiate_diags
Definition: pxe.h:61
struct s_PXENV_FILE_API_CHECK file_api_check
Definition: pxe.h:74
Parameter block for pxenv_undi_clear_statistics()
Definition: pxe_api.h:1224
Preboot eXecution Environment (PXE) error definitions.
struct s_PXENV_GET_FILE_SIZE get_file_size
Definition: pxe.h:72
UINT16_t DataSize
Minimum required data segment size.
Definition: pxe.h:165
Parameter block for pxenv_undi_force_interrupt()
Definition: pxe_api.h:1262
An UNDI expansion ROM header.
Definition: pxe.h:120
PXENV_STATUS_t Status
Definition: pxe.h:29
UINT8_t ROMLength
ROM length in 512-byte blocks.
Definition: pxe.h:127
UINT16_t Signature
Signature.
Definition: pxe.h:125
struct s_PXENV_UNDI_GET_INFORMATION undi_get_information
Definition: pxe.h:58
struct s_PXENV_START_BASE start_base
Definition: pxe.h:36
Parameter block for pxenv_tftp_read()
Definition: pxe_api.h:623
Parameter block for pxenv_unload_stack()
Definition: pxe_api.h:253
struct s_PXENV_UNDI_GET_NIC_TYPE undi_get_nic_type
Definition: pxe.h:64
struct s_PXENV_UNDI_SET_MCAST_ADDRESS undi_set_mcast_address
Definition: pxe.h:55
Parameter block for pxenv_file_close()
Definition: pxe_api.h:1558
Parameter block for pxenv_undi_initialize()
Definition: pxe_api.h:863
Parameter block for pxenv_undi_transmit()
Definition: pxe_api.h:1049
struct s_PXENV_UDP_READ udp_read
Definition: pxe.h:46
Parameter block for pxenv_udp_close()
Definition: pxe_api.h:740
struct s_PXENV_UNDI_RESET undi_reset_adapter
Definition: pxe.h:50
Parameter block for pxenv_get_cached_info()
Definition: pxe_api.h:286
Parameter block for pxenv_undi_set_packet_filter()
Definition: pxe_api.h:1128
Parameter block for pxenv_undi_get_nic_type()
Definition: pxe_api.h:1329
A PCI expansion header.
Definition: pxe.h:175
struct s_PXENV_UNDI_TRANSMIT undi_transmit
Definition: pxe.h:54
struct s_PXENV_FILE_EXEC file_exec
Definition: pxe.h:73
Parameter block for pxenv_udp_read()
Definition: pxe_api.h:784
struct s_PXENV_GET_CACHED_INFO get_cached_info
Definition: pxe.h:32
struct s_PXENV_FILE_OPEN file_open
Definition: pxe.h:68
UINT8_t unused[0x13]
Unused.
Definition: pxe.h:129
UINT8_t UNDIRev[3]
UNDI revision.
Definition: pxe.h:159
Parameter block for pxenv_undi_close()
Definition: pxe_api.h:993
Parameter block for pxenv_file_api_check()
Definition: pxe_api.h:1665
UINT16_t UNDILoader
Offset to UNDI loader.
Definition: pxe.h:161
struct s_PXENV_FILE_READ file_read
Definition: pxe.h:71
struct s_PXENV_UNDI_STARTUP undi_startup
Definition: pxe.h:47
UINT16_t PXENV_STATUS_t
A PXE status code.
Definition: pxe_types.h:53
Parameter block for pxenv_file_select()
Definition: pxe_api.h:1581
An UNDI ROM ID structure.
Definition: pxe.h:140
UINT16_t PXENV_EXIT_t
A PXE exit code.
Definition: pxe_types.h:44
struct s_PXENV_UNDI_GET_STATISTICS undi_get_statistics
Definition: pxe.h:59
struct s_PXENV_UNDI_GET_MCAST_ADDRESS undi_get_mcast_address
Definition: pxe.h:63
struct s_PXENV_TFTP_READ_FILE tftp_read_file
Definition: pxe.h:41
UINT16_t PCIRHeader
Offset of the PCI ROM structure.
Definition: pxe.h:133
Parameter block for pxenv_udp_open()
Definition: pxe_api.h:720
Parameter block for pxenv_file_exit_hook()
Definition: pxe_api.h:1689
uint32_t signature
Signature.
Definition: pxe.h:180
Parameter block for pxenv_undi_set_station_address()
Definition: pxe_api.h:1108
UINT16_t PXEROMID
Offset of the PXE ROM ID structure.
Definition: pxe.h:131
Parameter block for pxenv_get_file_size()
Definition: pxe_api.h:1624
static struct net_device * netdev
Definition: gdbudp.c:52
uint8_t UINT8_t
An 8-bit unsigned integer.
Definition: pxe_types.h:31
Parameter block for pxenv_file_exec()
Definition: pxe_api.h:1645
struct s_PXENV_UDP_OPEN udp_open
Definition: pxe.h:43
struct s_PXENV_UNDI_CLEANUP undi_cleanup
Definition: pxe.h:48
struct s_PXENV_TFTP_READ_FILE restart_tftp
Definition: pxe.h:33
Parameter block for pxenv_undi_shutdown()
Definition: pxe_api.h:925
struct s_PXENV_TFTP_CLOSE tftp_close
Definition: pxe.h:39
Parameter block for pxenv_undi_get_mcast_address()
Definition: pxe_api.h:1281
UINT8_t StructRev
Structure revision.
Definition: pxe.h:154
struct s_PXENV_UNDI_OPEN undi_open
Definition: pxe.h:52
Parameter block for pxenv_tftp_get_fsize()
Definition: pxe_api.h:688
Parameter block for pxenv_undi_startup()
Definition: pxe_api.h:825
struct s_PXENV_UNKNOWN unknown
Definition: pxe.h:30
Parameter block for pxenv_undi_set_mcast_address()
Definition: pxe_api.h:1087
struct s_PXENV_STOP_BASE stop_base
Definition: pxe.h:37
struct s_PXENV_UNDI_GET_IFACE_INFO undi_get_iface_info
Definition: pxe.h:65
uint16_t vendor_id
PCI vendor ID.
Definition: pxe.h:182
A network device.
Definition: netdevice.h:348
struct s_PXENV_FILE_CLOSE file_close
Definition: pxe.h:69
struct s_PXENV_UDP_WRITE udp_write
Definition: pxe.h:45
Parameter block for pxenv_undi_get_information()
Definition: pxe_api.h:1166
UINT8_t StructCksum
Checksum.
Definition: pxe.h:149
Parameter block for pxenv_tftp_close()
Definition: pxe_api.h:604
UINT16_t CodeSize
Minimum required code segment size.
Definition: pxe.h:167
PXENV_EXIT_t pxenv_tftp_read_file(struct s_PXENV_TFTP_READ_FILE *tftp_read_file)
TFTP/MTFTP read file.
Definition: pxe_tftp.c:480
struct net_device * pxe_netdev
Definition: pxe_undi.c:59
Preboot eXecution Environment (PXE) API.
uint16_t opcode
Opcode.
Definition: pxe.h:91
unsigned int uint32_t
Definition: stdint.h:12
struct s_PXENV_TFTP_GET_FSIZE tftp_get_fsize
Definition: pxe.h:42
struct s_PXENV_UNDI_GET_STATE undi_get_state
Definition: pxe.h:66
struct s_PXENV_UNDI_SET_PACKET_FILTER undi_set_packet_filter
Definition: pxe.h:57
Parameter block for pxenv_undi_get_state()
Definition: pxe_api.h:1427
UINT32_t Signature
Signature.
Definition: pxe.h:145
Parameter block for pxenv_undi_cleanup()
Definition: pxe_api.h:844
struct s_PXENV_UDP_CLOSE udp_close
Definition: pxe.h:44
UINT16_t StackSize
Minimum required stack segment size.
Definition: pxe.h:163
struct s_PXENV_START_UNDI start_undi
Definition: pxe.h:34
uint16_t params_len
Length of parameters.
Definition: pxe.h:89
struct s_PXENV_UNDI_CLOSE undi_close
Definition: pxe.h:53
struct s_PXENV_TFTP_OPEN tftp_open
Definition: pxe.h:38
Parameter block for pxenv_file_open()
Definition: pxe_api.h:1536
Parameter block for pxenv_start_base()
Definition: pxe_api.h:527
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
A PXE API call.
Definition: pxe.h:81
Parameter block for pxenv_undi_reset_adapter()
Definition: pxe_api.h:904
uint16_t device_id
PCI device ID.
Definition: pxe.h:184
Parameter block for pxenv_undi_initiate_diags()
Definition: pxe_api.h:1243
struct s_PXENV_UNDI_SET_STATION_ADDRESS undi_set_station_address
Definition: pxe.h:56
uint16_t UINT16_t
A 16-bit unsigned integer.
Definition: pxe_types.h:34
Parameter block for undi_loader()
Definition: pxe_api.h:1729
uint32_t UINT32_t
A 32-bit unsigned integer.
Definition: pxe_types.h:37
Parameter block for pxenv_undi_get_iface_info()
Definition: pxe_api.h:1381
Parameter block for pxenv_tftp_read_file()
Definition: pxe_api.h:645
Parameter block for pxenv_tftp_open()
Definition: pxe_api.h:574
struct s_PXENV_FILE_EXIT_HOOK file_exit_hook
Definition: pxe.h:75
Linker tables.
PXE data types.
Device model.
Parameter block for pxenv_file_read()
Definition: pxe_api.h:1602
void pxe_set_netdev(struct net_device *netdev)
Set network device as current PXE network device.
Definition: pxe_undi.c:69
PXENV_EXIT_t(* entry)(union u_PXENV_ANY *params)
Entry point.
Definition: pxe.h:87
struct s_PXENV_UNLOAD_STACK unload_stack
Definition: pxe.h:31
Parameter block for pxenv_unknown()
Definition: pxe.h:16
struct s_PXENV_FILE_SELECT file_select
Definition: pxe.h:70
Parameter block for pxenv_start_undi()
Definition: pxe_api.h:438
UINT8_t StructLength
Length of structure.
Definition: pxe.h:147
void pxe_fake_cached_info(void)
Construct cached DHCP packets.
Definition: pxe_preboot.c:135
struct s_PXENV_TFTP_READ tftp_read
Definition: pxe.h:40
PXENV_STATUS_t Status
PXE status code.
Definition: pxe.h:17
struct s_PXENV_STOP_UNDI stop_undi
Definition: pxe.h:35
struct s_PXENV_UNDI_INITIALIZE undi_initialize
Definition: pxe.h:49
struct s_PXENV_UNDI_ISR undi_isr
Definition: pxe.h:67
Parameter block for pxenv_undi_get_statistics()
Definition: pxe_api.h:1201
const char * pxe_cmdline
PXE command line.
Definition: pxe_image.c:48
PXENV_EXIT_t undi_loader(struct s_UNDI_LOADER *undi_loader)
Definition: pxe_loader.c:39
Parameter block for pxenv_stop_undi()
Definition: pxe_api.h:508
Parameter block for pxenv_undi_open()
Definition: pxe_api.h:958
struct s_PXENV_UNDI_SHUTDOWN undi_shutdown
Definition: pxe.h:51
Parameter block for pxenv_udp_write()
Definition: pxe_api.h:759