2 * Copyright (c) 2000 Alfred Perlstein <alfred@freebsd.org>
4 * Copyright (c) 2000 Paul Saab <ps@freebsd.org>
6 * Copyright (c) 2000 John Baldwin <jhb@freebsd.org>
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * $FreeBSD: src/sys/boot/i386/libi386/pxe.h,v 1.6 2002/09/23 18:54:26 alfred Exp $
31 * $DragonFly: src/sys/boot/pc32/libi386/pxe.h,v 1.3 2003/11/10 06:08:36 dillon Exp $
35 * The typedefs and structures declared in this file
36 * clearly violate style(9), the reason for this is to conform to the
37 * typedefs/structure-names used in the Intel literature to avoid confusion.
39 * It's for your own good. :)
42 /* It seems that intel didn't think about ABI,
43 * either that or 16bit ABI != 32bit ABI (which seems reasonable)
44 * I have to thank Intel for the hair loss I incurred trying to figure
45 * out why PXE was mis-reading structures I was passing it (at least
46 * from my point of view)
48 * Solution: use gcc's '__packed' to correctly align
49 * structures passed into PXE
50 * Question: does this really work for PXE's expected ABI?
52 #define PACKED __attribute__((__packed__))
54 #define S_SIZE(s) s, sizeof(s) - 1
56 #define IP_STR "%d.%d.%d.%d"
58 (int)(ip >> 24) & 0xff, (int)(ip >> 16) & 0xff, \
59 (int)(ip >> 8) & 0xff, (int)ip & 0xff
61 #define MAC_STR "%02x:%02x:%02x:%02x:%02x:%02x"
62 #define MAC_ARGS(mac) \
63 mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]
65 #define PXENFSROOTPATH "/pxeroot"
78 typedef uint16_t SEGSEL_t;
79 typedef uint16_t PXENV_STATUS_t;
80 typedef uint32_t IP4_t;
81 typedef uint32_t ADDR32_t;
82 typedef uint16_t UDP_PORT_t;
84 #define MAC_ADDR_LEN 16
85 typedef uint8_t MAC_ADDR[MAC_ADDR_LEN];
89 uint8_t Signature[6]; /* 'PXENV+' */
90 uint16_t Version; /* MSB = major, LSB = minor */
91 uint8_t Length; /* structure length */
92 uint8_t Checksum; /* checksum pad */
93 SEGOFF16_t RMEntry; /* SEG:OFF to PXE entry point */
94 /* don't use PMOffset and PMSelector (from the 2.1 PXE manual) */
95 uint32_t PMOffset; /* Protected mode entry */
96 SEGSEL_t PMSelector; /* Protected mode selector */
97 SEGSEL_t StackSeg; /* Stack segment address */
98 uint16_t StackSize; /* Stack segment size (bytes) */
99 SEGSEL_t BC_CodeSeg; /* BC Code segment address */
100 uint16_t BC_CodeSize; /* BC Code segment size (bytes) */
101 SEGSEL_t BC_DataSeg; /* BC Data segment address */
102 uint16_t BC_DataSize; /* BC Data segment size (bytes) */
103 SEGSEL_t UNDIDataSeg; /* UNDI Data segment address */
104 uint16_t UNDIDataSize; /* UNDI Data segment size (bytes) */
105 SEGSEL_t UNDICodeSeg; /* UNDI Code segment address */
106 uint16_t UNDICodeSize; /* UNDI Code segment size (bytes) */
107 SEGOFF16_t PXEPtr; /* SEG:OFF to !PXE struct,
108 only present when Version > 2.1 */
113 uint8_t Signature[4];
114 uint8_t StructLength;
118 SEGOFF16_t UNDIROMID;
119 SEGOFF16_t BaseROMID;
120 SEGOFF16_t EntryPointSP;
121 SEGOFF16_t EntryPointESP;
122 SEGOFF16_t StatusCallout;
125 SEGSEL_t FirstSelector;
129 SEGDESC_t UNDICodeWrite;
132 SEGDESC_t BC_CodeWrite;
135 #define PXENV_START_UNDI 0x0000
137 PXENV_STATUS_t Status;
143 } PACKED t_PXENV_START_UNDI;
145 #define PXENV_UNDI_STARTUP 0x0001
147 PXENV_STATUS_t Status;
148 } PACKED t_PXENV_UNDI_STARTUP;
150 #define PXENV_UNDI_CLEANUP 0x0002
152 PXENV_STATUS_t Status;
153 } PACKED t_PXENV_UNDI_CLEANUP;
155 #define PXENV_UNDI_INITIALIZE 0x0003
157 PXENV_STATUS_t Status;
158 ADDR32_t ProtocolIni; /* Phys addr of a copy of the driver module */
160 } PACKED t_PXENV_UNDI_INITALIZE;
163 #define MAXNUM_MCADDR 8
165 PXENV_STATUS_t Status;
166 uint16_t MCastAddrCount;
167 MAC_ADDR McastAddr[MAXNUM_MCADDR];
168 } PACKED t_PXENV_UNDI_MCAST_ADDRESS;
170 #define PXENV_UNDI_RESET_ADAPTER 0x0004
172 PXENV_STATUS_t Status;
173 t_PXENV_UNDI_MCAST_ADDRESS R_Mcast_Buf;
174 } PACKED t_PXENV_UNDI_RESET;
176 #define PXENV_UNDI_SHUTDOWN 0x0005
178 PXENV_STATUS_t Status;
179 } PACKED t_PXENV_UNDI_SHUTDOWN;
181 #define PXENV_UNDI_OPEN 0x0006
183 PXENV_STATUS_t Status;
186 # define FLTR_DIRECTED 0x0001
187 # define FLTR_BRDCST 0x0002
188 # define FLTR_PRMSCS 0x0003
189 # define FLTR_SRC_RTG 0x0004
191 t_PXENV_UNDI_MCAST_ADDRESS R_Mcast_Buf;
192 } PACKED t_PXENV_UNDI_OPEN;
194 #define PXENV_UNDI_CLOSE 0x0007
196 PXENV_STATUS_t Status;
197 } PACKED t_PXENV_UNDI_CLOSE;
199 #define PXENV_UNDI_TRANSMIT 0x0008
201 PXENV_STATUS_t Status;
209 # define XMT_DESTADDR 0x0000
210 # define XMT_BROADCAST 0x0001
214 uint32_t Reserved[2];
215 } PACKED t_PXENV_UNDI_TRANSMIT;
217 #define MAX_DATA_BLKS 8
219 uint16_t ImmedLength;
221 uint16_t DataBlkCount;
226 SEGOFF16_t TDDataPtr;
227 } DataBlock[MAX_DATA_BLKS];
228 } PACKED t_PXENV_UNDI_TBD;
230 #define PXENV_UNDI_SET_MCAST_ADDRESS 0x0009
232 PXENV_STATUS_t Status;
233 t_PXENV_UNDI_MCAST_ADDRESS R_Mcast_Buf;
234 } PACKED t_PXENV_UNDI_SET_MCAST_ADDR;
236 #define PXENV_UNDI_SET_STATION_ADDRESS 0x000A
238 PXENV_STATUS_t Status;
239 MAC_ADDR StationAddress; /* Temp MAC addres to use */
240 } PACKED t_PXENV_UNDI_SET_STATION_ADDR;
242 #define PXENV_UNDI_SET_PACKET_FILTER 0x000B
244 PXENV_STATUS_t Status;
245 uint8_t filter; /* see UNDI_OPEN (0x0006) */
246 } PACKED t_PXENV_UNDI_SET_PACKET_FILTER;
248 #define PXENV_UNDI_GET_INFORMATION 0x000C
250 PXENV_STATUS_t Status;
251 uint16_t BaseIo; /* Adapter base I/O address */
252 uint16_t IntNumber; /* Adapter IRQ number */
253 uint16_t MaxTranUnit; /* Adapter maximum transmit unit */
254 uint16_t HwType; /* Type of protocol at the hardware addr */
255 # define ETHER_TYPE 1
256 # define EXP_ETHER_TYPE 2
258 # define ARCNET_TYPE 7
260 uint16_t HwAddrLen; /* Length of hardware address */
261 MAC_ADDR CurrentNodeAddress; /* Current hardware address */
262 MAC_ADDR PermNodeAddress; /* Permanent hardware address */
263 SEGSEL_t ROMAddress; /* Real mode ROM segment address */
264 uint16_t RxBufCt; /* Receive queue length */
265 uint16_t TxBufCt; /* Transmit queue length */
266 } PACKED t_PXENV_UNDI_GET_INFORMATION;
268 #define PXENV_UNDI_GET_STATISTICS 0x000D
270 PXENV_STATUS_t Status;
271 uint32_t XmitGoodFrames; /* Number of successful transmissions */
272 uint32_t RcvGoodFrames; /* Number of good frames received */
273 uint32_t RcvCRCErrors; /* Number of frames with CRC errors */
274 uint32_t RcvResourceErrors; /* Number of frames dropped */
275 } PACKED t_PXENV_UNDI_GET_STATISTICS;
277 #define PXENV_UNDI_CLEAR_STATISTICS 0x000E
279 PXENV_STATUS_t Status;
280 } PACKED t_PXENV_UNDI_CLEAR_STATISTICS;
282 #define PXENV_UNDI_INITIATE_DIAGS 0x000F
284 PXENV_STATUS_t Status;
285 } PACKED t_PXENV_UNDI_INITIATE_DIAGS;
287 #define PXENV_UNDI_FORCE_INTERRUPT 0x0010
289 PXENV_STATUS_t Status;
290 } PACKED t_PXENV_UNDI_FORCE_INTERRUPT;
292 #define PXENV_UNDI_GET_MCAST_ADDRESS 0x0011
294 PXENV_STATUS_t Status;
295 IP4_t InetAddr; /* IP mulicast address */
296 MAC_ADDR MediaAddr; /* MAC multicast address */
297 } PACKED t_PXENV_UNDI_GET_MCAST_ADDR;
299 #define PXENV_UNDI_GET_NIC_TYPE 0x0012
301 PXENV_STATUS_t Status;
302 uint8_t NicType; /* Type of NIC */
305 # define CardBus_NIC 4
316 uint16_t SubVendor_ID;
317 uint16_t SubDevice_ID;
320 uint32_t EISA_Dev_ID;
327 } PACKED t_PXENV_UNDI_GET_NIC_TYPE;
329 #define PXENV_UNDI_GET_IFACE_INFO 0x0013
331 PXENV_STATUS_t Status;
332 uint8_t IfaceType[16]; /* Name of MAC type in ASCII. */
333 uint32_t LinkSpeed; /* Defined in NDIS 2.0 spec */
334 uint32_t ServiceFlags; /* Defined in NDIS 2.0 spec */
335 uint32_t Reserved[4]; /* must be 0 */
336 } PACKED t_PXENV_UNDI_GET_NDIS_INFO;
338 #define PXENV_UNDI_ISR 0x0014
340 PXENV_STATUS_t Status;
341 uint16_t FuncFlag; /* PXENV_UNDI_ISR_OUT_xxx */
342 uint16_t BufferLength; /* Length of Frame */
343 uint16_t FrameLength; /* Total length of reciever frame */
344 uint16_t FrameHeaderLength; /* Length of the media header in Frame */
345 SEGOFF16_t Frame; /* receive buffer */
346 uint8_t ProtType; /* Protocol type */
347 uint8_t PktType; /* Packet Type */
348 # define PXENV_UNDI_ISR_IN_START 1
349 # define PXENV_UNDI_ISR_IN_PROCESS 2
350 # define PXENV_UNDI_ISR_IN_GET_NEXT 3
352 /* one of these will be returned for PXENV_UNDI_ISR_IN_START */
353 # define PXENV_UNDI_ISR_OUT_OURS 0
354 # define PXENV_UNDI_ISR_OUT_NOT_OUTS 1
357 * one of these will bre returnd for PXEND_UNDI_ISR_IN_PROCESS
358 * and PXENV_UNDI_ISR_IN_GET_NEXT
360 # define PXENV_UNDI_ISR_OUT_DONE 0
361 # define PXENV_UNDI_ISR_OUT_TRANSMIT 2
362 # define PXENV_UNDI_ISR_OUT_RECIEVE 3
363 # define PXENV_UNDI_ISR_OUT_BUSY 4
364 } PACKED t_PXENV_UNDI_ISR;
366 #define PXENV_STOP_UNDI 0x0015
368 PXENV_STATUS_t Status;
369 } PACKED t_PXENV_STOP_UNDI;
371 #define PXENV_TFTP_OPEN 0x0020
373 PXENV_STATUS_t Status;
374 IP4_t ServerIPAddress;
375 IP4_t GatewayIPAddress;
376 uint8_t FileName[128];
379 } PACKED t_PXENV_TFTP_OPEN;
381 #define PXENV_TFTP_CLOSE 0x0021
383 PXENV_STATUS_t Status;
384 } PACKED t_PXENV_TFTP_CLOSE;
386 #define PXENV_TFTP_READ 0x0022
388 PXENV_STATUS_t Status;
389 uint16_t PacketNumber;
392 } PACKED t_PXENV_TFTP_READ;
394 #define PXENV_TFTP_READ_FILE 0x0023
396 PXENV_STATUS_t Status;
397 uint8_t FileName[128];
400 IP4_t ServerIPAddress;
401 IP4_t GatewayIPAdress;
403 UDP_PORT_t TFTPClntPort;
404 UDP_PORT_t TFTPSrvPort;
405 uint16_t TFTPOpenTimeOut;
406 uint16_t TFTPReopenDelay;
407 } PACKED t_PXENV_TFTP_READ_FILE;
409 #define PXENV_TFTP_GET_FSIZE 0x0025
411 PXENV_STATUS_t Status;
412 IP4_t ServerIPAddress;
413 IP4_t GatewayIPAdress;
414 uint8_t FileName[128];
416 } PACKED t_PXENV_TFTP_GET_FSIZE;
418 #define PXENV_UDP_OPEN 0x0030
420 PXENV_STATUS_t status;
421 IP4_t src_ip; /* IP address of this station */
422 } PACKED t_PXENV_UDP_OPEN;
424 #define PXENV_UDP_CLOSE 0x0031
426 PXENV_STATUS_t status;
427 } PACKED t_PXENV_UDP_CLOSE;
429 #define PXENV_UDP_READ 0x0032
431 PXENV_STATUS_t status;
432 IP4_t src_ip; /* IP of sender */
433 IP4_t dest_ip; /* Only accept packets sent to this IP */
434 UDP_PORT_t s_port; /* UDP source port of sender */
435 UDP_PORT_t d_port; /* Only accept packets sent to this port */
436 uint16_t buffer_size; /* Size of the packet buffer */
437 SEGOFF16_t buffer; /* SEG:OFF to the packet buffer */
438 } PACKED t_PXENV_UDP_READ;
440 #define PXENV_UDP_WRITE 0x0033
442 PXENV_STATUS_t status;
443 IP4_t ip; /* dest ip addr */
444 IP4_t gw; /* ip gateway */
445 UDP_PORT_t src_port; /* source udp port */
446 UDP_PORT_t dst_port; /* destination udp port */
447 uint16_t buffer_size; /* Size of the packet buffer */
448 SEGOFF16_t buffer; /* SEG:OFF to the packet buffer */
449 } PACKED t_PXENV_UDP_WRITE;
451 #define PXENV_UNLOAD_STACK 0x0070
453 PXENV_STATUS_t Status;
454 uint8_t reserved[10];
455 } PACKED t_PXENV_UNLOAD_STACK;
458 #define PXENV_GET_CACHED_INFO 0x0071
460 PXENV_STATUS_t Status;
461 uint16_t PacketType; /* type (defined right here) */
462 # define PXENV_PACKET_TYPE_DHCP_DISCOVER 1
463 # define PXENV_PACKET_TYPE_DHCP_ACK 2
464 # define PXENV_PACKET_TYPE_BINL_REPLY 3
465 uint16_t BufferSize; /* max to copy, leave at 0 for pointer */
466 SEGOFF16_t Buffer; /* copy to, leave at 0 for pointer */
467 uint16_t BufferLimit; /* max size of buffer in BC dataseg ? */
468 } PACKED t_PXENV_GET_CACHED_INFO;
471 /* structure filled in by PXENV_GET_CACHED_INFO
472 * (how we determine which IP we downloaded the initial bootstrap from)
473 * words can't describe...
479 uint8_t Hardware; /* hardware type */
480 uint8_t Hardlen; /* hardware addr len */
481 uint8_t Gatehops; /* zero it */
482 uint32_t ident; /* random number chosen by client */
483 uint16_t seconds; /* seconds since did initial bootstrap */
484 uint16_t Flags; /* seconds since did initial bootstrap */
485 # define BOOTP_BCAST 0x8000 /* ? */
486 IP4_t cip; /* Client IP */
487 IP4_t yip; /* Your IP */
488 IP4_t sip; /* IP to use for next boot stage */
489 IP4_t gip; /* Relay IP ? */
490 MAC_ADDR CAddr; /* Client hardware address */
491 uint8_t Sname[64]; /* Server's hostname (Optional) */
492 uint8_t bootfile[128]; /* boot filename */
495 # define BOOTP_DHCPVEND 1024 /* DHCP extended vendor field size */
497 # define BOOTP_DHCPVEND 312 /* DHCP standard vendor field size */
499 uint8_t d[BOOTP_DHCPVEND]; /* raw array of vendor/dhcp options */
501 uint8_t magic[4]; /* DHCP magic cookie */
503 # define VM_RFC1048 0x63825363L /* ? */
505 uint32_t flags; /* bootp flags/opcodes */
506 uint8_t pad[56]; /* I don't think intel knows what a
512 #define PXENV_RESTART_TFTP 0x0073
513 #define t_PXENV_RESTART_TFTP t_PXENV_TFTP_READ_FILE
515 #define PXENV_START_BASE 0x0075
517 PXENV_STATUS_t Status;
518 } PACKED t_PXENV_START_BASE;
520 #define PXENV_STOP_BASE 0x0076
522 PXENV_STATUS_t Status;
523 } PACKED t_PXENV_STOP_BASE;