1 /* ----------------------------------------------------------------------- *
3 * Copyright 2007-2008 H. Peter Anvin - All Rights Reserved
5 * Permission is hereby granted, free of charge, to any person
6 * obtaining a copy of this software and associated documentation
7 * files (the "Software"), to deal in the Software without
8 * restriction, including without limitation the rights to use,
9 * copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom
11 * the Software is furnished to do so, subject to the following
14 * The above copyright notice and this permission notice shall
15 * be included in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 * OTHER DEALINGS IN THE SOFTWARE.
26 * ----------------------------------------------------------------------- */
31 * PXE definitions and function prototypes for SYSLINUX
34 #ifndef _SYSLINUX_PXE_H
35 #define _SYSLINUX_PXE_H
38 #include <netinet/in.h>
39 #include <klibc/compiler.h>
42 /* PXE spec structures and definitions. These mostly follow the PXE
43 spec, except when the PXE spec is unnecessarily stupid. Of course,
44 that is most of the time. */
46 /* Basic types; use Unix-like _t convention instead of SCREAMING; also
47 re-use types we already have, like in_addr_t. */
49 typedef uint16_t pxenv_status_t
;
51 #define MAC_ADDR_LEN 16
52 typedef uint8_t mac_addr_t
[MAC_ADDR_LEN
];
54 /* "Protected mode segment descriptor" according to PXE... */
59 } __packed pxe_segdesc_t
;
61 typedef far_ptr_t segoff16_t
;
73 #define BOOTP_BCAST 0x8000
74 in_addr_t cip
; /* Client IP address */
75 in_addr_t yip
; /* You IP address */
76 in_addr_t sip
; /* next server IP address */
77 in_addr_t gip
; /*relay agent IP address */
80 uint8_t bootfile
[128];
82 #define BOOTP_DHCPVEND 1024
83 uint8_t d
[BOOTP_DHCPVEND
];
86 #define VM_RFC1048 0x63825363L
91 } __packed pxe_bootp_t
;
93 /* Function calling structures and constants */
95 typedef struct s_PXENV_GET_CACHED_INFO
{
96 pxenv_status_t Status
;
98 #define PXENV_PACKET_TYPE_DHCP_DISCOVER 1
99 #define PXENV_PACKET_TYPE_DHCP_ACK 2
100 #define PXENV_PACKET_TYPE_CACHED_REPLY 3
103 uint16_t BufferLimit
;
104 } __packed t_PXENV_GET_CACHED_INFO
;
106 typedef struct s_PXENV_START_UNDI
{
107 pxenv_status_t Status
;
113 } __packed t_PXENV_START_UNDI
;
115 typedef struct s_PXENV_STOP_UNDI
{
116 pxenv_status_t Status
;
117 } __packed t_PXENV_STOP_UNDI
;
119 typedef struct s_PXENV_START_BASE
{
120 pxenv_status_t Status
;
121 } __packed t_PXENV_START_BASE
;
123 typedef struct s_PXENV_STOP_BASE
{
124 pxenv_status_t Status
;
125 } __packed t_PXENV_STOP_BASE
;
127 typedef struct s_PXENV_TFTP_OPEN
{
128 pxenv_status_t Status
;
129 in_addr_t ServerIPAddress
;
130 in_addr_t GatewayIPAddress
;
131 uint8_t FileName
[128];
134 } __packed t_PXENV_TFTP_OPEN
;
136 typedef struct s_PXENV_TFTP_CLOSE
{
137 pxenv_status_t Status
;
138 } __packed t_PXENV_TFTP_CLOSE
;
140 typedef struct s_PXENV_TFTP_READ
{
141 pxenv_status_t Status
;
142 uint16_t PacketNumber
;
145 } __packed t_PXENV_TFTP_READ
;
147 typedef struct s_PXENV_TFTP_READ_FILE
{
148 pxenv_status_t Status
;
149 uint8_t FileName
[128];
152 in_addr_t ServerIPAddress
;
153 in_addr_t GatewayIPAddress
;
154 in_addr_t McastIPAddress
;
155 in_port_t TFTPClntPort
;
156 in_port_t TFTPSrvPort
;
157 uint16_t TFTPOpenTimeOut
;
158 uint16_t TFTPReopenDelay
;
159 } __packed t_PXENV_TFTP_READ_FILE
;
161 typedef struct s_PXENV_TFTP_GET_FSIZE
{
162 pxenv_status_t Status
;
163 in_addr_t ServerIPAddress
;
164 in_addr_t GatewayIPAddress
;
165 uint8_t FileName
[128];
167 } __packed t_PXENV_TFTP_GET_FSIZE
;
169 typedef struct s_PXENV_UDP_OPEN
{
170 pxenv_status_t status
;
172 } __packed t_PXENV_UDP_OPEN
;
174 typedef struct s_PXENV_UDP_CLOSE
{
175 pxenv_status_t status
;
176 } __packed t_PXENV_UDP_CLOSE
;
178 typedef struct s_PXENV_UDP_WRITE
{
179 pxenv_status_t status
;
184 uint16_t buffer_size
;
186 } __packed t_PXENV_UDP_WRITE
;
188 typedef struct s_PXENV_UDP_READ
{
189 pxenv_status_t status
;
194 uint16_t buffer_size
;
196 } __packed t_PXENV_UDP_READ
;
198 typedef struct s_PXENV_UNDI_STARTUP
{
199 pxenv_status_t Status
;
200 } __packed t_PXENV_UNDI_STARTUP
;
202 typedef struct s_PXENV_UNDI_CLEANUP
{
203 pxenv_status_t Status
;
204 } __packed t_PXENV_UNDI_CLEANUP
;
206 typedef struct s_PXENV_UNDI_INITIALIZE
{
207 pxenv_status_t Status
;
210 } __packed t_PXENV_UNDI_INITIALIZE
;
212 #define MAXNUM_MCADDR 8
213 typedef struct s_PXENV_UNDI_MCAST_ADDRESS
{
214 uint16_t MCastAddrCount
;
215 mac_addr_t McastAddr
[MAXNUM_MCADDR
];
216 } __packed t_PXENV_UNDI_MCAST_ADDRESS
;
218 typedef struct s_PXENV_UNDI_RESET
{
219 pxenv_status_t Status
;
220 t_PXENV_UNDI_MCAST_ADDRESS R_Mcast_Buf
;
221 } __packed t_PXENV_UNDI_RESET
;
223 typedef struct s_PXENV_UNDI_SHUTDOWN
{
224 pxenv_status_t Status
;
225 } __packed t_PXENV_UNDI_SHUTDOWN
;
227 typedef struct s_PXENV_UNDI_OPEN
{
228 pxenv_status_t Status
;
231 #define FLTR_DIRECTED 0x0001
232 #define FLTR_BRDCST 0x0002
233 #define FLTR_PRMSCS 0x0004
234 #define FLTR_SRC_RTG 0x0008
235 t_PXENV_UNDI_MCAST_ADDRESS R_Mcast_Buf
;
236 } __packed t_PXENV_UNDI_OPEN
;
238 typedef struct s_PXENV_UNDI_CLOSE
{
239 pxenv_status_t Status
;
240 } __packed t_PXENV_UNDI_CLOSE
;
242 typedef struct s_PXENV_UNDI_TRANSMIT
{
243 pxenv_status_t Status
;
250 #define XMT_DESTADDR 0x0000
251 #define XMT_BROADCAST 0x0001
254 uint32_t Reserved
[2];
255 } __packed t_PXENV_UNDI_TRANSMIT
;
256 #define MAX_DATA_BLKS 8
257 typedef struct s_PXENV_UNDI_TBD
{
258 uint16_t ImmedLength
;
260 uint16_t DataBlkCount
;
265 segoff16_t TDDataPtr
;
266 } DataBlock
[MAX_DATA_BLKS
];
267 } __packed t_PXENV_UNDI_TBD
;
269 typedef struct s_PXENV_UNDI_SET_MCAST_ADDRESS
{
270 pxenv_status_t Status
;
271 t_PXENV_UNDI_MCAST_ADDRESS R_Mcast_Buf
;
272 } __packed t_PXENV_UNDI_SET_MCAST_ADDR
;
274 typedef struct s_PXENV_UNDI_SET_STATION_ADDRESS
{
275 pxenv_status_t Status
;
276 mac_addr_t StationAddress
;
277 } __packed t_PXENV_UNDI_SET_STATION_ADDR
;
279 typedef struct s_PXENV_UNDI_SET_PACKET_FILTER
{
280 pxenv_status_t Status
;
282 } __packed t_PXENV_UNDI_SET_PACKET_FILTER
;
284 typedef struct s_PXENV_UNDI_GET_INFORMATION
{
285 pxenv_status_t Status
;
288 uint16_t MaxTranUnit
;
291 #define EXP_ETHER_TYPE 2
293 #define ARCNET_TYPE 7
295 mac_addr_t CurrentNodeAddress
;
296 mac_addr_t PermNodeAddress
;
300 } __packed t_PXENV_UNDI_GET_INFORMATION
;
302 typedef struct s_PXENV_UNDI_GET_STATISTICS
{
303 pxenv_status_t Status
;
304 uint32_t XmtGoodFrames
;
305 uint32_t RcvGoodFrames
;
306 uint32_t RcvCRCErrors
;
307 uint32_t RcvResourceErrors
;
308 } __packed t_PXENV_UNDI_GET_STATISTICS
;
310 typedef struct s_PXENV_UNDI_CLEAR_STATISTICS
{
311 pxenv_status_t Status
;
312 } __packed t_PXENV_UNDI_CLEAR_STATISTICS
;
314 typedef struct s_PXENV_UNDI_INITIATE_DIAGS
{
315 pxenv_status_t Status
;
316 } __packed t_PXENV_UNDI_INITIATE_DIAGS
;
318 typedef struct s_PXENV_UNDI_FORCE_INTERRUPT
{
319 pxenv_status_t Status
;
320 } __packed t_PXENV_UNDI_FORCE_INTERRUPT
;
322 typedef struct s_PXENV_UNDI_GET_MCAST_ADDRESS
{
323 pxenv_status_t Status
;
325 mac_addr_t MediaAddr
;
326 } __packed t_PXENV_UNDI_GET_MCAST_ADDR
;
328 typedef struct s_PXENV_UNDI_GET_NIC_TYPE
{
329 pxenv_status_t Status
;
333 #define CardBus_NIC 4
343 uint16_t SubVendor_ID
;
344 uint16_t SubDevice_ID
;
347 uint32_t EISA_Dev_ID
;
354 } __packed t_PXENV_UNDI_GET_NIC_TYPE
;
356 typedef struct s_PXENV_UNDI_GET_IFACE_INFO
{
357 pxenv_status_t Status
;
358 uint8_t IfaceType
[16];
360 uint32_t ServiceFlags
;
361 uint32_t Reserved
[4];
362 } __packed t_PXENV_UNDI_GET_NDIS_INFO
;
364 typedef struct s_PXENV_UNDI_GET_STATE
{
365 #define PXE_UNDI_GET_STATE_STARTED 1
366 #define PXE_UNDI_GET_STATE_INITIALIZED 2
367 #define PXE_UNDI_GET_STATE_OPENED 3
368 pxenv_status_t Status
;
370 } __packed t_PXENV_UNDI_GET_STATE
;
372 typedef struct s_PXENV_UNDI_ISR
{
373 pxenv_status_t Status
;
375 uint16_t BufferLength
;
376 uint16_t FrameLength
;
377 uint16_t FrameHeaderLength
;
381 } __packed t_PXENV_UNDI_ISR
;
382 #define PXENV_UNDI_ISR_IN_START 1
383 #define PXENV_UNDI_ISR_IN_PROCESS 2
384 #define PXENV_UNDI_ISR_IN_GET_NEXT 3
385 /* One of these will be returned for
386 PXENV_UNDI_ISR_IN_START */
387 #define PXENV_UNDI_ISR_OUT_OURS 0
388 #define PXENV_UNDI_USR_OUT_NOT_OURS 1
389 /* One of these will be returned for
390 PXENV_UNDI_ISR_IN_PROCESS and
391 PXENV_UNDI_ISR_IN_GET_NEXT */
392 #define PXENV_UNDI_ISR_OUT_DONE 0
393 #define PXENV_UNDI_ISR_OUT_TRANSMIT 2
394 #define PXENV_UNDI_ISR_OUT_RECEIVE 3
395 #define PXENV_UNDI_ISR_OUT_BUSY 4
397 /* Function numbers and error codes */
399 #define PXENV_TFTP_OPEN 0x0020
400 #define PXENV_TFTP_CLOSE 0x0021
401 #define PXENV_TFTP_READ 0x0022
402 #define PXENV_TFTP_READ_FILE 0x0023
403 #define PXENV_TFTP_READ_FILE_PMODE 0x0024
404 #define PXENV_TFTP_GET_FSIZE 0x0025
406 #define PXENV_UDP_OPEN 0x0030
407 #define PXENV_UDP_CLOSE 0x0031
408 #define PXENV_UDP_READ 0x0032
409 #define PXENV_UDP_WRITE 0x0033
411 #define PXENV_START_UNDI 0x0000
412 #define PXENV_UNDI_STARTUP 0x0001
413 #define PXENV_UNDI_CLEANUP 0x0002
414 #define PXENV_UNDI_INITIALIZE 0x0003
415 #define PXENV_UNDI_RESET_NIC 0x0004
416 #define PXENV_UNDI_SHUTDOWN 0x0005
417 #define PXENV_UNDI_OPEN 0x0006
418 #define PXENV_UNDI_CLOSE 0x0007
419 #define PXENV_UNDI_TRANSMIT 0x0008
420 #define PXENV_UNDI_SET_MCAST_ADDR 0x0009
421 #define PXENV_UNDI_SET_STATION_ADDR 0x000A
422 #define PXENV_UNDI_SET_PACKET_FILTER 0x000B
423 #define PXENV_UNDI_GET_INFORMATION 0x000C
424 #define PXENV_UNDI_GET_STATISTICS 0x000D
425 #define PXENV_UNDI_CLEAR_STATISTICS 0x000E
426 #define PXENV_UNDI_INITIATE_DIAGS 0x000F
427 #define PXENV_UNDI_FORCE_INTERRUPT 0x0010
428 #define PXENV_UNDI_GET_MCAST_ADDR 0x0011
429 #define PXENV_UNDI_GET_NIC_TYPE 0x0012
430 #define PXENV_UNDI_GET_IFACE_INFO 0x0013
431 #define PXENV_UNDI_ISR 0x0014
432 #define PXENV_STOP_UNDI 0x0015 /* Overlap...? */
433 #define PXENV_UNDI_GET_STATE 0x0015 /* Overlap...? */
435 #define PXENV_UNLOAD_STACK 0x0070
436 #define PXENV_GET_CACHED_INFO 0x0071
437 #define PXENV_RESTART_DHCP 0x0072
438 #define PXENV_RESTART_TFTP 0x0073
439 #define PXENV_MODE_SWITCH 0x0074
440 #define PXENV_START_BASE 0x0075
441 #define PXENV_STOP_BASE 0x0076
443 #define PXENV_EXIT_SUCCESS 0x0000
444 #define PXENV_EXIT_FAILURE 0x0001
446 #define PXENV_STATUS_SUCCESS 0x00
447 #define PXENV_STATUS_FAILURE 0x01
448 #define PXENV_STATUS_BAD_FUNC 0x02
449 #define PXENV_STATUS_UNSUPPORTED 0x03
450 #define PXENV_STATUS_KEEP_UNDI 0x04
451 #define PXENV_STATUS_KEEP_ALL 0x05
452 #define PXENV_STATUS_OUT_OF_RESOURCES 0x06
453 #define PXENV_STATUS_ARP_TIMEOUT 0x11
454 #define PXENV_STATUS_UDP_CLOSED 0x18
455 #define PXENV_STATUS_UDP_OPEN 0x19
456 #define PXENV_STATUS_TFTP_CLOSED 0x1A
457 #define PXENV_STATUS_TFTP_OPEN 0x1B
458 #define PXENV_STATUS_MCOPY_PROBLEM 0x20
459 #define PXENV_STATUS_BIS_INTEGRITY_FAILURE 0x21
460 #define PXENV_STATUS_BIS_VALIDATE_FAILURE 0x22
461 #define PXENV_STATUS_BIS_INIT_FAILURE 0x23
462 #define PXENV_STATUS_BIS_SHUTDOWN_FAILURE 0x24
463 #define PXENV_STATUS_BIS_GBOA_FAILURE 0x25
464 #define PXENV_STATUS_BIS_FREE_FAILURE 0x26
465 #define PXENV_STATUS_BIS_GSI_FAILURE 0x27
466 #define PXENV_STATUS_BIS_BAD_CKSUM 0x28
467 #define PXENV_STATUS_TFTP_CANNOT_ARP_ADDRESS 0x30
468 #define PXENV_STATUS_TFTP_OPEN_TIMEOUT 0x32
470 #define PXENV_STATUS_TFTP_UNKNOWN_OPCODE 0x33
471 #define PXENV_STATUS_TFTP_READ_TIMEOUT 0x35
472 #define PXENV_STATUS_TFTP_ERROR_OPCODE 0x36
473 #define PXENV_STATUS_TFTP_CANNOT_OPEN_CONNECTION 0x38
474 #define PXENV_STATUS_TFTP_CANNOT_READ_FROM_CONNECTION 0x39
475 #define PXENV_STATUS_TFTP_TOO_MANY_PACKAGES 0x3A
476 #define PXENV_STATUS_TFTP_FILE_NOT_FOUND 0x3B
477 #define PXENV_STATUS_TFTP_ACCESS_VIOLATION 0x3C
478 #define PXENV_STATUS_TFTP_NO_MCAST_ADDRESS 0x3D
479 #define PXENV_STATUS_TFTP_NO_FILESIZE 0x3E
480 #define PXENV_STATUS_TFTP_INVALID_PACKET_SIZE 0x3F
481 #define PXENV_STATUS_DHCP_TIMEOUT 0x51
482 #define PXENV_STATUS_DHCP_NO_IP_ADDRESS 0x52
483 #define PXENV_STATUS_DHCP_NO_BOOTFILE_NAME 0x53
484 #define PXENV_STATUS_DHCP_BAD_IP_ADDRESS 0x54
485 #define PXENV_STATUS_UNDI_INVALID_FUNCTION 0x60
486 #define PXENV_STATUS_UNDI_MEDIATEST_FAILED 0x61
487 #define PXENV_STATUS_UNDI_CANNOT_INIT_NIC_FOR_MCAST 0x62
488 #define PXENV_STATUS_UNDI_CANNOT_INITIALIZE_NIC 0x63
489 #define PXENV_STATUS_UNDI_CANNOT_INITIALIZE_PHY 0x64
490 #define PXENV_STATUS_UNDI_CANNOT_READ_CONFIG_DATA 0x65
491 #define PXENV_STATUS_UNDI_CANNOT_READ_INIT_DATA 0x66
492 #define PXENV_STATUS_UNDI_BAD_MAC_ADDRESS 0x67
493 #define PXENV_STATUS_UNDI_BAD_EEPROM_CHECKSUM 0x68
494 #define PXENV_STATUS_UNDI_ERROR_SETTING_ISR 0x69
495 #define PXENV_STATUS_UNDI_INVALID_STATE 0x6A
496 #define PXENV_STATUS_UNDI_TRANSMIT_ERROR 0x6B
497 #define PXENV_STATUS_UNDI_INVALID_PARAMETER 0x6C
498 #define PXENV_STATUS_BSTRAP_PROMPT_MENU 0x74
499 #define PXENV_STATUS_BSTRAP_MCAST_ADDR 0x76
500 #define PXENV_STATUS_BSTRAP_MISSING_LIST 0x77
501 #define PXENV_STATUS_BSTRAP_NO_RESPONSE 0x78
502 #define PXENV_STATUS_BSTRAP_FILE_TOO_BIG 0x79
503 #define PXENV_STATUS_BINL_CANCELED_BY_KEYSTROKE 0xA0
504 #define PXENV_STATUS_BINL_NO_PXE_SERVER 0xA1
505 #define PXENV_STATUS_NOT_AVAILABLE_IN_PMODE 0xA2
506 #define PXENV_STATUS_NOT_AVAILABLE_IN_RMODE 0xA3
507 #define PXENV_STATUS_BUSD_DEVICE_NOT_SUPPORTED 0xB0
508 #define PXENV_STATUS_LOADER_NO_FREE_BASE_MEMORY 0xC0
509 #define PXENV_STATUS_LOADER_NO_BC_ROMID 0xC1
510 #define PXENV_STATUS_LOADER_BAD_BC_ROMID 0xC2
511 #define PXENV_STATUS_LOADER_BAD_BC_RUNTIME_IMAGE 0xC3
512 #define PXENV_STATUS_LOADER_NO_UNDI_ROMID 0xC4
513 #define PXENV_STATUS_LOADER_BAD_UNDI_ROMID 0xC5
514 #define PXENV_STATUS_LOADER_BAD_UNDI_DRIVER_IMAGE 0xC6
515 #define PXENV_STATUS_LOADER_NO_PXE_STRUCT 0xC8
516 #define PXENV_STATUS_LOADER_NO_PXENV_STRUCT 0xC9
517 #define PXENV_STATUS_LOADER_UNDI_START 0xCA
518 #define PXENV_STATUS_LOADER_BC_START 0xCB
520 /* SYSLINUX-defined PXE utility functions */
521 int pxe_get_cached_info(int level
, void **buf
, size_t * len
);
522 int pxe_get_nic_type(t_PXENV_UNDI_GET_NIC_TYPE
* gnt
);
523 uint32_t pxe_dns(const char *hostname
);
525 #endif /* _SYSLINUX_PXE_H */