Add qemu 2.4.0
[kvmfornfv.git] / qemu / roms / ipxe / src / arch / i386 / include / pxe.h
1 #ifndef PXE_H
2 #define PXE_H
3
4 FILE_LICENCE ( GPL2_OR_LATER );
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() */
16 struct s_PXENV_UNKNOWN {
17         PXENV_STATUS_t Status;                  /**< PXE status code */
18 } __attribute__ (( packed ));
19
20 typedef struct s_PXENV_UNKNOWN PXENV_UNKNOWN_t;
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 */
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;
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 */
89         uint16_t params_len;
90         /** Opcode */
91         uint16_t 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 */
120 struct undi_rom_header {
121         /** Signature
122          *
123          * Must be equal to @c ROM_SIGNATURE
124          */
125         UINT16_t Signature;
126         /** ROM length in 512-byte blocks */
127         UINT8_t ROMLength;
128         /** Unused */
129         UINT8_t unused[0x13];
130         /** Offset of the PXE ROM ID structure */
131         UINT16_t PXEROMID;
132         /** Offset of the PCI ROM structure */
133         UINT16_t PCIRHeader;
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          */
145         UINT32_t Signature;
146         /** Length of structure */
147         UINT8_t StructLength;
148         /** Checksum */
149         UINT8_t StructCksum;
150         /** Structure revision
151          *
152          * Must be zero.
153          */
154         UINT8_t StructRev;
155         /** UNDI revision
156          *
157          * Version 2.1.0 is encoded as the byte sequence 0x00, 0x01, 0x02.
158          */
159         UINT8_t UNDIRev[3];
160         /** Offset to UNDI loader */
161         UINT16_t UNDILoader;
162         /** Minimum required stack segment size */
163         UINT16_t StackSize;
164         /** Minimum required data segment size */
165         UINT16_t DataSize;
166         /** Minimum required code segment size */
167         UINT16_t CodeSize;
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          */
180         uint32_t signature;
181         /** PCI vendor ID */
182         uint16_t vendor_id;
183         /** PCI device ID */
184         uint16_t 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 PXENV_EXIT_t pxenv_tftp_read_file ( struct s_PXENV_TFTP_READ_FILE
196                                            *tftp_read_file );
197 extern PXENV_EXIT_t undi_loader ( struct s_UNDI_LOADER *undi_loader );
198
199 #endif /* PXE_H */