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
5559087Sps#define	PXENFSROOTPATH	"/pxeroot"
5659087Sps
5758993Spstypedef struct {
5858993Sps	uint16_t		offset;
5958993Sps	uint16_t		segment;
6058993Sps} SEGOFF16_t;
6158993Sps
6258993Spstypedef struct {
6358993Sps	uint16_t		Seg_Addr;
6458993Sps	uint32_t		Phy_Addr;
6558993Sps	uint16_t		Seg_Size;
6658993Sps} SEGDESC_t;
6758993Sps
6858993Spstypedef	uint16_t		SEGSEL_t;
6958993Spstypedef	uint16_t		PXENV_STATUS_t;
7058993Spstypedef	uint32_t		IP4_t;
7158993Spstypedef	uint32_t		ADDR32_t;
7258993Spstypedef	uint16_t		UDP_PORT_t;
7358993Sps
7458993Sps#define	MAC_ADDR_LEN		16
7558993Spstypedef	uint8_t			MAC_ADDR[MAC_ADDR_LEN];
7658993Sps
7758993Sps/* PXENV+ */
7858993Spstypedef struct {
7958993Sps	uint8_t		Signature[6];	/* 'PXENV+' */
8058993Sps	uint16_t	Version;	/* MSB = major, LSB = minor */
8158993Sps	uint8_t		Length;		/* structure length */
8258993Sps	uint8_t		Checksum;	/* checksum pad */
8358993Sps	SEGOFF16_t	RMEntry;	/* SEG:OFF to PXE entry point */
8458993Sps	/* don't use PMOffset and PMSelector (from the 2.1 PXE manual) */
8558993Sps	uint32_t	PMOffset;	/* Protected mode entry */
8658993Sps	SEGSEL_t	PMSelector;	/* Protected mode selector */
8758993Sps	SEGSEL_t	StackSeg;	/* Stack segment address */
8858993Sps	uint16_t	StackSize;	/* Stack segment size (bytes) */
8958993Sps	SEGSEL_t	BC_CodeSeg;	/* BC Code segment address */
9058993Sps	uint16_t	BC_CodeSize;	/* BC Code segment size (bytes) */
9158993Sps	SEGSEL_t	BC_DataSeg;	/* BC Data segment address */
9258993Sps	uint16_t	BC_DataSize;	/* BC Data segment size (bytes) */
9358993Sps	SEGSEL_t	UNDIDataSeg;	/* UNDI Data segment address */
9458993Sps	uint16_t	UNDIDataSize;	/* UNDI Data segment size (bytes) */
9558993Sps	SEGSEL_t	UNDICodeSeg;	/* UNDI Code segment address */
9658993Sps	uint16_t	UNDICodeSize;	/* UNDI Code segment size (bytes) */
9758993Sps	SEGOFF16_t	PXEPtr;		/* SEG:OFF to !PXE struct,
9858993Sps					   only present when Version > 2.1 */
9958993Sps} PACKED pxenv_t;
10058993Sps
10158993Sps/* !PXE */
10258993Spstypedef struct {
10358993Sps	uint8_t		Signature[4];
10458993Sps	uint8_t		StructLength;
10558993Sps	uint8_t		StructCksum;
10658993Sps	uint8_t		StructRev;
10758993Sps	uint8_t		reserved_1;
10858993Sps	SEGOFF16_t	UNDIROMID;
10958993Sps	SEGOFF16_t	BaseROMID;
11058993Sps	SEGOFF16_t	EntryPointSP;
11158993Sps	SEGOFF16_t	EntryPointESP;
11258993Sps	SEGOFF16_t	StatusCallout;
11358993Sps	uint8_t		reserved_2;
11458993Sps	uint8_t		SegDescCn;
11558993Sps	SEGSEL_t	FirstSelector;
11658993Sps	SEGDESC_t	Stack;
11758993Sps	SEGDESC_t	UNDIData;
11858993Sps	SEGDESC_t	UNDICode;
11958993Sps	SEGDESC_t	UNDICodeWrite;
12058993Sps	SEGDESC_t	BC_Data;
12158993Sps	SEGDESC_t	BC_Code;
12258993Sps	SEGDESC_t	BC_CodeWrite;
12358993Sps} PACKED pxe_t;
12458993Sps
12558993Sps#define	PXENV_START_UNDI		0x0000
12658993Spstypedef struct {
12758993Sps	PXENV_STATUS_t	Status;
12858993Sps	uint16_t	ax;
12958993Sps	uint16_t	bx;
13058993Sps	uint16_t	dx;
13158993Sps	uint16_t	di;
13258993Sps	uint16_t	es;
13358993Sps} PACKED t_PXENV_START_UNDI;
13458993Sps
13558993Sps#define	PXENV_UNDI_STARTUP		0x0001
13658993Spstypedef struct {
13758993Sps	PXENV_STATUS_t	Status;
13858993Sps} PACKED t_PXENV_UNDI_STARTUP;
13958993Sps
14058993Sps#define	PXENV_UNDI_CLEANUP		0x0002
14158993Spstypedef struct {
14258993Sps	PXENV_STATUS_t	Status;
14358993Sps} PACKED t_PXENV_UNDI_CLEANUP;
14458993Sps
14558993Sps#define	PXENV_UNDI_INITIALIZE		0x0003
14658993Spstypedef struct {
14758993Sps	PXENV_STATUS_t	Status;
14858993Sps	ADDR32_t	ProtocolIni;	/* Phys addr of a copy of the driver module */
14958993Sps	uint8_t		reserved[8];
15058993Sps} PACKED t_PXENV_UNDI_INITALIZE;
15158993Sps
15258993Sps
15358993Sps#define	MAXNUM_MCADDR		8
15458993Spstypedef struct {
15558993Sps	PXENV_STATUS_t	Status;
15658993Sps	uint16_t	MCastAddrCount;
15758993Sps	MAC_ADDR	McastAddr[MAXNUM_MCADDR];
15858993Sps} PACKED t_PXENV_UNDI_MCAST_ADDRESS;
15958993Sps
16058993Sps#define	PXENV_UNDI_RESET_ADAPTER	0x0004
16158993Spstypedef struct {
16258993Sps	PXENV_STATUS_t	Status;
16358993Sps	t_PXENV_UNDI_MCAST_ADDRESS R_Mcast_Buf;
16458993Sps} PACKED t_PXENV_UNDI_RESET;
16558993Sps
16658993Sps#define	PXENV_UNDI_SHUTDOWN		0x0005
16758993Spstypedef struct {
16858993Sps	PXENV_STATUS_t	Status;
16958993Sps} PACKED t_PXENV_UNDI_SHUTDOWN;
17058993Sps
17158993Sps#define	PXENV_UNDI_OPEN			0x0006
17258993Spstypedef struct {
17358993Sps	PXENV_STATUS_t	Status;
17458993Sps	uint16_t	OpenFlag;
17558993Sps	uint16_t	PktFilter;
17658993Sps#	define FLTR_DIRECTED	0x0001
17758993Sps#	define FLTR_BRDCST	0x0002
17858993Sps#	define FLTR_PRMSCS	0x0003
17958993Sps#	define FLTR_SRC_RTG	0x0004
18058993Sps
18158993Sps	t_PXENV_UNDI_MCAST_ADDRESS R_Mcast_Buf;
18258993Sps} PACKED t_PXENV_UNDI_OPEN;
18358993Sps
18458993Sps#define	PXENV_UNDI_CLOSE		0x0007
18558993Spstypedef struct {
18658993Sps	PXENV_STATUS_t	Status;
18758993Sps} PACKED t_PXENV_UNDI_CLOSE;
18858993Sps
18958993Sps#define	PXENV_UNDI_TRANSMIT		0x0008
19058993Spstypedef struct {
19158993Sps	PXENV_STATUS_t	Status;
19258993Sps	uint8_t		Protocol;
19358993Sps#	define P_UNKNOWN	0
19458993Sps#	define P_IP		1
19558993Sps#	define P_ARP		2
19658993Sps#	define P_RARP		3
19758993Sps
19858993Sps	uint8_t		XmitFlag;
19958993Sps#	define XMT_DESTADDR	0x0000
20058993Sps#	define XMT_BROADCAST	0x0001
20158993Sps
20258993Sps	SEGOFF16_t	DestAddr;
20358993Sps	SEGOFF16_t	TBD;
20458993Sps	uint32_t	Reserved[2];
20558993Sps} PACKED t_PXENV_UNDI_TRANSMIT;
20658993Sps
20758993Sps#define	MAX_DATA_BLKS		8
20858993Spstypedef struct {
20958993Sps	uint16_t	ImmedLength;
21058993Sps	SEGOFF16_t	Xmit;
21158993Sps	uint16_t	DataBlkCount;
21258993Sps	struct	DataBlk {
21358993Sps		uint8_t		TDPtrType;
21458993Sps		uint8_t		TDRsvdByte;
21558993Sps		uint16_t	TDDataLen;
21658993Sps		SEGOFF16_t	TDDataPtr;
21758993Sps	} DataBlock[MAX_DATA_BLKS];
21858993Sps} PACKED t_PXENV_UNDI_TBD;
21958993Sps
22058993Sps#define	PXENV_UNDI_SET_MCAST_ADDRESS	0x0009
22158993Spstypedef struct {
22258993Sps	PXENV_STATUS_t	Status;
22358993Sps	t_PXENV_UNDI_MCAST_ADDRESS R_Mcast_Buf;
22458993Sps} PACKED t_PXENV_UNDI_SET_MCAST_ADDR;
22558993Sps
22658993Sps#define	PXENV_UNDI_SET_STATION_ADDRESS	0x000A
22758993Spstypedef struct {
22858993Sps	PXENV_STATUS_t	Status;
22958993Sps	MAC_ADDR	StationAddress;		/* Temp MAC addres to use */
23058993Sps} PACKED t_PXENV_UNDI_SET_STATION_ADDR;
23158993Sps
23258993Sps#define	PXENV_UNDI_SET_PACKET_FILTER	0x000B
23358993Spstypedef struct {
23458993Sps	PXENV_STATUS_t	Status;
23558993Sps	uint8_t		filter;			/* see UNDI_OPEN (0x0006) */
23658993Sps} PACKED t_PXENV_UNDI_SET_PACKET_FILTER;
23758993Sps
23858993Sps#define	PXENV_UNDI_GET_INFORMATION	0x000C
23958993Spstypedef struct {
24058993Sps	PXENV_STATUS_t	Status;
24158993Sps	uint16_t	BaseIo;			/* Adapter base I/O address */
24258993Sps	uint16_t	IntNumber;		/* Adapter IRQ number */
24358993Sps	uint16_t	MaxTranUnit;		/* Adapter maximum transmit unit */
24458993Sps	uint16_t	HwType;			/* Type of protocol at the hardware addr */
24558993Sps#	define ETHER_TYPE	1
24658993Sps#	define EXP_ETHER_TYPE	2
24758993Sps#	define IEEE_TYPE	6
24858993Sps#	define ARCNET_TYPE	7
24958993Sps
25058993Sps	uint16_t	HwAddrLen;		/* Length of hardware address */
25158993Sps	MAC_ADDR	CurrentNodeAddress;	/* Current hardware address */
25258993Sps	MAC_ADDR	PermNodeAddress;	/* Permanent hardware address */
25358993Sps	SEGSEL_t	ROMAddress;		/* Real mode ROM segment address */
25458993Sps	uint16_t	RxBufCt;		/* Receive queue length */
25558993Sps	uint16_t	TxBufCt;		/* Transmit queue length */
25658993Sps} PACKED t_PXENV_UNDI_GET_INFORMATION;
25758993Sps
25858993Sps#define	PXENV_UNDI_GET_STATISTICS	0x000D
25958993Spstypedef struct {
26058993Sps	PXENV_STATUS_t	Status;
26158993Sps	uint32_t	XmitGoodFrames;		/* Number of successful transmissions */
26258993Sps	uint32_t	RcvGoodFrames;		/* Number of good frames received */
26358993Sps	uint32_t	RcvCRCErrors;		/* Number of frames with CRC errors */
26458993Sps	uint32_t	RcvResourceErrors;	/* Number of frames dropped */
26558993Sps} PACKED t_PXENV_UNDI_GET_STATISTICS;
26658993Sps
26758993Sps#define	PXENV_UNDI_CLEAR_STATISTICS	0x000E
26858993Spstypedef struct {
26958993Sps	PXENV_STATUS_t	Status;
27058993Sps} PACKED t_PXENV_UNDI_CLEAR_STATISTICS;
27158993Sps
27258993Sps#define	PXENV_UNDI_INITIATE_DIAGS	0x000F
27358993Spstypedef struct {
27458993Sps	PXENV_STATUS_t	Status;
27558993Sps} PACKED t_PXENV_UNDI_INITIATE_DIAGS;
27658993Sps
27758993Sps#define	PXENV_UNDI_FORCE_INTERRUPT	0x0010
27858993Spstypedef struct {
27958993Sps	PXENV_STATUS_t	Status;
28058993Sps} PACKED t_PXENV_UNDI_FORCE_INTERRUPT;
28158993Sps
28258993Sps#define	PXENV_UNDI_GET_MCAST_ADDRESS	0x0011
28358993Spstypedef struct {
28458993Sps	PXENV_STATUS_t	Status;
28558993Sps	IP4_t		InetAddr;		/* IP mulicast address */
28658993Sps	MAC_ADDR	MediaAddr;		/* MAC multicast address */
28758993Sps} PACKED t_PXENV_UNDI_GET_MCAST_ADDR;
28858993Sps
28958993Sps#define	PXENV_UNDI_GET_NIC_TYPE		0x0012
29058993Spstypedef struct {
29158993Sps	PXENV_STATUS_t	Status;
29258993Sps	uint8_t		NicType;		/* Type of NIC */
29358993Sps#	define PCI_NIC		2
29458993Sps#	define PnP_NIC		3
29558993Sps#	define CardBus_NIC	4
29658993Sps
29758993Sps	union {
29858993Sps		struct {
29958993Sps			uint16_t	Vendor_ID;
30058993Sps			uint16_t	Dev_ID;
30158993Sps			uint8_t		Base_Class;
30258993Sps			uint8_t		Sub_Class;
30358993Sps			uint8_t		Prog_Intf;
30458993Sps			uint8_t		Rev;
30558993Sps			uint16_t	BusDevFunc;
30658993Sps			uint16_t	SubVendor_ID;
30758993Sps			uint16_t	SubDevice_ID;
30858993Sps		} pci, cardbus;
30958993Sps		struct {
31058993Sps			uint32_t	EISA_Dev_ID;
31158993Sps			uint8_t		Base_Class;
31258993Sps			uint8_t		Sub_Class;
31358993Sps			uint8_t		Prog_Intf;
31458993Sps			uint16_t	CardSelNum;
31558993Sps		} pnp;
31658993Sps	} info;
31758993Sps} PACKED t_PXENV_UNDI_GET_NIC_TYPE;
31858993Sps
31958993Sps#define	PXENV_UNDI_GET_IFACE_INFO	0x0013
32058993Spstypedef struct {
32158993Sps	PXENV_STATUS_t	Status;
32258993Sps	uint8_t		IfaceType[16];		/* Name of MAC type in ASCII. */
32358993Sps	uint32_t	LinkSpeed;		/* Defined in NDIS 2.0 spec */
32458993Sps	uint32_t	ServiceFlags;		/* Defined in NDIS 2.0 spec */
32558993Sps	uint32_t	Reserved[4];		/* must be 0 */
32658993Sps} PACKED t_PXENV_UNDI_GET_NDIS_INFO;
32758993Sps
32858993Sps#define	PXENV_UNDI_ISR			0x0014
32958993Spstypedef struct {
33058993Sps	PXENV_STATUS_t	Status;
33158993Sps	uint16_t	FuncFlag;		/* PXENV_UNDI_ISR_OUT_xxx */
33258993Sps	uint16_t	BufferLength;		/* Length of Frame */
33358993Sps	uint16_t	FrameLength;		/* Total length of reciever frame */
33458993Sps	uint16_t	FrameHeaderLength;	/* Length of the media header in Frame */
33558993Sps	SEGOFF16_t	Frame;			/* receive buffer */
33658993Sps	uint8_t		ProtType;		/* Protocol type */
33758993Sps	uint8_t		PktType;		/* Packet Type */
33858993Sps#	define PXENV_UNDI_ISR_IN_START		1
33958993Sps#	define PXENV_UNDI_ISR_IN_PROCESS	2
34058993Sps#	define PXENV_UNDI_ISR_IN_GET_NEXT	3
34158993Sps
34258993Sps	/* one of these will be returned for PXENV_UNDI_ISR_IN_START */
34358993Sps#	define PXENV_UNDI_ISR_OUT_OURS		0
34458993Sps#	define PXENV_UNDI_ISR_OUT_NOT_OUTS	1
34558993Sps
34658993Sps	/*
34758993Sps	 * one of these will bre returnd for PXEND_UNDI_ISR_IN_PROCESS
34858993Sps	 * and PXENV_UNDI_ISR_IN_GET_NEXT
34958993Sps	 */
35058993Sps#	define PXENV_UNDI_ISR_OUT_DONE		0
35158993Sps#	define PXENV_UNDI_ISR_OUT_TRANSMIT	2
35258993Sps#	define PXENV_UNDI_ISR_OUT_RECIEVE	3
35358993Sps#	define PXENV_UNDI_ISR_OUT_BUSY		4
35458993Sps} PACKED t_PXENV_UNDI_ISR;
35558993Sps
35658993Sps#define	PXENV_STOP_UNDI			0x0015
35758993Spstypedef struct {
35858993Sps	PXENV_STATUS_t	Status;
35958993Sps} PACKED t_PXENV_STOP_UNDI;
36058993Sps
36158993Sps#define	PXENV_TFTP_OPEN			0x0020
36258993Spstypedef struct {
36358993Sps	PXENV_STATUS_t	Status;
36458993Sps	IP4_t		ServerIPAddress;
36558993Sps	IP4_t		GatewayIPAddress;
36658993Sps	uint8_t		FileName[128];
36758993Sps	UDP_PORT_t	TFTPPort;
36858993Sps	uint16_t	PacketSize;
36958993Sps} PACKED t_PXENV_TFTP_OPEN;
37058993Sps
37158993Sps#define	PXENV_TFTP_CLOSE		0x0021
37258993Spstypedef struct {
37358993Sps	PXENV_STATUS_t	Status;
37458993Sps} PACKED t_PXENV_TFTP_CLOSE;
37558993Sps
37658993Sps#define	PXENV_TFTP_READ			0x0022
37758993Spstypedef struct {
37858993Sps	PXENV_STATUS_t	Status;
37958993Sps	uint16_t	PacketNumber;
38058993Sps	uint16_t	BufferSize;
38158993Sps	SEGOFF16_t	Buffer;
38258993Sps} PACKED t_PXENV_TFTP_READ;
38358993Sps
38458993Sps#define	PXENV_TFTP_READ_FILE		0x0023
38558993Spstypedef struct {
38658993Sps	PXENV_STATUS_t	Status;
38758993Sps	uint8_t		FileName[128];
38858993Sps	uint32_t	BufferSize;
38958993Sps	ADDR32_t	Buffer;
39058993Sps	IP4_t		ServerIPAddress;
39158993Sps	IP4_t		GatewayIPAdress;
39258993Sps	IP4_t		McastIPAdress;
39358993Sps	UDP_PORT_t	TFTPClntPort;
39458993Sps	UDP_PORT_t	TFTPSrvPort;
39558993Sps	uint16_t	TFTPOpenTimeOut;
39658993Sps	uint16_t	TFTPReopenDelay;
39758993Sps} PACKED t_PXENV_TFTP_READ_FILE;
39858993Sps
39958993Sps#define	PXENV_TFTP_GET_FSIZE		0x0025
40058993Spstypedef struct {
40158993Sps	PXENV_STATUS_t	Status;
40258993Sps	IP4_t		ServerIPAddress;
40358993Sps	IP4_t		GatewayIPAdress;
40458993Sps	uint8_t		FileName[128];
40558993Sps	uint32_t	FileSize;
40658993Sps} PACKED t_PXENV_TFTP_GET_FSIZE;
40758993Sps
40858993Sps#define	PXENV_UDP_OPEN			0x0030
40958993Spstypedef struct {
41058993Sps	PXENV_STATUS_t	status;
41158993Sps	IP4_t		src_ip;		/* IP address of this station */
41258993Sps} PACKED t_PXENV_UDP_OPEN;
41358993Sps
41458993Sps#define	PXENV_UDP_CLOSE			0x0031
41558993Spstypedef struct {
41658993Sps	PXENV_STATUS_t	status;
41758993Sps} PACKED t_PXENV_UDP_CLOSE;
41858993Sps
41958993Sps#define	PXENV_UDP_READ			0x0032
42058993Spstypedef struct {
42158993Sps	PXENV_STATUS_t	status;
42258993Sps	IP4_t		src_ip;		/* IP of sender */
42358993Sps	IP4_t		dest_ip;	/* Only accept packets sent to this IP */
42458993Sps	UDP_PORT_t	s_port;		/* UDP source port of sender */
42558993Sps	UDP_PORT_t	d_port;		/* Only accept packets sent to this port */
42658993Sps	uint16_t	buffer_size;	/* Size of the packet buffer */
42758993Sps	SEGOFF16_t	buffer;		/* SEG:OFF to the packet buffer */
42858993Sps} PACKED t_PXENV_UDP_READ;
42958993Sps
43058999Sps#define	PXENV_UDP_WRITE			0x0033
43158999Spstypedef struct {
43258999Sps	PXENV_STATUS_t	status;
43358999Sps	IP4_t		ip;		/* dest ip addr */
43458999Sps	IP4_t		gw;		/* ip gateway */
43558999Sps	UDP_PORT_t	src_port;	/* source udp port */
43658999Sps	UDP_PORT_t	dst_port;	/* destination udp port */
43758999Sps	uint16_t	buffer_size;	/* Size of the packet buffer */
43858999Sps	SEGOFF16_t	buffer;		/* SEG:OFF to the packet buffer */
43958999Sps} PACKED t_PXENV_UDP_WRITE;
44058999Sps
44158993Sps#define	PXENV_UNLOAD_STACK		0x0070
44258993Spstypedef struct {
44358993Sps	PXENV_STATUS_t	Status;
44458993Sps	uint8_t		reserved[10];
44558993Sps} PACKED t_PXENV_UNLOAD_STACK;
44658993Sps
44758993Sps
44858993Sps#define	PXENV_GET_CACHED_INFO		0x0071
44958993Spstypedef struct {
45058993Sps	PXENV_STATUS_t	Status;
45158993Sps	uint16_t	PacketType;	/* type (defined right here) */
45258993Sps#	define PXENV_PACKET_TYPE_DHCP_DISCOVER  1
45358993Sps#	define PXENV_PACKET_TYPE_DHCP_ACK       2
45458993Sps#	define PXENV_PACKET_TYPE_BINL_REPLY     3
45558993Sps	uint16_t	BufferSize;	/* max to copy, leave at 0 for pointer */
45658993Sps	SEGOFF16_t	Buffer;		/* copy to, leave at 0 for pointer */
45758993Sps	uint16_t	BufferLimit;	/* max size of buffer in BC dataseg ? */
45858993Sps} PACKED t_PXENV_GET_CACHED_INFO;
45958993Sps
46058993Sps
46158993Sps/* structure filled in by PXENV_GET_CACHED_INFO
46258993Sps * (how we determine which IP we downloaded the initial bootstrap from)
46358993Sps * words can't describe...
46458993Sps */
46558993Spstypedef struct {
46658993Sps	uint8_t		opcode;
46758993Sps#	define BOOTP_REQ	1
46858993Sps#	define BOOTP_REP	2
46958993Sps	uint8_t		Hardware;	/* hardware type */
47058993Sps	uint8_t		Hardlen;	/* hardware addr len */
47158993Sps	uint8_t		Gatehops;	/* zero it */
47258993Sps	uint32_t	ident;		/* random number chosen by client */
47358993Sps	uint16_t	seconds;	/* seconds since did initial bootstrap */
47458993Sps	uint16_t	Flags;		/* seconds since did initial bootstrap */
47558993Sps#	define BOOTP_BCAST	0x8000		/* ? */
47658993Sps	IP4_t		cip;		/* Client IP */
47758993Sps	IP4_t		yip;		/* Your IP */
47858993Sps	IP4_t		sip;		/* IP to use for next boot stage */
47958993Sps	IP4_t		gip;		/* Relay IP ? */
48058993Sps	MAC_ADDR	CAddr;		/* Client hardware address */
48158993Sps	uint8_t		Sname[64];	/* Server's hostname (Optional) */
48258993Sps	uint8_t		bootfile[128];	/* boot filename */
48358993Sps	union {
48458993Sps#		if 1
48558993Sps#		define BOOTP_DHCPVEND  1024    /* DHCP extended vendor field size */
48658993Sps#		else
48758993Sps#		define BOOTP_DHCPVEND  312	/* DHCP standard vendor field size */
48858993Sps#		endif
48958993Sps		uint8_t		d[BOOTP_DHCPVEND];	/* raw array of vendor/dhcp options */
49058993Sps		struct {
49158993Sps			uint8_t		magic[4];	/* DHCP magic cookie */
49264527Sps#			ifndef		VM_RFC1048
49358993Sps#			define		VM_RFC1048	0x63825363L	/* ? */
49464527Sps#			endif
49558993Sps			uint32_t	flags;		/* bootp flags/opcodes */
49658993Sps			uint8_t		pad[56];	/* I don't think intel knows what a
49758993Sps							   union does... */
49858993Sps		} v;
49958993Sps	} vendor;
50058993Sps} PACKED BOOTPLAYER;
50158993Sps
50258993Sps#define	PXENV_RESTART_TFTP		0x0073
50358993Sps#define	t_PXENV_RESTART_TFTP		t_PXENV_TFTP_READ_FILE
50458993Sps
50558993Sps#define	PXENV_START_BASE		0x0075
50658993Spstypedef struct {
50758993Sps	PXENV_STATUS_t	Status;
50858993Sps} PACKED t_PXENV_START_BASE;
50958993Sps
51058993Sps#define	PXENV_STOP_BASE			0x0076
51158993Spstypedef struct {
51258993Sps	PXENV_STATUS_t	Status;
51358993Sps} PACKED t_PXENV_STOP_BASE;
514