158993Sps/*
258993Sps * Copyright (c) 2000 Alfred Perlstein <alfred@freebsd.org>
358993Sps * All rights reserved.
458993Sps * Copyright (c) 2000 Paul Saab <ps@freebsd.org>
558993Sps * All rights reserved.
658993Sps * Copyright (c) 2000 John Baldwin <jhb@freebsd.org>
758993Sps * All rights reserved.
858993Sps *
958993Sps * Redistribution and use in source and binary forms, with or without
1058993Sps * modification, are permitted provided that the following conditions
1158993Sps * are met:
1258993Sps * 1. Redistributions of source code must retain the above copyright
1358993Sps *    notice, this list of conditions and the following disclaimer.
1458993Sps * 2. Redistributions in binary form must reproduce the above copyright
1558993Sps *    notice, this list of conditions and the following disclaimer in the
1658993Sps *    documentation and/or other materials provided with the distribution.
1758993Sps *
1858993Sps * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1958993Sps * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2058993Sps * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2158993Sps * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
2258993Sps * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2358993Sps * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2458993Sps * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2558993Sps * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2658993Sps * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2758993Sps * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2858993Sps * SUCH DAMAGE.
2958993Sps *
3058993Sps * $FreeBSD$
3158993Sps */
3258993Sps
3358993Sps/*
3458993Sps * The typedefs and structures declared in this file
3558993Sps * clearly violate style(9), the reason for this is to conform to the
3658993Sps * typedefs/structure-names used in the Intel literature to avoid confusion.
3758993Sps *
3858993Sps * It's for your own good. :)
3958993Sps */
4058993Sps
4158993Sps/* It seems that intel didn't think about ABI,
4258993Sps * either that or 16bit ABI != 32bit ABI (which seems reasonable)
4358993Sps * I have to thank Intel for the hair loss I incurred trying to figure
4458993Sps * out why PXE was mis-reading structures I was passing it (at least
4558993Sps * from my point of view)
4658993Sps *
47103870Salfred * Solution: use gcc's '__packed' to correctly align
4858993Sps * structures passed into PXE
4958993Sps * Question: does this really work for PXE's expected ABI?
5058993Sps */
51103870Salfred#define	PACKED		__packed
5258993Sps
5358993Sps#define	S_SIZE(s)	s, sizeof(s) - 1
5458993Sps
5558993Sps#define	IP_STR		"%d.%d.%d.%d"
5658993Sps#define	IP_ARGS(ip)					\
5758993Sps	(int)(ip >> 24) & 0xff, (int)(ip >> 16) & 0xff, \
5858993Sps	(int)(ip >> 8) & 0xff, (int)ip & 0xff
5958993Sps
6058993Sps#define	MAC_STR		"%02x:%02x:%02x:%02x:%02x:%02x"
6158993Sps#define	MAC_ARGS(mac)					\
6258993Sps	mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]
6358993Sps
6459087Sps#define	PXENFSROOTPATH	"/pxeroot"
6559087Sps
6658993Spstypedef struct {
6758993Sps	uint16_t		offset;
6858993Sps	uint16_t		segment;
6958993Sps} SEGOFF16_t;
7058993Sps
7158993Spstypedef struct {
7258993Sps	uint16_t		Seg_Addr;
7358993Sps	uint32_t		Phy_Addr;
7458993Sps	uint16_t		Seg_Size;
7558993Sps} SEGDESC_t;
7658993Sps
7758993Spstypedef	uint16_t		SEGSEL_t;
7858993Spstypedef	uint16_t		PXENV_STATUS_t;
7958993Spstypedef	uint32_t		IP4_t;
8058993Spstypedef	uint32_t		ADDR32_t;
8158993Spstypedef	uint16_t		UDP_PORT_t;
8258993Sps
8358993Sps#define	MAC_ADDR_LEN		16
8458993Spstypedef	uint8_t			MAC_ADDR[MAC_ADDR_LEN];
8558993Sps
8658993Sps/* PXENV+ */
8758993Spstypedef struct {
8858993Sps	uint8_t		Signature[6];	/* 'PXENV+' */
8958993Sps	uint16_t	Version;	/* MSB = major, LSB = minor */
9058993Sps	uint8_t		Length;		/* structure length */
9158993Sps	uint8_t		Checksum;	/* checksum pad */
9258993Sps	SEGOFF16_t	RMEntry;	/* SEG:OFF to PXE entry point */
9358993Sps	/* don't use PMOffset and PMSelector (from the 2.1 PXE manual) */
9458993Sps	uint32_t	PMOffset;	/* Protected mode entry */
9558993Sps	SEGSEL_t	PMSelector;	/* Protected mode selector */
9658993Sps	SEGSEL_t	StackSeg;	/* Stack segment address */
9758993Sps	uint16_t	StackSize;	/* Stack segment size (bytes) */
9858993Sps	SEGSEL_t	BC_CodeSeg;	/* BC Code segment address */
9958993Sps	uint16_t	BC_CodeSize;	/* BC Code segment size (bytes) */
10058993Sps	SEGSEL_t	BC_DataSeg;	/* BC Data segment address */
10158993Sps	uint16_t	BC_DataSize;	/* BC Data segment size (bytes) */
10258993Sps	SEGSEL_t	UNDIDataSeg;	/* UNDI Data segment address */
10358993Sps	uint16_t	UNDIDataSize;	/* UNDI Data segment size (bytes) */
10458993Sps	SEGSEL_t	UNDICodeSeg;	/* UNDI Code segment address */
10558993Sps	uint16_t	UNDICodeSize;	/* UNDI Code segment size (bytes) */
10658993Sps	SEGOFF16_t	PXEPtr;		/* SEG:OFF to !PXE struct,
10758993Sps					   only present when Version > 2.1 */
10858993Sps} PACKED pxenv_t;
10958993Sps
11058993Sps/* !PXE */
11158993Spstypedef struct {
11258993Sps	uint8_t		Signature[4];
11358993Sps	uint8_t		StructLength;
11458993Sps	uint8_t		StructCksum;
11558993Sps	uint8_t		StructRev;
11658993Sps	uint8_t		reserved_1;
11758993Sps	SEGOFF16_t	UNDIROMID;
11858993Sps	SEGOFF16_t	BaseROMID;
11958993Sps	SEGOFF16_t	EntryPointSP;
12058993Sps	SEGOFF16_t	EntryPointESP;
12158993Sps	SEGOFF16_t	StatusCallout;
12258993Sps	uint8_t		reserved_2;
12358993Sps	uint8_t		SegDescCn;
12458993Sps	SEGSEL_t	FirstSelector;
12558993Sps	SEGDESC_t	Stack;
12658993Sps	SEGDESC_t	UNDIData;
12758993Sps	SEGDESC_t	UNDICode;
12858993Sps	SEGDESC_t	UNDICodeWrite;
12958993Sps	SEGDESC_t	BC_Data;
13058993Sps	SEGDESC_t	BC_Code;
13158993Sps	SEGDESC_t	BC_CodeWrite;
13258993Sps} PACKED pxe_t;
13358993Sps
13458993Sps#define	PXENV_START_UNDI		0x0000
13558993Spstypedef struct {
13658993Sps	PXENV_STATUS_t	Status;
13758993Sps	uint16_t	ax;
13858993Sps	uint16_t	bx;
13958993Sps	uint16_t	dx;
14058993Sps	uint16_t	di;
14158993Sps	uint16_t	es;
14258993Sps} PACKED t_PXENV_START_UNDI;
14358993Sps
14458993Sps#define	PXENV_UNDI_STARTUP		0x0001
14558993Spstypedef struct {
14658993Sps	PXENV_STATUS_t	Status;
14758993Sps} PACKED t_PXENV_UNDI_STARTUP;
14858993Sps
14958993Sps#define	PXENV_UNDI_CLEANUP		0x0002
15058993Spstypedef struct {
15158993Sps	PXENV_STATUS_t	Status;
15258993Sps} PACKED t_PXENV_UNDI_CLEANUP;
15358993Sps
15458993Sps#define	PXENV_UNDI_INITIALIZE		0x0003
15558993Spstypedef struct {
15658993Sps	PXENV_STATUS_t	Status;
15758993Sps	ADDR32_t	ProtocolIni;	/* Phys addr of a copy of the driver module */
15858993Sps	uint8_t		reserved[8];
15958993Sps} PACKED t_PXENV_UNDI_INITALIZE;
16058993Sps
16158993Sps
16258993Sps#define	MAXNUM_MCADDR		8
16358993Spstypedef struct {
16458993Sps	PXENV_STATUS_t	Status;
16558993Sps	uint16_t	MCastAddrCount;
16658993Sps	MAC_ADDR	McastAddr[MAXNUM_MCADDR];
16758993Sps} PACKED t_PXENV_UNDI_MCAST_ADDRESS;
16858993Sps
16958993Sps#define	PXENV_UNDI_RESET_ADAPTER	0x0004
17058993Spstypedef struct {
17158993Sps	PXENV_STATUS_t	Status;
17258993Sps	t_PXENV_UNDI_MCAST_ADDRESS R_Mcast_Buf;
17358993Sps} PACKED t_PXENV_UNDI_RESET;
17458993Sps
17558993Sps#define	PXENV_UNDI_SHUTDOWN		0x0005
17658993Spstypedef struct {
17758993Sps	PXENV_STATUS_t	Status;
17858993Sps} PACKED t_PXENV_UNDI_SHUTDOWN;
17958993Sps
18058993Sps#define	PXENV_UNDI_OPEN			0x0006
18158993Spstypedef struct {
18258993Sps	PXENV_STATUS_t	Status;
18358993Sps	uint16_t	OpenFlag;
18458993Sps	uint16_t	PktFilter;
18558993Sps#	define FLTR_DIRECTED	0x0001
18658993Sps#	define FLTR_BRDCST	0x0002
18758993Sps#	define FLTR_PRMSCS	0x0003
18858993Sps#	define FLTR_SRC_RTG	0x0004
18958993Sps
19058993Sps	t_PXENV_UNDI_MCAST_ADDRESS R_Mcast_Buf;
19158993Sps} PACKED t_PXENV_UNDI_OPEN;
19258993Sps
19358993Sps#define	PXENV_UNDI_CLOSE		0x0007
19458993Spstypedef struct {
19558993Sps	PXENV_STATUS_t	Status;
19658993Sps} PACKED t_PXENV_UNDI_CLOSE;
19758993Sps
19858993Sps#define	PXENV_UNDI_TRANSMIT		0x0008
19958993Spstypedef struct {
20058993Sps	PXENV_STATUS_t	Status;
20158993Sps	uint8_t		Protocol;
20258993Sps#	define P_UNKNOWN	0
20358993Sps#	define P_IP		1
20458993Sps#	define P_ARP		2
20558993Sps#	define P_RARP		3
20658993Sps
20758993Sps	uint8_t		XmitFlag;
20858993Sps#	define XMT_DESTADDR	0x0000
20958993Sps#	define XMT_BROADCAST	0x0001
21058993Sps
21158993Sps	SEGOFF16_t	DestAddr;
21258993Sps	SEGOFF16_t	TBD;
21358993Sps	uint32_t	Reserved[2];
21458993Sps} PACKED t_PXENV_UNDI_TRANSMIT;
21558993Sps
21658993Sps#define	MAX_DATA_BLKS		8
21758993Spstypedef struct {
21858993Sps	uint16_t	ImmedLength;
21958993Sps	SEGOFF16_t	Xmit;
22058993Sps	uint16_t	DataBlkCount;
22158993Sps	struct	DataBlk {
22258993Sps		uint8_t		TDPtrType;
22358993Sps		uint8_t		TDRsvdByte;
22458993Sps		uint16_t	TDDataLen;
22558993Sps		SEGOFF16_t	TDDataPtr;
22658993Sps	} DataBlock[MAX_DATA_BLKS];
22758993Sps} PACKED t_PXENV_UNDI_TBD;
22858993Sps
22958993Sps#define	PXENV_UNDI_SET_MCAST_ADDRESS	0x0009
23058993Spstypedef struct {
23158993Sps	PXENV_STATUS_t	Status;
23258993Sps	t_PXENV_UNDI_MCAST_ADDRESS R_Mcast_Buf;
23358993Sps} PACKED t_PXENV_UNDI_SET_MCAST_ADDR;
23458993Sps
23558993Sps#define	PXENV_UNDI_SET_STATION_ADDRESS	0x000A
23658993Spstypedef struct {
23758993Sps	PXENV_STATUS_t	Status;
23858993Sps	MAC_ADDR	StationAddress;		/* Temp MAC addres to use */
23958993Sps} PACKED t_PXENV_UNDI_SET_STATION_ADDR;
24058993Sps
24158993Sps#define	PXENV_UNDI_SET_PACKET_FILTER	0x000B
24258993Spstypedef struct {
24358993Sps	PXENV_STATUS_t	Status;
24458993Sps	uint8_t		filter;			/* see UNDI_OPEN (0x0006) */
24558993Sps} PACKED t_PXENV_UNDI_SET_PACKET_FILTER;
24658993Sps
24758993Sps#define	PXENV_UNDI_GET_INFORMATION	0x000C
24858993Spstypedef struct {
24958993Sps	PXENV_STATUS_t	Status;
25058993Sps	uint16_t	BaseIo;			/* Adapter base I/O address */
25158993Sps	uint16_t	IntNumber;		/* Adapter IRQ number */
25258993Sps	uint16_t	MaxTranUnit;		/* Adapter maximum transmit unit */
25358993Sps	uint16_t	HwType;			/* Type of protocol at the hardware addr */
25458993Sps#	define ETHER_TYPE	1
25558993Sps#	define EXP_ETHER_TYPE	2
25658993Sps#	define IEEE_TYPE	6
25758993Sps#	define ARCNET_TYPE	7
25858993Sps
25958993Sps	uint16_t	HwAddrLen;		/* Length of hardware address */
26058993Sps	MAC_ADDR	CurrentNodeAddress;	/* Current hardware address */
26158993Sps	MAC_ADDR	PermNodeAddress;	/* Permanent hardware address */
26258993Sps	SEGSEL_t	ROMAddress;		/* Real mode ROM segment address */
26358993Sps	uint16_t	RxBufCt;		/* Receive queue length */
26458993Sps	uint16_t	TxBufCt;		/* Transmit queue length */
26558993Sps} PACKED t_PXENV_UNDI_GET_INFORMATION;
26658993Sps
26758993Sps#define	PXENV_UNDI_GET_STATISTICS	0x000D
26858993Spstypedef struct {
26958993Sps	PXENV_STATUS_t	Status;
27058993Sps	uint32_t	XmitGoodFrames;		/* Number of successful transmissions */
27158993Sps	uint32_t	RcvGoodFrames;		/* Number of good frames received */
27258993Sps	uint32_t	RcvCRCErrors;		/* Number of frames with CRC errors */
27358993Sps	uint32_t	RcvResourceErrors;	/* Number of frames dropped */
27458993Sps} PACKED t_PXENV_UNDI_GET_STATISTICS;
27558993Sps
27658993Sps#define	PXENV_UNDI_CLEAR_STATISTICS	0x000E
27758993Spstypedef struct {
27858993Sps	PXENV_STATUS_t	Status;
27958993Sps} PACKED t_PXENV_UNDI_CLEAR_STATISTICS;
28058993Sps
28158993Sps#define	PXENV_UNDI_INITIATE_DIAGS	0x000F
28258993Spstypedef struct {
28358993Sps	PXENV_STATUS_t	Status;
28458993Sps} PACKED t_PXENV_UNDI_INITIATE_DIAGS;
28558993Sps
28658993Sps#define	PXENV_UNDI_FORCE_INTERRUPT	0x0010
28758993Spstypedef struct {
28858993Sps	PXENV_STATUS_t	Status;
28958993Sps} PACKED t_PXENV_UNDI_FORCE_INTERRUPT;
29058993Sps
29158993Sps#define	PXENV_UNDI_GET_MCAST_ADDRESS	0x0011
29258993Spstypedef struct {
29358993Sps	PXENV_STATUS_t	Status;
29458993Sps	IP4_t		InetAddr;		/* IP mulicast address */
29558993Sps	MAC_ADDR	MediaAddr;		/* MAC multicast address */
29658993Sps} PACKED t_PXENV_UNDI_GET_MCAST_ADDR;
29758993Sps
29858993Sps#define	PXENV_UNDI_GET_NIC_TYPE		0x0012
29958993Spstypedef struct {
30058993Sps	PXENV_STATUS_t	Status;
30158993Sps	uint8_t		NicType;		/* Type of NIC */
30258993Sps#	define PCI_NIC		2
30358993Sps#	define PnP_NIC		3
30458993Sps#	define CardBus_NIC	4
30558993Sps
30658993Sps	union {
30758993Sps		struct {
30858993Sps			uint16_t	Vendor_ID;
30958993Sps			uint16_t	Dev_ID;
31058993Sps			uint8_t		Base_Class;
31158993Sps			uint8_t		Sub_Class;
31258993Sps			uint8_t		Prog_Intf;
31358993Sps			uint8_t		Rev;
31458993Sps			uint16_t	BusDevFunc;
31558993Sps			uint16_t	SubVendor_ID;
31658993Sps			uint16_t	SubDevice_ID;
31758993Sps		} pci, cardbus;
31858993Sps		struct {
31958993Sps			uint32_t	EISA_Dev_ID;
32058993Sps			uint8_t		Base_Class;
32158993Sps			uint8_t		Sub_Class;
32258993Sps			uint8_t		Prog_Intf;
32358993Sps			uint16_t	CardSelNum;
32458993Sps		} pnp;
32558993Sps	} info;
32658993Sps} PACKED t_PXENV_UNDI_GET_NIC_TYPE;
32758993Sps
32858993Sps#define	PXENV_UNDI_GET_IFACE_INFO	0x0013
32958993Spstypedef struct {
33058993Sps	PXENV_STATUS_t	Status;
33158993Sps	uint8_t		IfaceType[16];		/* Name of MAC type in ASCII. */
33258993Sps	uint32_t	LinkSpeed;		/* Defined in NDIS 2.0 spec */
33358993Sps	uint32_t	ServiceFlags;		/* Defined in NDIS 2.0 spec */
33458993Sps	uint32_t	Reserved[4];		/* must be 0 */
33558993Sps} PACKED t_PXENV_UNDI_GET_NDIS_INFO;
33658993Sps
33758993Sps#define	PXENV_UNDI_ISR			0x0014
33858993Spstypedef struct {
33958993Sps	PXENV_STATUS_t	Status;
34058993Sps	uint16_t	FuncFlag;		/* PXENV_UNDI_ISR_OUT_xxx */
34158993Sps	uint16_t	BufferLength;		/* Length of Frame */
34258993Sps	uint16_t	FrameLength;		/* Total length of reciever frame */
34358993Sps	uint16_t	FrameHeaderLength;	/* Length of the media header in Frame */
34458993Sps	SEGOFF16_t	Frame;			/* receive buffer */
34558993Sps	uint8_t		ProtType;		/* Protocol type */
34658993Sps	uint8_t		PktType;		/* Packet Type */
34758993Sps#	define PXENV_UNDI_ISR_IN_START		1
34858993Sps#	define PXENV_UNDI_ISR_IN_PROCESS	2
34958993Sps#	define PXENV_UNDI_ISR_IN_GET_NEXT	3
35058993Sps
35158993Sps	/* one of these will be returned for PXENV_UNDI_ISR_IN_START */
35258993Sps#	define PXENV_UNDI_ISR_OUT_OURS		0
35358993Sps#	define PXENV_UNDI_ISR_OUT_NOT_OUTS	1
35458993Sps
35558993Sps	/*
35658993Sps	 * one of these will bre returnd for PXEND_UNDI_ISR_IN_PROCESS
35758993Sps	 * and PXENV_UNDI_ISR_IN_GET_NEXT
35858993Sps	 */
35958993Sps#	define PXENV_UNDI_ISR_OUT_DONE		0
36058993Sps#	define PXENV_UNDI_ISR_OUT_TRANSMIT	2
36158993Sps#	define PXENV_UNDI_ISR_OUT_RECIEVE	3
36258993Sps#	define PXENV_UNDI_ISR_OUT_BUSY		4
36358993Sps} PACKED t_PXENV_UNDI_ISR;
36458993Sps
36558993Sps#define	PXENV_STOP_UNDI			0x0015
36658993Spstypedef struct {
36758993Sps	PXENV_STATUS_t	Status;
36858993Sps} PACKED t_PXENV_STOP_UNDI;
36958993Sps
37058993Sps#define	PXENV_TFTP_OPEN			0x0020
37158993Spstypedef struct {
37258993Sps	PXENV_STATUS_t	Status;
37358993Sps	IP4_t		ServerIPAddress;
37458993Sps	IP4_t		GatewayIPAddress;
37558993Sps	uint8_t		FileName[128];
37658993Sps	UDP_PORT_t	TFTPPort;
37758993Sps	uint16_t	PacketSize;
37858993Sps} PACKED t_PXENV_TFTP_OPEN;
37958993Sps
38058993Sps#define	PXENV_TFTP_CLOSE		0x0021
38158993Spstypedef struct {
38258993Sps	PXENV_STATUS_t	Status;
38358993Sps} PACKED t_PXENV_TFTP_CLOSE;
38458993Sps
38558993Sps#define	PXENV_TFTP_READ			0x0022
38658993Spstypedef struct {
38758993Sps	PXENV_STATUS_t	Status;
38858993Sps	uint16_t	PacketNumber;
38958993Sps	uint16_t	BufferSize;
39058993Sps	SEGOFF16_t	Buffer;
39158993Sps} PACKED t_PXENV_TFTP_READ;
39258993Sps
39358993Sps#define	PXENV_TFTP_READ_FILE		0x0023
39458993Spstypedef struct {
39558993Sps	PXENV_STATUS_t	Status;
39658993Sps	uint8_t		FileName[128];
39758993Sps	uint32_t	BufferSize;
39858993Sps	ADDR32_t	Buffer;
39958993Sps	IP4_t		ServerIPAddress;
40058993Sps	IP4_t		GatewayIPAdress;
40158993Sps	IP4_t		McastIPAdress;
40258993Sps	UDP_PORT_t	TFTPClntPort;
40358993Sps	UDP_PORT_t	TFTPSrvPort;
40458993Sps	uint16_t	TFTPOpenTimeOut;
40558993Sps	uint16_t	TFTPReopenDelay;
40658993Sps} PACKED t_PXENV_TFTP_READ_FILE;
40758993Sps
40858993Sps#define	PXENV_TFTP_GET_FSIZE		0x0025
40958993Spstypedef struct {
41058993Sps	PXENV_STATUS_t	Status;
41158993Sps	IP4_t		ServerIPAddress;
41258993Sps	IP4_t		GatewayIPAdress;
41358993Sps	uint8_t		FileName[128];
41458993Sps	uint32_t	FileSize;
41558993Sps} PACKED t_PXENV_TFTP_GET_FSIZE;
41658993Sps
41758993Sps#define	PXENV_UDP_OPEN			0x0030
41858993Spstypedef struct {
41958993Sps	PXENV_STATUS_t	status;
42058993Sps	IP4_t		src_ip;		/* IP address of this station */
42158993Sps} PACKED t_PXENV_UDP_OPEN;
42258993Sps
42358993Sps#define	PXENV_UDP_CLOSE			0x0031
42458993Spstypedef struct {
42558993Sps	PXENV_STATUS_t	status;
42658993Sps} PACKED t_PXENV_UDP_CLOSE;
42758993Sps
42858993Sps#define	PXENV_UDP_READ			0x0032
42958993Spstypedef struct {
43058993Sps	PXENV_STATUS_t	status;
43158993Sps	IP4_t		src_ip;		/* IP of sender */
43258993Sps	IP4_t		dest_ip;	/* Only accept packets sent to this IP */
43358993Sps	UDP_PORT_t	s_port;		/* UDP source port of sender */
43458993Sps	UDP_PORT_t	d_port;		/* Only accept packets sent to this port */
43558993Sps	uint16_t	buffer_size;	/* Size of the packet buffer */
43658993Sps	SEGOFF16_t	buffer;		/* SEG:OFF to the packet buffer */
43758993Sps} PACKED t_PXENV_UDP_READ;
43858993Sps
43958999Sps#define	PXENV_UDP_WRITE			0x0033
44058999Spstypedef struct {
44158999Sps	PXENV_STATUS_t	status;
44258999Sps	IP4_t		ip;		/* dest ip addr */
44358999Sps	IP4_t		gw;		/* ip gateway */
44458999Sps	UDP_PORT_t	src_port;	/* source udp port */
44558999Sps	UDP_PORT_t	dst_port;	/* destination udp port */
44658999Sps	uint16_t	buffer_size;	/* Size of the packet buffer */
44758999Sps	SEGOFF16_t	buffer;		/* SEG:OFF to the packet buffer */
44858999Sps} PACKED t_PXENV_UDP_WRITE;
44958999Sps
45058993Sps#define	PXENV_UNLOAD_STACK		0x0070
45158993Spstypedef struct {
45258993Sps	PXENV_STATUS_t	Status;
45358993Sps	uint8_t		reserved[10];
45458993Sps} PACKED t_PXENV_UNLOAD_STACK;
45558993Sps
45658993Sps
45758993Sps#define	PXENV_GET_CACHED_INFO		0x0071
45858993Spstypedef struct {
45958993Sps	PXENV_STATUS_t	Status;
46058993Sps	uint16_t	PacketType;	/* type (defined right here) */
46158993Sps#	define PXENV_PACKET_TYPE_DHCP_DISCOVER  1
46258993Sps#	define PXENV_PACKET_TYPE_DHCP_ACK       2
46358993Sps#	define PXENV_PACKET_TYPE_BINL_REPLY     3
46458993Sps	uint16_t	BufferSize;	/* max to copy, leave at 0 for pointer */
46558993Sps	SEGOFF16_t	Buffer;		/* copy to, leave at 0 for pointer */
46658993Sps	uint16_t	BufferLimit;	/* max size of buffer in BC dataseg ? */
46758993Sps} PACKED t_PXENV_GET_CACHED_INFO;
46858993Sps
46958993Sps
47058993Sps/* structure filled in by PXENV_GET_CACHED_INFO
47158993Sps * (how we determine which IP we downloaded the initial bootstrap from)
47258993Sps * words can't describe...
47358993Sps */
47458993Spstypedef struct {
47558993Sps	uint8_t		opcode;
47658993Sps#	define BOOTP_REQ	1
47758993Sps#	define BOOTP_REP	2
47858993Sps	uint8_t		Hardware;	/* hardware type */
47958993Sps	uint8_t		Hardlen;	/* hardware addr len */
48058993Sps	uint8_t		Gatehops;	/* zero it */
48158993Sps	uint32_t	ident;		/* random number chosen by client */
48258993Sps	uint16_t	seconds;	/* seconds since did initial bootstrap */
48358993Sps	uint16_t	Flags;		/* seconds since did initial bootstrap */
48458993Sps#	define BOOTP_BCAST	0x8000		/* ? */
48558993Sps	IP4_t		cip;		/* Client IP */
48658993Sps	IP4_t		yip;		/* Your IP */
48758993Sps	IP4_t		sip;		/* IP to use for next boot stage */
48858993Sps	IP4_t		gip;		/* Relay IP ? */
48958993Sps	MAC_ADDR	CAddr;		/* Client hardware address */
49058993Sps	uint8_t		Sname[64];	/* Server's hostname (Optional) */
49158993Sps	uint8_t		bootfile[128];	/* boot filename */
49258993Sps	union {
49358993Sps#		if 1
49458993Sps#		define BOOTP_DHCPVEND  1024    /* DHCP extended vendor field size */
49558993Sps#		else
49658993Sps#		define BOOTP_DHCPVEND  312	/* DHCP standard vendor field size */
49758993Sps#		endif
49858993Sps		uint8_t		d[BOOTP_DHCPVEND];	/* raw array of vendor/dhcp options */
49958993Sps		struct {
50058993Sps			uint8_t		magic[4];	/* DHCP magic cookie */
50164527Sps#			ifndef		VM_RFC1048
50258993Sps#			define		VM_RFC1048	0x63825363L	/* ? */
50364527Sps#			endif
50458993Sps			uint32_t	flags;		/* bootp flags/opcodes */
50558993Sps			uint8_t		pad[56];	/* I don't think intel knows what a
50658993Sps							   union does... */
50758993Sps		} v;
50858993Sps	} vendor;
50958993Sps} PACKED BOOTPLAYER;
51058993Sps
51158993Sps#define	PXENV_RESTART_TFTP		0x0073
51258993Sps#define	t_PXENV_RESTART_TFTP		t_PXENV_TFTP_READ_FILE
51358993Sps
51458993Sps#define	PXENV_START_BASE		0x0075
51558993Spstypedef struct {
51658993Sps	PXENV_STATUS_t	Status;
51758993Sps} PACKED t_PXENV_START_BASE;
51858993Sps
51958993Sps#define	PXENV_STOP_BASE			0x0076
52058993Spstypedef struct {
52158993Sps	PXENV_STATUS_t	Status;
52258993Sps} PACKED t_PXENV_STOP_BASE;
523