Forgot tar.c
[grub2/jjazz.git] / include / grub / i386 / pc / pxe.h
blob4821328963d5fd12bce96cdda5d9642ed2b4bf06
1 /*
2 * GRUB -- GRand Unified Bootloader
3 * Copyright (C) 2008 Free Software Foundation, Inc.
5 * GRUB is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * GRUB is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
19 #ifndef GRUB_CPU_PXE_H
20 #define GRUB_CPU_PXE_H
22 #include <grub/types.h>
24 #define GRUB_PXENV_TFTP_OPEN 0x0020
25 #define GRUB_PXENV_TFTP_CLOSE 0x0021
26 #define GRUB_PXENV_TFTP_READ 0x0022
27 #define GRUB_PXENV_TFTP_READ_FILE 0x0023
28 #define GRUB_PXENV_TFTP_READ_FILE_PMODE 0x0024
29 #define GRUB_PXENV_TFTP_GET_FSIZE 0x0025
31 #define GRUB_PXENV_UDP_OPEN 0x0030
32 #define GRUB_PXENV_UDP_CLOSE 0x0031
33 #define GRUB_PXENV_UDP_READ 0x0032
34 #define GRUB_PXENV_UDP_WRITE 0x0033
36 #define GRUB_PXENV_START_UNDI 0x0000
37 #define GRUB_PXENV_UNDI_STARTUP 0x0001
38 #define GRUB_PXENV_UNDI_CLEANUP 0x0002
39 #define GRUB_PXENV_UNDI_INITIALIZE 0x0003
40 #define GRUB_PXENV_UNDI_RESET_NIC 0x0004
41 #define GRUB_PXENV_UNDI_SHUTDOWN 0x0005
42 #define GRUB_PXENV_UNDI_OPEN 0x0006
43 #define GRUB_PXENV_UNDI_CLOSE 0x0007
44 #define GRUB_PXENV_UNDI_TRANSMIT 0x0008
45 #define GRUB_PXENV_UNDI_SET_MCAST_ADDR 0x0009
46 #define GRUB_PXENV_UNDI_SET_STATION_ADDR 0x000A
47 #define GRUB_PXENV_UNDI_SET_PACKET_FILTER 0x000B
48 #define GRUB_PXENV_UNDI_GET_INFORMATION 0x000C
49 #define GRUB_PXENV_UNDI_GET_STATISTICS 0x000D
50 #define GRUB_PXENV_UNDI_CLEAR_STATISTICS 0x000E
51 #define GRUB_PXENV_UNDI_INITIATE_DIAGS 0x000F
52 #define GRUB_PXENV_UNDI_FORCE_INTERRUPT 0x0010
53 #define GRUB_PXENV_UNDI_GET_MCAST_ADDR 0x0011
54 #define GRUB_PXENV_UNDI_GET_NIC_TYPE 0x0012
55 #define GRUB_PXENV_UNDI_GET_IFACE_INFO 0x0013
56 #define GRUB_PXENV_UNDI_ISR 0x0014
57 #define GRUB_PXENV_STOP_UNDI 0x0015
58 #define GRUB_PXENV_UNDI_GET_STATE 0x0015
60 #define GRUB_PXENV_UNLOAD_STACK 0x0070
61 #define GRUB_PXENV_GET_CACHED_INFO 0x0071
62 #define GRUB_PXENV_RESTART_DHCP 0x0072
63 #define GRUB_PXENV_RESTART_TFTP 0x0073
64 #define GRUB_PXENV_MODE_SWITCH 0x0074
65 #define GRUB_PXENV_START_BASE 0x0075
66 #define GRUB_PXENV_STOP_BASE 0x0076
68 #define GRUB_PXENV_EXIT_SUCCESS 0x0000
69 #define GRUB_PXENV_EXIT_FAILURE 0x0001
71 #define GRUB_PXENV_STATUS_SUCCESS 0x00
72 #define GRUB_PXENV_STATUS_FAILURE 0x01
73 #define GRUB_PXENV_STATUS_BAD_FUNC 0x02
74 #define GRUB_PXENV_STATUS_UNSUPPORTED 0x03
75 #define GRUB_PXENV_STATUS_KEEP_UNDI 0x04
76 #define GRUB_PXENV_STATUS_KEEP_ALL 0x05
77 #define GRUB_PXENV_STATUS_OUT_OF_RESOURCES 0x06
78 #define GRUB_PXENV_STATUS_ARP_TIMEOUT 0x11
79 #define GRUB_PXENV_STATUS_UDP_CLOSED 0x18
80 #define GRUB_PXENV_STATUS_UDP_OPEN 0x19
81 #define GRUB_PXENV_STATUS_TFTP_CLOSED 0x1A
82 #define GRUB_PXENV_STATUS_TFTP_OPEN 0x1B
83 #define GRUB_PXENV_STATUS_MCOPY_PROBLEM 0x20
84 #define GRUB_PXENV_STATUS_BIS_INTEGRITY_FAILURE 0x21
85 #define GRUB_PXENV_STATUS_BIS_VALIDATE_FAILURE 0x22
86 #define GRUB_PXENV_STATUS_BIS_INIT_FAILURE 0x23
87 #define GRUB_PXENV_STATUS_BIS_SHUTDOWN_FAILURE 0x24
88 #define GRUB_PXENV_STATUS_BIS_GBOA_FAILURE 0x25
89 #define GRUB_PXENV_STATUS_BIS_FREE_FAILURE 0x26
90 #define GRUB_PXENV_STATUS_BIS_GSI_FAILURE 0x27
91 #define GRUB_PXENV_STATUS_BIS_BAD_CKSUM 0x28
92 #define GRUB_PXENV_STATUS_TFTP_CANNOT_ARP_ADDRESS 0x30
93 #define GRUB_PXENV_STATUS_TFTP_OPEN_TIMEOUT 0x32
95 #define GRUB_PXENV_STATUS_TFTP_UNKNOWN_OPCODE 0x33
96 #define GRUB_PXENV_STATUS_TFTP_READ_TIMEOUT 0x35
97 #define GRUB_PXENV_STATUS_TFTP_ERROR_OPCODE 0x36
98 #define GRUB_PXENV_STATUS_TFTP_CANNOT_OPEN_CONNECTION 0x38
99 #define GRUB_PXENV_STATUS_TFTP_CANNOT_READ_FROM_CONNECTION 0x39
100 #define GRUB_PXENV_STATUS_TFTP_TOO_MANY_PACKAGES 0x3A
101 #define GRUB_PXENV_STATUS_TFTP_FILE_NOT_FOUND 0x3B
102 #define GRUB_PXENV_STATUS_TFTP_ACCESS_VIOLATION 0x3C
103 #define GRUB_PXENV_STATUS_TFTP_NO_MCAST_ADDRESS 0x3D
104 #define GRUB_PXENV_STATUS_TFTP_NO_FILESIZE 0x3E
105 #define GRUB_PXENV_STATUS_TFTP_INVALID_PACKET_SIZE 0x3F
106 #define GRUB_PXENV_STATUS_DHCP_TIMEOUT 0x51
107 #define GRUB_PXENV_STATUS_DHCP_NO_IP_ADDRESS 0x52
108 #define GRUB_PXENV_STATUS_DHCP_NO_BOOTFILE_NAME 0x53
109 #define GRUB_PXENV_STATUS_DHCP_BAD_IP_ADDRESS 0x54
110 #define GRUB_PXENV_STATUS_UNDI_INVALID_FUNCTION 0x60
111 #define GRUB_PXENV_STATUS_UNDI_MEDIATEST_FAILED 0x61
112 #define GRUB_PXENV_STATUS_UNDI_CANNOT_INIT_NIC_FOR_MCAST 0x62
113 #define GRUB_PXENV_STATUS_UNDI_CANNOT_INITIALIZE_NIC 0x63
114 #define GRUB_PXENV_STATUS_UNDI_CANNOT_INITIALIZE_PHY 0x64
115 #define GRUB_PXENV_STATUS_UNDI_CANNOT_READ_CONFIG_DATA 0x65
116 #define GRUB_PXENV_STATUS_UNDI_CANNOT_READ_INIT_DATA 0x66
117 #define GRUB_PXENV_STATUS_UNDI_BAD_MAC_ADDRESS 0x67
118 #define GRUB_PXENV_STATUS_UNDI_BAD_EEPROM_CHECKSUM 0x68
119 #define GRUB_PXENV_STATUS_UNDI_ERROR_SETTING_ISR 0x69
120 #define GRUB_PXENV_STATUS_UNDI_INVALID_STATE 0x6A
121 #define GRUB_PXENV_STATUS_UNDI_TRANSMIT_ERROR 0x6B
122 #define GRUB_PXENV_STATUS_UNDI_INVALID_PARAMETER 0x6C
123 #define GRUB_PXENV_STATUS_BSTRAP_PROMPT_MENU 0x74
124 #define GRUB_PXENV_STATUS_BSTRAP_MCAST_ADDR 0x76
125 #define GRUB_PXENV_STATUS_BSTRAP_MISSING_LIST 0x77
126 #define GRUB_PXENV_STATUS_BSTRAP_NO_RESPONSE 0x78
127 #define GRUB_PXENV_STATUS_BSTRAP_FILE_TOO_BIG 0x79
128 #define GRUB_PXENV_STATUS_BINL_CANCELED_BY_KEYSTROKE 0xA0
129 #define GRUB_PXENV_STATUS_BINL_NO_PXE_SERVER 0xA1
130 #define GRUB_PXENV_STATUS_NOT_AVAILABLE_IN_PMODE 0xA2
131 #define GRUB_PXENV_STATUS_NOT_AVAILABLE_IN_RMODE 0xA3
132 #define GRUB_PXENV_STATUS_BUSD_DEVICE_NOT_SUPPORTED 0xB0
133 #define GRUB_PXENV_STATUS_LOADER_NO_FREE_BASE_MEMORY 0xC0
134 #define GRUB_PXENV_STATUS_LOADER_NO_BC_ROMID 0xC1
135 #define GRUB_PXENV_STATUS_LOADER_BAD_BC_ROMID 0xC2
136 #define GRUB_PXENV_STATUS_LOADER_BAD_BC_RUNTIME_IMAGE 0xC3
137 #define GRUB_PXENV_STATUS_LOADER_NO_UNDI_ROMID 0xC4
138 #define GRUB_PXENV_STATUS_LOADER_BAD_UNDI_ROMID 0xC5
139 #define GRUB_PXENV_STATUS_LOADER_BAD_UNDI_DRIVER_IMAGE 0xC6
140 #define GRUB_PXENV_STATUS_LOADER_NO_PXE_STRUCT 0xC8
141 #define GRUB_PXENV_STATUS_LOADER_NO_PXENV_STRUCT 0xC9
142 #define GRUB_PXENV_STATUS_LOADER_UNDI_START 0xCA
143 #define GRUB_PXENV_STATUS_LOADER_BC_START 0xCB
145 #define GRUB_PXENV_PACKET_TYPE_DHCP_DISCOVER 1
146 #define GRUB_PXENV_PACKET_TYPE_DHCP_ACK 2
147 #define GRUB_PXENV_PACKET_TYPE_CACHED_REPLY 3
149 #define GRUB_PXE_BOOTP_REQ 1
150 #define GRUB_PXE_BOOTP_REP 2
152 #define GRUB_PXE_BOOTP_BCAST 0x8000
154 #if 1
155 #define GRUB_PXE_BOOTP_DHCPVEND 1024 /* DHCP extended vendor field size. */
156 #else
157 #define GRUB_PXE_BOOTP_DHCPVEND 312 /* DHCP standard vendor field size. */
158 #endif
160 #define GRUB_PXE_MIN_BLKSIZE 512
161 #define GRUB_PXE_MAX_BLKSIZE 1432
163 #define GRUB_PXE_TFTP_PORT 69
165 #define GRUB_PXE_VM_RFC1048 0x63825363L
167 #define GRUB_PXE_ERR_LEN 0xFFFFFFFF
169 #ifndef ASM_FILE
171 struct grub_pxenv
173 grub_uint8_t signature[6]; /* 'PXENV+'. */
174 grub_uint16_t version; /* MSB = major, LSB = minor. */
175 grub_uint8_t length; /* structure length. */
176 grub_uint8_t checksum; /* checksum pad. */
177 grub_uint32_t rm_entry; /* SEG:OFF to PXE entry point. */
178 grub_uint32_t pm_offset; /* Protected mode entry. */
179 grub_uint16_t pm_selector; /* Protected mode selector. */
180 grub_uint16_t stack_seg; /* Stack segment address. */
181 grub_uint16_t stack_size; /* Stack segment size (bytes). */
182 grub_uint16_t bc_code_seg; /* BC Code segment address. */
183 grub_uint16_t bc_code_size; /* BC Code segment size (bytes). */
184 grub_uint16_t bc_data_seg; /* BC Data segment address. */
185 grub_uint16_t bc_data_size; /* BC Data segment size (bytes). */
186 grub_uint16_t undi_data_seg; /* UNDI Data segment address. */
187 grub_uint16_t undi_data_size; /* UNDI Data segment size (bytes). */
188 grub_uint16_t undi_code_seg; /* UNDI Code segment address. */
189 grub_uint16_t undi_code_size; /* UNDI Code segment size (bytes). */
190 grub_uint32_t pxe_ptr; /* SEG:OFF to !PXE struct. */
191 } __attribute__ ((packed));
193 struct grub_pxenv_get_cached_info
195 grub_uint16_t status;
196 grub_uint16_t packet_type;
197 grub_uint16_t buffer_size;
198 grub_uint32_t buffer;
199 grub_uint16_t buffer_limit;
200 } __attribute__ ((packed));
202 #define GRUB_PXE_MAC_ADDR_LEN 16
204 typedef grub_uint8_t grub_pxe_mac_addr[GRUB_PXE_MAC_ADDR_LEN];
206 struct grub_pxenv_boot_player
208 grub_uint8_t opcode;
209 grub_uint8_t hw_type; /* hardware type. */
210 grub_uint8_t hw_len; /* hardware addr len. */
211 grub_uint8_t gate_hops; /* zero it. */
212 grub_uint32_t ident; /* random number chosen by client. */
213 grub_uint16_t seconds; /* seconds since did initial bootstrap. */
214 grub_uint16_t flags;
215 grub_uint32_t client_ip;
216 grub_uint32_t your_ip;
217 grub_uint32_t server_ip;
218 grub_uint32_t gateway_ip;
219 grub_pxe_mac_addr mac_addr;
220 grub_uint8_t server_name[64];
221 grub_uint8_t boot_file[128];
222 union
224 grub_uint8_t d[GRUB_PXE_BOOTP_DHCPVEND]; /* raw array of vendor/dhcp options. */
225 struct
227 grub_uint32_t magic; /* DHCP magic cookie. */
228 grub_uint32_t flags; /* bootp flags/opcodes. */
229 grub_uint8_t padding[56];
230 } v;
231 } vendor;
232 } __attribute__ ((packed));
234 struct grub_pxenv_tftp_open
236 grub_uint16_t status;
237 grub_uint32_t server_ip;
238 grub_uint32_t gateway_ip;
239 grub_uint8_t filename[128];
240 grub_uint16_t tftp_port;
241 grub_uint16_t packet_size;
242 } __attribute__ ((packed));
244 struct grub_pxenv_tftp_close
246 grub_uint16_t status;
247 } __attribute__ ((packed));
249 struct grub_pxenv_tftp_read
251 grub_uint16_t status;
252 grub_uint16_t packet_number;
253 grub_uint16_t buffer_size;
254 grub_uint32_t buffer;
255 } __attribute__ ((packed));
257 struct grub_pxenv_tftp_get_fsize
259 grub_uint16_t status;
260 grub_uint32_t server_ip;
261 grub_uint32_t gateway_ip;
262 grub_uint8_t filename[128];
263 grub_uint32_t file_size;
264 } __attribute__ ((packed));
266 struct grub_pxenv_udp_open
268 grub_uint16_t status;
269 grub_uint32_t src_ip;
270 } __attribute__ ((packed));
272 struct grub_pxenv_udp_close
274 grub_uint16_t status;
275 } __attribute__ ((packed));
277 struct grub_pxenv_udp_write
279 grub_uint16_t status;
280 grub_uint32_t ip;
281 grub_uint32_t gateway;
282 grub_uint16_t src_port;
283 grub_uint16_t dst_port;
284 grub_uint16_t buffer_size;
285 grub_uint32_t buffer;
286 } __attribute__ ((packed));
288 struct grub_pxenv_udp_read
290 grub_uint16_t status;
291 grub_uint32_t src_ip;
292 grub_uint32_t dst_ip;
293 grub_uint16_t src_port;
294 grub_uint16_t dst_port;
295 grub_uint16_t buffer_size;
296 grub_uint32_t buffer;
297 } __attribute__ ((packed));
299 struct grub_pxenv_unload_stack
301 grub_uint16_t status;
302 grub_uint8_t reserved[10];
303 } __attribute__ ((packed));
305 struct grub_pxenv * EXPORT_FUNC(grub_pxe_scan) (void);
306 int EXPORT_FUNC(grub_pxe_call) (int func, void * data);
308 extern struct grub_pxenv *grub_pxe_pxenv;
309 extern grub_uint32_t grub_pxe_your_ip;
310 extern grub_uint32_t grub_pxe_server_ip;
311 extern grub_uint32_t grub_pxe_gateway_ip;
312 extern int grub_pxe_blksize;
314 void grub_pxe_unload (void);
316 #endif
318 #endif /* GRUB_CPU_PXE_H */