You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

pxe.h 31KB

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