VirtualBox

source: vbox/trunk/src/VBox/Devices/PC/Etherboot-src/include/pxe.h@ 41371

最後變更 在這個檔案從41371是 1,由 vboxsync 提交於 55 年 前

import

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 30.6 KB
 
1/*
2 * pxe.h for Etherboot.
3 *
4 * PXE is technically specified only for i386, but there's no reason
5 * why we shouldn't make the API available for other architectures,
6 * provided that someone wants to write the shim that allows an
7 * external program to call pxe_api_call().
8 *
9 * We stick with Intel's data structure definitions as far as possible
10 * on other architectures. Generally the only i386-specific stuff is
11 * related to addressing: real-mode segment:offset addresses, segment
12 * selectors, segment descriptors etc. We allow an architecture-
13 * specific header to define these types, then build the PXE
14 * structures. Note that we retain the names from the PXE
15 * specification document (e.g. SEGOFF16_t) even if the architecture
16 * in question doesn't represent a SEGOFF16_t as anything resembling a
17 * 16-bit segment:offset address. This is done in order to keep the
18 * structure definitions as close as possible to those in the spec, to
19 * minimise confusion.
20 *
21 * This file derives from several originals. One is pxe.h from
22 * FreeBSD. Another is general.h86 from netboot. The original
23 * copyright notices are reproduced below. This entire file is
24 * licensed under the GPL; the netboot code is GPL anyway and the
25 * FreeBSD code allows us to relicense under the GPL provided that we
26 * retain the FreeBSD copyright notice. This is my understanding,
27 * anyway. Other portions are my own and therefore Copyright (C) 2004
28 * Michael Brown <[email protected]>.
29 *
30 * This program is free software; you can redistribute it and/or
31 * modify it under the terms of the GNU General Public License as
32 * published by the Free Software Foundation; either version 2 of the
33 * License, or any later version.
34 *
35 * This program is distributed in the hope that it will be useful, but
36 * WITHOUT ANY WARRANTY; without even the implied warranty of
37 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
38 * General Public License for more details.
39 *
40 * You should have received a copy of the GNU General Public License
41 * along with this program; if not, write to the Free Software
42 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
43 */
44
45#ifndef PXE_H
46#define PXE_H
47
48/* Include architecture-specific PXE data types
49 *
50 * May define SEGOFF16_t, SEGDESC_t and SEGSEL_t. These should be
51 * #defines to underlying * types. May also define
52 * IS_NULL_SEGOFF16(segoff16), SEGOFF16_TO_PTR(segoff16) and
53 * PTR_TO_SEGOFF16(ptr,segoff16)
54 */
55#ifndef PXE_TYPES_H
56#include <pxe_types.h>
57#endif
58
59/* Defaults in case pxe_types.h did not define a type. These are
60 * placeholder structures just to make the code compile.
61 */
62#ifndef SEGOFF16_t
63#define SEGOFF16_t void*
64#endif
65
66#ifndef IS_NULL_SEGOFF16
67#define IS_NULL_SEGOFF16(segoff16) ( (segoff16) == NULL )
68#endif
69
70#ifndef SEGOFF16_TO_PTR
71#define SEGOFF16_TO_PTR(segoff16) (segoff16)
72#endif
73
74#ifndef PTR_TO_SEGOFF16
75#define PTR_TO_SEGOFF16(ptr,segoff16) (segoff16) = (ptr);
76#endif
77
78#ifndef SEGDESC_t
79#define SEGDESC_t void
80#endif
81
82#ifndef SEGSEL_t
83#define SEGSEL_t void
84#endif
85
86/*****************************************************************************
87 * The following portion of this file is derived from FreeBSD's pxe.h.
88 * Do not remove the copyright notice below.
89 *****************************************************************************
90 */
91
92/*
93 * Copyright (c) 2000 Alfred Perlstein <[email protected]>
94 * All rights reserved.
95 * Copyright (c) 2000 Paul Saab <[email protected]>
96 * All rights reserved.
97 * Copyright (c) 2000 John Baldwin <[email protected]>
98 * All rights reserved.
99 *
100 * Redistribution and use in source and binary forms, with or without
101 * modification, are permitted provided that the following conditions
102 * are met:
103 * 1. Redistributions of source code must retain the above copyright
104 * notice, this list of conditions and the following disclaimer.
105 * 2. Redistributions in binary form must reproduce the above copyright
106 * notice, this list of conditions and the following disclaimer in the
107 * documentation and/or other materials provided with the distribution.
108 *
109 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
110 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
111 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
112 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
113 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
114 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
115 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
116 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
117 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
118 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
119 * SUCH DAMAGE.
120 *
121 * $FreeBSD: src/sys/boot/i386/libi386/pxe.h,v 1.4.2.2 2000/09/10 02:52:18 ps Exp $
122 */
123
124/*
125 * The typedefs and structures declared in this file
126 * clearly violate style(9), the reason for this is to conform to the
127 * typedefs/structure-names used in the Intel literature to avoid confusion.
128 *
129 * It's for your own good. :)
130 */
131
132/* It seems that intel didn't think about ABI,
133 * either that or 16bit ABI != 32bit ABI (which seems reasonable)
134 * I have to thank Intel for the hair loss I incurred trying to figure
135 * out why PXE was mis-reading structures I was passing it (at least
136 * from my point of view)
137 *
138 * Solution: use gcc's '__attribute__ ((packed))' to correctly align
139 * structures passed into PXE
140 * Question: does this really work for PXE's expected ABI?
141 */
142#ifndef PACKED
143#define PACKED __attribute__ ((packed))
144#endif
145
146#define S_SIZE(s) s, sizeof(s) - 1
147
148#define IP_STR "%d.%d.%d.%d"
149#define IP_ARGS(ip) \
150 (int)(ip >> 24) & 0xff, (int)(ip >> 16) & 0xff, \
151 (int)(ip >> 8) & 0xff, (int)ip & 0xff
152
153#define MAC_STR "%02x:%02x:%02x:%02x:%02x:%02x"
154#define MAC_ARGS(mac) \
155 mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]
156
157typedef uint16_t PXENV_EXIT_t;
158typedef uint16_t PXENV_STATUS_t;
159typedef uint32_t IP4_t;
160typedef uint32_t ADDR32_t;
161/* It seems as though UDP_PORT_t is in network order, although I can't
162 * find anything in the spec to back this up. (Michael Brown)
163 */
164typedef uint16_t UDP_PORT_t;
165
166#define MAC_ADDR_LEN 16
167typedef uint8_t MAC_ADDR[MAC_ADDR_LEN];
168
169/* PXENV+ */
170typedef struct {
171 uint8_t Signature[6]; /* 'PXENV+' */
172 uint16_t Version; /* MSB = major, LSB = minor */
173 uint8_t Length; /* structure length */
174 uint8_t Checksum; /* checksum pad */
175 SEGOFF16_t RMEntry; /* SEG:OFF to PXE entry point */
176 /* don't use PMOffset and PMSelector (from the 2.1 PXE manual) */
177 uint32_t PMOffset; /* Protected mode entry */
178 SEGSEL_t PMSelector; /* Protected mode selector */
179 SEGSEL_t StackSeg; /* Stack segment address */
180 uint16_t StackSize; /* Stack segment size (bytes) */
181 SEGSEL_t BC_CodeSeg; /* BC Code segment address */
182 uint16_t BC_CodeSize; /* BC Code segment size (bytes) */
183 SEGSEL_t BC_DataSeg; /* BC Data segment address */
184 uint16_t BC_DataSize; /* BC Data segment size (bytes) */
185 SEGSEL_t UNDIDataSeg; /* UNDI Data segment address */
186 uint16_t UNDIDataSize; /* UNDI Data segment size (bytes) */
187 SEGSEL_t UNDICodeSeg; /* UNDI Code segment address */
188 uint16_t UNDICodeSize; /* UNDI Code segment size (bytes) */
189 SEGOFF16_t PXEPtr; /* SEG:OFF to !PXE struct,
190 only present when Version > 2.1 */
191} PACKED pxenv_t;
192
193/* !PXE */
194typedef struct {
195 uint8_t Signature[4];
196 uint8_t StructLength;
197 uint8_t StructCksum;
198 uint8_t StructRev;
199 uint8_t reserved_1;
200 SEGOFF16_t UNDIROMID;
201 SEGOFF16_t BaseROMID;
202 SEGOFF16_t EntryPointSP;
203 SEGOFF16_t EntryPointESP;
204 SEGOFF16_t StatusCallout;
205 uint8_t reserved_2;
206 uint8_t SegDescCn;
207 SEGSEL_t FirstSelector;
208 SEGDESC_t Stack;
209 SEGDESC_t UNDIData;
210 SEGDESC_t UNDICode;
211 SEGDESC_t UNDICodeWrite;
212 SEGDESC_t BC_Data;
213 SEGDESC_t BC_Code;
214 SEGDESC_t BC_CodeWrite;
215} PACKED pxe_t;
216
217#define PXENV_START_UNDI 0x0000
218typedef struct {
219 PXENV_STATUS_t Status;
220 uint16_t ax;
221 uint16_t bx;
222 uint16_t dx;
223 uint16_t di;
224 uint16_t es;
225} PACKED t_PXENV_START_UNDI;
226
227#define PXENV_UNDI_STARTUP 0x0001
228typedef struct {
229 PXENV_STATUS_t Status;
230} PACKED t_PXENV_UNDI_STARTUP;
231
232#define PXENV_UNDI_CLEANUP 0x0002
233typedef struct {
234 PXENV_STATUS_t Status;
235} PACKED t_PXENV_UNDI_CLEANUP;
236
237#define PXENV_UNDI_INITIALIZE 0x0003
238typedef struct {
239 PXENV_STATUS_t Status;
240 ADDR32_t ProtocolIni; /* Phys addr of a copy of the driver module */
241 uint8_t reserved[8];
242} PACKED t_PXENV_UNDI_INITIALIZE;
243
244
245#define MAXNUM_MCADDR 8
246typedef struct {
247 uint16_t MCastAddrCount;
248 MAC_ADDR McastAddr[MAXNUM_MCADDR];
249} PACKED t_PXENV_UNDI_MCAST_ADDRESS;
250
251#define PXENV_UNDI_RESET_ADAPTER 0x0004
252typedef struct {
253 PXENV_STATUS_t Status;
254 t_PXENV_UNDI_MCAST_ADDRESS R_Mcast_Buf;
255} PACKED t_PXENV_UNDI_RESET_ADAPTER;
256
257#define PXENV_UNDI_SHUTDOWN 0x0005
258typedef struct {
259 PXENV_STATUS_t Status;
260} PACKED t_PXENV_UNDI_SHUTDOWN;
261
262#define PXENV_UNDI_OPEN 0x0006
263typedef struct {
264 PXENV_STATUS_t Status;
265 uint16_t OpenFlag;
266 uint16_t PktFilter;
267# define FLTR_DIRECTED 0x0001
268# define FLTR_BRDCST 0x0002
269# define FLTR_PRMSCS 0x0003
270# define FLTR_SRC_RTG 0x0004
271
272 t_PXENV_UNDI_MCAST_ADDRESS R_Mcast_Buf;
273} PACKED t_PXENV_UNDI_OPEN;
274
275#define PXENV_UNDI_CLOSE 0x0007
276typedef struct {
277 PXENV_STATUS_t Status;
278} PACKED t_PXENV_UNDI_CLOSE;
279
280#define PXENV_UNDI_TRANSMIT 0x0008
281typedef struct {
282 PXENV_STATUS_t Status;
283 uint8_t Protocol;
284# define P_UNKNOWN 0
285# define P_IP 1
286# define P_ARP 2
287# define P_RARP 3
288
289 uint8_t XmitFlag;
290# define XMT_DESTADDR 0x0000
291# define XMT_BROADCAST 0x0001
292
293 SEGOFF16_t DestAddr;
294 SEGOFF16_t TBD;
295 uint32_t Reserved[2];
296} PACKED t_PXENV_UNDI_TRANSMIT;
297
298#define MAX_DATA_BLKS 8
299typedef struct {
300 uint16_t ImmedLength;
301 SEGOFF16_t Xmit;
302 uint16_t DataBlkCount;
303 struct DataBlk {
304 uint8_t TDPtrType;
305 uint8_t TDRsvdByte;
306 uint16_t TDDataLen;
307 SEGOFF16_t TDDataPtr;
308 } DataBlock[MAX_DATA_BLKS];
309} PACKED t_PXENV_UNDI_TBD;
310
311#define PXENV_UNDI_SET_MCAST_ADDRESS 0x0009
312typedef struct {
313 PXENV_STATUS_t Status;
314 t_PXENV_UNDI_MCAST_ADDRESS R_Mcast_Buf;
315} PACKED t_PXENV_UNDI_SET_MCAST_ADDRESS;
316
317#define PXENV_UNDI_SET_STATION_ADDRESS 0x000A
318typedef struct {
319 PXENV_STATUS_t Status;
320 MAC_ADDR StationAddress; /* Temp MAC addres to use */
321} PACKED t_PXENV_UNDI_SET_STATION_ADDRESS;
322
323#define PXENV_UNDI_SET_PACKET_FILTER 0x000B
324typedef struct {
325 PXENV_STATUS_t Status;
326 uint8_t filter; /* see UNDI_OPEN (0x0006) */
327} PACKED t_PXENV_UNDI_SET_PACKET_FILTER;
328
329#define PXENV_UNDI_GET_INFORMATION 0x000C
330typedef struct {
331 PXENV_STATUS_t Status;
332 uint16_t BaseIo; /* Adapter base I/O address */
333 uint16_t IntNumber; /* Adapter IRQ number */
334 uint16_t MaxTranUnit; /* Adapter maximum transmit unit */
335 uint16_t HwType; /* Type of protocol at the hardware addr */
336# define ETHER_TYPE 1
337# define EXP_ETHER_TYPE 2
338# define IEEE_TYPE 6
339# define ARCNET_TYPE 7
340
341 uint16_t HwAddrLen; /* Length of hardware address */
342 MAC_ADDR CurrentNodeAddress; /* Current hardware address */
343 MAC_ADDR PermNodeAddress; /* Permanent hardware address */
344 SEGSEL_t ROMAddress; /* Real mode ROM segment address */
345 uint16_t RxBufCt; /* Receive queue length */
346 uint16_t TxBufCt; /* Transmit queue length */
347} PACKED t_PXENV_UNDI_GET_INFORMATION;
348
349#define PXENV_UNDI_GET_STATISTICS 0x000D
350typedef struct {
351 PXENV_STATUS_t Status;
352 uint32_t XmitGoodFrames; /* Number of successful transmissions */
353 uint32_t RcvGoodFrames; /* Number of good frames received */
354 uint32_t RcvCRCErrors; /* Number of frames with CRC errors */
355 uint32_t RcvResourceErrors; /* Number of frames dropped */
356} PACKED t_PXENV_UNDI_GET_STATISTICS;
357
358#define PXENV_UNDI_CLEAR_STATISTICS 0x000E
359typedef struct {
360 PXENV_STATUS_t Status;
361} PACKED t_PXENV_UNDI_CLEAR_STATISTICS;
362
363#define PXENV_UNDI_INITIATE_DIAGS 0x000F
364typedef struct {
365 PXENV_STATUS_t Status;
366} PACKED t_PXENV_UNDI_INITIATE_DIAGS;
367
368#define PXENV_UNDI_FORCE_INTERRUPT 0x0010
369typedef struct {
370 PXENV_STATUS_t Status;
371} PACKED t_PXENV_UNDI_FORCE_INTERRUPT;
372
373#define PXENV_UNDI_GET_MCAST_ADDRESS 0x0011
374typedef struct {
375 PXENV_STATUS_t Status;
376 IP4_t InetAddr; /* IP mulicast address */
377 MAC_ADDR MediaAddr; /* MAC multicast address */
378} PACKED t_PXENV_UNDI_GET_MCAST_ADDRESS;
379
380#define PXENV_UNDI_GET_NIC_TYPE 0x0012
381typedef struct {
382 PXENV_STATUS_t Status;
383 uint8_t NicType; /* Type of NIC */
384# define PCI_NIC 2
385# define PnP_NIC 3
386# define CardBus_NIC 4
387
388 union {
389 struct {
390 uint16_t Vendor_ID;
391 uint16_t Dev_ID;
392 uint8_t Base_Class;
393 uint8_t Sub_Class;
394 uint8_t Prog_Intf;
395 uint8_t Rev;
396 uint16_t BusDevFunc;
397 uint16_t SubVendor_ID;
398 uint16_t SubDevice_ID;
399 } pci, cardbus;
400 struct {
401 uint32_t EISA_Dev_ID;
402 uint8_t Base_Class;
403 uint8_t Sub_Class;
404 uint8_t Prog_Intf;
405 uint16_t CardSelNum;
406 } pnp;
407 } info;
408} PACKED t_PXENV_UNDI_GET_NIC_TYPE;
409
410#define PXENV_UNDI_GET_IFACE_INFO 0x0013
411typedef struct {
412 PXENV_STATUS_t Status;
413 uint8_t IfaceType[16]; /* Name of MAC type in ASCII. */
414 uint32_t LinkSpeed; /* Defined in NDIS 2.0 spec */
415 uint32_t ServiceFlags; /* Defined in NDIS 2.0 spec */
416 uint32_t Reserved[4]; /* must be 0 */
417} PACKED t_PXENV_UNDI_GET_IFACE_INFO;
418
419#define PXENV_UNDI_ISR 0x0014
420typedef struct {
421 PXENV_STATUS_t Status;
422 uint16_t FuncFlag; /* PXENV_UNDI_ISR_OUT_xxx */
423 uint16_t BufferLength; /* Length of Frame */
424 uint16_t FrameLength; /* Total length of reciever frame */
425 uint16_t FrameHeaderLength; /* Length of the media header in Frame */
426 SEGOFF16_t Frame; /* receive buffer */
427 uint8_t ProtType; /* Protocol type */
428 uint8_t PktType; /* Packet Type */
429# define PXENV_UNDI_ISR_IN_START 1
430# define PXENV_UNDI_ISR_IN_PROCESS 2
431# define PXENV_UNDI_ISR_IN_GET_NEXT 3
432
433 /* one of these will be returned for PXENV_UNDI_ISR_IN_START */
434# define PXENV_UNDI_ISR_OUT_OURS 0
435# define PXENV_UNDI_ISR_OUT_NOT_OURS 1
436
437 /*
438 * one of these will bre returnd for PXEND_UNDI_ISR_IN_PROCESS
439 * and PXENV_UNDI_ISR_IN_GET_NEXT
440 */
441# define PXENV_UNDI_ISR_OUT_DONE 0
442# define PXENV_UNDI_ISR_OUT_TRANSMIT 2
443# define PXENV_UNDI_ISR_OUT_RECEIVE 3
444# define PXENV_UNDI_ISR_OUT_BUSY 4
445} PACKED t_PXENV_UNDI_ISR;
446
447#define PXENV_STOP_UNDI 0x0015
448typedef struct {
449 PXENV_STATUS_t Status;
450} PACKED t_PXENV_STOP_UNDI;
451
452#define PXENV_TFTP_OPEN 0x0020
453typedef struct {
454 PXENV_STATUS_t Status;
455 IP4_t ServerIPAddress;
456 IP4_t GatewayIPAddress;
457 uint8_t FileName[128];
458 UDP_PORT_t TFTPPort;
459 uint16_t PacketSize;
460} PACKED t_PXENV_TFTP_OPEN;
461
462#define PXENV_TFTP_CLOSE 0x0021
463typedef struct {
464 PXENV_STATUS_t Status;
465} PACKED t_PXENV_TFTP_CLOSE;
466
467#define PXENV_TFTP_READ 0x0022
468typedef struct {
469 PXENV_STATUS_t Status;
470 uint16_t PacketNumber;
471 uint16_t BufferSize;
472 SEGOFF16_t Buffer;
473} PACKED t_PXENV_TFTP_READ;
474
475#define PXENV_TFTP_READ_FILE 0x0023
476typedef struct {
477 PXENV_STATUS_t Status;
478 uint8_t FileName[128];
479 uint32_t BufferSize;
480 ADDR32_t Buffer;
481 IP4_t ServerIPAddress;
482 IP4_t GatewayIPAdress;
483 IP4_t McastIPAdress;
484 UDP_PORT_t TFTPClntPort;
485 UDP_PORT_t TFTPSrvPort;
486 uint16_t TFTPOpenTimeOut;
487 uint16_t TFTPReopenDelay;
488} PACKED t_PXENV_TFTP_READ_FILE;
489
490#define PXENV_TFTP_GET_FSIZE 0x0025
491typedef struct {
492 PXENV_STATUS_t Status;
493 IP4_t ServerIPAddress;
494 IP4_t GatewayIPAdress;
495 uint8_t FileName[128];
496 uint32_t FileSize;
497} PACKED t_PXENV_TFTP_GET_FSIZE;
498
499#define PXENV_UDP_OPEN 0x0030
500typedef struct {
501 PXENV_STATUS_t Status;
502 IP4_t src_ip; /* IP address of this station */
503} PACKED t_PXENV_UDP_OPEN;
504
505#define PXENV_UDP_CLOSE 0x0031
506typedef struct {
507 PXENV_STATUS_t Status;
508} PACKED t_PXENV_UDP_CLOSE;
509
510#define PXENV_UDP_READ 0x0032
511typedef struct {
512 PXENV_STATUS_t Status;
513 IP4_t src_ip; /* IP of sender */
514 IP4_t dest_ip; /* Only accept packets sent to this IP */
515 UDP_PORT_t s_port; /* UDP source port of sender */
516 UDP_PORT_t d_port; /* Only accept packets sent to this port */
517 uint16_t buffer_size; /* Size of the packet buffer */
518 SEGOFF16_t buffer; /* SEG:OFF to the packet buffer */
519} PACKED t_PXENV_UDP_READ;
520
521#define PXENV_UDP_WRITE 0x0033
522typedef struct {
523 PXENV_STATUS_t Status;
524 IP4_t ip; /* dest ip addr */
525 IP4_t gw; /* ip gateway */
526 UDP_PORT_t src_port; /* source udp port */
527 UDP_PORT_t dst_port; /* destination udp port */
528 uint16_t buffer_size; /* Size of the packet buffer */
529 SEGOFF16_t buffer; /* SEG:OFF to the packet buffer */
530} PACKED t_PXENV_UDP_WRITE;
531
532#define PXENV_UNLOAD_STACK 0x0070
533typedef struct {
534 PXENV_STATUS_t Status;
535 uint8_t reserved[10];
536} PACKED t_PXENV_UNLOAD_STACK;
537
538
539#define PXENV_GET_CACHED_INFO 0x0071
540typedef struct {
541 PXENV_STATUS_t Status;
542 uint16_t PacketType; /* type (defined right here) */
543# define PXENV_PACKET_TYPE_DHCP_DISCOVER 1
544# define PXENV_PACKET_TYPE_DHCP_ACK 2
545#ifdef VBOX
546# define PXENV_PACKET_TYPE_CACHED_REPLY 3
547#else /* !VBOX */
548# define PXENV_PACKET_TYPE_BINL_REPLY 3
549#endif /* !VBOX */
550 uint16_t BufferSize; /* max to copy, leave at 0 for pointer */
551 SEGOFF16_t Buffer; /* copy to, leave at 0 for pointer */
552 uint16_t BufferLimit; /* max size of buffer in BC dataseg ? */
553} PACKED t_PXENV_GET_CACHED_INFO;
554
555
556/* structure filled in by PXENV_GET_CACHED_INFO
557 * (how we determine which IP we downloaded the initial bootstrap from)
558 * words can't describe...
559 */
560typedef struct {
561 uint8_t opcode;
562# define BOOTP_REQ 1
563# define BOOTP_REP 2
564 uint8_t Hardware; /* hardware type */
565 uint8_t Hardlen; /* hardware addr len */
566 uint8_t Gatehops; /* zero it */
567 uint32_t ident; /* random number chosen by client */
568 uint16_t seconds; /* seconds since did initial bootstrap */
569 uint16_t Flags; /* seconds since did initial bootstrap */
570# define BOOTP_BCAST 0x8000 /* ? */
571 IP4_t cip; /* Client IP */
572 IP4_t yip; /* Your IP */
573 IP4_t sip; /* IP to use for next boot stage */
574 IP4_t gip; /* Relay IP ? */
575 MAC_ADDR CAddr; /* Client hardware address */
576 uint8_t Sname[64]; /* Server's hostname (Optional) */
577 uint8_t bootfile[128]; /* boot filename */
578 union {
579# if 1
580# define BOOTP_DHCPVEND 1024 /* DHCP extended vendor field size */
581# else
582# define BOOTP_DHCPVEND 312 /* DHCP standard vendor field size */
583# endif
584 uint8_t d[BOOTP_DHCPVEND]; /* raw array of vendor/dhcp options */
585 struct {
586 uint8_t magic[4]; /* DHCP magic cookie */
587# ifndef VM_RFC1048
588# define VM_RFC1048 0x63825363L /* ? */
589# endif
590 uint32_t flags; /* bootp flags/opcodes */
591 uint8_t pad[56]; /* I don't think intel knows what a
592 union does... */
593 } v;
594 } vendor;
595} PACKED BOOTPLAYER;
596
597#define PXENV_RESTART_TFTP 0x0073
598#define t_PXENV_RESTART_TFTP t_PXENV_TFTP_READ_FILE
599
600#define PXENV_START_BASE 0x0075
601typedef struct {
602 PXENV_STATUS_t Status;
603} PACKED t_PXENV_START_BASE;
604
605#define PXENV_STOP_BASE 0x0076
606typedef struct {
607 PXENV_STATUS_t Status;
608} PACKED t_PXENV_STOP_BASE;
609
610/*****************************************************************************
611 * The following portion of this file is derived from netboot's
612 * general.h86. Do not remove the copyright notice below.
613 *****************************************************************************
614 */
615
616/*
617 * general.h86 - Common PXE definitions
618 *
619 * Copyright (C) 2003 Gero Kuhlmann <[email protected]>
620 *
621 * This program is free software; you can redistribute it and/or modify
622 * it under the terms of the GNU General Public License as published by
623 * the Free Software Foundation; either version 2 of the License, or
624 * any later version.
625 *
626 * This program is distributed in the hope that it will be useful,
627 * but WITHOUT ANY WARRANTY; without even the implied warranty of
628 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
629 * GNU General Public License for more details.
630 *
631 * You should have received a copy of the GNU General Public License
632 * along with this program; if not, write to the Free Software
633 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
634 *
635 * $Id: pxe.h 1 1970-01-01 00:00:00Z vboxsync $
636 */
637
638/*
639 **************************************************************************
640 *
641 * This file contains the Preboot API common definitions as
642 * per Intels PXE specification version 2.0.
643 *
644 * Updated to comply with PXE specification version 2.1 by Michael Brown.
645 *
646 **************************************************************************
647 *
648 * Result codes returned in AX by a PXENV API service:
649 */
650#define PXENV_EXIT_SUCCESS 0x0000
651#define PXENV_EXIT_FAILURE 0x0001
652
653
654
655/*
656 **************************************************************************
657 *
658 * CPU types (defined in WfM 1.1):
659 */
660#define PXENV_CPU_X86 0
661#define PXENV_CPU_ALPHA 1
662#define PXENV_CPU_PPC 2
663
664
665
666/*
667 **************************************************************************
668 *
669 * Bus types (defined in WfM 1.1):
670 */
671#define PXENV_BUS_ISA 0
672#define PXENV_BUS_EISA 1
673#define PXENV_BUS_MCA 2
674#define PXENV_BUS_PCI 3
675#define PXENV_BUS_VESA 4
676#define PXENV_BUS_PCMCIA 5
677
678
679
680/*
681 **************************************************************************
682 *
683 * Status codes returned in the status word of the PXENV API parameter
684 * structure. Some of these codes are also used to return status
685 * information from a boot image loader back to the bootrom.
686 */
687
688/* Generic API errors that are reported by the loader */
689#define PXENV_STATUS_SUCCESS 0x00
690#define PXENV_STATUS_FAILURE 0x01 /* general failure */
691#define PXENV_STATUS_BAD_FUNC 0x02 /* invalid function number */
692#define PXENV_STATUS_UNSUPPORTED 0x03 /* not yet supported */
693#define PXENV_STATUS_KEEP_UNDI 0x04 /* keep UNDI in memory */
694#define PXENV_STATUS_KEEP_ALL 0x05 /* keep everything in memory */
695#define PXENV_STATUS_OUT_OF_RESOURCES 0x06 /* also keep everything */
696
697/* ARP/UDP errors (0x10 to 0x1F) */
698#define PXENV_STATUS_ARP_CANCELED 0x10 /* ARP canceled by keystroke */
699#define PXENV_STATUS_ARP_TIMEOUT 0x11 /* ARP timeout */
700#define PXENV_STATUS_UDP_CLOSED 0x18 /* UDP closed */
701#define PXENV_STATUS_UDP_OPEN 0x19 /* UDP already open */
702#define PXENV_STATUS_TFTP_CLOSED 0x1A /* TFTP closed */
703#define PXENV_STATUS_TFTP_OPEN 0x1B /* TFTP already opened */
704
705/* BIOS/system errors (0x20 to 0x2F) */
706#define PXENV_STATUS_MCOPY_PROBLEM 0x20 /* can't copy into memory */
707
708/* TFP errors (0x30 to 0x3F) */
709#define PXENV_STATUS_TFTP_CANNOT_ARP 0x30 /* TFTP ARP problem */
710#define PXENV_STATUS_TFTP_OPEN_CANCELED 0x31 /* TFTP open canceled by key */
711#define PXENV_STATUS_TFTP_OPEN_TIMEOUT 0x32 /* timeout during TFTP open */
712#define PXENV_STATUS_TFTP_UNKNOWN_OPCODE 0x33 /* unknown TFTP opcode */
713#define PXENV_STATUS_TFTP_READ_CANCELED 0x34 /* TFTP read canceled by key */
714#define PXENV_STATUS_TFTP_READ_TIMEOUT 0x35 /* timeout during TFTP read */
715#define PXENV_STATUS_TFTP_ERROR_OPCODE 0x36 /* bad TFTP opcode */
716#define PXENV_STATUS_TFTP_CANNOT_OPEN_CONNECTION \
717 0x38 /* error during TFTP open */
718#define PXENV_STATUS_TFTP_CANNOT_READ_FROM_CONNECTION \
719 0x39 /* error during TFTP read */
720#define PXENV_STATUS_TFTP_TOO_MANY_PACKAGES \
721 0x3A /* too many packages */
722#define PXENV_STATUS_TFTP_FILE_NOT_FOUND 0x3B /* file not found */
723#define PXENV_STATUS_TFTP_ACCESS_VIOLATION 0x3C /* access violation */
724#define PXENV_STATUS_TFTP_NO_MCAST_ADDRESS 0x3D /* no multicast address */
725#define PXENV_STATUS_TFTP_NO_FILESIZE 0x3E /* unable to get file size */
726#define PXENV_STATUS_TFTP_INVALID_PACKET_SIZE \
727 0x3F /* invalid packet size */
728
729/* BOOTP errors (0x40 to 0x4F) */
730#define PXENV_STATUS_BOOTP_CANCELED 0x40 /* BOOTP canceled by key */
731#define PXENV_STATUS_BOOTP_TIMEOUT 0x41 /* timeout during BOOTP */
732#define PXENV_STATUS_BOOTP_NO_FILE 0x42 /* missing bootfile name */
733
734/* DHCP errors (0x50 to 0x5F) */
735#define PXENV_STATUS_DHCP_CANCELED 0x50 /* DHCP canceled by key */
736#define PXENV_STATUS_DHCP_TIMEOUT 0x51 /* timeout during DHCP */
737#define PXENV_STATUS_DHCP_NO_IP_ADDRESS 0x52 /* missing IP address */
738#define PXENV_STATUS_DHCP_NO_BOOTFILE_NAME 0x53 /* missing bootfile name */
739#define PXENV_STATUS_DHCP_BAD_IP_ADDRESS 0x54 /* invalid IP address */
740
741/* Driver errors (0x60 to 0x6F) */
742#define PXENV_STATUS_UNDI_INVALID_FUNCTION 0x60 /* invalid UNDI function */
743#define PXENV_STATUS_UNDI_MEDIATEST_FAILED 0x61 /* media test failed */
744#define PXENV_STATUS_UNDI_CANNOT_INIT_NIC_FOR_MCAST \
745 0x62 /* cannot init for multicast */
746#define PXENV_STATUS_UNDI_CANNOT_INITIALIZE_NIC \
747 0x63 /* cannot init NIC */
748#define PXENV_STATUS_UNDI_CANNOT_INITIALIZE_PHY \
749 0x64 /* cannot init hardware */
750#define PXENV_STATUS_UNDI_CANNOT_READ_CONFIG_DATA \
751 0x65 /* cannot read config data */
752#define PXENV_STATUS_UNDI_CANNOT_READ_INIT_DATA \
753 0x66 /* cannot read init data */
754#define PXENV_STATUS_UNDI_BAD_MAC_ADDRESS 0x67 /* invalid hardware address */
755#define PXENV_STATUS_UNDI_BAD_EEPROM_CHECKSUM \
756 0x68 /* invalid EEPROM checksum */
757#define PXENV_STATUS_UNDI_ERROR_SETTING_ISR 0x69
758#define PXENV_STATUS_UNDI_INVALID_STATE 0x6a /* invalid UNDI state */
759#define PXENV_STATUS_UNDI_TRANSMIT_ERROR 0x6b /* transmit error */
760#define PXENV_STATUS_UNDI_INVALID_PARAMETER \
761 0x6c /* almost anything */
762
763/* Bootstrap (.1) errors (0x70 to 0x7F) */
764#define PXENV_STATUS_BSTRAP_PROMPT_MENU 0x74 /* invalid bootstrap menu */
765#define PXENV_STATUS_BSTRAP_MCAST_ADDR 0x76 /* missing multicast address */
766#define PXENV_STATUS_BSTRAP_MISSING_LIST 0x77 /* missing file list */
767#define PXENV_STATUS_BSTRAP_NO_RESPONSE 0x78 /* no response from server */
768#define PXENV_STATUS_BSTRAP_FILE_TOO_BIG 0x79 /* next file too big */
769
770/* Environment (.2) errors (0x80 to 0x8F) */
771
772/* MTFTP errors (0x90 to 0x9F) */
773#define PXENV_STATUS_MTFTP_OPEN_CANCEL 0x91 /* MTFTP open canceled by key */
774#define PXENV_STATUS_MTFTP_OPEN_TIMEOUT 0x92 /* timeout during MTFTP open */
775#define PXENV_STATUS_MTFTP_UNKNOWN_OP 0x93 /* unknown TFTP opcode */
776#define PXENV_STATUS_MTFTP_READ_CANCEL 0x94 /* MTFTP read canceled by key */
777#define PXENV_STATUS_MTFTP_READ_TIMEOUT 0x95 /* timeout during MTFTP read */
778#define PXENV_STATUS_MTFTP_ERROR_OP 0x96 /* bad TFTP opcode */
779#define PXENV_STATUS_MTFTP_CANNOT_OPEN 0x98 /* error during MTFTP open */
780#define PXENV_STATUS_MTFTP_CANNOT_READ 0x99 /* error during MTFTP read */
781#define PXENV_STATUS_MTFTP_TOO_MANY 0x9A /* too many packages */
782#define PXENV_STATUS_MTFTP_PACK_SIZE 0x9B /* invalid package size */
783
784/* Misc. errors (0xA0 to 0xAF) */
785#define PXENV_STATUS_BINL_CANCELED_BY_KEYSTROKE \
786 0xA0 /* BINL canceled by key */
787#define PXENV_STATUS_BINL_NO_PXE_SERVER 0xA1 /* no BINL server found */
788#define PXENV_STATUS_NOT_AVAILABLE_IN_PMODE \
789 0xA2 /* not avail. in prot mode */
790#define PXENV_STATUS_NOT_AVAILABLE_IN_RMODE \
791 0xA3 /* not avail. in real mode */
792
793/* BUSD errors (0xB0 to 0xBF) */
794#define PXENV_STATUS_BUSD_DEVICE_NOT_SUPPORTED \
795 0xB0 /* BUSD services not enabled */
796#define PXENV_STATUS_BUSD_DEV_ENABLE 0xB1 /* BUSD device not enabled */
797
798/* Loader errors (0xC0 to 0xCF) */
799#define PXENV_STATUS_LOADER_NO_FREE_BASE_MEMORY \
800 0xC0 /* no free base memory */
801#define PXENV_STATUS_LOADER_NO_BC_ROMID 0xC1 /* no base code rom ID */
802#define PXENV_STATUS_LOADER_BAD_BC_ROMID 0xC2 /* bad base code rom ID */
803#define PXENV_STATUS_LOADER_BAD_BC_RUNTIME_IMAGE \
804 0xC3 /* bad base code image */
805#define PXENV_STATUS_LOADER_NO_UNDI_ROMID 0xC4 /* no UNDI rom ID */
806#define PXENV_STATUS_LOADER_BAD_UNDI_ROMID 0xC5 /* bad UNDI rom ID */
807#define PXENV_STATUS_LOADER_UNDI_DRIVER_IMAGE \
808 0xC6 /* bad UNDI runtime image */
809#define PXENV_STATUS_LOADER_NO_PXE_STRUCT 0xC8 /* missing !PXE struct */
810#define PXENV_STATUS_LOADER_NO_PXENV_STRUCT \
811 0xC9 /* missing PXENV+ struct */
812#define PXENV_STATUS_LOADER_UNDI_START 0xCA /* UNDI not started */
813#define PXENV_STATUS_LOADER_BC_START 0xCB /* base code not started */
814
815/* Reserved errors (0xD0 to 0xFF) */
816#define PXENV_STATUS_IMAGE_INVALID 0xD0 /* invalid boot image */
817#define PXENV_STATUS_STOP_BASE 0xD1 /* error stopping base code */
818#define PXENV_STATUS_UNLOAD_BASE 0xD2 /* error unloading base code */
819#define PXENV_STATUS_STOP_UNDI 0xD3 /* error stopping UNDI */
820#define PXENV_STATUS_CLEANUP_UNDI 0xD4 /* error cleaning up UNDI */
821
822
823/*****************************************************************************
824 * The remainder of this file is original to Etherboot.
825 *****************************************************************************
826 */
827
828/* Dummy PXE opcode for the loader routine. We do this to make the
829 * API simpler
830 */
831#define PXENV_UNDI_LOADER 0x104d /* 'load' */
832
833typedef struct undi_loader {
834 union {
835 struct {
836 PXENV_STATUS_t Status;
837 uint16_t ax;
838 uint16_t bx;
839 uint16_t dx;
840 uint16_t di;
841 uint16_t es;
842 };
843 t_PXENV_START_UNDI start_undi;
844 };
845 uint16_t undi_ds;
846 uint16_t undi_cs;
847 SEGOFF16_t pxe_ptr;
848 SEGOFF16_t pxenv_ptr;
849} PACKED undi_loader_t;
850
851/* Union used for PXE API calls; we don't know the type of the
852 * structure until we interpret the opcode. Also, Status is available
853 * in the same location for any opcode, and it's convenient to have
854 * non-specific access to it.
855 */
856typedef union {
857 PXENV_STATUS_t Status; /* Make it easy to read status
858 for any operation */
859 t_PXENV_START_UNDI start_undi;
860 t_PXENV_UNDI_STARTUP undi_startup;
861 t_PXENV_UNDI_CLEANUP undi_cleanup;
862 t_PXENV_UNDI_INITIALIZE undi_initialize;
863 t_PXENV_UNDI_RESET_ADAPTER undi_reset_adapter;
864 t_PXENV_UNDI_SHUTDOWN undi_shutdown;
865 t_PXENV_UNDI_OPEN undi_open;
866 t_PXENV_UNDI_CLOSE undi_close;
867 t_PXENV_UNDI_TRANSMIT undi_transmit;
868 t_PXENV_UNDI_SET_MCAST_ADDRESS undi_set_mcast_address;
869 t_PXENV_UNDI_SET_STATION_ADDRESS undi_set_station_address;
870 t_PXENV_UNDI_SET_PACKET_FILTER undi_set_packet_filter;
871 t_PXENV_UNDI_GET_INFORMATION undi_get_information;
872 t_PXENV_UNDI_GET_STATISTICS undi_get_statistics;
873 t_PXENV_UNDI_CLEAR_STATISTICS undi_clear_statistics;
874 t_PXENV_UNDI_INITIATE_DIAGS undi_initiate_diags;
875 t_PXENV_UNDI_FORCE_INTERRUPT undi_force_interrupt;
876 t_PXENV_UNDI_GET_MCAST_ADDRESS undi_get_mcast_address;
877 t_PXENV_UNDI_GET_NIC_TYPE undi_get_nic_type;
878 t_PXENV_UNDI_GET_IFACE_INFO undi_get_iface_info;
879 t_PXENV_UNDI_ISR undi_isr;
880 t_PXENV_STOP_UNDI stop_undi;
881 t_PXENV_TFTP_OPEN tftp_open;
882 t_PXENV_TFTP_CLOSE tftp_close;
883 t_PXENV_TFTP_READ tftp_read;
884 t_PXENV_TFTP_READ_FILE tftp_read_file;
885 t_PXENV_TFTP_GET_FSIZE tftp_get_fsize;
886 t_PXENV_UDP_OPEN udp_open;
887 t_PXENV_UDP_CLOSE udp_close;
888 t_PXENV_UDP_READ udp_read;
889 t_PXENV_UDP_WRITE udp_write;
890 t_PXENV_UNLOAD_STACK unload_stack;
891 t_PXENV_GET_CACHED_INFO get_cached_info;
892 t_PXENV_RESTART_TFTP restart_tftp;
893 t_PXENV_START_BASE start_base;
894 t_PXENV_STOP_BASE stop_base;
895 undi_loader_t loader;
896} t_PXENV_ANY;
897
898/* PXE stack status indicator. See pxe_export.c for further
899 * explanation.
900 */
901typedef enum {
902 CAN_UNLOAD = 0,
903 MIDWAY,
904 READY
905} pxe_stack_state_t;
906
907/* Data structures installed as part of a PXE stack. Architectures
908 * will have extra information to append to the end of this.
909 */
910#define PXE_TFTP_MAGIC_COOKIE ( ( 'P'<<24 ) | ( 'x'<<16 ) | ( 'T'<<8 ) | 'f' )
911typedef struct {
912 pxe_t pxe __attribute__ ((aligned(16)));
913 pxenv_t pxenv __attribute__ ((aligned(16)));
914 pxe_stack_state_t state;
915 union {
916 BOOTPLAYER cached_info;
917 char packet[ETH_FRAME_LEN];
918 struct {
919 uint32_t magic_cookie;
920 unsigned int len;
921 int eof;
922 char data[TFTP_MAX_PACKET];
923 } tftpdata;
924 struct {
925 char *buffer;
926 uint32_t offset;
927 uint32_t bufferlen;
928 } readfile;
929 };
930 struct {} arch_data __attribute__ ((aligned(16)));
931} pxe_stack_t;
932
933#endif /* PXE_H */
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette