4 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
9 #include <ipxe/device.h>
10 #include <ipxe/tables.h>
12 /** PXE API invalid function code */
13 #define PXENV_UNKNOWN 0xffff
15 /** Parameter block for pxenv_unknown() */
16 struct s_PXENV_UNKNOWN {
17 PXENV_STATUS_t Status; /**< PXE status code */
18 } __attribute__ (( packed ));
20 typedef struct s_PXENV_UNKNOWN PXENV_UNKNOWN_t;
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.
28 /* Make it easy to read status for any operation */
29 PXENV_STATUS_t Status;
30 struct s_PXENV_UNKNOWN unknown;
31 struct s_PXENV_UNLOAD_STACK unload_stack;
32 struct s_PXENV_GET_CACHED_INFO get_cached_info;
33 struct s_PXENV_TFTP_READ_FILE restart_tftp;
34 struct s_PXENV_START_UNDI start_undi;
35 struct s_PXENV_STOP_UNDI stop_undi;
36 struct s_PXENV_START_BASE start_base;
37 struct s_PXENV_STOP_BASE stop_base;
38 struct s_PXENV_TFTP_OPEN tftp_open;
39 struct s_PXENV_TFTP_CLOSE tftp_close;
40 struct s_PXENV_TFTP_READ tftp_read;
41 struct s_PXENV_TFTP_READ_FILE tftp_read_file;
42 struct s_PXENV_TFTP_GET_FSIZE tftp_get_fsize;
43 struct s_PXENV_UDP_OPEN udp_open;
44 struct s_PXENV_UDP_CLOSE udp_close;
45 struct s_PXENV_UDP_WRITE udp_write;
46 struct s_PXENV_UDP_READ udp_read;
47 struct s_PXENV_UNDI_STARTUP undi_startup;
48 struct s_PXENV_UNDI_CLEANUP undi_cleanup;
49 struct s_PXENV_UNDI_INITIALIZE undi_initialize;
50 struct s_PXENV_UNDI_RESET undi_reset_adapter;
51 struct s_PXENV_UNDI_SHUTDOWN undi_shutdown;
52 struct s_PXENV_UNDI_OPEN undi_open;
53 struct s_PXENV_UNDI_CLOSE undi_close;
54 struct s_PXENV_UNDI_TRANSMIT undi_transmit;
55 struct s_PXENV_UNDI_SET_MCAST_ADDRESS undi_set_mcast_address;
56 struct s_PXENV_UNDI_SET_STATION_ADDRESS undi_set_station_address;
57 struct s_PXENV_UNDI_SET_PACKET_FILTER undi_set_packet_filter;
58 struct s_PXENV_UNDI_GET_INFORMATION undi_get_information;
59 struct s_PXENV_UNDI_GET_STATISTICS undi_get_statistics;
60 struct s_PXENV_UNDI_CLEAR_STATISTICS undi_clear_statistics;
61 struct s_PXENV_UNDI_INITIATE_DIAGS undi_initiate_diags;
62 struct s_PXENV_UNDI_FORCE_INTERRUPT undi_force_interrupt;
63 struct s_PXENV_UNDI_GET_MCAST_ADDRESS undi_get_mcast_address;
64 struct s_PXENV_UNDI_GET_NIC_TYPE undi_get_nic_type;
65 struct s_PXENV_UNDI_GET_IFACE_INFO undi_get_iface_info;
66 struct s_PXENV_UNDI_GET_STATE undi_get_state;
67 struct s_PXENV_UNDI_ISR undi_isr;
68 struct s_PXENV_FILE_OPEN file_open;
69 struct s_PXENV_FILE_CLOSE file_close;
70 struct s_PXENV_FILE_SELECT file_select;
71 struct s_PXENV_FILE_READ file_read;
72 struct s_PXENV_GET_FILE_SIZE get_file_size;
73 struct s_PXENV_FILE_EXEC file_exec;
74 struct s_PXENV_FILE_API_CHECK file_api_check;
75 struct s_PXENV_FILE_EXIT_HOOK file_exit_hook;
78 typedef union u_PXENV_ANY PXENV_ANY_t;
84 * @v params PXE API call parameters
85 * @ret exit PXE API call exit code
87 PXENV_EXIT_t ( * entry ) ( union u_PXENV_ANY *params );
88 /** Length of parameters */
94 /** PXE API call table */
95 #define PXE_API_CALLS __table ( struct pxe_api_call, "pxe_api_calls" )
97 /** Declare a PXE API call */
98 #define __pxe_api_call __table_entry ( PXE_API_CALLS, 01 )
101 * Define a PXE API call
104 * @v _entry Entry point
105 * @v _params_type Type of parameter structure
106 * @ret call PXE API call
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 ), \
119 /** An UNDI expansion ROM header */
120 struct undi_rom_header {
123 * Must be equal to @c ROM_SIGNATURE
126 /** ROM length in 512-byte blocks */
129 UINT8_t unused[0x13];
130 /** Offset of the PXE ROM ID structure */
132 /** Offset of the PCI ROM structure */
134 } __attribute__ (( packed ));
136 /** Signature for an expansion ROM */
137 #define ROM_SIGNATURE 0xaa55
139 /** An UNDI ROM ID structure */
143 * Must be equal to @c UNDI_ROM_ID_SIGNATURE
146 /** Length of structure */
147 UINT8_t StructLength;
150 /** Structure revision
157 * Version 2.1.0 is encoded as the byte sequence 0x00, 0x01, 0x02.
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 ));
170 /** Signature for an UNDI ROM ID structure */
171 #define UNDI_ROM_ID_SIGNATURE \
172 ( ( 'U' << 0 ) + ( 'N' << 8 ) + ( 'D' << 16 ) + ( 'I' << 24 ) )
174 /** A PCI expansion header */
178 * Must be equal to @c PCIR_SIGNATURE
185 } __attribute__ (( packed ));
187 /** Signature for an UNDI ROM ID structure */
188 #define PCIR_SIGNATURE \
189 ( ( 'P' << 0 ) + ( 'C' << 8 ) + ( 'I' << 16 ) + ( 'R' << 24 ) )
191 extern struct net_device *pxe_netdev;
192 extern const char *pxe_cmdline;
194 extern void pxe_set_netdev ( struct net_device *netdev );
195 extern PXENV_EXIT_t pxenv_tftp_read_file ( struct s_PXENV_TFTP_READ_FILE
197 extern PXENV_EXIT_t undi_loader ( struct s_UNDI_LOADER *undi_loader );