Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

etherboot.h 8.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  1. #ifndef ETHERBOOT_H
  2. #define ETHERBOOT_H
  3. /*
  4. * Standard includes that we always want
  5. *
  6. */
  7. #include "compiler.h"
  8. #include "stddef.h"
  9. #include "stdint.h"
  10. #include <unistd.h>
  11. /*
  12. * IMPORTANT!!!!!!!!!!!!!!
  13. *
  14. * Everything below this point is cruft left over from older versions
  15. * of Etherboot. Do not add *anything* below this point. Things are
  16. * gradually being moved to individual header files.
  17. *
  18. */
  19. #include <stdarg.h>
  20. #include "osdep.h"
  21. #ifndef BOOT_FIRST
  22. #define BOOT_FIRST BOOT_NIC
  23. #endif
  24. #ifndef BOOT_SECOND
  25. #define BOOT_SECOND BOOT_NOTHING
  26. #endif
  27. #ifndef BOOT_THIRD
  28. #define BOOT_THIRD BOOT_NOTHING
  29. #endif
  30. #define DEFAULT_BOOT_ORDER ( \
  31. (BOOT_FIRST << (0*BOOT_BITS)) | \
  32. (BOOT_SECOND << (1*BOOT_BITS)) | \
  33. (BOOT_THIRD << (2*BOOT_BITS)) | \
  34. (BOOT_NOTHING << (3*BOOT_BITS)) | \
  35. 0)
  36. #ifdef BOOT_INDEX
  37. #define DEFAULT_BOOT_INDEX BOOT_INDEX
  38. #else
  39. #define DEFAULT_BOOT_INDEX 0
  40. #endif
  41. #if !defined(TAGGED_IMAGE) && !defined(AOUT_IMAGE) && !defined(ELF_IMAGE) && !defined(ELF64_IMAGE) && !defined(COFF_IMAGE) && !defined(RAW_IMAGE)
  42. #define TAGGED_IMAGE /* choose at least one */
  43. #endif
  44. #define K_ESC '\033'
  45. #define K_EOF '\04' /* Ctrl-D */
  46. #define K_INTR '\03' /* Ctrl-C */
  47. /* Edit this to change the path to hostspecific kernel image
  48. kernel.<client_ip_address> in RARP boot */
  49. #ifndef DEFAULT_KERNELPATH
  50. #define DEFAULT_KERNELPATH "/tftpboot/kernel.%@"
  51. #endif
  52. #ifdef FREEBSD_PXEEMU
  53. #undef DEFAULT_BOOTFILE
  54. #ifndef PXENFSROOTPATH
  55. #define PXENFSROOTPATH ""
  56. #endif
  57. #define DEFAULT_BOOTFILE PXENFSROOTPATH "/boot/pxeboot"
  58. #endif
  59. #ifndef MAX_TFTP_RETRIES
  60. #define MAX_TFTP_RETRIES 20
  61. #endif
  62. #ifndef MAX_BOOTP_RETRIES
  63. #define MAX_BOOTP_RETRIES 20
  64. #endif
  65. #define MAX_BOOTP_EXTLEN (ETH_MAX_MTU-sizeof(struct bootpip_t))
  66. #ifndef MAX_ARP_RETRIES
  67. #define MAX_ARP_RETRIES 20
  68. #endif
  69. #ifndef MAX_RPC_RETRIES
  70. #define MAX_RPC_RETRIES 20
  71. #endif
  72. /* Link configuration time in tenths of a second */
  73. #ifndef VALID_LINK_TIMEOUT
  74. #define VALID_LINK_TIMEOUT 100 /* 10.0 seconds */
  75. #endif
  76. /* Inter-packet retry in ticks */
  77. #ifndef TIMEOUT
  78. #define TIMEOUT (10*TICKS_PER_SEC)
  79. #endif
  80. #ifndef BOOTP_TIMEOUT
  81. #define BOOTP_TIMEOUT (2*TICKS_PER_SEC)
  82. #endif
  83. /* Max interval between IGMP packets */
  84. #define IGMP_INTERVAL (10*TICKS_PER_SEC)
  85. #define IGMPv1_ROUTER_PRESENT_TIMEOUT (400*TICKS_PER_SEC)
  86. /* These settings have sense only if compiled with -DCONGESTED */
  87. /* total retransmission timeout in ticks */
  88. #define TFTP_TIMEOUT (30*TICKS_PER_SEC)
  89. /* packet retransmission timeout in ticks */
  90. #ifdef CONGESTED
  91. #define TFTP_REXMT (3*TICKS_PER_SEC)
  92. #else
  93. #define TFTP_REXMT TIMEOUT
  94. #endif
  95. #ifndef NULL
  96. #define NULL ((void *)0)
  97. #endif
  98. #include <gpxe/if_ether.h>
  99. enum {
  100. ARP_CLIENT, ARP_SERVER, ARP_GATEWAY,
  101. ARP_NAMESERVER,
  102. #ifdef PXE_EXPORT
  103. ARP_PROXYDHCP,
  104. #endif
  105. MAX_ARP
  106. };
  107. #define RARP_REQUEST 3
  108. #define RARP_REPLY 4
  109. #include <gpxe/in.h>
  110. /* Helper macros used to identify when DHCP options are valid/invalid in/outside of encapsulation */
  111. #define NON_ENCAP_OPT in_encapsulated_options == 0 &&
  112. #ifdef ALLOW_ONLY_ENCAPSULATED
  113. #define ENCAP_OPT in_encapsulated_options == 1 &&
  114. #else
  115. #define ENCAP_OPT
  116. #endif
  117. #include <gpxe/if_arp.h>
  118. #include "ip.h"
  119. #include "udp.h"
  120. #include "old_tcp.h"
  121. #include "bootp.h"
  122. #include "igmp.h"
  123. #include "nfs.h"
  124. #include "console.h"
  125. #include "stdlib.h"
  126. struct arptable_t {
  127. struct in_addr ipaddr;
  128. uint8_t node[6];
  129. } PACKED;
  130. #define KERNEL_BUF (bootp_data.bootp_reply.bp_file)
  131. #define FLOPPY_BOOT_LOCATION 0x7c00
  132. struct rom_info {
  133. unsigned short rom_segment;
  134. unsigned short rom_length;
  135. };
  136. extern inline int rom_address_ok(struct rom_info *rom, int assigned_rom_segment)
  137. {
  138. return (assigned_rom_segment < 0xC000
  139. || assigned_rom_segment == rom->rom_segment);
  140. }
  141. /* Define a type for passing info to a loaded program */
  142. struct ebinfo {
  143. uint8_t major, minor; /* Version */
  144. uint16_t flags; /* Bit flags */
  145. };
  146. /***************************************************************************
  147. External prototypes
  148. ***************************************************************************/
  149. /* main.c */
  150. struct Elf_Bhdr;
  151. extern int main();
  152. extern char as_main_program;
  153. /* nic.c */
  154. extern void rx_qdrain P((void));
  155. extern int ip_transmit P((int len, const void *buf));
  156. extern void build_ip_hdr P((unsigned long destip, int ttl, int protocol,
  157. int option_len, int len, const void *buf));
  158. extern void build_udp_hdr P((unsigned long destip,
  159. unsigned int srcsock, unsigned int destsock, int ttl,
  160. int len, const void *buf));
  161. extern int udp_transmit P((unsigned long destip, unsigned int srcsock,
  162. unsigned int destsock, int len, const void *buf));
  163. extern int tcp_transmit(unsigned long destip, unsigned int srcsock,
  164. unsigned int destsock, long send_seq, long recv_seq,
  165. int window, int flags, int len, const void *buf);
  166. int tcp_reset(struct iphdr *ip);
  167. typedef int (*reply_t)(int ival, void *ptr, unsigned short ptype, struct iphdr *ip, struct udphdr *udp, struct tcphdr *tcp);
  168. extern int await_reply P((reply_t reply, int ival, void *ptr, long timeout));
  169. extern int decode_rfc1533 P((unsigned char *, unsigned int, unsigned int, int));
  170. #define RAND_MAX 2147483647L
  171. extern uint16_t ipchksum P((const void *ip, unsigned long len));
  172. extern uint16_t add_ipchksums P((unsigned long offset, uint16_t sum, uint16_t new));
  173. extern long rfc2131_sleep_interval P((long base, int exp));
  174. extern void cleanup P((void));
  175. /* osloader.c */
  176. /* Be careful with sector_t it is an unsigned long long on x86 */
  177. typedef uint64_t sector_t;
  178. typedef sector_t (*os_download_t)(unsigned char *data, unsigned int len, int eof);
  179. extern os_download_t probe_image(unsigned char *data, unsigned int len);
  180. extern int load_block P((unsigned char *, unsigned int, unsigned int, int ));
  181. /* misc.c */
  182. extern void twiddle P((void));
  183. extern void interruptible_sleep P((int secs));
  184. extern int strcasecmp P((const char *a, const char *b));
  185. extern char *substr P((const char *a, const char *b));
  186. extern unsigned long get_boot_order(unsigned long order, unsigned *index);
  187. extern void disk_init P((void));
  188. extern unsigned int pcbios_disk_read P((int drv,int c,int h,int s,char *buf));
  189. /* start32.S */
  190. struct os_entry_regs {
  191. /* Be careful changing this structure
  192. * as it is used by assembly language code.
  193. */
  194. uint32_t edi; /* 0 */
  195. uint32_t esi; /* 4 */
  196. uint32_t ebp; /* 8 */
  197. uint32_t esp; /* 12 */
  198. uint32_t ebx; /* 16 */
  199. uint32_t edx; /* 20 */
  200. uint32_t ecx; /* 24 */
  201. uint32_t eax; /* 28 */
  202. uint32_t saved_ebp; /* 32 */
  203. uint32_t saved_esi; /* 36 */
  204. uint32_t saved_edi; /* 40 */
  205. uint32_t saved_ebx; /* 44 */
  206. uint32_t saved_eip; /* 48 */
  207. uint32_t saved_esp; /* 52 */
  208. };
  209. struct regs {
  210. /* Be careful changing this structure
  211. * as it is used by assembly language code.
  212. */
  213. uint32_t edi; /* 0 */
  214. uint32_t esi; /* 4 */
  215. uint32_t ebp; /* 8 */
  216. uint32_t esp; /* 12 */
  217. uint32_t ebx; /* 16 */
  218. uint32_t edx; /* 20 */
  219. uint32_t ecx; /* 24 */
  220. uint32_t eax; /* 28 */
  221. };
  222. extern struct os_entry_regs os_regs;
  223. extern struct regs initial_regs;
  224. extern int xstart32(unsigned long entry_point, ...);
  225. extern int xstart_lm(unsigned long entry_point, unsigned long params);
  226. extern void xend32 P((void));
  227. struct Elf_Bhdr *prepare_boot_params(void *header);
  228. extern int elf_start(unsigned long machine, unsigned long entry, unsigned long params);
  229. extern unsigned long currticks P((void));
  230. extern void exit P((int status));
  231. /***************************************************************************
  232. External variables
  233. ***************************************************************************/
  234. /* main.c */
  235. extern struct rom_info rom;
  236. extern char *hostname;
  237. extern int hostnamelen;
  238. extern unsigned char *addparam;
  239. extern int addparamlen;
  240. extern jmp_buf restart_etherboot;
  241. extern int url_port;
  242. extern struct arptable_t arptable[MAX_ARP];
  243. #ifdef IMAGE_MENU
  244. extern int menutmo,menudefault;
  245. extern unsigned char *defparams;
  246. extern int defparams_max;
  247. #endif
  248. #ifdef MOTD
  249. extern unsigned char *motd[RFC1533_VENDOR_NUMOFMOTD];
  250. #endif
  251. extern struct bootpd_t bootp_data;
  252. #define BOOTP_DATA_ADDR (&bootp_data)
  253. extern unsigned char *end_of_rfc1533;
  254. #ifdef IMAGE_FREEBSD
  255. extern int freebsd_howto;
  256. #define FREEBSD_KERNEL_ENV_SIZE 256
  257. extern char freebsd_kernel_env[FREEBSD_KERNEL_ENV_SIZE];
  258. #endif
  259. /*
  260. * Local variables:
  261. * c-basic-offset: 8
  262. * End:
  263. */
  264. #endif /* ETHERBOOT_H */