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 24KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788
  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. #include "errno.h"
  57. /* Defaults in case pxe_types.h did not define a type. These are
  58. * placeholder structures just to make the code compile.
  59. */
  60. #ifndef SEGOFF16_t
  61. #define SEGOFF16_t void*
  62. #endif
  63. #ifndef IS_NULL_SEGOFF16
  64. #define IS_NULL_SEGOFF16(segoff16) ( (segoff16) == NULL )
  65. #endif
  66. #ifndef SEGOFF16_TO_PTR
  67. #define SEGOFF16_TO_PTR(segoff16) (segoff16)
  68. #endif
  69. #ifndef PTR_TO_SEGOFF16
  70. #define PTR_TO_SEGOFF16(ptr,segoff16) (segoff16) = (ptr);
  71. #endif
  72. #ifndef SEGDESC_t
  73. #define SEGDESC_t void
  74. #endif
  75. #ifndef SEGSEL_t
  76. #define SEGSEL_t void
  77. #endif
  78. /*****************************************************************************
  79. * The following portion of this file is derived from FreeBSD's pxe.h.
  80. * Do not remove the copyright notice below.
  81. *****************************************************************************
  82. */
  83. /*
  84. * Copyright (c) 2000 Alfred Perlstein <alfred@freebsd.org>
  85. * All rights reserved.
  86. * Copyright (c) 2000 Paul Saab <ps@freebsd.org>
  87. * All rights reserved.
  88. * Copyright (c) 2000 John Baldwin <jhb@freebsd.org>
  89. * All rights reserved.
  90. *
  91. * Redistribution and use in source and binary forms, with or without
  92. * modification, are permitted provided that the following conditions
  93. * are met:
  94. * 1. Redistributions of source code must retain the above copyright
  95. * notice, this list of conditions and the following disclaimer.
  96. * 2. Redistributions in binary form must reproduce the above copyright
  97. * notice, this list of conditions and the following disclaimer in the
  98. * documentation and/or other materials provided with the distribution.
  99. *
  100. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  101. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  102. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  103. * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  104. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  105. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  106. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  107. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  108. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  109. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  110. * SUCH DAMAGE.
  111. *
  112. * $FreeBSD: src/sys/boot/i386/libi386/pxe.h,v 1.4.2.2 2000/09/10 02:52:18 ps Exp $
  113. */
  114. /*
  115. * The typedefs and structures declared in this file
  116. * clearly violate style(9), the reason for this is to conform to the
  117. * typedefs/structure-names used in the Intel literature to avoid confusion.
  118. *
  119. * It's for your own good. :)
  120. */
  121. /* It seems that intel didn't think about ABI,
  122. * either that or 16bit ABI != 32bit ABI (which seems reasonable)
  123. * I have to thank Intel for the hair loss I incurred trying to figure
  124. * out why PXE was mis-reading structures I was passing it (at least
  125. * from my point of view)
  126. *
  127. * Solution: use gcc's '__attribute__ ((packed))' to correctly align
  128. * structures passed into PXE
  129. * Question: does this really work for PXE's expected ABI?
  130. */
  131. #ifndef PACKED
  132. #define PACKED __attribute__ ((packed))
  133. #endif
  134. #define S_SIZE(s) s, sizeof(s) - 1
  135. #define IP_STR "%d.%d.%d.%d"
  136. #define IP_ARGS(ip) \
  137. (int)(ip >> 24) & 0xff, (int)(ip >> 16) & 0xff, \
  138. (int)(ip >> 8) & 0xff, (int)ip & 0xff
  139. #define MAC_STR "%02x:%02x:%02x:%02x:%02x:%02x"
  140. #define MAC_ARGS(mac) \
  141. mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]
  142. typedef uint16_t PXENV_EXIT_t;
  143. typedef uint16_t PXENV_STATUS_t;
  144. typedef uint32_t IP4_t;
  145. typedef uint32_t ADDR32_t;
  146. /* It seems as though UDP_PORT_t is in network order, although I can't
  147. * find anything in the spec to back this up. (Michael Brown)
  148. */
  149. typedef uint16_t UDP_PORT_t;
  150. #define MAC_ADDR_LEN 16
  151. typedef uint8_t MAC_ADDR[MAC_ADDR_LEN];
  152. /* PXENV+ */
  153. typedef struct {
  154. uint8_t Signature[6]; /* 'PXENV+' */
  155. uint16_t Version; /* MSB = major, LSB = minor */
  156. uint8_t Length; /* structure length */
  157. uint8_t Checksum; /* checksum pad */
  158. SEGOFF16_t RMEntry; /* SEG:OFF to PXE entry point */
  159. /* don't use PMOffset and PMSelector (from the 2.1 PXE manual) */
  160. uint32_t PMOffset; /* Protected mode entry */
  161. SEGSEL_t PMSelector; /* Protected mode selector */
  162. SEGSEL_t StackSeg; /* Stack segment address */
  163. uint16_t StackSize; /* Stack segment size (bytes) */
  164. SEGSEL_t BC_CodeSeg; /* BC Code segment address */
  165. uint16_t BC_CodeSize; /* BC Code segment size (bytes) */
  166. SEGSEL_t BC_DataSeg; /* BC Data segment address */
  167. uint16_t BC_DataSize; /* BC Data segment size (bytes) */
  168. SEGSEL_t UNDIDataSeg; /* UNDI Data segment address */
  169. uint16_t UNDIDataSize; /* UNDI Data segment size (bytes) */
  170. SEGSEL_t UNDICodeSeg; /* UNDI Code segment address */
  171. uint16_t UNDICodeSize; /* UNDI Code segment size (bytes) */
  172. SEGOFF16_t PXEPtr; /* SEG:OFF to !PXE struct,
  173. only present when Version > 2.1 */
  174. } PACKED pxenv_t;
  175. /* !PXE */
  176. typedef struct {
  177. uint8_t Signature[4];
  178. uint8_t StructLength;
  179. uint8_t StructCksum;
  180. uint8_t StructRev;
  181. uint8_t reserved_1;
  182. SEGOFF16_t UNDIROMID;
  183. SEGOFF16_t BaseROMID;
  184. SEGOFF16_t EntryPointSP;
  185. SEGOFF16_t EntryPointESP;
  186. SEGOFF16_t StatusCallout;
  187. uint8_t reserved_2;
  188. uint8_t SegDescCn;
  189. SEGSEL_t FirstSelector;
  190. SEGDESC_t Stack;
  191. SEGDESC_t UNDIData;
  192. SEGDESC_t UNDICode;
  193. SEGDESC_t UNDICodeWrite;
  194. SEGDESC_t BC_Data;
  195. SEGDESC_t BC_Code;
  196. SEGDESC_t BC_CodeWrite;
  197. } PACKED pxe_t;
  198. #define PXENV_START_UNDI 0x0000
  199. typedef struct {
  200. PXENV_STATUS_t Status;
  201. uint16_t ax;
  202. uint16_t bx;
  203. uint16_t dx;
  204. uint16_t di;
  205. uint16_t es;
  206. } PACKED t_PXENV_START_UNDI;
  207. #define PXENV_UNDI_STARTUP 0x0001
  208. typedef struct {
  209. PXENV_STATUS_t Status;
  210. } PACKED t_PXENV_UNDI_STARTUP;
  211. #define PXENV_UNDI_CLEANUP 0x0002
  212. typedef struct {
  213. PXENV_STATUS_t Status;
  214. } PACKED t_PXENV_UNDI_CLEANUP;
  215. #define PXENV_UNDI_INITIALIZE 0x0003
  216. typedef struct {
  217. PXENV_STATUS_t Status;
  218. ADDR32_t ProtocolIni; /* Phys addr of a copy of the driver module */
  219. uint8_t reserved[8];
  220. } PACKED t_PXENV_UNDI_INITIALIZE;
  221. #define MAXNUM_MCADDR 8
  222. typedef struct {
  223. uint16_t MCastAddrCount;
  224. MAC_ADDR McastAddr[MAXNUM_MCADDR];
  225. } PACKED t_PXENV_UNDI_MCAST_ADDRESS;
  226. #define PXENV_UNDI_RESET_ADAPTER 0x0004
  227. typedef struct {
  228. PXENV_STATUS_t Status;
  229. t_PXENV_UNDI_MCAST_ADDRESS R_Mcast_Buf;
  230. } PACKED t_PXENV_UNDI_RESET_ADAPTER;
  231. #define PXENV_UNDI_SHUTDOWN 0x0005
  232. typedef struct {
  233. PXENV_STATUS_t Status;
  234. } PACKED t_PXENV_UNDI_SHUTDOWN;
  235. #define PXENV_UNDI_OPEN 0x0006
  236. typedef struct {
  237. PXENV_STATUS_t Status;
  238. uint16_t OpenFlag;
  239. uint16_t PktFilter;
  240. # define FLTR_DIRECTED 0x0001
  241. # define FLTR_BRDCST 0x0002
  242. # define FLTR_PRMSCS 0x0003
  243. # define FLTR_SRC_RTG 0x0004
  244. t_PXENV_UNDI_MCAST_ADDRESS R_Mcast_Buf;
  245. } PACKED t_PXENV_UNDI_OPEN;
  246. #define PXENV_UNDI_CLOSE 0x0007
  247. typedef struct {
  248. PXENV_STATUS_t Status;
  249. } PACKED t_PXENV_UNDI_CLOSE;
  250. #define PXENV_UNDI_TRANSMIT 0x0008
  251. typedef struct {
  252. PXENV_STATUS_t Status;
  253. uint8_t Protocol;
  254. # define P_UNKNOWN 0
  255. # define P_IP 1
  256. # define P_ARP 2
  257. # define P_RARP 3
  258. uint8_t XmitFlag;
  259. # define XMT_DESTADDR 0x0000
  260. # define XMT_BROADCAST 0x0001
  261. SEGOFF16_t DestAddr;
  262. SEGOFF16_t TBD;
  263. uint32_t Reserved[2];
  264. } PACKED t_PXENV_UNDI_TRANSMIT;
  265. #define MAX_DATA_BLKS 8
  266. typedef struct {
  267. uint16_t ImmedLength;
  268. SEGOFF16_t Xmit;
  269. uint16_t DataBlkCount;
  270. struct DataBlk {
  271. uint8_t TDPtrType;
  272. uint8_t TDRsvdByte;
  273. uint16_t TDDataLen;
  274. SEGOFF16_t TDDataPtr;
  275. } DataBlock[MAX_DATA_BLKS];
  276. } PACKED t_PXENV_UNDI_TBD;
  277. #define PXENV_UNDI_SET_MCAST_ADDRESS 0x0009
  278. typedef struct {
  279. PXENV_STATUS_t Status;
  280. t_PXENV_UNDI_MCAST_ADDRESS R_Mcast_Buf;
  281. } PACKED t_PXENV_UNDI_SET_MCAST_ADDRESS;
  282. #define PXENV_UNDI_SET_STATION_ADDRESS 0x000A
  283. typedef struct {
  284. PXENV_STATUS_t Status;
  285. MAC_ADDR StationAddress; /* Temp MAC addres to use */
  286. } PACKED t_PXENV_UNDI_SET_STATION_ADDRESS;
  287. #define PXENV_UNDI_SET_PACKET_FILTER 0x000B
  288. typedef struct {
  289. PXENV_STATUS_t Status;
  290. uint8_t filter; /* see UNDI_OPEN (0x0006) */
  291. } PACKED t_PXENV_UNDI_SET_PACKET_FILTER;
  292. #define PXENV_UNDI_GET_INFORMATION 0x000C
  293. typedef struct {
  294. PXENV_STATUS_t Status;
  295. uint16_t BaseIo; /* Adapter base I/O address */
  296. uint16_t IntNumber; /* Adapter IRQ number */
  297. uint16_t MaxTranUnit; /* Adapter maximum transmit unit */
  298. uint16_t HwType; /* Type of protocol at the hardware addr */
  299. # define ETHER_TYPE 1
  300. # define EXP_ETHER_TYPE 2
  301. # define IEEE_TYPE 6
  302. # define ARCNET_TYPE 7
  303. uint16_t HwAddrLen; /* Length of hardware address */
  304. MAC_ADDR CurrentNodeAddress; /* Current hardware address */
  305. MAC_ADDR PermNodeAddress; /* Permanent hardware address */
  306. SEGSEL_t ROMAddress; /* Real mode ROM segment address */
  307. uint16_t RxBufCt; /* Receive queue length */
  308. uint16_t TxBufCt; /* Transmit queue length */
  309. } PACKED t_PXENV_UNDI_GET_INFORMATION;
  310. #define PXENV_UNDI_GET_STATISTICS 0x000D
  311. typedef struct {
  312. PXENV_STATUS_t Status;
  313. uint32_t XmitGoodFrames; /* Number of successful transmissions */
  314. uint32_t RcvGoodFrames; /* Number of good frames received */
  315. uint32_t RcvCRCErrors; /* Number of frames with CRC errors */
  316. uint32_t RcvResourceErrors; /* Number of frames dropped */
  317. } PACKED t_PXENV_UNDI_GET_STATISTICS;
  318. #define PXENV_UNDI_CLEAR_STATISTICS 0x000E
  319. typedef struct {
  320. PXENV_STATUS_t Status;
  321. } PACKED t_PXENV_UNDI_CLEAR_STATISTICS;
  322. #define PXENV_UNDI_INITIATE_DIAGS 0x000F
  323. typedef struct {
  324. PXENV_STATUS_t Status;
  325. } PACKED t_PXENV_UNDI_INITIATE_DIAGS;
  326. #define PXENV_UNDI_FORCE_INTERRUPT 0x0010
  327. typedef struct {
  328. PXENV_STATUS_t Status;
  329. } PACKED t_PXENV_UNDI_FORCE_INTERRUPT;
  330. #define PXENV_UNDI_GET_MCAST_ADDRESS 0x0011
  331. typedef struct {
  332. PXENV_STATUS_t Status;
  333. IP4_t InetAddr; /* IP mulicast address */
  334. MAC_ADDR MediaAddr; /* MAC multicast address */
  335. } PACKED t_PXENV_UNDI_GET_MCAST_ADDRESS;
  336. #define PXENV_UNDI_GET_NIC_TYPE 0x0012
  337. typedef struct {
  338. PXENV_STATUS_t Status;
  339. uint8_t NicType; /* Type of NIC */
  340. # define PCI_NIC 2
  341. # define PnP_NIC 3
  342. # define CardBus_NIC 4
  343. union {
  344. struct {
  345. uint16_t Vendor_ID;
  346. uint16_t Dev_ID;
  347. uint8_t Base_Class;
  348. uint8_t Sub_Class;
  349. uint8_t Prog_Intf;
  350. uint8_t Rev;
  351. uint16_t BusDevFunc;
  352. uint16_t SubVendor_ID;
  353. uint16_t SubDevice_ID;
  354. } pci, cardbus;
  355. struct {
  356. uint32_t EISA_Dev_ID;
  357. uint8_t Base_Class;
  358. uint8_t Sub_Class;
  359. uint8_t Prog_Intf;
  360. uint16_t CardSelNum;
  361. } pnp;
  362. } info;
  363. } PACKED t_PXENV_UNDI_GET_NIC_TYPE;
  364. #define PXENV_UNDI_GET_IFACE_INFO 0x0013
  365. typedef struct {
  366. PXENV_STATUS_t Status;
  367. uint8_t IfaceType[16]; /* Name of MAC type in ASCII. */
  368. uint32_t LinkSpeed; /* Defined in NDIS 2.0 spec */
  369. uint32_t ServiceFlags; /* Defined in NDIS 2.0 spec */
  370. uint32_t Reserved[4]; /* must be 0 */
  371. } PACKED t_PXENV_UNDI_GET_IFACE_INFO;
  372. #define PXENV_UNDI_ISR 0x0014
  373. typedef struct {
  374. PXENV_STATUS_t Status;
  375. uint16_t FuncFlag; /* PXENV_UNDI_ISR_OUT_xxx */
  376. uint16_t BufferLength; /* Length of Frame */
  377. uint16_t FrameLength; /* Total length of reciever frame */
  378. uint16_t FrameHeaderLength; /* Length of the media header in Frame */
  379. SEGOFF16_t Frame; /* receive buffer */
  380. uint8_t ProtType; /* Protocol type */
  381. uint8_t PktType; /* Packet Type */
  382. # define PXENV_UNDI_ISR_IN_START 1
  383. # define PXENV_UNDI_ISR_IN_PROCESS 2
  384. # define PXENV_UNDI_ISR_IN_GET_NEXT 3
  385. /* one of these will be returned for PXENV_UNDI_ISR_IN_START */
  386. # define PXENV_UNDI_ISR_OUT_OURS 0
  387. # define PXENV_UNDI_ISR_OUT_NOT_OURS 1
  388. /*
  389. * one of these will bre returnd for PXEND_UNDI_ISR_IN_PROCESS
  390. * and PXENV_UNDI_ISR_IN_GET_NEXT
  391. */
  392. # define PXENV_UNDI_ISR_OUT_DONE 0
  393. # define PXENV_UNDI_ISR_OUT_TRANSMIT 2
  394. # define PXENV_UNDI_ISR_OUT_RECEIVE 3
  395. # define PXENV_UNDI_ISR_OUT_BUSY 4
  396. } PACKED t_PXENV_UNDI_ISR;
  397. #define PXENV_STOP_UNDI 0x0015
  398. typedef struct {
  399. PXENV_STATUS_t Status;
  400. } PACKED t_PXENV_STOP_UNDI;
  401. #define PXENV_TFTP_OPEN 0x0020
  402. typedef struct {
  403. PXENV_STATUS_t Status;
  404. IP4_t ServerIPAddress;
  405. IP4_t GatewayIPAddress;
  406. uint8_t FileName[128];
  407. UDP_PORT_t TFTPPort;
  408. uint16_t PacketSize;
  409. } PACKED t_PXENV_TFTP_OPEN;
  410. #define PXENV_TFTP_CLOSE 0x0021
  411. typedef struct {
  412. PXENV_STATUS_t Status;
  413. } PACKED t_PXENV_TFTP_CLOSE;
  414. #define PXENV_TFTP_READ 0x0022
  415. typedef struct {
  416. PXENV_STATUS_t Status;
  417. uint16_t PacketNumber;
  418. uint16_t BufferSize;
  419. SEGOFF16_t Buffer;
  420. } PACKED t_PXENV_TFTP_READ;
  421. #define PXENV_TFTP_READ_FILE 0x0023
  422. typedef struct {
  423. PXENV_STATUS_t Status;
  424. uint8_t FileName[128];
  425. uint32_t BufferSize;
  426. ADDR32_t Buffer;
  427. IP4_t ServerIPAddress;
  428. IP4_t GatewayIPAdress;
  429. IP4_t McastIPAdress;
  430. UDP_PORT_t TFTPClntPort;
  431. UDP_PORT_t TFTPSrvPort;
  432. uint16_t TFTPOpenTimeOut;
  433. uint16_t TFTPReopenDelay;
  434. } PACKED t_PXENV_TFTP_READ_FILE;
  435. #define PXENV_TFTP_GET_FSIZE 0x0025
  436. typedef struct {
  437. PXENV_STATUS_t Status;
  438. IP4_t ServerIPAddress;
  439. IP4_t GatewayIPAdress;
  440. uint8_t FileName[128];
  441. uint32_t FileSize;
  442. } PACKED t_PXENV_TFTP_GET_FSIZE;
  443. #define PXENV_UDP_OPEN 0x0030
  444. typedef struct {
  445. PXENV_STATUS_t Status;
  446. IP4_t src_ip; /* IP address of this station */
  447. } PACKED t_PXENV_UDP_OPEN;
  448. #define PXENV_UDP_CLOSE 0x0031
  449. typedef struct {
  450. PXENV_STATUS_t Status;
  451. } PACKED t_PXENV_UDP_CLOSE;
  452. #define PXENV_UDP_READ 0x0032
  453. typedef struct {
  454. PXENV_STATUS_t Status;
  455. IP4_t src_ip; /* IP of sender */
  456. IP4_t dest_ip; /* Only accept packets sent to this IP */
  457. UDP_PORT_t s_port; /* UDP source port of sender */
  458. UDP_PORT_t d_port; /* Only accept packets sent to this port */
  459. uint16_t buffer_size; /* Size of the packet buffer */
  460. SEGOFF16_t buffer; /* SEG:OFF to the packet buffer */
  461. } PACKED t_PXENV_UDP_READ;
  462. #define PXENV_UDP_WRITE 0x0033
  463. typedef struct {
  464. PXENV_STATUS_t Status;
  465. IP4_t ip; /* dest ip addr */
  466. IP4_t gw; /* ip gateway */
  467. UDP_PORT_t src_port; /* source udp port */
  468. UDP_PORT_t dst_port; /* destination udp port */
  469. uint16_t buffer_size; /* Size of the packet buffer */
  470. SEGOFF16_t buffer; /* SEG:OFF to the packet buffer */
  471. } PACKED t_PXENV_UDP_WRITE;
  472. #define PXENV_UNLOAD_STACK 0x0070
  473. typedef struct {
  474. PXENV_STATUS_t Status;
  475. uint8_t reserved[10];
  476. } PACKED t_PXENV_UNLOAD_STACK;
  477. #define PXENV_GET_CACHED_INFO 0x0071
  478. typedef struct {
  479. PXENV_STATUS_t Status;
  480. uint16_t PacketType; /* type (defined right here) */
  481. # define PXENV_PACKET_TYPE_DHCP_DISCOVER 1
  482. # define PXENV_PACKET_TYPE_DHCP_ACK 2
  483. # define PXENV_PACKET_TYPE_BINL_REPLY 3
  484. uint16_t BufferSize; /* max to copy, leave at 0 for pointer */
  485. SEGOFF16_t Buffer; /* copy to, leave at 0 for pointer */
  486. uint16_t BufferLimit; /* max size of buffer in BC dataseg ? */
  487. } PACKED t_PXENV_GET_CACHED_INFO;
  488. /* structure filled in by PXENV_GET_CACHED_INFO
  489. * (how we determine which IP we downloaded the initial bootstrap from)
  490. * words can't describe...
  491. */
  492. typedef struct {
  493. uint8_t opcode;
  494. # define BOOTP_REQ 1
  495. # define BOOTP_REP 2
  496. uint8_t Hardware; /* hardware type */
  497. uint8_t Hardlen; /* hardware addr len */
  498. uint8_t Gatehops; /* zero it */
  499. uint32_t ident; /* random number chosen by client */
  500. uint16_t seconds; /* seconds since did initial bootstrap */
  501. uint16_t Flags; /* seconds since did initial bootstrap */
  502. # define BOOTP_BCAST 0x8000 /* ? */
  503. IP4_t cip; /* Client IP */
  504. IP4_t yip; /* Your IP */
  505. IP4_t sip; /* IP to use for next boot stage */
  506. IP4_t gip; /* Relay IP ? */
  507. MAC_ADDR CAddr; /* Client hardware address */
  508. uint8_t Sname[64]; /* Server's hostname (Optional) */
  509. uint8_t bootfile[128]; /* boot filename */
  510. union {
  511. # if 1
  512. # define BOOTP_DHCPVEND 1024 /* DHCP extended vendor field size */
  513. # else
  514. # define BOOTP_DHCPVEND 312 /* DHCP standard vendor field size */
  515. # endif
  516. uint8_t d[BOOTP_DHCPVEND]; /* raw array of vendor/dhcp options */
  517. struct {
  518. uint8_t magic[4]; /* DHCP magic cookie */
  519. # ifndef VM_RFC1048
  520. # define VM_RFC1048 0x63825363L /* ? */
  521. # endif
  522. uint32_t flags; /* bootp flags/opcodes */
  523. uint8_t pad[56]; /* I don't think intel knows what a
  524. union does... */
  525. } v;
  526. } vendor;
  527. } PACKED BOOTPLAYER;
  528. #define PXENV_RESTART_TFTP 0x0073
  529. #define t_PXENV_RESTART_TFTP t_PXENV_TFTP_READ_FILE
  530. #define PXENV_START_BASE 0x0075
  531. typedef struct {
  532. PXENV_STATUS_t Status;
  533. } PACKED t_PXENV_START_BASE;
  534. #define PXENV_STOP_BASE 0x0076
  535. typedef struct {
  536. PXENV_STATUS_t Status;
  537. } PACKED t_PXENV_STOP_BASE;
  538. /*****************************************************************************
  539. * The following portion of this file is derived from netboot's
  540. * general.h86. Do not remove the copyright notice below.
  541. *****************************************************************************
  542. */
  543. /*
  544. * general.h86 - Common PXE definitions
  545. *
  546. * Copyright (C) 2003 Gero Kuhlmann <gero@gkminix.han.de>
  547. *
  548. * This program is free software; you can redistribute it and/or modify
  549. * it under the terms of the GNU General Public License as published by
  550. * the Free Software Foundation; either version 2 of the License, or
  551. * any later version.
  552. *
  553. * This program is distributed in the hope that it will be useful,
  554. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  555. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  556. * GNU General Public License for more details.
  557. *
  558. * You should have received a copy of the GNU General Public License
  559. * along with this program; if not, write to the Free Software
  560. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  561. *
  562. * $Id$
  563. */
  564. /*
  565. **************************************************************************
  566. *
  567. * This file contains the Preboot API common definitions as
  568. * per Intels PXE specification version 2.0.
  569. *
  570. * Updated to comply with PXE specification version 2.1 by Michael Brown.
  571. *
  572. **************************************************************************
  573. *
  574. * Result codes returned in AX by a PXENV API service:
  575. */
  576. #define PXENV_EXIT_SUCCESS 0x0000
  577. #define PXENV_EXIT_FAILURE 0x0001
  578. /*
  579. **************************************************************************
  580. *
  581. * CPU types (defined in WfM 1.1):
  582. */
  583. #define PXENV_CPU_X86 0
  584. #define PXENV_CPU_ALPHA 1
  585. #define PXENV_CPU_PPC 2
  586. /*
  587. **************************************************************************
  588. *
  589. * Bus types (defined in WfM 1.1):
  590. */
  591. #define PXENV_BUS_ISA 0
  592. #define PXENV_BUS_EISA 1
  593. #define PXENV_BUS_MCA 2
  594. #define PXENV_BUS_PCI 3
  595. #define PXENV_BUS_VESA 4
  596. #define PXENV_BUS_PCMCIA 5
  597. /*****************************************************************************
  598. * The remainder of this file is original to Etherboot.
  599. *****************************************************************************
  600. */
  601. /* Dummy PXE opcode for the loader routine. We do this to make the
  602. * API simpler
  603. */
  604. #define PXENV_UNDI_LOADER 0x104d /* 'load' */
  605. typedef struct undi_loader {
  606. union {
  607. struct {
  608. PXENV_STATUS_t Status;
  609. uint16_t ax;
  610. uint16_t bx;
  611. uint16_t dx;
  612. uint16_t di;
  613. uint16_t es;
  614. };
  615. t_PXENV_START_UNDI start_undi;
  616. };
  617. uint16_t undi_ds;
  618. uint16_t undi_cs;
  619. SEGOFF16_t pxe_ptr;
  620. SEGOFF16_t pxenv_ptr;
  621. } PACKED undi_loader_t;
  622. /* Union used for PXE API calls; we don't know the type of the
  623. * structure until we interpret the opcode. Also, Status is available
  624. * in the same location for any opcode, and it's convenient to have
  625. * non-specific access to it.
  626. */
  627. typedef union {
  628. PXENV_STATUS_t Status; /* Make it easy to read status
  629. for any operation */
  630. t_PXENV_START_UNDI start_undi;
  631. t_PXENV_UNDI_STARTUP undi_startup;
  632. t_PXENV_UNDI_CLEANUP undi_cleanup;
  633. t_PXENV_UNDI_INITIALIZE undi_initialize;
  634. t_PXENV_UNDI_RESET_ADAPTER undi_reset_adapter;
  635. t_PXENV_UNDI_SHUTDOWN undi_shutdown;
  636. t_PXENV_UNDI_OPEN undi_open;
  637. t_PXENV_UNDI_CLOSE undi_close;
  638. t_PXENV_UNDI_TRANSMIT undi_transmit;
  639. t_PXENV_UNDI_SET_MCAST_ADDRESS undi_set_mcast_address;
  640. t_PXENV_UNDI_SET_STATION_ADDRESS undi_set_station_address;
  641. t_PXENV_UNDI_SET_PACKET_FILTER undi_set_packet_filter;
  642. t_PXENV_UNDI_GET_INFORMATION undi_get_information;
  643. t_PXENV_UNDI_GET_STATISTICS undi_get_statistics;
  644. t_PXENV_UNDI_CLEAR_STATISTICS undi_clear_statistics;
  645. t_PXENV_UNDI_INITIATE_DIAGS undi_initiate_diags;
  646. t_PXENV_UNDI_FORCE_INTERRUPT undi_force_interrupt;
  647. t_PXENV_UNDI_GET_MCAST_ADDRESS undi_get_mcast_address;
  648. t_PXENV_UNDI_GET_NIC_TYPE undi_get_nic_type;
  649. t_PXENV_UNDI_GET_IFACE_INFO undi_get_iface_info;
  650. t_PXENV_UNDI_ISR undi_isr;
  651. t_PXENV_STOP_UNDI stop_undi;
  652. t_PXENV_TFTP_OPEN tftp_open;
  653. t_PXENV_TFTP_CLOSE tftp_close;
  654. t_PXENV_TFTP_READ tftp_read;
  655. t_PXENV_TFTP_READ_FILE tftp_read_file;
  656. t_PXENV_TFTP_GET_FSIZE tftp_get_fsize;
  657. t_PXENV_UDP_OPEN udp_open;
  658. t_PXENV_UDP_CLOSE udp_close;
  659. t_PXENV_UDP_READ udp_read;
  660. t_PXENV_UDP_WRITE udp_write;
  661. t_PXENV_UNLOAD_STACK unload_stack;
  662. t_PXENV_GET_CACHED_INFO get_cached_info;
  663. t_PXENV_RESTART_TFTP restart_tftp;
  664. t_PXENV_START_BASE start_base;
  665. t_PXENV_STOP_BASE stop_base;
  666. undi_loader_t loader;
  667. } t_PXENV_ANY;
  668. /* PXE stack status indicator. See pxe_export.c for further
  669. * explanation.
  670. */
  671. typedef enum {
  672. CAN_UNLOAD = 0,
  673. MIDWAY,
  674. READY
  675. } pxe_stack_state_t;
  676. /* Data structures installed as part of a PXE stack. Architectures
  677. * will have extra information to append to the end of this.
  678. */
  679. #define PXE_TFTP_MAGIC_COOKIE ( ( 'P'<<24 ) | ( 'x'<<16 ) | ( 'T'<<8 ) | 'f' )
  680. typedef struct {
  681. pxe_t pxe __attribute__ ((aligned(16)));
  682. pxenv_t pxenv __attribute__ ((aligned(16)));
  683. pxe_stack_state_t state;
  684. union {
  685. BOOTPLAYER cached_info;
  686. char packet[ETH_FRAME_LEN];
  687. struct {
  688. uint32_t magic_cookie;
  689. unsigned int len;
  690. int eof;
  691. char data[TFTP_MAX_PACKET];
  692. } tftpdata;
  693. struct {
  694. char *buffer;
  695. uint32_t offset;
  696. uint32_t bufferlen;
  697. } readfile;
  698. };
  699. struct {} arch_data __attribute__ ((aligned(16)));
  700. } pxe_stack_t;
  701. #endif /* PXE_H */