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 * As an alternative, at your option, you may use this file under the
21 * following terms, known as the "MIT license":
23 * Copyright (c) 2005-2009 Michael Brown <mbrown@fensystems.co.uk>
25 * Permission is hereby granted, free of charge, to any person
26 * obtaining a copy of this software and associated documentation
27 * files (the "Software"), to deal in the Software without
28 * restriction, including without limitation the rights to use, copy,
29 * modify, merge, publish, distribute, sublicense, and/or sell copies
30 * of the Software, and to permit persons to whom the Software is
31 * furnished to do so, subject to the following conditions:
33 * The above copyright notice and this permission notice shall be
34 * included in all copies or substantial portions of the Software.
36 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
37 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
38 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
39 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
40 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
41 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
42 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
48 * Preboot eXecution Environment (PXE) API
52 FILE_LICENCE ( GPL2_OR_LATER );
54 #include "pxe_types.h"
56 /** @addtogroup pxe Preboot eXecution Environment (PXE) API
60 /** @defgroup pxe_api_call PXE entry points
62 * PXE entry points and calling conventions
67 /** The PXENV+ structure */
71 * Contains the bytes 'P', 'X', 'E', 'N', 'V', '+'.
76 * MSB is major version number, LSB is minor version number.
77 * If the API version number is 0x0201 or greater, the !PXE
78 * structure pointed to by #PXEPtr should be used instead of
79 * this data structure.
82 UINT8_t Length; /**< Length of this structure */
85 * The byte checksum of this structure (using the length in
86 * #Length) must be zero.
89 SEGOFF16_t RMEntry; /**< Real-mode PXENV+ entry point */
90 /** Protected-mode PXENV+ entry point offset
92 * PXE 2.1 deprecates this entry point. For protected-mode
93 * API calls, use the !PXE structure pointed to by #PXEPtr
97 /** Protected-mode PXENV+ entry point segment selector
99 * PXE 2.1 deprecates this entry point. For protected-mode
100 * API calls, use the !PXE structure pointed to by #PXEPtr
104 SEGSEL_t StackSeg; /**< Stack segment selector */
105 UINT16_t StackSize; /**< Stack segment size */
106 SEGSEL_t BC_CodeSeg; /**< Base-code code segment selector */
107 UINT16_t BC_CodeSize; /**< Base-code code segment size */
108 SEGSEL_t BC_DataSeg; /**< Base-code data segment selector */
109 UINT16_t BC_DataSize; /**< Base-code data segment size */
110 SEGSEL_t UNDIDataSeg; /**< UNDI data segment selector */
111 UINT16_t UNDIDataSize; /**< UNDI data segment size */
112 SEGSEL_t UNDICodeSeg; /**< UNDI code segment selector */
113 UINT16_t UNDICodeSize; /**< UNDI code segment size */
114 /** Address of the !PXE structure
116 * This field is present only if #Version is 0x0201 or
117 * greater. If present, it points to a struct s_PXE.
120 } __attribute__ (( packed ));
122 typedef struct s_PXENV PXENV_t;
124 /** The !PXE structure */
128 * Contains the bytes '!', 'P', 'X', 'E'.
130 UINT8_t Signature[4];
131 UINT8_t StructLength; /**< Length of this structure */
134 * The byte checksum of this structure (using the length in
135 * #StructLength) must be zero.
138 /** Revision of this structure
140 * For PXE version 2.1, this field must be zero.
143 UINT8_t reserved_1; /**< Must be zero */
144 /** Address of the UNDI ROM ID structure
146 * This is a pointer to a struct s_UNDI_ROM_ID.
148 SEGOFF16_t UNDIROMID;
149 /** Address of the Base Code ROM ID structure
151 * This is a pointer to a struct s_BC_ROM_ID.
153 SEGOFF16_t BaseROMID;
154 /** 16-bit !PXE entry point
156 * This is the entry point for either real mode, or protected
157 * mode with a 16-bit stack segment.
159 SEGOFF16_t EntryPointSP;
160 /** 32-bit !PXE entry point
162 * This is the entry point for protected mode with a 32-bit
165 SEGOFF16_t EntryPointESP;
166 /** Status call-out function
168 * @v 0 (if in a time-out loop)
169 * @v n Number of a received TFTP packet
170 * @ret 0 Continue operation
171 * @ret 1 Cancel operation
173 * This function will be called whenever the PXE stack is in
174 * protected mode, is waiting for an event (e.g. a DHCP reply)
175 * and wishes to allow the user to cancel the operation.
176 * Parameters are passed in register %ax; the return value
177 * must also be placed in register %ax. All other registers
178 * and flags @b must be preserved.
180 * In real mode, an internal function (that checks for a
181 * keypress) will be used.
183 * If this field is set to -1, no status call-out function
184 * will be used and consequently the user will not be allowed
185 * to interrupt operations.
187 * @note The PXE specification version 2.1 defines the
188 * StatusCallout field, mentions it 11 times, but nowhere
189 * defines what it actually does or how it gets called.
190 * Fortunately, the WfM specification version 1.1a deigns to
191 * inform us of such petty details.
193 SEGOFF16_t StatusCallout;
194 UINT8_t reserved_2; /**< Must be zero */
195 /** Number of segment descriptors
197 * If this number is greater than 7, the remaining descriptors
198 * follow immediately after #BC_CodeWrite.
201 /** First protected-mode selector
203 * This is the segment selector value for the first segment
204 * assigned to PXE. Protected-mode selectors must be
205 * consecutive, according to the PXE 2.1 specification, though
206 * no reason is given. Each #SEGDESC_t includes a field for
207 * the segment selector, so this information is entirely
210 SEGSEL_t FirstSelector;
211 /** Stack segment descriptor */
213 /** UNDI data segment descriptor */
215 /** UNDI code segment descriptor */
217 /** UNDI writable code segment descriptor */
218 SEGDESC_t UNDICodeWrite;
219 /** Base-code data segment descriptor */
221 /** Base-code code segment descriptor */
223 /** Base-code writable code segment descriptor */
224 SEGDESC_t BC_CodeWrite;
225 } __attribute__ (( packed ));
227 typedef struct s_PXE PXE_t;
229 /** @} */ /* pxe_api_call */
231 /** @defgroup pxe_preboot_api PXE Preboot API
233 * General high-level functions: #PXENV_UNLOAD_STACK, #PXENV_START_UNDI etc.
238 /** @defgroup pxenv_unload_stack PXENV_UNLOAD_STACK
240 * UNLOAD BASE CODE STACK
245 /** PXE API function code for pxenv_unload_stack() */
246 #define PXENV_UNLOAD_STACK 0x0070
248 /** Parameter block for pxenv_unload_stack() */
249 struct s_PXENV_UNLOAD_STACK {
250 PXENV_STATUS_t Status; /**< PXE status code */
251 UINT8_t reserved[10]; /**< Must be zero */
252 } __attribute__ (( packed ));
254 typedef struct s_PXENV_UNLOAD_STACK PXENV_UNLOAD_STACK_t;
256 /** @} */ /* pxenv_unload_stack */
258 /** @defgroup pxenv_get_cached_info PXENV_GET_CACHED_INFO
265 /** PXE API function code for pxenv_get_cached_info() */
266 #define PXENV_GET_CACHED_INFO 0x0071
268 /** The client's DHCPDISCOVER packet */
269 #define PXENV_PACKET_TYPE_DHCP_DISCOVER 1
271 /** The DHCP server's DHCPACK packet */
272 #define PXENV_PACKET_TYPE_DHCP_ACK 2
274 /** The Boot Server's Discover Reply packet
276 * This packet contains DHCP option 60 set to "PXEClient", a valid
277 * boot file name, and may or may not contain MTFTP options.
279 #define PXENV_PACKET_TYPE_CACHED_REPLY 3
281 /** Parameter block for pxenv_get_cached_info() */
282 struct s_PXENV_GET_CACHED_INFO {
283 PXENV_STATUS_t Status; /**< PXE status code */
286 * Valid values are #PXENV_PACKET_TYPE_DHCP_DISCOVER,
287 * #PXENV_PACKET_TYPE_DHCP_ACK or #PXENV_PACKET_TYPE_CACHED_REPLY
290 UINT16_t BufferSize; /**< Buffer size */
291 SEGOFF16_t Buffer; /**< Buffer address */
292 UINT16_t BufferLimit; /**< Maximum buffer size */
293 } __attribute__ (( packed ));
295 typedef struct s_PXENV_GET_CACHED_INFO PXENV_GET_CACHED_INFO_t;
297 #define BOOTP_REQ 1 /**< A BOOTP request packet */
298 #define BOOTP_REP 2 /**< A BOOTP reply packet */
300 /** DHCP broadcast flag
302 * Request a broadcast response (DHCPOFFER or DHCPACK) from the DHCP
305 #define BOOTP_BCAST 0x8000
307 #define VM_RFC1048 0x63825363L /**< DHCP magic cookie */
309 /** Maximum length of DHCP options */
310 #define BOOTP_DHCPVEND 1024
312 /** Format of buffer filled in by pxenv_get_cached_info()
314 * This somewhat convoluted data structure simply describes the layout
315 * of a DHCP packet. Refer to RFC2131 section 2 for a full
321 * Valid values are #BOOTP_REQ and #BOOTP_REP.
324 /** NIC hardware type.
326 * Valid values are as for s_PXENV_UNDI_GET_INFORMATION::HwType.
329 UINT8_t Hardlen; /**< MAC address length */
332 * Zero in packets sent by the client. May be non-zero in
333 * replies from the DHCP server, if the reply comes via a DHCP
337 UINT32_t ident; /**< DHCP transaction id (xid) */
340 * Number of seconds since the client began the DHCP
346 * This is the bitwise-OR of any of the following values:
350 /** Client IP address
352 * Set only if the client already has an IP address.
357 * This is the IP address that the server assigns to the
361 /** Server IP address
363 * This is the IP address of the BOOTP/DHCP server.
366 /** Gateway IP address
368 * This is the IP address of the BOOTP/DHCP relay agent, if
369 * any. It is @b not (necessarily) the address of the default
370 * gateway for routing purposes.
373 MAC_ADDR_t CAddr; /**< Client MAC address */
374 UINT8_t Sname[64]; /**< Server host name */
375 UINT8_t bootfile[128]; /**< Boot file name */
378 * Don't ask. Just laugh. Then burn a copy of the PXE
379 * specification and send Intel an e-mail asking them if
380 * they've figured out what a "union" does in C yet.
382 union bootph_vendor {
383 UINT8_t d[BOOTP_DHCPVEND]; /**< DHCP options */
385 struct bootph_vendor_v {
386 /** DHCP magic cookie
388 * Should have the value #VM_RFC1048.
391 UINT32_t flags; /**< BOOTP flags/opcodes */
392 /** "End of BOOTP vendor extensions"
394 * Abandon hope, all ye who consider the
395 * purpose of this field.
400 } __attribute__ (( packed ));
402 typedef struct bootph BOOTPLAYER_t;
404 /** @} */ /* pxenv_get_cached_info */
406 /** @defgroup pxenv_restart_tftp PXENV_RESTART_TFTP
413 /** PXE API function code for pxenv_restart_tftp() */
414 #define PXENV_RESTART_TFTP 0x0073
416 /** Parameter block for pxenv_restart_tftp() */
417 struct s_PXENV_TFTP_READ_FILE;
419 typedef struct s_PXENV_RESTART_TFTP PXENV_RESTART_TFTP_t;
421 /** @} */ /* pxenv_restart_tftp */
423 /** @defgroup pxenv_start_undi PXENV_START_UNDI
430 /** PXE API function code for pxenv_start_undi() */
431 #define PXENV_START_UNDI 0x0000
433 /** Parameter block for pxenv_start_undi() */
434 struct s_PXENV_START_UNDI {
435 PXENV_STATUS_t Status; /**< PXE status code */
436 /** %ax register as passed to the Option ROM initialisation routine.
438 * For a PCI device, this should contain the bus:dev:fn value
439 * that uniquely identifies the PCI device in the system. For
440 * a non-PCI device, this field is not defined.
443 /** %bx register as passed to the Option ROM initialisation routine.
445 * For an ISAPnP device, this should contain the Card Select
446 * Number assigned to the ISAPnP card. For non-ISAPnP
447 * devices, this should contain 0xffff.
450 /** %dx register as passed to the Option ROM initialisation routine.
452 * For an ISAPnP device, this should contain the ISAPnP Read
453 * Port address as currently set in all ISAPnP cards. If
454 * there are no ISAPnP cards, this should contain 0xffff. (If
455 * this is a non-ISAPnP device, but there are ISAPnP cards in
456 * the system, this value is not well defined.)
459 /** %di register as passed to the Option ROM initialisation routine.
461 * This contains the #OFF16_t portion of a struct #s_SEGOFF16
462 * that points to the System BIOS Plug and Play Installation
463 * Check Structure. (Refer to section 4.4 of the Plug and
464 * Play BIOS specification for a description of this
467 * @note The PXE specification defines the type of this field
468 * as #UINT16_t. For x86, #OFF16_t and #UINT16_t are
469 * equivalent anyway; for other architectures #OFF16_t makes
473 /** %es register as passed to the Option ROM initialisation routine.
475 * This contains the #SEGSEL_t portion of a struct #s_SEGOFF16
476 * that points to the System BIOS Plug and Play Installation
477 * Check Structure. (Refer to section 4.4 of the Plug and
478 * Play BIOS specification for a description of this
481 * @note The PXE specification defines the type of this field
482 * as #UINT16_t. For x86, #SEGSEL_t and #UINT16_t are
483 * equivalent anyway; for other architectures #SEGSEL_t makes
487 } __attribute__ (( packed ));
489 typedef struct s_PXENV_START_UNDI PXENV_START_UNDI_t;
491 /** @} */ /* pxenv_start_undi */
493 /** @defgroup pxenv_stop_undi PXENV_STOP_UNDI
500 /** PXE API function code for pxenv_stop_undi() */
501 #define PXENV_STOP_UNDI 0x0015
503 /** Parameter block for pxenv_stop_undi() */
504 struct s_PXENV_STOP_UNDI {
505 PXENV_STATUS_t Status; /**< PXE status code */
506 } __attribute__ (( packed ));
508 typedef struct s_PXENV_STOP_UNDI PXENV_STOP_UNDI_t;
510 /** @} */ /* pxenv_stop_undi */
512 /** @defgroup pxenv_start_base PXENV_START_BASE
519 /** PXE API function code for pxenv_start_base() */
520 #define PXENV_START_BASE 0x0075
522 /** Parameter block for pxenv_start_base() */
523 struct s_PXENV_START_BASE {
524 PXENV_STATUS_t Status; /**< PXE status code */
525 } __attribute__ (( packed ));
527 typedef struct s_PXENV_START_BASE PXENV_START_BASE_t;
529 /** @} */ /* pxenv_start_base */
531 /** @defgroup pxenv_stop_base PXENV_STOP_BASE
538 /** PXE API function code for pxenv_stop_base() */
539 #define PXENV_STOP_BASE 0x0076
541 /** Parameter block for pxenv_stop_base() */
542 struct s_PXENV_STOP_BASE {
543 PXENV_STATUS_t Status; /**< PXE status code */
544 } __attribute__ (( packed ));
546 typedef struct s_PXENV_STOP_BASE PXENV_STOP_BASE_t;
548 /** @} */ /* pxenv_stop_base */
550 /** @} */ /* pxe_preboot_api */
552 /** @defgroup pxe_tftp_api PXE TFTP API
554 * Download files via TFTP or MTFTP
559 /** @defgroup pxenv_tftp_open PXENV_TFTP_OPEN
566 /** PXE API function code for pxenv_tftp_open() */
567 #define PXENV_TFTP_OPEN 0x0020
569 /** Parameter block for pxenv_tftp_open() */
570 struct s_PXENV_TFTP_OPEN {
571 PXENV_STATUS_t Status; /**< PXE status code */
572 IP4_t ServerIPAddress; /**< TFTP server IP address */
573 IP4_t GatewayIPAddress; /**< Relay agent IP address */
574 UINT8_t FileName[128]; /**< File name */
575 UDP_PORT_t TFTPPort; /**< TFTP server UDP port */
576 /** Requested size of TFTP packets
578 * This is the TFTP "blksize" option. This must be at least
579 * 512, since servers that do not support TFTP options cannot
580 * negotiate blocksizes smaller than this.
583 } __attribute__ (( packed ));
585 typedef struct s_PXENV_TFTP_OPEN PXENV_TFTP_OPEN_t;
587 /** @} */ /* pxenv_tftp_open */
589 /** @defgroup pxenv_tftp_close PXENV_TFTP_CLOSE
596 /** PXE API function code for pxenv_tftp_close() */
597 #define PXENV_TFTP_CLOSE 0x0021
599 /** Parameter block for pxenv_tftp_close() */
600 struct s_PXENV_TFTP_CLOSE {
601 PXENV_STATUS_t Status; /**< PXE status code */
602 } __attribute__ (( packed ));
604 typedef struct s_PXENV_TFTP_CLOSE PXENV_TFTP_CLOSE_t;
606 /** @} */ /* pxenv_tftp_close */
608 /** @defgroup pxenv_tftp_read PXENV_TFTP_READ
615 /** PXE API function code for pxenv_tftp_read() */
616 #define PXENV_TFTP_READ 0x0022
618 /** Parameter block for pxenv_tftp_read() */
619 struct s_PXENV_TFTP_READ {
620 PXENV_STATUS_t Status; /**< PXE status code */
621 UINT16_t PacketNumber; /**< TFTP packet number */
622 UINT16_t BufferSize; /**< Size of data buffer */
623 SEGOFF16_t Buffer; /**< Address of data buffer */
624 } __attribute__ (( packed ));
626 typedef struct s_PXENV_TFTP_READ PXENV_TFTP_READ_t;
628 /** @} */ /* pxenv_tftp_read */
630 /** @defgroup pxenv_tftp_read_file PXENV_TFTP_READ_FILE
632 * TFTP/MTFTP READ FILE
637 /** PXE API function code for pxenv_tftp_read_file() */
638 #define PXENV_TFTP_READ_FILE 0x0023
640 /** Parameter block for pxenv_tftp_read_file() */
641 struct s_PXENV_TFTP_READ_FILE {
642 PXENV_STATUS_t Status; /**< PXE status code */
643 UINT8_t FileName[128]; /**< File name */
644 UINT32_t BufferSize; /**< Size of data buffer */
645 ADDR32_t Buffer; /**< Address of data buffer */
646 IP4_t ServerIPAddress; /**< TFTP server IP address */
647 IP4_t GatewayIPAddress; /**< Relay agent IP address */
648 /** File multicast IP address */
649 IP4_t McastIPAddress;
650 /** Client multicast listening port */
651 UDP_PORT_t TFTPClntPort;
652 /** Server multicast listening port */
653 UDP_PORT_t TFTPSrvPort;
654 /** TFTP open timeout.
656 * This is the timeout for receiving the first DATA or ACK
657 * packets during the MTFTP Listen phase.
659 UINT16_t TFTPOpenTimeOut;
660 /** TFTP reopen timeout.
662 * This is the timeout for receiving an ACK packet while in
663 * the MTFTP Listen phase (when at least one ACK packet has
664 * already been seen).
666 UINT16_t TFTPReopenDelay;
667 } __attribute__ (( packed ));
669 typedef struct s_PXENV_TFTP_READ_FILE PXENV_TFTP_READ_FILE_t;
671 /** @} */ /* pxenv_tftp_read_file */
673 /** @defgroup pxenv_tftp_get_fsize PXENV_TFTP_GET_FSIZE
680 /** PXE API function code for pxenv_tftp_get_fsize() */
681 #define PXENV_TFTP_GET_FSIZE 0x0025
683 /** Parameter block for pxenv_tftp_get_fsize() */
684 struct s_PXENV_TFTP_GET_FSIZE {
685 PXENV_STATUS_t Status; /**< PXE status code */
686 IP4_t ServerIPAddress; /**< TFTP server IP address */
687 IP4_t GatewayIPAddress; /**< Relay agent IP address */
688 UINT8_t FileName[128]; /**< File name */
689 UINT32_t FileSize; /**< Size of the file */
690 } __attribute__ (( packed ));
692 typedef struct s_PXENV_TFTP_GET_FSIZE PXENV_TFTP_GET_FSIZE_t;
694 /** @} */ /* pxenv_tftp_get_fsize */
696 /** @} */ /* pxe_tftp_api */
698 /** @defgroup pxe_udp_api PXE UDP API
700 * Transmit and receive UDP packets
705 /** @defgroup pxenv_udp_open PXENV_UDP_OPEN
712 /** PXE API function code for pxenv_udp_open() */
713 #define PXENV_UDP_OPEN 0x0030
715 /** Parameter block for pxenv_udp_open() */
716 struct s_PXENV_UDP_OPEN {
717 PXENV_STATUS_t Status; /**< PXE status code */
718 IP4_t src_ip; /**< IP address of this station */
719 } __attribute__ (( packed ));
721 typedef struct s_PXENV_UDP_OPEN PXENV_UDP_OPEN_t;
723 /** @} */ /* pxenv_udp_open */
725 /** @defgroup pxenv_udp_close PXENV_UDP_CLOSE
732 /** PXE API function code for pxenv_udp_close() */
733 #define PXENV_UDP_CLOSE 0x0031
735 /** Parameter block for pxenv_udp_close() */
736 struct s_PXENV_UDP_CLOSE {
737 PXENV_STATUS_t Status; /**< PXE status code */
738 } __attribute__ (( packed ));
740 typedef struct s_PXENV_UDP_CLOSE PXENV_UDP_CLOSE_t;
742 /** @} */ /* pxenv_udp_close */
744 /** @defgroup pxenv_udp_write PXENV_UDP_WRITE
751 /** PXE API function code for pxenv_udp_write() */
752 #define PXENV_UDP_WRITE 0x0033
754 /** Parameter block for pxenv_udp_write() */
755 struct s_PXENV_UDP_WRITE {
756 PXENV_STATUS_t Status; /**< PXE status code */
757 IP4_t ip; /**< Destination IP address */
758 IP4_t gw; /**< Relay agent IP address */
759 UDP_PORT_t src_port; /**< Source UDP port */
760 UDP_PORT_t dst_port; /**< Destination UDP port */
761 UINT16_t buffer_size; /**< UDP payload buffer size */
762 SEGOFF16_t buffer; /**< UDP payload buffer address */
763 } __attribute__ (( packed ));
765 typedef struct s_PXENV_UDP_WRITE PXENV_UDP_WRITE_t;
767 /** @} */ /* pxenv_udp_write */
769 /** @defgroup pxenv_udp_read PXENV_UDP_READ
776 /** PXE API function code for pxenv_udp_read() */
777 #define PXENV_UDP_READ 0x0032
779 /** Parameter block for pxenv_udp_read() */
780 struct s_PXENV_UDP_READ {
781 PXENV_STATUS_t Status; /**< PXE status code */
782 IP4_t src_ip; /**< Source IP address */
783 IP4_t dest_ip; /**< Destination IP address */
784 UDP_PORT_t s_port; /**< Source UDP port */
785 UDP_PORT_t d_port; /**< Destination UDP port */
786 UINT16_t buffer_size; /**< UDP payload buffer size */
787 SEGOFF16_t buffer; /**< UDP payload buffer address */
788 } __attribute__ (( packed ));
790 typedef struct s_PXENV_UDP_READ PXENV_UDP_READ_t;
792 /** @} */ /* pxenv_udp_read */
794 /** @} */ /* pxe_udp_api */
796 /** @defgroup pxe_undi_api PXE UNDI API
798 * Direct control of the network interface card
803 /** @defgroup pxenv_undi_startup PXENV_UNDI_STARTUP
810 /** PXE API function code for pxenv_undi_startup() */
811 #define PXENV_UNDI_STARTUP 0x0001
813 #define PXENV_BUS_ISA 0 /**< ISA bus type */
814 #define PXENV_BUS_EISA 1 /**< EISA bus type */
815 #define PXENV_BUS_MCA 2 /**< MCA bus type */
816 #define PXENV_BUS_PCI 3 /**< PCI bus type */
817 #define PXENV_BUS_VESA 4 /**< VESA bus type */
818 #define PXENV_BUS_PCMCIA 5 /**< PCMCIA bus type */
820 /** Parameter block for pxenv_undi_startup() */
821 struct s_PXENV_UNDI_STARTUP {
822 PXENV_STATUS_t Status; /**< PXE status code */
823 } __attribute__ (( packed ));
825 typedef struct s_PXENV_UNDI_STARTUP PXENV_UNDI_STARTUP_t;
827 /** @} */ /* pxenv_undi_startup */
829 /** @defgroup pxenv_undi_cleanup PXENV_UNDI_CLEANUP
836 /** PXE API function code for pxenv_undi_cleanup() */
837 #define PXENV_UNDI_CLEANUP 0x0002
839 /** Parameter block for pxenv_undi_cleanup() */
840 struct s_PXENV_UNDI_CLEANUP {
841 PXENV_STATUS_t Status; /**< PXE status code */
842 } __attribute__ (( packed ));
844 typedef struct s_PXENV_UNDI_CLEANUP PXENV_UNDI_CLEANUP_t;
846 /** @} */ /* pxenv_undi_cleanup */
848 /** @defgroup pxenv_undi_initialize PXENV_UNDI_INITIALIZE
855 /** PXE API function code for pxenv_undi_initialize() */
856 #define PXENV_UNDI_INITIALIZE 0x0003
858 /** Parameter block for pxenv_undi_initialize() */
859 struct s_PXENV_UNDI_INITIALIZE {
860 PXENV_STATUS_t Status; /**< PXE status code */
861 /** NDIS 2.0 configuration information, or NULL
863 * This is a pointer to the data structure returned by the
864 * NDIS 2.0 GetProtocolManagerInfo() API call. The data
865 * structure is documented, in a rather haphazard way, in
866 * section 4-17 of the NDIS 2.0 specification.
868 ADDR32_t ProtocolIni;
869 UINT8_t reserved[8]; /**< Must be zero */
870 } __attribute__ (( packed ));
872 typedef struct s_PXENV_UNDI_INITIALIZE PXENV_UNDI_INITIALIZE_t;
874 /** @} */ /* pxenv_undi_initialize */
876 /** @defgroup pxenv_undi_reset_adapter PXENV_UNDI_RESET_ADAPTER
883 /** PXE API function code for pxenv_undi_reset_adapter() */
884 #define PXENV_UNDI_RESET_ADAPTER 0x0004
886 /** Maximum number of multicast MAC addresses */
887 #define MAXNUM_MCADDR 8
889 /** List of multicast MAC addresses */
890 struct s_PXENV_UNDI_MCAST_ADDRESS {
891 /** Number of multicast MAC addresses */
892 UINT16_t MCastAddrCount;
893 /** List of up to #MAXNUM_MCADDR multicast MAC addresses */
894 MAC_ADDR_t McastAddr[MAXNUM_MCADDR];
895 } __attribute__ (( packed ));
897 typedef struct s_PXENV_UNDI_MCAST_ADDRESS PXENV_UNDI_MCAST_ADDRESS_t;
899 /** Parameter block for pxenv_undi_reset_adapter() */
900 struct s_PXENV_UNDI_RESET {
901 PXENV_STATUS_t Status; /**< PXE status code */
902 /** Multicast MAC addresses */
903 struct s_PXENV_UNDI_MCAST_ADDRESS R_Mcast_Buf;
904 } __attribute__ (( packed ));
906 typedef struct s_PXENV_UNDI_RESET PXENV_UNDI_RESET_t;
908 /** @} */ /* pxenv_undi_reset_adapter */
910 /** @defgroup pxenv_undi_shutdown PXENV_UNDI_SHUTDOWN
917 /** PXE API function code for pxenv_undi_shutdown() */
918 #define PXENV_UNDI_SHUTDOWN 0x0005
920 /** Parameter block for pxenv_undi_shutdown() */
921 struct s_PXENV_UNDI_SHUTDOWN {
922 PXENV_STATUS_t Status; /**< PXE status code */
923 } __attribute__ (( packed ));
925 typedef struct s_PXENV_UNDI_SHUTDOWN PXENV_UNDI_SHUTDOWN_t;
927 /** @} */ /* pxenv_undi_shutdown */
929 /** @defgroup pxenv_undi_open PXENV_UNDI_OPEN
936 /** PXE API function code for pxenv_undi_open() */
937 #define PXENV_UNDI_OPEN 0x0006
939 /** Accept "directed" packets
941 * These are packets addresses to either this adapter's MAC address or
942 * to any of the configured multicast MAC addresses (see
943 * #s_PXENV_UNDI_MCAST_ADDRESS).
945 #define FLTR_DIRECTED 0x0001
946 /** Accept broadcast packets */
947 #define FLTR_BRDCST 0x0002
948 /** Accept all packets; listen in promiscuous mode */
949 #define FLTR_PRMSCS 0x0004
950 /** Accept source-routed packets */
951 #define FLTR_SRC_RTG 0x0008
953 /** Parameter block for pxenv_undi_open() */
954 struct s_PXENV_UNDI_OPEN {
955 PXENV_STATUS_t Status; /**< PXE status code */
956 /** Open flags as defined in NDIS 2.0
958 * This is the OpenOptions field as passed to the NDIS 2.0
959 * OpenAdapter() API call. It is defined to be "adapter
960 * specific", though 0 is guaranteed to be a valid value.
963 /** Receive packet filter
965 * This is the bitwise-OR of any of the following flags:
966 * #FLTR_DIRECTED, #FLTR_BRDCST, #FLTR_PRMSCS and
970 /** Multicast MAC addresses */
971 struct s_PXENV_UNDI_MCAST_ADDRESS R_Mcast_Buf;
972 } __attribute__ (( packed ));
974 typedef struct s_PXENV_UNDI_OPEN PXENV_UNDI_OPEN_t;
976 /** @} */ /* pxenv_undi_open */
978 /** @defgroup pxenv_undi_close PXENV_UNDI_CLOSE
985 /** PXE API function code for pxenv_undi_close() */
986 #define PXENV_UNDI_CLOSE 0x0007
988 /** Parameter block for pxenv_undi_close() */
989 struct s_PXENV_UNDI_CLOSE {
990 PXENV_STATUS_t Status; /**< PXE status code */
991 } __attribute__ (( packed ));
993 typedef struct s_PXENV_UNDI_CLOSE PXENV_UNDI_CLOSE_t;
995 /** @} */ /* pxenv_undi_close */
997 /** @defgroup pxenv_undi_transmit PXENV_UNDI_TRANSMIT
999 * UNDI TRANSMIT PACKET
1004 /** PXE API function code for pxenv_undi_transmit() */
1005 #define PXENV_UNDI_TRANSMIT 0x0008
1007 #define P_UNKNOWN 0 /**< Media header already filled in */
1008 #define P_IP 1 /**< IP protocol */
1009 #define P_ARP 2 /**< ARP protocol */
1010 #define P_RARP 3 /**< RARP protocol */
1011 #define P_OTHER 4 /**< Other protocol */
1013 #define XMT_DESTADDR 0x0000 /**< Unicast packet */
1014 #define XMT_BROADCAST 0x0001 /**< Broadcast packet */
1016 /** Maximum number of data blocks in a transmit buffer descriptor */
1017 #define MAX_DATA_BLKS 8
1019 /** A transmit buffer descriptor, as pointed to by s_PXENV_UNDI_TRANSMIT::TBD
1021 struct s_PXENV_UNDI_TBD {
1022 UINT16_t ImmedLength; /**< Length of the transmit buffer */
1023 SEGOFF16_t Xmit; /**< Address of the transmit buffer */
1024 UINT16_t DataBlkCount;
1025 /** Array of up to #MAX_DATA_BLKS additional transmit buffers */
1029 * A value of 0 would indicate that #TDDataPtr were an
1030 * #ADDR32_t rather than a #SEGOFF16_t. The PXE
1031 * specification version 2.1 explicitly states that
1032 * this is not supported; #TDDataPtr will always be a
1036 UINT8_t TDRsvdByte; /**< Must be zero */
1037 UINT16_t TDDataLen; /**< Length of this transmit buffer */
1038 SEGOFF16_t TDDataPtr; /**< Address of this transmit buffer */
1039 } DataBlock[MAX_DATA_BLKS];
1040 } __attribute__ (( packed ));
1042 typedef struct s_PXENV_UNDI_TBD PXENV_UNDI_TBD_t;
1044 /** Parameter block for pxenv_undi_transmit() */
1045 struct s_PXENV_UNDI_TRANSMIT {
1046 PXENV_STATUS_t Status; /**< PXE status code */
1049 * Valid values are #P_UNKNOWN, #P_IP, #P_ARP or #P_RARP. If
1050 * the caller has already filled in the media header, this
1051 * field must be set to #P_UNKNOWN.
1054 /** Unicast/broadcast flag
1056 * Valid values are #XMT_DESTADDR or #XMT_BROADCAST.
1059 SEGOFF16_t DestAddr; /**< Destination MAC address */
1060 /** Address of the Transmit Buffer Descriptor
1062 * This is a pointer to a struct s_PXENV_UNDI_TBD.
1065 UINT32_t Reserved[2]; /**< Must be zero */
1066 } __attribute__ (( packed ));
1068 typedef struct s_PXENV_UNDI_TRANSMIT PXENV_UNDI_TRANSMIT_t;
1070 /** @} */ /* pxenv_undi_transmit */
1072 /** @defgroup pxenv_undi_set_mcast_address PXENV_UNDI_SET_MCAST_ADDRESS
1074 * UNDI SET MULTICAST ADDRESS
1079 /** PXE API function code for pxenv_undi_set_mcast_address() */
1080 #define PXENV_UNDI_SET_MCAST_ADDRESS 0x0009
1082 /** Parameter block for pxenv_undi_set_mcast_address() */
1083 struct s_PXENV_UNDI_SET_MCAST_ADDRESS {
1084 PXENV_STATUS_t Status; /**< PXE status code */
1085 /** List of multicast addresses */
1086 struct s_PXENV_UNDI_MCAST_ADDRESS R_Mcast_Buf;
1087 } __attribute__ (( packed ));
1089 typedef struct s_PXENV_UNDI_SET_MCAST_ADDRESS PXENV_UNDI_SET_MCAST_ADDRESS_t;
1091 /** @} */ /* pxenv_undi_set_mcast_address */
1093 /** @defgroup pxenv_undi_set_station_address PXENV_UNDI_SET_STATION_ADDRESS
1095 * UNDI SET STATION ADDRESS
1100 /** PXE API function code for pxenv_undi_set_station_address() */
1101 #define PXENV_UNDI_SET_STATION_ADDRESS 0x000a
1103 /** Parameter block for pxenv_undi_set_station_address() */
1104 struct s_PXENV_UNDI_SET_STATION_ADDRESS {
1105 PXENV_STATUS_t Status; /**< PXE status code */
1106 MAC_ADDR_t StationAddress; /**< Station MAC address */
1107 } __attribute__ (( packed ));
1109 typedef struct s_PXENV_UNDI_SET_STATION_ADDRESS PXENV_UNDI_SET_STATION_ADDRESS_t;
1111 /** @} */ /* pxenv_undi_set_station_address */
1113 /** @defgroup pxenv_undi_set_packet_filter PXENV_UNDI_SET_PACKET_FILTER
1115 * UNDI SET PACKET FILTER
1120 /** PXE API function code for pxenv_undi_set_packet_filter() */
1121 #define PXENV_UNDI_SET_PACKET_FILTER 0x000b
1123 /** Parameter block for pxenv_undi_set_packet_filter() */
1124 struct s_PXENV_UNDI_SET_PACKET_FILTER {
1125 PXENV_STATUS_t Status; /**< PXE status code */
1126 /** Receive packet filter
1128 * This field takes the same values as
1129 * s_PXENV_UNDI_OPEN::PktFilter.
1131 * @note Yes, this field is a different size to
1132 * s_PXENV_UNDI_OPEN::PktFilter. Blame "the managers at Intel
1133 * who apparently let a consultant come up with the spec
1134 * without any kind of adult supervision" (quote from hpa).
1137 } __attribute__ (( packed ));
1139 typedef struct s_PXENV_UNDI_SET_PACKET_FILTER PXENV_UNDI_SET_PACKET_FILTER_t;
1141 /** @} */ /* pxenv_undi_set_packet_filter */
1143 /** @defgroup pxenv_undi_get_information PXENV_UNDI_GET_INFORMATION
1145 * UNDI GET INFORMATION
1150 /** PXE API function code for pxenv_undi_get_information() */
1151 #define PXENV_UNDI_GET_INFORMATION 0x000c
1153 #define ETHER_TYPE 1 /**< Ethernet (10Mb) */
1154 #define EXP_ETHER_TYPE 2 /**< Experimental Ethernet (3Mb) */
1155 #define AX25_TYPE 3 /**< Amateur Radio AX.25 */
1156 #define TOKEN_RING_TYPE 4 /**< Proteon ProNET Token Ring */
1157 #define CHAOS_TYPE 5 /**< Chaos */
1158 #define IEEE_TYPE 6 /**< IEEE 802 Networks */
1159 #define ARCNET_TYPE 7 /**< ARCNET */
1161 /** Parameter block for pxenv_undi_get_information() */
1162 struct s_PXENV_UNDI_GET_INFORMATION {
1163 PXENV_STATUS_t Status; /**< PXE status code */
1164 UINT16_t BaseIo; /**< I/O base address */
1165 UINT16_t IntNumber; /**< IRQ number */
1166 UINT16_t MaxTranUnit; /**< Adapter MTU */
1169 * Valid values are defined in RFC1010 ("Assigned numbers"),
1170 * and are #ETHER_TYPE, #EXP_ETHER_TYPE, #AX25_TYPE,
1171 * #TOKEN_RING_TYPE, #CHAOS_TYPE, #IEEE_TYPE or #ARCNET_TYPE.
1174 UINT16_t HwAddrLen; /**< MAC address length */
1175 MAC_ADDR_t CurrentNodeAddress; /**< Current MAC address */
1176 MAC_ADDR_t PermNodeAddress; /**< Permanent (EEPROM) MAC address */
1177 SEGSEL_t ROMAddress; /**< Real-mode ROM segment address */
1178 UINT16_t RxBufCt; /**< Receive queue length */
1179 UINT16_t TxBufCt; /**< Transmit queue length */
1180 } __attribute__ (( packed ));
1182 typedef struct s_PXENV_UNDI_GET_INFORMATION PXENV_UNDI_GET_INFORMATION_t;
1184 /** @} */ /* pxenv_undi_get_information */
1186 /** @defgroup pxenv_undi_get_statistics PXENV_UNDI_GET_STATISTICS
1188 * UNDI GET STATISTICS
1193 /** PXE API function code for pxenv_undi_get_statistics() */
1194 #define PXENV_UNDI_GET_STATISTICS 0x000d
1196 /** Parameter block for pxenv_undi_get_statistics() */
1197 struct s_PXENV_UNDI_GET_STATISTICS {
1198 PXENV_STATUS_t Status; /**< PXE status code */
1199 UINT32_t XmtGoodFrames; /**< Successful transmission count */
1200 UINT32_t RcvGoodFrames; /**< Successful reception count */
1201 UINT32_t RcvCRCErrors; /**< Receive CRC error count */
1202 UINT32_t RcvResourceErrors; /**< Receive queue overflow count */
1203 } __attribute__ (( packed ));
1205 typedef struct s_PXENV_UNDI_GET_STATISTICS PXENV_UNDI_GET_STATISTICS_t;
1207 /** @} */ /* pxenv_undi_get_statistics */
1209 /** @defgroup pxenv_undi_clear_statistics PXENV_UNDI_CLEAR_STATISTICS
1211 * UNDI CLEAR STATISTICS
1216 /** PXE API function code for pxenv_undi_clear_statistics() */
1217 #define PXENV_UNDI_CLEAR_STATISTICS 0x000e
1219 /** Parameter block for pxenv_undi_clear_statistics() */
1220 struct s_PXENV_UNDI_CLEAR_STATISTICS {
1221 PXENV_STATUS_t Status; /**< PXE status code */
1222 } __attribute__ (( packed ));
1224 typedef struct s_PXENV_UNDI_CLEAR_STATISTICS PXENV_UNDI_CLEAR_STATISTICS_t;
1226 /** @} */ /* pxenv_undi_clear_statistics */
1228 /** @defgroup pxenv_undi_initiate_diags PXENV_UNDI_INITIATE_DIAGS
1230 * UNDI INITIATE DIAGS
1235 /** PXE API function code for pxenv_undi_initiate_diags() */
1236 #define PXENV_UNDI_INITIATE_DIAGS 0x000f
1238 /** Parameter block for pxenv_undi_initiate_diags() */
1239 struct s_PXENV_UNDI_INITIATE_DIAGS {
1240 PXENV_STATUS_t Status; /**< PXE status code */
1241 } __attribute__ (( packed ));
1243 typedef struct s_PXENV_UNDI_INITIATE_DIAGS PXENV_UNDI_INITIATE_DIAGS_t;
1245 /** @} */ /* pxenv_undi_initiate_diags */
1247 /** @defgroup pxenv_undi_force_interrupt PXENV_UNDI_FORCE_INTERRUPT
1249 * UNDI FORCE INTERRUPT
1254 /** PXE API function code for pxenv_undi_force_interrupt() */
1255 #define PXENV_UNDI_FORCE_INTERRUPT 0x0010
1257 /** Parameter block for pxenv_undi_force_interrupt() */
1258 struct s_PXENV_UNDI_FORCE_INTERRUPT {
1259 PXENV_STATUS_t Status; /**< PXE status code */
1260 } __attribute__ (( packed ));
1262 typedef struct s_PXENV_UNDI_FORCE_INTERRUPT PXENV_UNDI_FORCE_INTERRUPT_t;
1264 /** @} */ /* pxenv_undi_force_interrupt */
1266 /** @defgroup pxenv_undi_get_mcast_address PXENV_UNDI_GET_MCAST_ADDRESS
1268 * UNDI GET MULTICAST ADDRESS
1273 /** PXE API function code for pxenv_undi_get_mcast_address() */
1274 #define PXENV_UNDI_GET_MCAST_ADDRESS 0x0011
1276 /** Parameter block for pxenv_undi_get_mcast_address() */
1277 struct s_PXENV_UNDI_GET_MCAST_ADDRESS {
1278 PXENV_STATUS_t Status; /**< PXE status code */
1279 IP4_t InetAddr; /**< Multicast IP address */
1280 MAC_ADDR_t MediaAddr; /**< Multicast MAC address */
1281 } __attribute__ (( packed ));
1283 typedef struct s_PXENV_UNDI_GET_MCAST_ADDRESS PXENV_UNDI_GET_MCAST_ADDRESS_t;
1285 /** @} */ /* pxenv_undi_get_mcast_address */
1287 /** @defgroup pxenv_undi_get_nic_type PXENV_UNDI_GET_NIC_TYPE
1294 /** PXE API function code for pxenv_undi_get_nic_type() */
1295 #define PXENV_UNDI_GET_NIC_TYPE 0x0012
1297 #define PCI_NIC 2 /**< PCI network card */
1298 #define PnP_NIC 3 /**< ISAPnP network card */
1299 #define CardBus_NIC 4 /**< CardBus network card */
1301 /** Information for a PCI or equivalent NIC */
1302 struct pci_nic_info {
1303 UINT16_t Vendor_ID; /**< PCI vendor ID */
1304 UINT16_t Dev_ID; /**< PCI device ID */
1305 UINT8_t Base_Class; /**< PCI base class */
1306 UINT8_t Sub_Class; /**< PCI sub class */
1307 UINT8_t Prog_Intf; /**< PCI programming interface */
1308 UINT8_t Rev; /**< PCI revision */
1309 UINT16_t BusDevFunc; /**< PCI bus:dev:fn address */
1310 UINT16_t SubVendor_ID; /**< PCI subvendor ID */
1311 UINT16_t SubDevice_ID; /**< PCI subdevice ID */
1312 } __attribute__ (( packed ));
1314 /** Information for an ISAPnP or equivalent NIC */
1315 struct pnp_nic_info {
1316 UINT32_t EISA_Dev_ID; /**< EISA device ID */
1317 UINT8_t Base_Class; /**< Base class */
1318 UINT8_t Sub_Class; /**< Sub class */
1319 UINT8_t Prog_Intf; /**< Programming interface */
1320 /** Card Select Number assigned to card */
1321 UINT16_t CardSelNum;
1322 } __attribute__ (( packed ));
1324 /** Parameter block for pxenv_undi_get_nic_type() */
1325 struct s_PXENV_UNDI_GET_NIC_TYPE {
1326 PXENV_STATUS_t Status; /**< PXE status code */
1329 * Valid values are #PCI_NIC, #PnP_NIC or #CardBus_NIC.
1332 /** NIC information */
1333 union nic_type_info {
1334 /** NIC information (if #NicType==#PCI_NIC) */
1335 struct pci_nic_info pci;
1336 /** NIC information (if #NicType==#CardBus_NIC) */
1337 struct pci_nic_info cardbus;
1338 /** NIC information (if #NicType==#PnP_NIC) */
1339 struct pnp_nic_info pnp;
1341 } __attribute__ (( packed ));
1343 typedef struct s_PXENV_UNDI_GET_NIC_TYPE PXENV_UNDI_GET_NIC_TYPE_t;
1345 /** @} */ /* pxenv_undi_get_nic_type */
1347 /** @defgroup pxenv_undi_get_iface_info PXENV_UNDI_GET_IFACE_INFO
1349 * UNDI GET IFACE INFO
1354 /** PXE API function code for pxenv_undi_get_iface_info() */
1355 #define PXENV_UNDI_GET_IFACE_INFO 0x0013
1357 /** Broadcast supported */
1358 #define SUPPORTED_BROADCAST 0x0001
1359 /** Multicast supported */
1360 #define SUPPORTED_MULTICAST 0x0002
1361 /** Functional/group addressing supported */
1362 #define SUPPORTED_GROUP 0x0004
1363 /** Promiscuous mode supported */
1364 #define SUPPORTED_PROMISCUOUS 0x0008
1365 /** Software settable station address */
1366 #define SUPPORTED_SET_STATION_ADDRESS 0x0010
1367 /** InitiateDiagnostics supported */
1368 #define SUPPORTED_DIAGNOSTICS 0x0040
1369 /** Reset MAC supported */
1370 #define SUPPORTED_RESET 0x0400
1371 /** Open / Close Adapter supported */
1372 #define SUPPORTED_OPEN_CLOSE 0x0800
1373 /** Interrupt Request supported */
1374 #define SUPPORTED_IRQ 0x1000
1376 /** Parameter block for pxenv_undi_get_iface_info() */
1377 struct s_PXENV_UNDI_GET_IFACE_INFO {
1378 PXENV_STATUS_t Status; /**< PXE status code */
1381 * This is defined in the NDIS 2.0 specification to be one of
1382 * the strings "802.3", "802.4", "802.5", "802.6", "DIX",
1383 * "DIX+802.3", "APPLETALK", "ARCNET", "FDDI", "SDLC", "BSC",
1384 * "HDLC", or "ISDN".
1386 * "Normal" Ethernet, for various historical reasons, is
1389 UINT8_t IfaceType[16];
1390 UINT32_t LinkSpeed; /**< Link speed, in bits per second */
1393 * These are the "service flags" defined in the "MAC
1394 * Service-Specific Characteristics" table in the NDIS 2.0
1395 * specification. Almost all of them are irrelevant to PXE.
1397 UINT32_t ServiceFlags;
1398 UINT32_t Reserved[4]; /**< Must be zero */
1399 } __attribute__ (( packed ));
1401 typedef struct s_PXENV_UNDI_GET_IFACE_INFO PXENV_UNDI_GET_IFACE_INFO_t;
1403 /** @} */ /* pxenv_undi_get_iface_info */
1405 /** @defgroup pxenv_undi_get_state PXENV_UNDI_GET_STATE
1412 /** PXE API function code for pxenv_undi_get_state() */
1413 #define PXENV_UNDI_GET_STATE 0x0015
1415 /** pxenv_start_undi() has been called */
1416 #define PXE_UNDI_GET_STATE_STARTED 1
1417 /** pxenv_undi_initialize() has been called */
1418 #define PXE_UNDI_GET_STATE_INITIALIZED 2
1419 /** pxenv_undi_open() has been called */
1420 #define PXE_UNDI_GET_STATE_OPENED 3
1422 /** Parameter block for pxenv_undi_get_state() */
1423 struct s_PXENV_UNDI_GET_STATE {
1424 PXENV_STATUS_t Status; /**< PXE status code */
1425 /** Current state of the UNDI driver
1427 * Valid values are #PXE_UNDI_GET_STATE_STARTED,
1428 * #PXE_UNDI_GET_STATE_INITIALIZED or
1429 * #PXE_UNDI_GET_STATE_OPENED.
1432 } __attribute__ (( packed ));
1434 typedef struct s_PXENV_UNDI_GET_STATE PXENV_UNDI_GET_STATE_t;
1436 /** @} */ /* pxenv_undi_get_state */
1438 /** @defgroup pxenv_undi_isr PXENV_UNDI_ISR
1445 /** PXE API function code for pxenv_undi_isr() */
1446 #define PXENV_UNDI_ISR 0x0014
1448 /** Determine whether or not this is our interrupt */
1449 #define PXENV_UNDI_ISR_IN_START 1
1450 /** Start processing interrupt */
1451 #define PXENV_UNDI_ISR_IN_PROCESS 2
1452 /** Continue processing interrupt */
1453 #define PXENV_UNDI_ISR_IN_GET_NEXT 3
1454 /** This interrupt was ours */
1455 #define PXENV_UNDI_ISR_OUT_OURS 0
1456 /** This interrupt was not ours */
1457 #define PXENV_UNDI_ISR_OUT_NOT_OURS 1
1458 /** Finished processing interrupt */
1459 #define PXENV_UNDI_ISR_OUT_DONE 0
1460 /** A packet transmission has completed */
1461 #define PXENV_UNDI_ISR_OUT_TRANSMIT 2
1462 /** A packet has been received */
1463 #define PXENV_UNDI_ISR_OUT_RECEIVE 3
1464 /** We are already in the middle of processing an interrupt */
1465 #define PXENV_UNDI_ISR_OUT_BUSY 4
1467 /** Unicast packet (or packet captured in promiscuous mode) */
1468 #define P_DIRECTED 0
1469 /** Broadcast packet */
1470 #define P_BROADCAST 1
1471 /** Multicast packet */
1472 #define P_MULTICAST 2
1474 /** Parameter block for pxenv_undi_isr() */
1475 struct s_PXENV_UNDI_ISR {
1476 PXENV_STATUS_t Status; /**< PXE status code */
1479 * Valid values are #PXENV_UNDI_ISR_IN_START,
1480 * #PXENV_UNDI_ISR_IN_PROCESS, #PXENV_UNDI_ISR_IN_GET_NEXT,
1481 * #PXENV_UNDI_ISR_OUT_OURS, #PXENV_UNDI_ISR_OUT_NOT_OURS,
1482 * #PXENV_UNDI_ISR_OUT_DONE, #PXENV_UNDI_ISR_OUT_TRANSMIT,
1483 * #PXENV_UNDI_ISR_OUT_RECEIVE or #PXENV_UNDI_ISR_OUT_BUSY.
1486 UINT16_t BufferLength; /**< Data buffer length */
1487 UINT16_t FrameLength; /**< Total frame length */
1488 UINT16_t FrameHeaderLength; /**< Frame header length */
1489 SEGOFF16_t Frame; /**< Data buffer address */
1492 * Valid values are #P_IP, #P_ARP, #P_RARP or #P_OTHER.
1497 * Valid values are #P_DIRECTED, #P_BROADCAST or #P_MULTICAST.
1500 } __attribute__ (( packed ));
1502 typedef struct s_PXENV_UNDI_ISR PXENV_UNDI_ISR_t;
1504 /** @} */ /* pxenv_undi_isr */
1506 /** @} */ /* pxe_undi_api */
1508 /** @defgroup pxe_file_api PXE FILE API
1510 * POSIX-like file operations
1515 /** Minimum possible opcode used within PXE FILE API */
1516 #define PXENV_FILE_MIN 0x00e0
1518 /** Minimum possible opcode used within PXE FILE API */
1519 #define PXENV_FILE_MAX 0x00ef
1521 /** @defgroup pxenv_file_open PXENV_FILE_OPEN
1528 /** PXE API function code for pxenv_file_open() */
1529 #define PXENV_FILE_OPEN 0x00e0
1531 /** Parameter block for pxenv_file_open() */
1532 struct s_PXENV_FILE_OPEN {
1533 PXENV_STATUS_t Status; /**< PXE status code */
1534 UINT16_t FileHandle; /**< File handle */
1535 SEGOFF16_t FileName; /**< File URL */
1536 UINT32_t Reserved; /**< Reserved */
1537 } __attribute__ (( packed ));
1539 typedef struct s_PXENV_FILE_OPEN PXENV_FILE_OPEN_t;
1541 /** @} */ /* pxenv_file_open */
1543 /** @defgroup pxenv_file_close PXENV_FILE_CLOSE
1550 /** PXE API function code for pxenv_file_close() */
1551 #define PXENV_FILE_CLOSE 0x00e1
1553 /** Parameter block for pxenv_file_close() */
1554 struct s_PXENV_FILE_CLOSE {
1555 PXENV_STATUS_t Status; /**< PXE status code */
1556 UINT16_t FileHandle; /**< File handle */
1557 } __attribute__ (( packed ));
1559 typedef struct s_PXENV_FILE_CLOSE PXENV_FILE_CLOSE_t;
1561 /** @} */ /* pxenv_file_close */
1563 /** @defgroup pxenv_file_select PXENV_FILE_SELECT
1570 /** PXE API function code for pxenv_file_select() */
1571 #define PXENV_FILE_SELECT 0x00e2
1573 /** File is ready for reading */
1574 #define RDY_READ 0x0001
1576 /** Parameter block for pxenv_file_select() */
1577 struct s_PXENV_FILE_SELECT {
1578 PXENV_STATUS_t Status; /**< PXE status code */
1579 UINT16_t FileHandle; /**< File handle */
1580 UINT16_t Ready; /**< Indication of readiness */
1581 } __attribute__ (( packed ));
1583 typedef struct s_PXENV_FILE_SELECT PXENV_FILE_SELECT_t;
1585 /** @} */ /* pxenv_file_select */
1587 /** @defgroup pxenv_file_read PXENV_FILE_READ
1594 /** PXE API function code for pxenv_file_read() */
1595 #define PXENV_FILE_READ 0x00e3
1597 /** Parameter block for pxenv_file_read() */
1598 struct s_PXENV_FILE_READ {
1599 PXENV_STATUS_t Status; /**< PXE status code */
1600 UINT16_t FileHandle; /**< File handle */
1601 UINT16_t BufferSize; /**< Data buffer size */
1602 SEGOFF16_t Buffer; /**< Data buffer */
1603 } __attribute__ (( packed ));
1605 typedef struct s_PXENV_FILE_READ PXENV_FILE_READ_t;
1607 /** @} */ /* pxenv_file_read */
1609 /** @defgroup pxenv_get_file_size PXENV_GET_FILE_SIZE
1616 /** PXE API function code for pxenv_get_file_size() */
1617 #define PXENV_GET_FILE_SIZE 0x00e4
1619 /** Parameter block for pxenv_get_file_size() */
1620 struct s_PXENV_GET_FILE_SIZE {
1621 PXENV_STATUS_t Status; /**< PXE status code */
1622 UINT16_t FileHandle; /**< File handle */
1623 UINT32_t FileSize; /**< File size */
1624 } __attribute__ (( packed ));
1626 typedef struct s_PXENV_GET_FILE_SIZE PXENV_GET_FILE_SIZE_t;
1628 /** @} */ /* pxenv_get_file_size */
1630 /** @defgroup pxenv_file_exec PXENV_FILE_EXEC
1637 /** PXE API function code for pxenv_file_exec() */
1638 #define PXENV_FILE_EXEC 0x00e5
1640 /** Parameter block for pxenv_file_exec() */
1641 struct s_PXENV_FILE_EXEC {
1642 PXENV_STATUS_t Status; /**< PXE status code */
1643 SEGOFF16_t Command; /**< Command to execute */
1644 } __attribute__ (( packed ));
1646 typedef struct s_PXENV_FILE_EXEC PXENV_FILE_EXEC_t;
1648 /** @} */ /* pxenv_file_exec */
1650 /** @defgroup pxenv_file_api_check PXENV_FILE_API_CHECK
1657 /** PXE API function code for pxenv_file_api_check() */
1658 #define PXENV_FILE_API_CHECK 0x00e6
1660 /** Parameter block for pxenv_file_api_check() */
1661 struct s_PXENV_FILE_API_CHECK {
1662 PXENV_STATUS_t Status; /**< PXE status code */
1663 UINT16_t Size; /**< Size of structure */
1664 UINT32_t Magic; /**< Magic number */
1665 UINT32_t Provider; /**< Implementation identifier */
1666 UINT32_t APIMask; /**< Supported API functions */
1667 UINT32_t Flags; /**< Reserved for the future */
1668 } __attribute__ (( packed ));
1670 typedef struct s_PXENV_FILE_API_CHECK PXENV_FILE_API_CHECK_t;
1672 /** @} */ /* pxenv_file_api_check */
1674 /** @defgroup pxenv_file_exit_hook PXENV_FILE_EXIT_HOOK
1681 /** PXE API function code for pxenv_file_exit_hook() */
1682 #define PXENV_FILE_EXIT_HOOK 0x00e7
1684 /** Parameter block for pxenv_file_exit_hook() */
1685 struct s_PXENV_FILE_EXIT_HOOK {
1686 PXENV_STATUS_t Status; /**< PXE status code */
1687 SEGOFF16_t Hook; /**< SEG16:OFF16 to jump to */
1688 } __attribute__ (( packed ));
1690 typedef struct s_PXENV_FILE_EXIT_HOOK PXENV_FILE_EXIT_HOOK_t;
1692 /** @} */ /* pxenv_file_exit_hook */
1694 /** @defgroup pxenv_file_cmdline PXENV_FILE_CMDLINE
1701 /** PXE API function code for pxenv_file_cmdline() */
1702 #define PXENV_FILE_CMDLINE 0x00e8
1704 /** Parameter block for pxenv_file_cmdline() */
1705 struct s_PXENV_FILE_CMDLINE {
1706 PXENV_STATUS_t Status; /**< PXE status code */
1707 UINT16_t BufferSize; /**< Data buffer size */
1708 SEGOFF16_t Buffer; /**< Data buffer */
1709 } __attribute__ (( packed ));
1711 typedef struct s_PXENV_FILE_CMDLINE PXENV_FILE_CMDLINE_t;
1713 /** @} */ /* pxe_file_cmdline */
1715 /** @} */ /* pxe_file_api */
1717 /** @defgroup pxe_loader_api PXE Loader API
1719 * The UNDI ROM loader API
1724 /** Parameter block for undi_loader() */
1725 struct s_UNDI_LOADER {
1726 /** PXE status code */
1727 PXENV_STATUS_t Status;
1728 /** %ax register as for PXENV_START_UNDI */
1730 /** %bx register as for PXENV_START_UNDI */
1732 /** %dx register as for PXENV_START_UNDI */
1734 /** %di register as for PXENV_START_UNDI */
1736 /** %es register as for PXENV_START_UNDI */
1738 /** UNDI data segment
1740 * @note The PXE specification defines the type of this field
1741 * as #UINT16_t. For x86, #SEGSEL_t and #UINT16_t are
1742 * equivalent anyway; for other architectures #SEGSEL_t makes
1746 /** UNDI code segment
1748 * @note The PXE specification defines the type of this field
1749 * as #UINT16_t. For x86, #SEGSEL_t and #UINT16_t are
1750 * equivalent anyway; for other architectures #SEGSEL_t makes
1754 /** Address of the !PXE structure (a struct s_PXE) */
1756 /** Address of the PXENV+ structure (a struct s_PXENV) */
1757 SEGOFF16_t PXENVptr;
1758 } __attribute__ (( packed ));
1760 typedef struct s_UNDI_LOADER UNDI_LOADER_t;
1762 /** @} */ /* pxe_loader_api */
1766 /** @page pxe_notes Etherboot PXE implementation notes
1768 @section pxe_routing IP routing
1770 Several PXE API calls (e.g. pxenv_tftp_open() and pxenv_udp_write())
1771 allow for the caller to specify a "relay agent IP address", often in a
1772 field called "gateway" or similar. The PXE specification states that
1773 "The IP layer should provide space for a minimum of four routing
1774 entries obtained from the default router and static route DHCP option
1775 tags in the DHCPACK message, plus any non-zero giaddr field from the
1776 DHCPOFFER message(s) accepted by the client".
1778 The DHCP static route option ("option static-routes" in dhcpd.conf)
1779 works only for classed IP routing (i.e. it provides no way to specify
1780 a subnet mask). Since virtually everything now uses classless IP
1781 routing, the DHCP static route option is almost totally useless, and
1782 is (according to the dhcp-options man page) not implemented by any of
1783 the popular DHCP clients.
1785 This leaves the caller-specified "relay agent IP address", the giaddr
1786 field from the DHCPOFFER message(s) and the default gateway(s)
1787 provided via the routers option ("option routers" in dhcpd.conf) in
1788 the DHCPACK message. Each of these is a default gateway address.
1789 It's a fair bet that the routers option should take priority over the
1790 giaddr field, since the routers option has to be explicitly specified
1791 by the DHCP server operator. Similarly, it's fair to assume that the
1792 caller-specified "relay agent IP address", if present, should take
1793 priority over any other routing table entries.
1795 @bug Etherboot currently ignores all potential sources of routing
1796 information other than the first router provided to it by a DHCP
1799 @section pxe_x86_modes x86 processor mode restrictions
1801 On the x86 platform, different PXE API calls have different
1802 restrictions on the processor modes (real or protected) that can be
1803 used. See the individual API call descriptions for the restrictions
1804 that apply to any particular call.
1806 @subsection pxe_x86_pmode16 Real mode, or protected-mode with 16-bit stack
1808 The PXE specification states that the API function can be called in
1809 protected mode only if the s_PXE::StatusCallout field is set to a
1810 non-zero value, and that the API function cannot be called with a
1811 32-bit stack segment.
1813 Etherboot does not enforce either of these restrictions; they seem (as
1814 with so much of the PXE specification) to be artifacts of the Intel
1819 #endif /* PXE_API_H */