5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of the
8 * License, or any later version.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 * You can also choose to distribute this program under the terms of
21 * the Unmodified Binary Distribution Licence (as given in the file
22 * COPYING.UBDL), provided that you have satisfied its requirements.
24 * As an alternative, at your option, you may use this file under the
25 * following terms, known as the "MIT license":
27 * Copyright (c) 2005-2009 Michael Brown <mbrown@fensystems.co.uk>
29 * Permission is hereby granted, free of charge, to any person
30 * obtaining a copy of this software and associated documentation
31 * files (the "Software"), to deal in the Software without
32 * restriction, including without limitation the rights to use, copy,
33 * modify, merge, publish, distribute, sublicense, and/or sell copies
34 * of the Software, and to permit persons to whom the Software is
35 * furnished to do so, subject to the following conditions:
37 * The above copyright notice and this permission notice shall be
38 * included in all copies or substantial portions of the Software.
40 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
41 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
42 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
43 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
44 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
45 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
46 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
52 * Preboot eXecution Environment (PXE) API
56 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
58 #include "pxe_types.h"
60 /** @addtogroup pxe Preboot eXecution Environment (PXE) API
64 /** @defgroup pxe_api_call PXE entry points
66 * PXE entry points and calling conventions
71 /** The PXENV+ structure */
75 * Contains the bytes 'P', 'X', 'E', 'N', 'V', '+'.
80 * MSB is major version number, LSB is minor version number.
81 * If the API version number is 0x0201 or greater, the !PXE
82 * structure pointed to by #PXEPtr should be used instead of
83 * this data structure.
86 UINT8_t Length; /**< Length of this structure */
89 * The byte checksum of this structure (using the length in
90 * #Length) must be zero.
93 SEGOFF16_t RMEntry; /**< Real-mode PXENV+ entry point */
94 /** Protected-mode PXENV+ entry point offset
96 * PXE 2.1 deprecates this entry point. For protected-mode
97 * API calls, use the !PXE structure pointed to by #PXEPtr
101 /** Protected-mode PXENV+ entry point segment selector
103 * PXE 2.1 deprecates this entry point. For protected-mode
104 * API calls, use the !PXE structure pointed to by #PXEPtr
108 SEGSEL_t StackSeg; /**< Stack segment selector */
109 UINT16_t StackSize; /**< Stack segment size */
110 SEGSEL_t BC_CodeSeg; /**< Base-code code segment selector */
111 UINT16_t BC_CodeSize; /**< Base-code code segment size */
112 SEGSEL_t BC_DataSeg; /**< Base-code data segment selector */
113 UINT16_t BC_DataSize; /**< Base-code data segment size */
114 SEGSEL_t UNDIDataSeg; /**< UNDI data segment selector */
115 UINT16_t UNDIDataSize; /**< UNDI data segment size */
116 SEGSEL_t UNDICodeSeg; /**< UNDI code segment selector */
117 UINT16_t UNDICodeSize; /**< UNDI code segment size */
118 /** Address of the !PXE structure
120 * This field is present only if #Version is 0x0201 or
121 * greater. If present, it points to a struct s_PXE.
124 } __attribute__ (( packed ));
126 typedef struct s_PXENV PXENV_t;
128 /** The !PXE structure */
132 * Contains the bytes '!', 'P', 'X', 'E'.
134 UINT8_t Signature[4];
135 UINT8_t StructLength; /**< Length of this structure */
138 * The byte checksum of this structure (using the length in
139 * #StructLength) must be zero.
142 /** Revision of this structure
144 * For PXE version 2.1, this field must be zero.
147 UINT8_t reserved_1; /**< Must be zero */
148 /** Address of the UNDI ROM ID structure
150 * This is a pointer to a struct s_UNDI_ROM_ID.
152 SEGOFF16_t UNDIROMID;
153 /** Address of the Base Code ROM ID structure
155 * This is a pointer to a struct s_BC_ROM_ID.
157 SEGOFF16_t BaseROMID;
158 /** 16-bit !PXE entry point
160 * This is the entry point for either real mode, or protected
161 * mode with a 16-bit stack segment.
163 SEGOFF16_t EntryPointSP;
164 /** 32-bit !PXE entry point
166 * This is the entry point for protected mode with a 32-bit
169 SEGOFF16_t EntryPointESP;
170 /** Status call-out function
172 * @v 0 (if in a time-out loop)
173 * @v n Number of a received TFTP packet
174 * @ret 0 Continue operation
175 * @ret 1 Cancel operation
177 * This function will be called whenever the PXE stack is in
178 * protected mode, is waiting for an event (e.g. a DHCP reply)
179 * and wishes to allow the user to cancel the operation.
180 * Parameters are passed in register %ax; the return value
181 * must also be placed in register %ax. All other registers
182 * and flags @b must be preserved.
184 * In real mode, an internal function (that checks for a
185 * keypress) will be used.
187 * If this field is set to -1, no status call-out function
188 * will be used and consequently the user will not be allowed
189 * to interrupt operations.
191 * @note The PXE specification version 2.1 defines the
192 * StatusCallout field, mentions it 11 times, but nowhere
193 * defines what it actually does or how it gets called.
194 * Fortunately, the WfM specification version 1.1a deigns to
195 * inform us of such petty details.
197 SEGOFF16_t StatusCallout;
198 UINT8_t reserved_2; /**< Must be zero */
199 /** Number of segment descriptors
201 * If this number is greater than 7, the remaining descriptors
202 * follow immediately after #BC_CodeWrite.
205 /** First protected-mode selector
207 * This is the segment selector value for the first segment
208 * assigned to PXE. Protected-mode selectors must be
209 * consecutive, according to the PXE 2.1 specification, though
210 * no reason is given. Each #SEGDESC_t includes a field for
211 * the segment selector, so this information is entirely
214 SEGSEL_t FirstSelector;
215 /** Stack segment descriptor */
217 /** UNDI data segment descriptor */
219 /** UNDI code segment descriptor */
221 /** UNDI writable code segment descriptor */
222 SEGDESC_t UNDICodeWrite;
223 /** Base-code data segment descriptor */
225 /** Base-code code segment descriptor */
227 /** Base-code writable code segment descriptor */
228 SEGDESC_t BC_CodeWrite;
229 } __attribute__ (( packed ));
231 typedef struct s_PXE PXE_t;
233 /** @} */ /* pxe_api_call */
235 /** @defgroup pxe_preboot_api PXE Preboot API
237 * General high-level functions: #PXENV_UNLOAD_STACK, #PXENV_START_UNDI etc.
242 /** @defgroup pxenv_unload_stack PXENV_UNLOAD_STACK
244 * UNLOAD BASE CODE STACK
249 /** PXE API function code for pxenv_unload_stack() */
250 #define PXENV_UNLOAD_STACK 0x0070
252 /** Parameter block for pxenv_unload_stack() */
253 struct s_PXENV_UNLOAD_STACK {
254 PXENV_STATUS_t Status; /**< PXE status code */
255 UINT8_t reserved[10]; /**< Must be zero */
256 } __attribute__ (( packed ));
258 typedef struct s_PXENV_UNLOAD_STACK PXENV_UNLOAD_STACK_t;
260 /** @} */ /* pxenv_unload_stack */
262 /** @defgroup pxenv_get_cached_info PXENV_GET_CACHED_INFO
269 /** PXE API function code for pxenv_get_cached_info() */
270 #define PXENV_GET_CACHED_INFO 0x0071
272 /** The client's DHCPDISCOVER packet */
273 #define PXENV_PACKET_TYPE_DHCP_DISCOVER 1
275 /** The DHCP server's DHCPACK packet */
276 #define PXENV_PACKET_TYPE_DHCP_ACK 2
278 /** The Boot Server's Discover Reply packet
280 * This packet contains DHCP option 60 set to "PXEClient", a valid
281 * boot file name, and may or may not contain MTFTP options.
283 #define PXENV_PACKET_TYPE_CACHED_REPLY 3
285 /** Parameter block for pxenv_get_cached_info() */
286 struct s_PXENV_GET_CACHED_INFO {
287 PXENV_STATUS_t Status; /**< PXE status code */
290 * Valid values are #PXENV_PACKET_TYPE_DHCP_DISCOVER,
291 * #PXENV_PACKET_TYPE_DHCP_ACK or #PXENV_PACKET_TYPE_CACHED_REPLY
294 UINT16_t BufferSize; /**< Buffer size */
295 SEGOFF16_t Buffer; /**< Buffer address */
296 UINT16_t BufferLimit; /**< Maximum buffer size */
297 } __attribute__ (( packed ));
299 typedef struct s_PXENV_GET_CACHED_INFO PXENV_GET_CACHED_INFO_t;
301 #define BOOTP_REQ 1 /**< A BOOTP request packet */
302 #define BOOTP_REP 2 /**< A BOOTP reply packet */
304 /** DHCP broadcast flag
306 * Request a broadcast response (DHCPOFFER or DHCPACK) from the DHCP
309 #define BOOTP_BCAST 0x8000
311 #define VM_RFC1048 0x63825363L /**< DHCP magic cookie */
313 /** Maximum length of DHCP options */
314 #define BOOTP_DHCPVEND 1024
316 /** Format of buffer filled in by pxenv_get_cached_info()
318 * This somewhat convoluted data structure simply describes the layout
319 * of a DHCP packet. Refer to RFC2131 section 2 for a full
325 * Valid values are #BOOTP_REQ and #BOOTP_REP.
328 /** NIC hardware type.
330 * Valid values are as for s_PXENV_UNDI_GET_INFORMATION::HwType.
333 UINT8_t Hardlen; /**< MAC address length */
336 * Zero in packets sent by the client. May be non-zero in
337 * replies from the DHCP server, if the reply comes via a DHCP
341 UINT32_t ident; /**< DHCP transaction id (xid) */
344 * Number of seconds since the client began the DHCP
350 * This is the bitwise-OR of any of the following values:
354 /** Client IP address
356 * Set only if the client already has an IP address.
361 * This is the IP address that the server assigns to the
365 /** Server IP address
367 * This is the IP address of the BOOTP/DHCP server.
370 /** Gateway IP address
372 * This is the IP address of the BOOTP/DHCP relay agent, if
373 * any. It is @b not (necessarily) the address of the default
374 * gateway for routing purposes.
377 MAC_ADDR_t CAddr; /**< Client MAC address */
378 UINT8_t Sname[64]; /**< Server host name */
379 UINT8_t bootfile[128]; /**< Boot file name */
382 * Don't ask. Just laugh. Then burn a copy of the PXE
383 * specification and send Intel an e-mail asking them if
384 * they've figured out what a "union" does in C yet.
386 union bootph_vendor {
387 UINT8_t d[BOOTP_DHCPVEND]; /**< DHCP options */
389 struct bootph_vendor_v {
390 /** DHCP magic cookie
392 * Should have the value #VM_RFC1048.
395 UINT32_t flags; /**< BOOTP flags/opcodes */
396 /** "End of BOOTP vendor extensions"
398 * Abandon hope, all ye who consider the
399 * purpose of this field.
404 } __attribute__ (( packed ));
406 typedef struct bootph BOOTPLAYER_t;
408 /** @} */ /* pxenv_get_cached_info */
410 /** @defgroup pxenv_restart_tftp PXENV_RESTART_TFTP
417 /** PXE API function code for pxenv_restart_tftp() */
418 #define PXENV_RESTART_TFTP 0x0073
420 /** Parameter block for pxenv_restart_tftp() */
421 struct s_PXENV_TFTP_READ_FILE;
423 typedef struct s_PXENV_RESTART_TFTP PXENV_RESTART_TFTP_t;
425 /** @} */ /* pxenv_restart_tftp */
427 /** @defgroup pxenv_start_undi PXENV_START_UNDI
434 /** PXE API function code for pxenv_start_undi() */
435 #define PXENV_START_UNDI 0x0000
437 /** Parameter block for pxenv_start_undi() */
438 struct s_PXENV_START_UNDI {
439 PXENV_STATUS_t Status; /**< PXE status code */
440 /** %ax register as passed to the Option ROM initialisation routine.
442 * For a PCI device, this should contain the bus:dev:fn value
443 * that uniquely identifies the PCI device in the system. For
444 * a non-PCI device, this field is not defined.
447 /** %bx register as passed to the Option ROM initialisation routine.
449 * For an ISAPnP device, this should contain the Card Select
450 * Number assigned to the ISAPnP card. For non-ISAPnP
451 * devices, this should contain 0xffff.
454 /** %dx register as passed to the Option ROM initialisation routine.
456 * For an ISAPnP device, this should contain the ISAPnP Read
457 * Port address as currently set in all ISAPnP cards. If
458 * there are no ISAPnP cards, this should contain 0xffff. (If
459 * this is a non-ISAPnP device, but there are ISAPnP cards in
460 * the system, this value is not well defined.)
463 /** %di register as passed to the Option ROM initialisation routine.
465 * This contains the #OFF16_t portion of a struct #s_SEGOFF16
466 * that points to the System BIOS Plug and Play Installation
467 * Check Structure. (Refer to section 4.4 of the Plug and
468 * Play BIOS specification for a description of this
471 * @note The PXE specification defines the type of this field
472 * as #UINT16_t. For x86, #OFF16_t and #UINT16_t are
473 * equivalent anyway; for other architectures #OFF16_t makes
477 /** %es register as passed to the Option ROM initialisation routine.
479 * This contains the #SEGSEL_t portion of a struct #s_SEGOFF16
480 * that points to the System BIOS Plug and Play Installation
481 * Check Structure. (Refer to section 4.4 of the Plug and
482 * Play BIOS specification for a description of this
485 * @note The PXE specification defines the type of this field
486 * as #UINT16_t. For x86, #SEGSEL_t and #UINT16_t are
487 * equivalent anyway; for other architectures #SEGSEL_t makes
491 } __attribute__ (( packed ));
493 typedef struct s_PXENV_START_UNDI PXENV_START_UNDI_t;
495 /** @} */ /* pxenv_start_undi */
497 /** @defgroup pxenv_stop_undi PXENV_STOP_UNDI
504 /** PXE API function code for pxenv_stop_undi() */
505 #define PXENV_STOP_UNDI 0x0015
507 /** Parameter block for pxenv_stop_undi() */
508 struct s_PXENV_STOP_UNDI {
509 PXENV_STATUS_t Status; /**< PXE status code */
510 } __attribute__ (( packed ));
512 typedef struct s_PXENV_STOP_UNDI PXENV_STOP_UNDI_t;
514 /** @} */ /* pxenv_stop_undi */
516 /** @defgroup pxenv_start_base PXENV_START_BASE
523 /** PXE API function code for pxenv_start_base() */
524 #define PXENV_START_BASE 0x0075
526 /** Parameter block for pxenv_start_base() */
527 struct s_PXENV_START_BASE {
528 PXENV_STATUS_t Status; /**< PXE status code */
529 } __attribute__ (( packed ));
531 typedef struct s_PXENV_START_BASE PXENV_START_BASE_t;
533 /** @} */ /* pxenv_start_base */
535 /** @defgroup pxenv_stop_base PXENV_STOP_BASE
542 /** PXE API function code for pxenv_stop_base() */
543 #define PXENV_STOP_BASE 0x0076
545 /** Parameter block for pxenv_stop_base() */
546 struct s_PXENV_STOP_BASE {
547 PXENV_STATUS_t Status; /**< PXE status code */
548 } __attribute__ (( packed ));
550 typedef struct s_PXENV_STOP_BASE PXENV_STOP_BASE_t;
552 /** @} */ /* pxenv_stop_base */
554 /** @} */ /* pxe_preboot_api */
556 /** @defgroup pxe_tftp_api PXE TFTP API
558 * Download files via TFTP or MTFTP
563 /** @defgroup pxenv_tftp_open PXENV_TFTP_OPEN
570 /** PXE API function code for pxenv_tftp_open() */
571 #define PXENV_TFTP_OPEN 0x0020
573 /** Parameter block for pxenv_tftp_open() */
574 struct s_PXENV_TFTP_OPEN {
575 PXENV_STATUS_t Status; /**< PXE status code */
576 IP4_t ServerIPAddress; /**< TFTP server IP address */
577 IP4_t GatewayIPAddress; /**< Relay agent IP address */
578 UINT8_t FileName[128]; /**< File name */
579 UDP_PORT_t TFTPPort; /**< TFTP server UDP port */
580 /** Requested size of TFTP packets
582 * This is the TFTP "blksize" option. This must be at least
583 * 512, since servers that do not support TFTP options cannot
584 * negotiate blocksizes smaller than this.
587 } __attribute__ (( packed ));
589 typedef struct s_PXENV_TFTP_OPEN PXENV_TFTP_OPEN_t;
591 /** @} */ /* pxenv_tftp_open */
593 /** @defgroup pxenv_tftp_close PXENV_TFTP_CLOSE
600 /** PXE API function code for pxenv_tftp_close() */
601 #define PXENV_TFTP_CLOSE 0x0021
603 /** Parameter block for pxenv_tftp_close() */
604 struct s_PXENV_TFTP_CLOSE {
605 PXENV_STATUS_t Status; /**< PXE status code */
606 } __attribute__ (( packed ));
608 typedef struct s_PXENV_TFTP_CLOSE PXENV_TFTP_CLOSE_t;
610 /** @} */ /* pxenv_tftp_close */
612 /** @defgroup pxenv_tftp_read PXENV_TFTP_READ
619 /** PXE API function code for pxenv_tftp_read() */
620 #define PXENV_TFTP_READ 0x0022
622 /** Parameter block for pxenv_tftp_read() */
623 struct s_PXENV_TFTP_READ {
624 PXENV_STATUS_t Status; /**< PXE status code */
625 UINT16_t PacketNumber; /**< TFTP packet number */
626 UINT16_t BufferSize; /**< Size of data buffer */
627 SEGOFF16_t Buffer; /**< Address of data buffer */
628 } __attribute__ (( packed ));
630 typedef struct s_PXENV_TFTP_READ PXENV_TFTP_READ_t;
632 /** @} */ /* pxenv_tftp_read */
634 /** @defgroup pxenv_tftp_read_file PXENV_TFTP_READ_FILE
636 * TFTP/MTFTP READ FILE
641 /** PXE API function code for pxenv_tftp_read_file() */
642 #define PXENV_TFTP_READ_FILE 0x0023
644 /** Parameter block for pxenv_tftp_read_file() */
645 struct s_PXENV_TFTP_READ_FILE {
646 PXENV_STATUS_t Status; /**< PXE status code */
647 UINT8_t FileName[128]; /**< File name */
648 UINT32_t BufferSize; /**< Size of data buffer */
649 ADDR32_t Buffer; /**< Address of data buffer */
650 IP4_t ServerIPAddress; /**< TFTP server IP address */
651 IP4_t GatewayIPAddress; /**< Relay agent IP address */
652 /** File multicast IP address */
653 IP4_t McastIPAddress;
654 /** Client multicast listening port */
655 UDP_PORT_t TFTPClntPort;
656 /** Server multicast listening port */
657 UDP_PORT_t TFTPSrvPort;
658 /** TFTP open timeout.
660 * This is the timeout for receiving the first DATA or ACK
661 * packets during the MTFTP Listen phase.
663 UINT16_t TFTPOpenTimeOut;
664 /** TFTP reopen timeout.
666 * This is the timeout for receiving an ACK packet while in
667 * the MTFTP Listen phase (when at least one ACK packet has
668 * already been seen).
670 UINT16_t TFTPReopenDelay;
671 } __attribute__ (( packed ));
673 typedef struct s_PXENV_TFTP_READ_FILE PXENV_TFTP_READ_FILE_t;
675 /** @} */ /* pxenv_tftp_read_file */
677 /** @defgroup pxenv_tftp_get_fsize PXENV_TFTP_GET_FSIZE
684 /** PXE API function code for pxenv_tftp_get_fsize() */
685 #define PXENV_TFTP_GET_FSIZE 0x0025
687 /** Parameter block for pxenv_tftp_get_fsize() */
688 struct s_PXENV_TFTP_GET_FSIZE {
689 PXENV_STATUS_t Status; /**< PXE status code */
690 IP4_t ServerIPAddress; /**< TFTP server IP address */
691 IP4_t GatewayIPAddress; /**< Relay agent IP address */
692 UINT8_t FileName[128]; /**< File name */
693 UINT32_t FileSize; /**< Size of the file */
694 } __attribute__ (( packed ));
696 typedef struct s_PXENV_TFTP_GET_FSIZE PXENV_TFTP_GET_FSIZE_t;
698 /** @} */ /* pxenv_tftp_get_fsize */
700 /** @} */ /* pxe_tftp_api */
702 /** @defgroup pxe_udp_api PXE UDP API
704 * Transmit and receive UDP packets
709 /** @defgroup pxenv_udp_open PXENV_UDP_OPEN
716 /** PXE API function code for pxenv_udp_open() */
717 #define PXENV_UDP_OPEN 0x0030
719 /** Parameter block for pxenv_udp_open() */
720 struct s_PXENV_UDP_OPEN {
721 PXENV_STATUS_t Status; /**< PXE status code */
722 IP4_t src_ip; /**< IP address of this station */
723 } __attribute__ (( packed ));
725 typedef struct s_PXENV_UDP_OPEN PXENV_UDP_OPEN_t;
727 /** @} */ /* pxenv_udp_open */
729 /** @defgroup pxenv_udp_close PXENV_UDP_CLOSE
736 /** PXE API function code for pxenv_udp_close() */
737 #define PXENV_UDP_CLOSE 0x0031
739 /** Parameter block for pxenv_udp_close() */
740 struct s_PXENV_UDP_CLOSE {
741 PXENV_STATUS_t Status; /**< PXE status code */
742 } __attribute__ (( packed ));
744 typedef struct s_PXENV_UDP_CLOSE PXENV_UDP_CLOSE_t;
746 /** @} */ /* pxenv_udp_close */
748 /** @defgroup pxenv_udp_write PXENV_UDP_WRITE
755 /** PXE API function code for pxenv_udp_write() */
756 #define PXENV_UDP_WRITE 0x0033
758 /** Parameter block for pxenv_udp_write() */
759 struct s_PXENV_UDP_WRITE {
760 PXENV_STATUS_t Status; /**< PXE status code */
761 IP4_t ip; /**< Destination IP address */
762 IP4_t gw; /**< Relay agent IP address */
763 UDP_PORT_t src_port; /**< Source UDP port */
764 UDP_PORT_t dst_port; /**< Destination UDP port */
765 UINT16_t buffer_size; /**< UDP payload buffer size */
766 SEGOFF16_t buffer; /**< UDP payload buffer address */
767 } __attribute__ (( packed ));
769 typedef struct s_PXENV_UDP_WRITE PXENV_UDP_WRITE_t;
771 /** @} */ /* pxenv_udp_write */
773 /** @defgroup pxenv_udp_read PXENV_UDP_READ
780 /** PXE API function code for pxenv_udp_read() */
781 #define PXENV_UDP_READ 0x0032
783 /** Parameter block for pxenv_udp_read() */
784 struct s_PXENV_UDP_READ {
785 PXENV_STATUS_t Status; /**< PXE status code */
786 IP4_t src_ip; /**< Source IP address */
787 IP4_t dest_ip; /**< Destination IP address */
788 UDP_PORT_t s_port; /**< Source UDP port */
789 UDP_PORT_t d_port; /**< Destination UDP port */
790 UINT16_t buffer_size; /**< UDP payload buffer size */
791 SEGOFF16_t buffer; /**< UDP payload buffer address */
792 } __attribute__ (( packed ));
794 typedef struct s_PXENV_UDP_READ PXENV_UDP_READ_t;
796 /** @} */ /* pxenv_udp_read */
798 /** @} */ /* pxe_udp_api */
800 /** @defgroup pxe_undi_api PXE UNDI API
802 * Direct control of the network interface card
807 /** @defgroup pxenv_undi_startup PXENV_UNDI_STARTUP
814 /** PXE API function code for pxenv_undi_startup() */
815 #define PXENV_UNDI_STARTUP 0x0001
817 #define PXENV_BUS_ISA 0 /**< ISA bus type */
818 #define PXENV_BUS_EISA 1 /**< EISA bus type */
819 #define PXENV_BUS_MCA 2 /**< MCA bus type */
820 #define PXENV_BUS_PCI 3 /**< PCI bus type */
821 #define PXENV_BUS_VESA 4 /**< VESA bus type */
822 #define PXENV_BUS_PCMCIA 5 /**< PCMCIA bus type */
824 /** Parameter block for pxenv_undi_startup() */
825 struct s_PXENV_UNDI_STARTUP {
826 PXENV_STATUS_t Status; /**< PXE status code */
827 } __attribute__ (( packed ));
829 typedef struct s_PXENV_UNDI_STARTUP PXENV_UNDI_STARTUP_t;
831 /** @} */ /* pxenv_undi_startup */
833 /** @defgroup pxenv_undi_cleanup PXENV_UNDI_CLEANUP
840 /** PXE API function code for pxenv_undi_cleanup() */
841 #define PXENV_UNDI_CLEANUP 0x0002
843 /** Parameter block for pxenv_undi_cleanup() */
844 struct s_PXENV_UNDI_CLEANUP {
845 PXENV_STATUS_t Status; /**< PXE status code */
846 } __attribute__ (( packed ));
848 typedef struct s_PXENV_UNDI_CLEANUP PXENV_UNDI_CLEANUP_t;
850 /** @} */ /* pxenv_undi_cleanup */
852 /** @defgroup pxenv_undi_initialize PXENV_UNDI_INITIALIZE
859 /** PXE API function code for pxenv_undi_initialize() */
860 #define PXENV_UNDI_INITIALIZE 0x0003
862 /** Parameter block for pxenv_undi_initialize() */
863 struct s_PXENV_UNDI_INITIALIZE {
864 PXENV_STATUS_t Status; /**< PXE status code */
865 /** NDIS 2.0 configuration information, or NULL
867 * This is a pointer to the data structure returned by the
868 * NDIS 2.0 GetProtocolManagerInfo() API call. The data
869 * structure is documented, in a rather haphazard way, in
870 * section 4-17 of the NDIS 2.0 specification.
872 ADDR32_t ProtocolIni;
873 UINT8_t reserved[8]; /**< Must be zero */
874 } __attribute__ (( packed ));
876 typedef struct s_PXENV_UNDI_INITIALIZE PXENV_UNDI_INITIALIZE_t;
878 /** @} */ /* pxenv_undi_initialize */
880 /** @defgroup pxenv_undi_reset_adapter PXENV_UNDI_RESET_ADAPTER
887 /** PXE API function code for pxenv_undi_reset_adapter() */
888 #define PXENV_UNDI_RESET_ADAPTER 0x0004
890 /** Maximum number of multicast MAC addresses */
891 #define MAXNUM_MCADDR 8
893 /** List of multicast MAC addresses */
894 struct s_PXENV_UNDI_MCAST_ADDRESS {
895 /** Number of multicast MAC addresses */
896 UINT16_t MCastAddrCount;
897 /** List of up to #MAXNUM_MCADDR multicast MAC addresses */
898 MAC_ADDR_t McastAddr[MAXNUM_MCADDR];
899 } __attribute__ (( packed ));
901 typedef struct s_PXENV_UNDI_MCAST_ADDRESS PXENV_UNDI_MCAST_ADDRESS_t;
903 /** Parameter block for pxenv_undi_reset_adapter() */
904 struct s_PXENV_UNDI_RESET {
905 PXENV_STATUS_t Status; /**< PXE status code */
906 /** Multicast MAC addresses */
907 struct s_PXENV_UNDI_MCAST_ADDRESS R_Mcast_Buf;
908 } __attribute__ (( packed ));
910 typedef struct s_PXENV_UNDI_RESET PXENV_UNDI_RESET_t;
912 /** @} */ /* pxenv_undi_reset_adapter */
914 /** @defgroup pxenv_undi_shutdown PXENV_UNDI_SHUTDOWN
921 /** PXE API function code for pxenv_undi_shutdown() */
922 #define PXENV_UNDI_SHUTDOWN 0x0005
924 /** Parameter block for pxenv_undi_shutdown() */
925 struct s_PXENV_UNDI_SHUTDOWN {
926 PXENV_STATUS_t Status; /**< PXE status code */
927 } __attribute__ (( packed ));
929 typedef struct s_PXENV_UNDI_SHUTDOWN PXENV_UNDI_SHUTDOWN_t;
931 /** @} */ /* pxenv_undi_shutdown */
933 /** @defgroup pxenv_undi_open PXENV_UNDI_OPEN
940 /** PXE API function code for pxenv_undi_open() */
941 #define PXENV_UNDI_OPEN 0x0006
943 /** Accept "directed" packets
945 * These are packets addresses to either this adapter's MAC address or
946 * to any of the configured multicast MAC addresses (see
947 * #s_PXENV_UNDI_MCAST_ADDRESS).
949 #define FLTR_DIRECTED 0x0001
950 /** Accept broadcast packets */
951 #define FLTR_BRDCST 0x0002
952 /** Accept all packets; listen in promiscuous mode */
953 #define FLTR_PRMSCS 0x0004
954 /** Accept source-routed packets */
955 #define FLTR_SRC_RTG 0x0008
957 /** Parameter block for pxenv_undi_open() */
958 struct s_PXENV_UNDI_OPEN {
959 PXENV_STATUS_t Status; /**< PXE status code */
960 /** Open flags as defined in NDIS 2.0
962 * This is the OpenOptions field as passed to the NDIS 2.0
963 * OpenAdapter() API call. It is defined to be "adapter
964 * specific", though 0 is guaranteed to be a valid value.
967 /** Receive packet filter
969 * This is the bitwise-OR of any of the following flags:
970 * #FLTR_DIRECTED, #FLTR_BRDCST, #FLTR_PRMSCS and
974 /** Multicast MAC addresses */
975 struct s_PXENV_UNDI_MCAST_ADDRESS R_Mcast_Buf;
976 } __attribute__ (( packed ));
978 typedef struct s_PXENV_UNDI_OPEN PXENV_UNDI_OPEN_t;
980 /** @} */ /* pxenv_undi_open */
982 /** @defgroup pxenv_undi_close PXENV_UNDI_CLOSE
989 /** PXE API function code for pxenv_undi_close() */
990 #define PXENV_UNDI_CLOSE 0x0007
992 /** Parameter block for pxenv_undi_close() */
993 struct s_PXENV_UNDI_CLOSE {
994 PXENV_STATUS_t Status; /**< PXE status code */
995 } __attribute__ (( packed ));
997 typedef struct s_PXENV_UNDI_CLOSE PXENV_UNDI_CLOSE_t;
999 /** @} */ /* pxenv_undi_close */
1001 /** @defgroup pxenv_undi_transmit PXENV_UNDI_TRANSMIT
1003 * UNDI TRANSMIT PACKET
1008 /** PXE API function code for pxenv_undi_transmit() */
1009 #define PXENV_UNDI_TRANSMIT 0x0008
1011 #define P_UNKNOWN 0 /**< Media header already filled in */
1012 #define P_IP 1 /**< IP protocol */
1013 #define P_ARP 2 /**< ARP protocol */
1014 #define P_RARP 3 /**< RARP protocol */
1015 #define P_OTHER 4 /**< Other protocol */
1017 #define XMT_DESTADDR 0x0000 /**< Unicast packet */
1018 #define XMT_BROADCAST 0x0001 /**< Broadcast packet */
1020 /** Maximum number of data blocks in a transmit buffer descriptor */
1021 #define MAX_DATA_BLKS 8
1023 /** A transmit buffer descriptor, as pointed to by s_PXENV_UNDI_TRANSMIT::TBD
1025 struct s_PXENV_UNDI_TBD {
1026 UINT16_t ImmedLength; /**< Length of the transmit buffer */
1027 SEGOFF16_t Xmit; /**< Address of the transmit buffer */
1028 UINT16_t DataBlkCount;
1029 /** Array of up to #MAX_DATA_BLKS additional transmit buffers */
1033 * A value of 0 would indicate that #TDDataPtr were an
1034 * #ADDR32_t rather than a #SEGOFF16_t. The PXE
1035 * specification version 2.1 explicitly states that
1036 * this is not supported; #TDDataPtr will always be a
1040 UINT8_t TDRsvdByte; /**< Must be zero */
1041 UINT16_t TDDataLen; /**< Length of this transmit buffer */
1042 SEGOFF16_t TDDataPtr; /**< Address of this transmit buffer */
1043 } DataBlock[MAX_DATA_BLKS];
1044 } __attribute__ (( packed ));
1046 typedef struct s_PXENV_UNDI_TBD PXENV_UNDI_TBD_t;
1048 /** Parameter block for pxenv_undi_transmit() */
1049 struct s_PXENV_UNDI_TRANSMIT {
1050 PXENV_STATUS_t Status; /**< PXE status code */
1053 * Valid values are #P_UNKNOWN, #P_IP, #P_ARP or #P_RARP. If
1054 * the caller has already filled in the media header, this
1055 * field must be set to #P_UNKNOWN.
1058 /** Unicast/broadcast flag
1060 * Valid values are #XMT_DESTADDR or #XMT_BROADCAST.
1063 SEGOFF16_t DestAddr; /**< Destination MAC address */
1064 /** Address of the Transmit Buffer Descriptor
1066 * This is a pointer to a struct s_PXENV_UNDI_TBD.
1069 UINT32_t Reserved[2]; /**< Must be zero */
1070 } __attribute__ (( packed ));
1072 typedef struct s_PXENV_UNDI_TRANSMIT PXENV_UNDI_TRANSMIT_t;
1074 /** @} */ /* pxenv_undi_transmit */
1076 /** @defgroup pxenv_undi_set_mcast_address PXENV_UNDI_SET_MCAST_ADDRESS
1078 * UNDI SET MULTICAST ADDRESS
1083 /** PXE API function code for pxenv_undi_set_mcast_address() */
1084 #define PXENV_UNDI_SET_MCAST_ADDRESS 0x0009
1086 /** Parameter block for pxenv_undi_set_mcast_address() */
1087 struct s_PXENV_UNDI_SET_MCAST_ADDRESS {
1088 PXENV_STATUS_t Status; /**< PXE status code */
1089 /** List of multicast addresses */
1090 struct s_PXENV_UNDI_MCAST_ADDRESS R_Mcast_Buf;
1091 } __attribute__ (( packed ));
1093 typedef struct s_PXENV_UNDI_SET_MCAST_ADDRESS PXENV_UNDI_SET_MCAST_ADDRESS_t;
1095 /** @} */ /* pxenv_undi_set_mcast_address */
1097 /** @defgroup pxenv_undi_set_station_address PXENV_UNDI_SET_STATION_ADDRESS
1099 * UNDI SET STATION ADDRESS
1104 /** PXE API function code for pxenv_undi_set_station_address() */
1105 #define PXENV_UNDI_SET_STATION_ADDRESS 0x000a
1107 /** Parameter block for pxenv_undi_set_station_address() */
1108 struct s_PXENV_UNDI_SET_STATION_ADDRESS {
1109 PXENV_STATUS_t Status; /**< PXE status code */
1110 MAC_ADDR_t StationAddress; /**< Station MAC address */
1111 } __attribute__ (( packed ));
1113 typedef struct s_PXENV_UNDI_SET_STATION_ADDRESS PXENV_UNDI_SET_STATION_ADDRESS_t;
1115 /** @} */ /* pxenv_undi_set_station_address */
1117 /** @defgroup pxenv_undi_set_packet_filter PXENV_UNDI_SET_PACKET_FILTER
1119 * UNDI SET PACKET FILTER
1124 /** PXE API function code for pxenv_undi_set_packet_filter() */
1125 #define PXENV_UNDI_SET_PACKET_FILTER 0x000b
1127 /** Parameter block for pxenv_undi_set_packet_filter() */
1128 struct s_PXENV_UNDI_SET_PACKET_FILTER {
1129 PXENV_STATUS_t Status; /**< PXE status code */
1130 /** Receive packet filter
1132 * This field takes the same values as
1133 * s_PXENV_UNDI_OPEN::PktFilter.
1135 * @note Yes, this field is a different size to
1136 * s_PXENV_UNDI_OPEN::PktFilter. Blame "the managers at Intel
1137 * who apparently let a consultant come up with the spec
1138 * without any kind of adult supervision" (quote from hpa).
1141 } __attribute__ (( packed ));
1143 typedef struct s_PXENV_UNDI_SET_PACKET_FILTER PXENV_UNDI_SET_PACKET_FILTER_t;
1145 /** @} */ /* pxenv_undi_set_packet_filter */
1147 /** @defgroup pxenv_undi_get_information PXENV_UNDI_GET_INFORMATION
1149 * UNDI GET INFORMATION
1154 /** PXE API function code for pxenv_undi_get_information() */
1155 #define PXENV_UNDI_GET_INFORMATION 0x000c
1157 #define ETHER_TYPE 1 /**< Ethernet (10Mb) */
1158 #define EXP_ETHER_TYPE 2 /**< Experimental Ethernet (3Mb) */
1159 #define AX25_TYPE 3 /**< Amateur Radio AX.25 */
1160 #define TOKEN_RING_TYPE 4 /**< Proteon ProNET Token Ring */
1161 #define CHAOS_TYPE 5 /**< Chaos */
1162 #define IEEE_TYPE 6 /**< IEEE 802 Networks */
1163 #define ARCNET_TYPE 7 /**< ARCNET */
1165 /** Parameter block for pxenv_undi_get_information() */
1166 struct s_PXENV_UNDI_GET_INFORMATION {
1167 PXENV_STATUS_t Status; /**< PXE status code */
1168 UINT16_t BaseIo; /**< I/O base address */
1169 UINT16_t IntNumber; /**< IRQ number */
1170 UINT16_t MaxTranUnit; /**< Adapter MTU */
1173 * Valid values are defined in RFC1010 ("Assigned numbers"),
1174 * and are #ETHER_TYPE, #EXP_ETHER_TYPE, #AX25_TYPE,
1175 * #TOKEN_RING_TYPE, #CHAOS_TYPE, #IEEE_TYPE or #ARCNET_TYPE.
1178 UINT16_t HwAddrLen; /**< MAC address length */
1179 MAC_ADDR_t CurrentNodeAddress; /**< Current MAC address */
1180 MAC_ADDR_t PermNodeAddress; /**< Permanent (EEPROM) MAC address */
1181 SEGSEL_t ROMAddress; /**< Real-mode ROM segment address */
1182 UINT16_t RxBufCt; /**< Receive queue length */
1183 UINT16_t TxBufCt; /**< Transmit queue length */
1184 } __attribute__ (( packed ));
1186 typedef struct s_PXENV_UNDI_GET_INFORMATION PXENV_UNDI_GET_INFORMATION_t;
1188 /** @} */ /* pxenv_undi_get_information */
1190 /** @defgroup pxenv_undi_get_statistics PXENV_UNDI_GET_STATISTICS
1192 * UNDI GET STATISTICS
1197 /** PXE API function code for pxenv_undi_get_statistics() */
1198 #define PXENV_UNDI_GET_STATISTICS 0x000d
1200 /** Parameter block for pxenv_undi_get_statistics() */
1201 struct s_PXENV_UNDI_GET_STATISTICS {
1202 PXENV_STATUS_t Status; /**< PXE status code */
1203 UINT32_t XmtGoodFrames; /**< Successful transmission count */
1204 UINT32_t RcvGoodFrames; /**< Successful reception count */
1205 UINT32_t RcvCRCErrors; /**< Receive CRC error count */
1206 UINT32_t RcvResourceErrors; /**< Receive queue overflow count */
1207 } __attribute__ (( packed ));
1209 typedef struct s_PXENV_UNDI_GET_STATISTICS PXENV_UNDI_GET_STATISTICS_t;
1211 /** @} */ /* pxenv_undi_get_statistics */
1213 /** @defgroup pxenv_undi_clear_statistics PXENV_UNDI_CLEAR_STATISTICS
1215 * UNDI CLEAR STATISTICS
1220 /** PXE API function code for pxenv_undi_clear_statistics() */
1221 #define PXENV_UNDI_CLEAR_STATISTICS 0x000e
1223 /** Parameter block for pxenv_undi_clear_statistics() */
1224 struct s_PXENV_UNDI_CLEAR_STATISTICS {
1225 PXENV_STATUS_t Status; /**< PXE status code */
1226 } __attribute__ (( packed ));
1228 typedef struct s_PXENV_UNDI_CLEAR_STATISTICS PXENV_UNDI_CLEAR_STATISTICS_t;
1230 /** @} */ /* pxenv_undi_clear_statistics */
1232 /** @defgroup pxenv_undi_initiate_diags PXENV_UNDI_INITIATE_DIAGS
1234 * UNDI INITIATE DIAGS
1239 /** PXE API function code for pxenv_undi_initiate_diags() */
1240 #define PXENV_UNDI_INITIATE_DIAGS 0x000f
1242 /** Parameter block for pxenv_undi_initiate_diags() */
1243 struct s_PXENV_UNDI_INITIATE_DIAGS {
1244 PXENV_STATUS_t Status; /**< PXE status code */
1245 } __attribute__ (( packed ));
1247 typedef struct s_PXENV_UNDI_INITIATE_DIAGS PXENV_UNDI_INITIATE_DIAGS_t;
1249 /** @} */ /* pxenv_undi_initiate_diags */
1251 /** @defgroup pxenv_undi_force_interrupt PXENV_UNDI_FORCE_INTERRUPT
1253 * UNDI FORCE INTERRUPT
1258 /** PXE API function code for pxenv_undi_force_interrupt() */
1259 #define PXENV_UNDI_FORCE_INTERRUPT 0x0010
1261 /** Parameter block for pxenv_undi_force_interrupt() */
1262 struct s_PXENV_UNDI_FORCE_INTERRUPT {
1263 PXENV_STATUS_t Status; /**< PXE status code */
1264 } __attribute__ (( packed ));
1266 typedef struct s_PXENV_UNDI_FORCE_INTERRUPT PXENV_UNDI_FORCE_INTERRUPT_t;
1268 /** @} */ /* pxenv_undi_force_interrupt */
1270 /** @defgroup pxenv_undi_get_mcast_address PXENV_UNDI_GET_MCAST_ADDRESS
1272 * UNDI GET MULTICAST ADDRESS
1277 /** PXE API function code for pxenv_undi_get_mcast_address() */
1278 #define PXENV_UNDI_GET_MCAST_ADDRESS 0x0011
1280 /** Parameter block for pxenv_undi_get_mcast_address() */
1281 struct s_PXENV_UNDI_GET_MCAST_ADDRESS {
1282 PXENV_STATUS_t Status; /**< PXE status code */
1283 IP4_t InetAddr; /**< Multicast IP address */
1284 MAC_ADDR_t MediaAddr; /**< Multicast MAC address */
1285 } __attribute__ (( packed ));
1287 typedef struct s_PXENV_UNDI_GET_MCAST_ADDRESS PXENV_UNDI_GET_MCAST_ADDRESS_t;
1289 /** @} */ /* pxenv_undi_get_mcast_address */
1291 /** @defgroup pxenv_undi_get_nic_type PXENV_UNDI_GET_NIC_TYPE
1298 /** PXE API function code for pxenv_undi_get_nic_type() */
1299 #define PXENV_UNDI_GET_NIC_TYPE 0x0012
1301 #define PCI_NIC 2 /**< PCI network card */
1302 #define PnP_NIC 3 /**< ISAPnP network card */
1303 #define CardBus_NIC 4 /**< CardBus network card */
1305 /** Information for a PCI or equivalent NIC */
1306 struct pci_nic_info {
1307 UINT16_t Vendor_ID; /**< PCI vendor ID */
1308 UINT16_t Dev_ID; /**< PCI device ID */
1309 UINT8_t Base_Class; /**< PCI base class */
1310 UINT8_t Sub_Class; /**< PCI sub class */
1311 UINT8_t Prog_Intf; /**< PCI programming interface */
1312 UINT8_t Rev; /**< PCI revision */
1313 UINT16_t BusDevFunc; /**< PCI bus:dev:fn address */
1314 UINT16_t SubVendor_ID; /**< PCI subvendor ID */
1315 UINT16_t SubDevice_ID; /**< PCI subdevice ID */
1316 } __attribute__ (( packed ));
1318 /** Information for an ISAPnP or equivalent NIC */
1319 struct pnp_nic_info {
1320 UINT32_t EISA_Dev_ID; /**< EISA device ID */
1321 UINT8_t Base_Class; /**< Base class */
1322 UINT8_t Sub_Class; /**< Sub class */
1323 UINT8_t Prog_Intf; /**< Programming interface */
1324 /** Card Select Number assigned to card */
1325 UINT16_t CardSelNum;
1326 } __attribute__ (( packed ));
1328 /** Parameter block for pxenv_undi_get_nic_type() */
1329 struct s_PXENV_UNDI_GET_NIC_TYPE {
1330 PXENV_STATUS_t Status; /**< PXE status code */
1333 * Valid values are #PCI_NIC, #PnP_NIC or #CardBus_NIC.
1336 /** NIC information */
1337 union nic_type_info {
1338 /** NIC information (if #NicType==#PCI_NIC) */
1339 struct pci_nic_info pci;
1340 /** NIC information (if #NicType==#CardBus_NIC) */
1341 struct pci_nic_info cardbus;
1342 /** NIC information (if #NicType==#PnP_NIC) */
1343 struct pnp_nic_info pnp;
1345 } __attribute__ (( packed ));
1347 typedef struct s_PXENV_UNDI_GET_NIC_TYPE PXENV_UNDI_GET_NIC_TYPE_t;
1349 /** @} */ /* pxenv_undi_get_nic_type */
1351 /** @defgroup pxenv_undi_get_iface_info PXENV_UNDI_GET_IFACE_INFO
1353 * UNDI GET IFACE INFO
1358 /** PXE API function code for pxenv_undi_get_iface_info() */
1359 #define PXENV_UNDI_GET_IFACE_INFO 0x0013
1361 /** Broadcast supported */
1362 #define SUPPORTED_BROADCAST 0x0001
1363 /** Multicast supported */
1364 #define SUPPORTED_MULTICAST 0x0002
1365 /** Functional/group addressing supported */
1366 #define SUPPORTED_GROUP 0x0004
1367 /** Promiscuous mode supported */
1368 #define SUPPORTED_PROMISCUOUS 0x0008
1369 /** Software settable station address */
1370 #define SUPPORTED_SET_STATION_ADDRESS 0x0010
1371 /** InitiateDiagnostics supported */
1372 #define SUPPORTED_DIAGNOSTICS 0x0040
1373 /** Reset MAC supported */
1374 #define SUPPORTED_RESET 0x0400
1375 /** Open / Close Adapter supported */
1376 #define SUPPORTED_OPEN_CLOSE 0x0800
1377 /** Interrupt Request supported */
1378 #define SUPPORTED_IRQ 0x1000
1380 /** Parameter block for pxenv_undi_get_iface_info() */
1381 struct s_PXENV_UNDI_GET_IFACE_INFO {
1382 PXENV_STATUS_t Status; /**< PXE status code */
1385 * This is defined in the NDIS 2.0 specification to be one of
1386 * the strings "802.3", "802.4", "802.5", "802.6", "DIX",
1387 * "DIX+802.3", "APPLETALK", "ARCNET", "FDDI", "SDLC", "BSC",
1388 * "HDLC", or "ISDN".
1390 * "Normal" Ethernet, for various historical reasons, is
1393 UINT8_t IfaceType[16];
1394 UINT32_t LinkSpeed; /**< Link speed, in bits per second */
1397 * These are the "service flags" defined in the "MAC
1398 * Service-Specific Characteristics" table in the NDIS 2.0
1399 * specification. Almost all of them are irrelevant to PXE.
1401 UINT32_t ServiceFlags;
1402 UINT32_t Reserved[4]; /**< Must be zero */
1403 } __attribute__ (( packed ));
1405 typedef struct s_PXENV_UNDI_GET_IFACE_INFO PXENV_UNDI_GET_IFACE_INFO_t;
1407 /** @} */ /* pxenv_undi_get_iface_info */
1409 /** @defgroup pxenv_undi_get_state PXENV_UNDI_GET_STATE
1416 /** PXE API function code for pxenv_undi_get_state() */
1417 #define PXENV_UNDI_GET_STATE 0x0015
1419 /** pxenv_start_undi() has been called */
1420 #define PXE_UNDI_GET_STATE_STARTED 1
1421 /** pxenv_undi_initialize() has been called */
1422 #define PXE_UNDI_GET_STATE_INITIALIZED 2
1423 /** pxenv_undi_open() has been called */
1424 #define PXE_UNDI_GET_STATE_OPENED 3
1426 /** Parameter block for pxenv_undi_get_state() */
1427 struct s_PXENV_UNDI_GET_STATE {
1428 PXENV_STATUS_t Status; /**< PXE status code */
1429 /** Current state of the UNDI driver
1431 * Valid values are #PXE_UNDI_GET_STATE_STARTED,
1432 * #PXE_UNDI_GET_STATE_INITIALIZED or
1433 * #PXE_UNDI_GET_STATE_OPENED.
1436 } __attribute__ (( packed ));
1438 typedef struct s_PXENV_UNDI_GET_STATE PXENV_UNDI_GET_STATE_t;
1440 /** @} */ /* pxenv_undi_get_state */
1442 /** @defgroup pxenv_undi_isr PXENV_UNDI_ISR
1449 /** PXE API function code for pxenv_undi_isr() */
1450 #define PXENV_UNDI_ISR 0x0014
1452 /** Determine whether or not this is our interrupt */
1453 #define PXENV_UNDI_ISR_IN_START 1
1454 /** Start processing interrupt */
1455 #define PXENV_UNDI_ISR_IN_PROCESS 2
1456 /** Continue processing interrupt */
1457 #define PXENV_UNDI_ISR_IN_GET_NEXT 3
1458 /** This interrupt was ours */
1459 #define PXENV_UNDI_ISR_OUT_OURS 0
1460 /** This interrupt was not ours */
1461 #define PXENV_UNDI_ISR_OUT_NOT_OURS 1
1462 /** Finished processing interrupt */
1463 #define PXENV_UNDI_ISR_OUT_DONE 0
1464 /** A packet transmission has completed */
1465 #define PXENV_UNDI_ISR_OUT_TRANSMIT 2
1466 /** A packet has been received */
1467 #define PXENV_UNDI_ISR_OUT_RECEIVE 3
1468 /** We are already in the middle of processing an interrupt */
1469 #define PXENV_UNDI_ISR_OUT_BUSY 4
1471 /** Unicast packet (or packet captured in promiscuous mode) */
1472 #define P_DIRECTED 0
1473 /** Broadcast packet */
1474 #define P_BROADCAST 1
1475 /** Multicast packet */
1476 #define P_MULTICAST 2
1478 /** Parameter block for pxenv_undi_isr() */
1479 struct s_PXENV_UNDI_ISR {
1480 PXENV_STATUS_t Status; /**< PXE status code */
1483 * Valid values are #PXENV_UNDI_ISR_IN_START,
1484 * #PXENV_UNDI_ISR_IN_PROCESS, #PXENV_UNDI_ISR_IN_GET_NEXT,
1485 * #PXENV_UNDI_ISR_OUT_OURS, #PXENV_UNDI_ISR_OUT_NOT_OURS,
1486 * #PXENV_UNDI_ISR_OUT_DONE, #PXENV_UNDI_ISR_OUT_TRANSMIT,
1487 * #PXENV_UNDI_ISR_OUT_RECEIVE or #PXENV_UNDI_ISR_OUT_BUSY.
1490 UINT16_t BufferLength; /**< Data buffer length */
1491 UINT16_t FrameLength; /**< Total frame length */
1492 UINT16_t FrameHeaderLength; /**< Frame header length */
1493 SEGOFF16_t Frame; /**< Data buffer address */
1496 * Valid values are #P_IP, #P_ARP, #P_RARP or #P_OTHER.
1501 * Valid values are #P_DIRECTED, #P_BROADCAST or #P_MULTICAST.
1504 } __attribute__ (( packed ));
1506 typedef struct s_PXENV_UNDI_ISR PXENV_UNDI_ISR_t;
1508 /** @} */ /* pxenv_undi_isr */
1510 /** @} */ /* pxe_undi_api */
1512 /** @defgroup pxe_file_api PXE FILE API
1514 * POSIX-like file operations
1519 /** Minimum possible opcode used within PXE FILE API */
1520 #define PXENV_FILE_MIN 0x00e0
1522 /** Minimum possible opcode used within PXE FILE API */
1523 #define PXENV_FILE_MAX 0x00ef
1525 /** @defgroup pxenv_file_open PXENV_FILE_OPEN
1532 /** PXE API function code for pxenv_file_open() */
1533 #define PXENV_FILE_OPEN 0x00e0
1535 /** Parameter block for pxenv_file_open() */
1536 struct s_PXENV_FILE_OPEN {
1537 PXENV_STATUS_t Status; /**< PXE status code */
1538 UINT16_t FileHandle; /**< File handle */
1539 SEGOFF16_t FileName; /**< File URL */
1540 UINT32_t Reserved; /**< Reserved */
1541 } __attribute__ (( packed ));
1543 typedef struct s_PXENV_FILE_OPEN PXENV_FILE_OPEN_t;
1545 /** @} */ /* pxenv_file_open */
1547 /** @defgroup pxenv_file_close PXENV_FILE_CLOSE
1554 /** PXE API function code for pxenv_file_close() */
1555 #define PXENV_FILE_CLOSE 0x00e1
1557 /** Parameter block for pxenv_file_close() */
1558 struct s_PXENV_FILE_CLOSE {
1559 PXENV_STATUS_t Status; /**< PXE status code */
1560 UINT16_t FileHandle; /**< File handle */
1561 } __attribute__ (( packed ));
1563 typedef struct s_PXENV_FILE_CLOSE PXENV_FILE_CLOSE_t;
1565 /** @} */ /* pxenv_file_close */
1567 /** @defgroup pxenv_file_select PXENV_FILE_SELECT
1574 /** PXE API function code for pxenv_file_select() */
1575 #define PXENV_FILE_SELECT 0x00e2
1577 /** File is ready for reading */
1578 #define RDY_READ 0x0001
1580 /** Parameter block for pxenv_file_select() */
1581 struct s_PXENV_FILE_SELECT {
1582 PXENV_STATUS_t Status; /**< PXE status code */
1583 UINT16_t FileHandle; /**< File handle */
1584 UINT16_t Ready; /**< Indication of readiness */
1585 } __attribute__ (( packed ));
1587 typedef struct s_PXENV_FILE_SELECT PXENV_FILE_SELECT_t;
1589 /** @} */ /* pxenv_file_select */
1591 /** @defgroup pxenv_file_read PXENV_FILE_READ
1598 /** PXE API function code for pxenv_file_read() */
1599 #define PXENV_FILE_READ 0x00e3
1601 /** Parameter block for pxenv_file_read() */
1602 struct s_PXENV_FILE_READ {
1603 PXENV_STATUS_t Status; /**< PXE status code */
1604 UINT16_t FileHandle; /**< File handle */
1605 UINT16_t BufferSize; /**< Data buffer size */
1606 SEGOFF16_t Buffer; /**< Data buffer */
1607 } __attribute__ (( packed ));
1609 typedef struct s_PXENV_FILE_READ PXENV_FILE_READ_t;
1611 /** @} */ /* pxenv_file_read */
1613 /** @defgroup pxenv_get_file_size PXENV_GET_FILE_SIZE
1620 /** PXE API function code for pxenv_get_file_size() */
1621 #define PXENV_GET_FILE_SIZE 0x00e4
1623 /** Parameter block for pxenv_get_file_size() */
1624 struct s_PXENV_GET_FILE_SIZE {
1625 PXENV_STATUS_t Status; /**< PXE status code */
1626 UINT16_t FileHandle; /**< File handle */
1627 UINT32_t FileSize; /**< File size */
1628 } __attribute__ (( packed ));
1630 typedef struct s_PXENV_GET_FILE_SIZE PXENV_GET_FILE_SIZE_t;
1632 /** @} */ /* pxenv_get_file_size */
1634 /** @defgroup pxenv_file_exec PXENV_FILE_EXEC
1641 /** PXE API function code for pxenv_file_exec() */
1642 #define PXENV_FILE_EXEC 0x00e5
1644 /** Parameter block for pxenv_file_exec() */
1645 struct s_PXENV_FILE_EXEC {
1646 PXENV_STATUS_t Status; /**< PXE status code */
1647 SEGOFF16_t Command; /**< Command to execute */
1648 } __attribute__ (( packed ));
1650 typedef struct s_PXENV_FILE_EXEC PXENV_FILE_EXEC_t;
1652 /** @} */ /* pxenv_file_exec */
1654 /** @defgroup pxenv_file_api_check PXENV_FILE_API_CHECK
1661 /** PXE API function code for pxenv_file_api_check() */
1662 #define PXENV_FILE_API_CHECK 0x00e6
1664 /** Parameter block for pxenv_file_api_check() */
1665 struct s_PXENV_FILE_API_CHECK {
1666 PXENV_STATUS_t Status; /**< PXE status code */
1667 UINT16_t Size; /**< Size of structure */
1668 UINT32_t Magic; /**< Magic number */
1669 UINT32_t Provider; /**< Implementation identifier */
1670 UINT32_t APIMask; /**< Supported API functions */
1671 UINT32_t Flags; /**< Reserved for the future */
1672 } __attribute__ (( packed ));
1674 typedef struct s_PXENV_FILE_API_CHECK PXENV_FILE_API_CHECK_t;
1676 /** @} */ /* pxenv_file_api_check */
1678 /** @defgroup pxenv_file_exit_hook PXENV_FILE_EXIT_HOOK
1685 /** PXE API function code for pxenv_file_exit_hook() */
1686 #define PXENV_FILE_EXIT_HOOK 0x00e7
1688 /** Parameter block for pxenv_file_exit_hook() */
1689 struct s_PXENV_FILE_EXIT_HOOK {
1690 PXENV_STATUS_t Status; /**< PXE status code */
1691 SEGOFF16_t Hook; /**< SEG16:OFF16 to jump to */
1692 } __attribute__ (( packed ));
1694 typedef struct s_PXENV_FILE_EXIT_HOOK PXENV_FILE_EXIT_HOOK_t;
1696 /** @} */ /* pxenv_file_exit_hook */
1698 /** @defgroup pxenv_file_cmdline PXENV_FILE_CMDLINE
1705 /** PXE API function code for pxenv_file_cmdline() */
1706 #define PXENV_FILE_CMDLINE 0x00e8
1708 /** Parameter block for pxenv_file_cmdline() */
1709 struct s_PXENV_FILE_CMDLINE {
1710 PXENV_STATUS_t Status; /**< PXE status code */
1711 UINT16_t BufferSize; /**< Data buffer size */
1712 SEGOFF16_t Buffer; /**< Data buffer */
1713 } __attribute__ (( packed ));
1715 typedef struct s_PXENV_FILE_CMDLINE PXENV_FILE_CMDLINE_t;
1717 /** @} */ /* pxe_file_cmdline */
1719 /** @} */ /* pxe_file_api */
1721 /** @defgroup pxe_loader_api PXE Loader API
1723 * The UNDI ROM loader API
1728 /** Parameter block for undi_loader() */
1729 struct s_UNDI_LOADER {
1730 /** PXE status code */
1731 PXENV_STATUS_t Status;
1732 /** %ax register as for PXENV_START_UNDI */
1734 /** %bx register as for PXENV_START_UNDI */
1736 /** %dx register as for PXENV_START_UNDI */
1738 /** %di register as for PXENV_START_UNDI */
1740 /** %es register as for PXENV_START_UNDI */
1742 /** UNDI data segment
1744 * @note The PXE specification defines the type of this field
1745 * as #UINT16_t. For x86, #SEGSEL_t and #UINT16_t are
1746 * equivalent anyway; for other architectures #SEGSEL_t makes
1750 /** UNDI code segment
1752 * @note The PXE specification defines the type of this field
1753 * as #UINT16_t. For x86, #SEGSEL_t and #UINT16_t are
1754 * equivalent anyway; for other architectures #SEGSEL_t makes
1758 /** Address of the !PXE structure (a struct s_PXE) */
1760 /** Address of the PXENV+ structure (a struct s_PXENV) */
1761 SEGOFF16_t PXENVptr;
1762 } __attribute__ (( packed ));
1764 typedef struct s_UNDI_LOADER UNDI_LOADER_t;
1766 /** @} */ /* pxe_loader_api */
1770 /** @page pxe_notes Etherboot PXE implementation notes
1772 @section pxe_routing IP routing
1774 Several PXE API calls (e.g. pxenv_tftp_open() and pxenv_udp_write())
1775 allow for the caller to specify a "relay agent IP address", often in a
1776 field called "gateway" or similar. The PXE specification states that
1777 "The IP layer should provide space for a minimum of four routing
1778 entries obtained from the default router and static route DHCP option
1779 tags in the DHCPACK message, plus any non-zero giaddr field from the
1780 DHCPOFFER message(s) accepted by the client".
1782 The DHCP static route option ("option static-routes" in dhcpd.conf)
1783 works only for classed IP routing (i.e. it provides no way to specify
1784 a subnet mask). Since virtually everything now uses classless IP
1785 routing, the DHCP static route option is almost totally useless, and
1786 is (according to the dhcp-options man page) not implemented by any of
1787 the popular DHCP clients.
1789 This leaves the caller-specified "relay agent IP address", the giaddr
1790 field from the DHCPOFFER message(s) and the default gateway(s)
1791 provided via the routers option ("option routers" in dhcpd.conf) in
1792 the DHCPACK message. Each of these is a default gateway address.
1793 It's a fair bet that the routers option should take priority over the
1794 giaddr field, since the routers option has to be explicitly specified
1795 by the DHCP server operator. Similarly, it's fair to assume that the
1796 caller-specified "relay agent IP address", if present, should take
1797 priority over any other routing table entries.
1799 @bug Etherboot currently ignores all potential sources of routing
1800 information other than the first router provided to it by a DHCP
1803 @section pxe_x86_modes x86 processor mode restrictions
1805 On the x86 platform, different PXE API calls have different
1806 restrictions on the processor modes (real or protected) that can be
1807 used. See the individual API call descriptions for the restrictions
1808 that apply to any particular call.
1810 @subsection pxe_x86_pmode16 Real mode, or protected-mode with 16-bit stack
1812 The PXE specification states that the API function can be called in
1813 protected mode only if the s_PXE::StatusCallout field is set to a
1814 non-zero value, and that the API function cannot be called with a
1815 32-bit stack segment.
1817 Etherboot does not enforce either of these restrictions; they seem (as
1818 with so much of the PXE specification) to be artifacts of the Intel
1823 #endif /* PXE_API_H */