1 /* $NetBSD: pxe.h,v 1.4 2005/12/11 12:17:49 christos Exp $ */
4 * Copyright (c) 2000 Alfred Perlstein <alfred@freebsd.org>
6 * Copyright (c) 2000 Paul Saab <ps@freebsd.org>
8 * Copyright (c) 2000 John Baldwin <jhb@freebsd.org>
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * Note that these structures and types are named according to
35 * the Intel PXE documentation.
38 #define MEMSTRCMP(p, s) memcmp((p), (s), sizeof(s) - 1)
40 #define IP_STR "%d.%d.%d.%d"
42 (int)(ip >> 24) & 0xff, (int)(ip >> 16) & 0xff, \
43 (int)(ip >> 8) & 0xff, (int)ip & 0xff
45 #define MAC_STR "%02x:%02x:%02x:%02x:%02x:%02x"
46 #define MAC_ARGS(mac) \
47 mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]
52 } SEGOFF16_t __packed
;
60 typedef uint16_t SEGSEL_t
;
61 typedef uint16_t PXENV_STATUS_t
;
62 typedef uint32_t IP4_t
;
63 typedef uint32_t ADDR32_t
;
64 typedef uint16_t UDP_PORT_t
;
66 #define MAC_ADDR_LEN 16
67 typedef uint8_t MAC_ADDR
[MAC_ADDR_LEN
];
71 uint8_t Signature
[6]; /* 'PXENV+' */
72 uint16_t Version
; /* MSB = major, LSB = minor */
73 uint8_t Length
; /* structure length */
74 uint8_t Checksum
; /* checksum pad */
75 SEGOFF16_t RMEntry
; /* SEG:OFF to PXE entry point */
76 /* don't use PMOffset and PMSelector (from the 2.1 PXE manual) */
77 uint32_t PMOffset
; /* Protected mode entry */
78 SEGSEL_t PMSelector
; /* Protected mode selector */
79 SEGSEL_t StackSeg
; /* Stack segment address */
80 uint16_t StackSize
; /* Stack segment size (bytes) */
81 SEGSEL_t BC_CodeSeg
; /* BC Code segment address */
82 uint16_t BC_CodeSize
; /* BC Code segment size (bytes) */
83 SEGSEL_t BC_DataSeg
; /* BC Data segment address */
84 uint16_t BC_DataSize
; /* BC Data segment size (bytes) */
85 SEGSEL_t UNDIDataSeg
; /* UNDI Data segment address */
86 uint16_t UNDIDataSize
; /* UNDI Data segment size (bytes) */
87 SEGSEL_t UNDICodeSeg
; /* UNDI Code segment address */
88 uint16_t UNDICodeSize
; /* UNDI Code segment size (bytes) */
89 SEGOFF16_t PXEPtr
; /* SEG:OFF to !PXE struct,
90 only present when Version > 2.1 */
100 SEGOFF16_t UNDIROMID
;
101 SEGOFF16_t BaseROMID
;
102 SEGOFF16_t EntryPointSP
;
103 SEGOFF16_t EntryPointESP
;
104 SEGOFF16_t StatusCallout
;
107 SEGSEL_t FirstSelector
;
111 SEGDESC_t UNDICodeWrite
;
114 SEGDESC_t BC_CodeWrite
;
117 #define PXENV_START_UNDI 0x0000
119 PXENV_STATUS_t Status
;
125 } __packed t_PXENV_START_UNDI
;
127 #define PXENV_UNDI_STARTUP 0x0001
129 PXENV_STATUS_t Status
;
130 } __packed t_PXENV_UNDI_STARTUP
;
132 #define PXENV_UNDI_CLEANUP 0x0002
134 PXENV_STATUS_t Status
;
135 } __packed t_PXENV_UNDI_CLEANUP
;
137 #define PXENV_UNDI_INITIALIZE 0x0003
139 PXENV_STATUS_t Status
;
140 ADDR32_t ProtocolIni
; /* Phys addr of a copy of the
143 } __packed t_PXENV_UNDI_INITALIZE
;
146 #define MAXNUM_MCADDR 8
148 PXENV_STATUS_t Status
;
149 uint16_t MCastAddrCount
;
150 MAC_ADDR McastAddr
[MAXNUM_MCADDR
];
151 } __packed t_PXENV_UNDI_MCAST_ADDRESS
;
153 #define PXENV_UNDI_RESET_ADAPTER 0x0004
155 PXENV_STATUS_t Status
;
156 t_PXENV_UNDI_MCAST_ADDRESS R_Mcast_Buf
;
157 } __packed t_PXENV_UNDI_RESET
;
159 #define PXENV_UNDI_SHUTDOWN 0x0005
161 PXENV_STATUS_t Status
;
162 } __packed t_PXENV_UNDI_SHUTDOWN
;
164 #define PXENV_UNDI_OPEN 0x0006
166 PXENV_STATUS_t Status
;
169 # define FLTR_DIRECTED 0x0001
170 # define FLTR_BRDCST 0x0002
171 # define FLTR_PRMSCS 0x0003
172 # define FLTR_SRC_RTG 0x0004
174 t_PXENV_UNDI_MCAST_ADDRESS R_Mcast_Buf
;
175 } __packed t_PXENV_UNDI_OPEN
;
177 #define PXENV_UNDI_CLOSE 0x0007
179 PXENV_STATUS_t Status
;
180 } __packed t_PXENV_UNDI_CLOSE
;
182 #define PXENV_UNDI_TRANSMIT 0x0008
184 PXENV_STATUS_t Status
;
192 # define XMT_DESTADDR 0x0000
193 # define XMT_BROADCAST 0x0001
197 uint32_t Reserved
[2];
198 } __packed t_PXENV_UNDI_TRANSMIT
;
200 #define MAX_DATA_BLKS 8
202 uint16_t ImmedLength
;
204 uint16_t DataBlkCount
;
209 SEGOFF16_t TDDataPtr
;
210 } DataBlock
[MAX_DATA_BLKS
];
211 } __packed t_PXENV_UNDI_TBD
;
213 #define PXENV_UNDI_SET_MCAST_ADDRESS 0x0009
215 PXENV_STATUS_t Status
;
216 t_PXENV_UNDI_MCAST_ADDRESS R_Mcast_Buf
;
217 } __packed t_PXENV_UNDI_SET_MCAST_ADDR
;
219 #define PXENV_UNDI_SET_STATION_ADDRESS 0x000A
221 PXENV_STATUS_t Status
;
222 MAC_ADDR StationAddress
; /* Temp MAC addres to use */
223 } __packed t_PXENV_UNDI_SET_STATION_ADDR
;
225 #define PXENV_UNDI_SET_PACKET_FILTER 0x000B
227 PXENV_STATUS_t Status
;
228 uint8_t filter
; /* see UNDI_OPEN (0x0006) */
229 } __packed t_PXENV_UNDI_SET_PACKET_FILTER
;
231 #define PXENV_UNDI_GET_INFORMATION 0x000C
233 PXENV_STATUS_t Status
;
234 uint16_t BaseIo
; /* Adapter base I/O address */
235 uint16_t IntNumber
; /* Adapter IRQ number */
236 uint16_t MaxTranUnit
; /* Adapter maximum transmit
238 uint16_t HwType
; /* Type of protocol at the
240 # define ETHER_TYPE 1
241 # define EXP_ETHER_TYPE 2
243 # define ARCNET_TYPE 7
245 uint16_t HwAddrLen
; /* Length of hardware address */
246 MAC_ADDR CurrentNodeAddress
; /* Current hardware address */
247 MAC_ADDR PermNodeAddress
; /* Permanent hardware address */
248 SEGSEL_t ROMAddress
; /* Real mode ROM segment
250 uint16_t RxBufCt
; /* Receive queue length */
251 uint16_t TxBufCt
; /* Transmit queue length */
252 } __packed t_PXENV_UNDI_GET_INFORMATION
;
254 #define PXENV_UNDI_GET_STATISTICS 0x000D
256 PXENV_STATUS_t Status
;
257 uint32_t XmitGoodFrames
; /* Number of successful
259 uint32_t RcvGoodFrames
; /* Number of good frames
261 uint32_t RcvCRCErrors
; /* Number of frames with
263 uint32_t RcvResourceErrors
; /* Number of frames dropped */
264 } __packed t_PXENV_UNDI_GET_STATISTICS
;
266 #define PXENV_UNDI_CLEAR_STATISTICS 0x000E
268 PXENV_STATUS_t Status
;
269 } __packed t_PXENV_UNDI_CLEAR_STATISTICS
;
271 #define PXENV_UNDI_INITIATE_DIAGS 0x000F
273 PXENV_STATUS_t Status
;
274 } __packed t_PXENV_UNDI_INITIATE_DIAGS
;
276 #define PXENV_UNDI_FORCE_INTERRUPT 0x0010
278 PXENV_STATUS_t Status
;
279 } __packed t_PXENV_UNDI_FORCE_INTERRUPT
;
281 #define PXENV_UNDI_GET_MCAST_ADDRESS 0x0011
283 PXENV_STATUS_t Status
;
284 IP4_t InetAddr
; /* IP mulicast address */
285 MAC_ADDR MediaAddr
; /* MAC multicast address */
286 } __packed t_PXENV_UNDI_GET_MCAST_ADDR
;
288 #define PXENV_UNDI_GET_NIC_TYPE 0x0012
290 PXENV_STATUS_t Status
;
291 uint8_t NicType
; /* Type of NIC */
294 # define CardBus_NIC 4
305 uint16_t SubVendor_ID
;
306 uint16_t SubDevice_ID
;
309 uint32_t EISA_Dev_ID
;
316 } __packed t_PXENV_UNDI_GET_NIC_TYPE
;
318 #define PXENV_UNDI_GET_IFACE_INFO 0x0013
320 PXENV_STATUS_t Status
;
321 uint8_t IfaceType
[16]; /* Name of MAC type in ASCII. */
322 uint32_t LinkSpeed
; /* Defined in NDIS 2.0 spec */
323 uint32_t ServiceFlags
; /* Defined in NDIS 2.0 spec */
324 uint32_t Reserved
[4]; /* must be 0 */
325 } __packed t_PXENV_UNDI_GET_NDIS_INFO
;
327 #define PXENV_UNDI_ISR 0x0014
329 PXENV_STATUS_t Status
;
330 uint16_t FuncFlag
; /* PXENV_UNDI_ISR_OUT_xxx */
331 uint16_t BufferLength
; /* Length of Frame */
332 uint16_t FrameLength
; /* Total length of reciever
334 uint16_t FrameHeaderLength
; /* Length of the media header
336 SEGOFF16_t Frame
; /* receive buffer */
337 uint8_t ProtType
; /* Protocol type */
338 uint8_t PktType
; /* Packet Type */
339 # define PXENV_UNDI_ISR_IN_START 1
340 # define PXENV_UNDI_ISR_IN_PROCESS 2
341 # define PXENV_UNDI_ISR_IN_GET_NEXT 3
343 /* one of these will be returned for PXENV_UNDI_ISR_IN_START */
344 # define PXENV_UNDI_ISR_OUT_OURS 0
345 # define PXENV_UNDI_ISR_OUT_NOT_OUTS 1
348 * one of these will bre returnd for PXEND_UNDI_ISR_IN_PROCESS
349 * and PXENV_UNDI_ISR_IN_GET_NEXT
351 # define PXENV_UNDI_ISR_OUT_DONE 0
352 # define PXENV_UNDI_ISR_OUT_TRANSMIT 2
353 # define PXENV_UNDI_ISR_OUT_RECIEVE 3
354 # define PXENV_UNDI_ISR_OUT_BUSY 4
355 } __packed t_PXENV_UNDI_ISR
;
357 #define PXENV_STOP_UNDI 0x0015
359 PXENV_STATUS_t Status
;
360 } __packed t_PXENV_STOP_UNDI
;
362 #define PXENV_TFTP_OPEN 0x0020
364 PXENV_STATUS_t Status
;
365 IP4_t ServerIPAddress
;
366 IP4_t GatewayIPAddress
;
367 uint8_t FileName
[128];
370 } __packed t_PXENV_TFTP_OPEN
;
372 #define PXENV_TFTP_CLOSE 0x0021
374 PXENV_STATUS_t Status
;
375 } __packed t_PXENV_TFTP_CLOSE
;
377 #define PXENV_TFTP_READ 0x0022
379 PXENV_STATUS_t Status
;
380 uint16_t PacketNumber
;
383 } __packed t_PXENV_TFTP_READ
;
385 #define PXENV_TFTP_READ_FILE 0x0023
387 PXENV_STATUS_t Status
;
388 uint8_t FileName
[128];
391 IP4_t ServerIPAddress
;
392 IP4_t GatewayIPAddress
;
393 IP4_t McastIPAddress
;
394 UDP_PORT_t TFTPClntPort
;
395 UDP_PORT_t TFTPSrvPort
;
396 uint16_t TFTPOpenTimeOut
;
397 uint16_t TFTPReopenDelay
;
398 } __packed t_PXENV_TFTP_READ_FILE
;
400 #define PXENV_TFTP_GET_FSIZE 0x0025
402 PXENV_STATUS_t Status
;
403 IP4_t ServerIPAddress
;
404 IP4_t GatewayIPAddress
;
405 uint8_t FileName
[128];
407 } __packed t_PXENV_TFTP_GET_FSIZE
;
409 #define PXENV_UDP_OPEN 0x0030
411 PXENV_STATUS_t status
;
412 IP4_t src_ip
; /* IP address of this station */
413 } __packed t_PXENV_UDP_OPEN
;
415 #define PXENV_UDP_CLOSE 0x0031
417 PXENV_STATUS_t status
;
418 } __packed t_PXENV_UDP_CLOSE
;
420 #define PXENV_UDP_READ 0x0032
422 PXENV_STATUS_t status
;
423 IP4_t src_ip
; /* IP of sender */
424 IP4_t dest_ip
; /* Only accept packets sent to
426 UDP_PORT_t s_port
; /* UDP source port of sender */
427 UDP_PORT_t d_port
; /* Only accept packets sent to
429 uint16_t buffer_size
; /* Size of the packet buffer */
430 SEGOFF16_t buffer
; /* SEG:OFF to the packet buffer */
431 } __packed t_PXENV_UDP_READ
;
433 #define PXENV_UDP_WRITE 0x0033
435 PXENV_STATUS_t status
;
436 IP4_t ip
; /* dest ip addr */
437 IP4_t gw
; /* ip gateway */
438 UDP_PORT_t src_port
; /* source udp port */
439 UDP_PORT_t dst_port
; /* destination udp port */
440 uint16_t buffer_size
; /* Size of the packet buffer */
441 SEGOFF16_t buffer
; /* SEG:OFF to the packet buffer */
442 } __packed t_PXENV_UDP_WRITE
;
444 #define PXENV_UNLOAD_STACK 0x0070
446 PXENV_STATUS_t Status
;
447 uint8_t reserved
[10];
448 } __packed t_PXENV_UNLOAD_STACK
;
451 #define PXENV_GET_CACHED_INFO 0x0071
453 PXENV_STATUS_t Status
;
454 uint16_t PacketType
; /* type (defined right here) */
455 # define PXENV_PACKET_TYPE_DHCP_DISCOVER 1
456 # define PXENV_PACKET_TYPE_DHCP_ACK 2
457 # define PXENV_PACKET_TYPE_BINL_REPLY 3
458 uint16_t BufferSize
; /* max to copy, leave at 0 for
460 SEGOFF16_t Buffer
; /* copy to, leave at 0 for pointer */
461 uint16_t BufferLimit
; /* max size of buffer in BC dataseg ? */
462 } __packed t_PXENV_GET_CACHED_INFO
;
465 /* structure filled in by PXENV_GET_CACHED_INFO
466 * (how we determine which IP we downloaded the initial bootstrap from)
467 * words can't describe...
473 uint8_t Hardware
; /* hardware type */
474 uint8_t Hardlen
; /* hardware addr len */
475 uint8_t Gatehops
; /* zero it */
476 uint32_t ident
; /* random number chosen by client */
477 uint16_t seconds
; /* seconds since did initial
479 uint16_t Flags
; /* seconds since did initial
481 # define BOOTP_BCAST 0x8000 /* ? */
482 IP4_t cip
; /* Client IP */
483 IP4_t yip
; /* Your IP */
484 IP4_t sip
; /* IP to use for next boot stage */
485 IP4_t gip
; /* Relay IP ? */
486 MAC_ADDR CAddr
; /* Client hardware address */
487 uint8_t Sname
[64]; /* Server's hostname (Optional) */
488 uint8_t bootfile
[128]; /* boot filename */
491 # define BOOTP_DHCPVEND 1024 /* DHCP extended vendor
494 # define BOOTP_DHCPVEND 312 /* DHCP standard vendor
497 uint8_t d
[BOOTP_DHCPVEND
]; /* raw array of
498 vendor/dhcp options */
500 uint8_t magic
[4]; /* DHCP magic cookie */
502 # define VM_RFC1048 0x63825363L /* ? */
504 uint32_t flags
; /* bootp flags/opcodes */
505 uint8_t pad
[56]; /* I don't think intel
510 } __packed BOOTPLAYER
;
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
;
525 #define PXENV_STATUS_SUCCESS 0
526 #define PXENV_STATUS_FAILURE 1
527 /* ...there are tons more, but we don't really care about them right now... */