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  /** Opcode */
90 };
91 
92 /** PXE API call table */
93 #define PXE_API_CALLS __table ( struct pxe_api_call, "pxe_api_calls" )
94 
95 /** Declare a PXE API call */
96 #define __pxe_api_call __table_entry ( PXE_API_CALLS, 01 )
97 
98 /**
99  * Define a PXE API call
100  *
101  * @v _opcode Opcode
102  * @v _entry Entry point
103  * @v _params_type Type of parameter structure
104  * @ret call PXE API call
105  */
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  }
115 
116 /** An UNDI expansion ROM header */
118  /** Signature
119  *
120  * Must be equal to @c ROM_SIGNATURE
121  */
123  /** ROM length in 512-byte blocks */
125  /** Unused */
127  /** Offset of the PXE ROM ID structure */
129  /** Offset of the PCI ROM structure */
131 } __attribute__ (( packed ));
132 
133 /** Signature for an expansion ROM */
134 #define ROM_SIGNATURE 0xaa55
135 
136 /** An UNDI ROM ID structure */
137 struct undi_rom_id {
138  /** Signature
139  *
140  * Must be equal to @c UNDI_ROM_ID_SIGNATURE
141  */
143  /** Length of structure */
145  /** Checksum */
147  /** Structure revision
148  *
149  * Must be zero.
150  */
152  /** UNDI revision
153  *
154  * Version 2.1.0 is encoded as the byte sequence 0x00, 0x01, 0x02.
155  */
157  /** Offset to UNDI loader */
159  /** Minimum required stack segment size */
161  /** Minimum required data segment size */
163  /** Minimum required code segment size */
165 } __attribute__ (( packed ));
166 
167 /** Signature for an UNDI ROM ID structure */
168 #define UNDI_ROM_ID_SIGNATURE \
169  ( ( 'U' << 0 ) + ( 'N' << 8 ) + ( 'D' << 16 ) + ( 'I' << 24 ) )
170 
171 /** A PCI expansion header */
172 struct pcir_header {
173  /** Signature
174  *
175  * Must be equal to @c PCIR_SIGNATURE
176  */
178  /** PCI vendor ID */
180  /** PCI device ID */
182 } __attribute__ (( packed ));
183 
184 /** Signature for an UNDI ROM ID structure */
185 #define PCIR_SIGNATURE \
186  ( ( 'P' << 0 ) + ( 'C' << 8 ) + ( 'I' << 16 ) + ( 'R' << 24 ) )
187 
188 extern struct net_device *pxe_netdev;
189 extern const char *pxe_cmdline;
190 
191 extern void pxe_set_netdev ( struct net_device *netdev );
192 extern void pxe_fake_cached_info ( void );
194  *tftp_read_file );
196 
197 #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:162
Parameter block for pxenv_undi_force_interrupt()
Definition: pxe_api.h:1262
An UNDI expansion ROM header.
Definition: pxe.h:117
PXENV_STATUS_t Status
Definition: pxe.h:29
UINT8_t ROMLength
ROM length in 512-byte blocks.
Definition: pxe.h:124
UINT16_t Signature
Signature.
Definition: pxe.h:122
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:172
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:126
UINT8_t UNDIRev[3]
UNDI revision.
Definition: pxe.h:156
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:158
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:137
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:130
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:177
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:128
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:151
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:179
A network device.
Definition: netdevice.h:352
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:146
Parameter block for pxenv_tftp_close()
Definition: pxe_api.h:604
UINT16_t CodeSize
Minimum required code segment size.
Definition: pxe.h:164
PXENV_EXIT_t pxenv_tftp_read_file(struct s_PXENV_TFTP_READ_FILE *tftp_read_file)
TFTP/MTFTP read file.
Definition: pxe_tftp.c:478
struct net_device * pxe_netdev
Definition: pxe_undi.c:59
Preboot eXecution Environment (PXE) API.
uint16_t opcode
Opcode.
Definition: pxe.h:89
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:142
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:160
struct s_PXENV_START_UNDI start_undi
Definition: pxe.h:34
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:181
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:144
void pxe_fake_cached_info(void)
Construct cached DHCP packets.
Definition: pxe_preboot.c:134
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