VirtualBox

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

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

import

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 13.3 KB
 
1#ifndef ETHERBOOT_H
2#define ETHERBOOT_H
3
4#include <stdarg.h>
5#include "osdep.h"
6#ifdef VBOX
7#include "etherboot-asm.h"
8#endif /* VBOX */
9
10#ifndef BOOT_FIRST
11#define BOOT_FIRST BOOT_NIC
12#endif
13#ifndef BOOT_SECOND
14#define BOOT_SECOND BOOT_NOTHING
15#endif
16#ifndef BOOT_THIRD
17#define BOOT_THIRD BOOT_NOTHING
18#endif
19
20#define DEFAULT_BOOT_ORDER ( \
21 (BOOT_FIRST << (0*BOOT_BITS)) | \
22 (BOOT_SECOND << (1*BOOT_BITS)) | \
23 (BOOT_THIRD << (2*BOOT_BITS)) | \
24 (BOOT_NOTHING << (3*BOOT_BITS)) | \
25 0)
26
27#ifdef BOOT_INDEX
28#define DEFAULT_BOOT_INDEX BOOT_INDEX
29#else
30#define DEFAULT_BOOT_INDEX 0
31#endif
32
33#if !defined(TAGGED_IMAGE) && !defined(AOUT_IMAGE) && !defined(ELF_IMAGE) && !defined(ELF64_IMAGE) && !defined(COFF_IMAGE) && !defined(RAW_IMAGE) && !defined(PXE_IMAGE)
34#define TAGGED_IMAGE /* choose at least one */
35#endif
36
37#undef CODE16
38#if defined(PCBIOS)
39#define CODE16
40#endif
41
42#ifdef VBOX
43#define __STRINGIFY(x) #x
44#define STRINGIFY(x) __STRINGIFY(x)
45#endif /* VBOX */
46
47#define K_ESC '\033'
48#define K_EOF '\04' /* Ctrl-D */
49#define K_INTR '\03' /* Ctrl-C */
50
51/* Edit this to change the path to hostspecific kernel image
52 kernel.<client_ip_address> in RARP boot */
53#ifndef DEFAULT_KERNELPATH
54#define DEFAULT_KERNELPATH "/tftpboot/kernel.%@"
55#endif
56
57#ifdef FREEBSD_PXEEMU
58#undef DEFAULT_BOOTFILE
59#ifndef PXENFSROOTPATH
60#define PXENFSROOTPATH ""
61#endif
62#define DEFAULT_BOOTFILE PXENFSROOTPATH "/boot/pxeboot"
63#endif
64
65/* Clean up console settings... mainly CONSOLE_FIRMWARE and CONSOLE_SERIAL are used
66 * in the sources (except start.S and serial.S which cannot include
67 * etherboot.h). At least one of the CONSOLE_xxx has to be set, and
68 * CONSOLE_DUAL sets both CONSOLE_CRT and CONSOLE_SERIAL. If none is set,
69 * CONSOLE_CRT is assumed. */
70#ifdef CONSOLE_CRT
71#define CONSOLE_FIRMWARE
72#endif
73#ifdef CONSOLE_DUAL
74#undef CONSOLE_FIRMWARE
75#define CONSOLE_FIRMWARE
76#undef CONSOLE_SERIAL
77#define CONSOLE_SERIAL
78#endif
79#if defined(CONSOLE_FIRMWARE) && defined(CONSOLE_SERIAL)
80#undef CONSOLE_DUAL
81#define CONSOLE_DUAL
82#endif
83#if !defined(CONSOLE_FIRMWARE) && !defined(CONSOLE_SERIAL)
84#define CONSOLE_FIRMWARE
85#endif
86
87#if !defined(DOWNLOAD_PROTO_TFTP) && !defined(DOWNLOAD_PROTO_NFS) && !defined(DOWNLOAD_PROTO_SLAM) && !defined(DOWNLOAD_PROTO_TFTM) && !defined(DOWNLOAD_PROTO_DISK) && !defined(DOWNLOAD_PROTO_HTTP) && !defined(DOWNLOAD_PROTO_FSP)
88#error No download protocol defined!
89#endif
90
91#ifndef MAX_TFTP_RETRIES
92#define MAX_TFTP_RETRIES 20
93#endif
94
95#ifndef MAX_BOOTP_RETRIES
96#define MAX_BOOTP_RETRIES 20
97#endif
98
99#define MAX_BOOTP_EXTLEN (ETH_MAX_MTU-sizeof(struct bootpip_t))
100
101#ifndef MAX_ARP_RETRIES
102#define MAX_ARP_RETRIES 20
103#endif
104
105#ifndef MAX_RPC_RETRIES
106#define MAX_RPC_RETRIES 20
107#endif
108
109/* Link configuration time in tenths of a second */
110#ifndef VALID_LINK_TIMEOUT
111#define VALID_LINK_TIMEOUT 100 /* 10.0 seconds */
112#endif
113
114/* Inter-packet retry in ticks */
115#ifndef TIMEOUT
116#define TIMEOUT (10*TICKS_PER_SEC)
117#endif
118
119#ifndef BOOTP_TIMEOUT
120#define BOOTP_TIMEOUT (2*TICKS_PER_SEC)
121#endif
122
123/* Max interval between IGMP packets */
124#define IGMP_INTERVAL (10*TICKS_PER_SEC)
125#define IGMPv1_ROUTER_PRESENT_TIMEOUT (400*TICKS_PER_SEC)
126
127/* These settings have sense only if compiled with -DCONGESTED */
128/* total retransmission timeout in ticks */
129#define TFTP_TIMEOUT (30*TICKS_PER_SEC)
130/* packet retransmission timeout in ticks */
131#ifdef CONGESTED
132#define TFTP_REXMT (3*TICKS_PER_SEC)
133#else
134#define TFTP_REXMT TIMEOUT
135#endif
136
137#ifndef NULL
138#define NULL ((void *)0)
139#endif
140
141#include "if_ether.h"
142
143enum {
144 ARP_CLIENT, ARP_SERVER, ARP_GATEWAY,
145#ifdef DNS_RESOLVER
146 ARP_NAMESERVER,
147#endif
148#ifdef PXE_EXPORT
149 ARP_PROXYDHCP,
150#endif
151 MAX_ARP
152};
153
154#define IGMP_SERVER 0
155#define MAX_IGMP IGMP_SERVER+1
156
157#define RARP_REQUEST 3
158#define RARP_REPLY 4
159
160#include "in.h"
161
162#define MULTICAST_MASK 0xF0000000
163#define MULTICAST_NETWORK 0xE0000000
164
165/* Helper macros used to identify when DHCP options are valid/invalid in/outside of encapsulation */
166/* helpers for decoding RFC1533_VENDOR encapsulated options */
167#ifdef PXE_DHCP_STRICT
168#define PXE_ENCAP_OPT in_pxe_encapsulated_options == 1 &&
169#define PXE_NONENCAP_OPT in_pxe_encapsulated_options == 0 &&
170#else
171#define PXE_ENCAP_OPT
172#define PXE_NONENCAP_OPT
173#endif /* PXE_DHCP_STRICT */
174
175#define NON_ENCAP_OPT in_encapsulated_options == 0 && PXE_NONENCAP_OPT
176#ifdef ALLOW_ONLY_ENCAPSULATED
177#define ENCAP_OPT in_encapsulated_options == 1 &&
178#else
179#define ENCAP_OPT PXE_NONENCAP_OPT
180#endif
181
182#include "if_arp.h"
183#include "ip.h"
184#include "udp.h"
185#include "tcp.h"
186#include "bootp.h"
187#include "tftp.h"
188#include "igmp.h"
189#include "nfs.h"
190
191struct arptable_t {
192 in_addr ipaddr;
193 uint8_t node[6];
194} PACKED;
195
196struct igmptable_t {
197 in_addr group;
198 unsigned long time;
199} PACKED;
200
201#define KERNEL_BUF (bootp_data.bootp_reply.bp_file)
202
203#define FLOPPY_BOOT_LOCATION 0x7c00
204
205struct rom_info {
206 unsigned short rom_segment;
207 unsigned short rom_length;
208};
209
210extern inline int rom_address_ok(struct rom_info *rom, int assigned_rom_segment)
211{
212 return (assigned_rom_segment < 0xC000
213 || assigned_rom_segment == rom->rom_segment);
214}
215
216/* Define a type for passing info to a loaded program */
217struct ebinfo {
218 uint8_t major, minor; /* Version */
219 uint16_t flags; /* Bit flags */
220};
221
222/***************************************************************************
223External prototypes
224***************************************************************************/
225/* main.c */
226struct Elf_Bhdr;
227extern int in_call(in_call_data_t *data, uint32_t opcode, va_list params);
228extern void console_init(void);
229extern int main(in_call_data_t *data, va_list params);
230extern int loadkernel P((const char *fname));
231extern char as_main_program;
232/* nic.c */
233extern void rx_qdrain P((void));
234extern int tftp P((const char *name, int (*)(unsigned char *, unsigned int, unsigned int, int)));
235extern int tftp_block P((struct tftpreq_info_t *, struct tftpblk_info_t *));
236extern int ip_transmit P((int len, const void *buf));
237extern void build_ip_hdr P((unsigned long destip, int ttl, int protocol,
238 int option_len, int len, const void *buf));
239extern void build_udp_hdr P((unsigned long destip,
240 unsigned int srcsock, unsigned int destsock, int ttl,
241 int len, const void *buf));
242extern int udp_transmit P((unsigned long destip, unsigned int srcsock,
243 unsigned int destsock, int len, const void *buf));
244extern int tcp_transmit(unsigned long destip, unsigned int srcsock,
245 unsigned int destsock, long send_seq, long recv_seq,
246 int window, int flags, int len, const void *buf);
247extern int tcp_reset(struct iphdr *ip);
248typedef int (*reply_t)(int ival, void *ptr, unsigned short ptype, struct iphdr *ip, struct udphdr *udp, struct tcphdr *tcp);
249extern int await_reply P((reply_t reply, int ival, void *ptr, long timeout));
250extern int decode_rfc1533 P((unsigned char *, unsigned int, unsigned int, int));
251extern void join_group(int slot, unsigned long group);
252extern void leave_group(int slot);
253#define RAND_MAX 2147483647L
254extern uint16_t ipchksum P((const void *ip, unsigned long len));
255extern uint16_t add_ipchksums P((unsigned long offset, uint16_t sum, uint16_t new));
256extern int32_t random P((void));
257extern long rfc2131_sleep_interval P((long base, int exp));
258extern long rfc1112_sleep_interval P((long base, int exp));
259#ifndef DOWNLOAD_PROTO_TFTP
260#define tftp(fname, load_block) 0
261#endif
262extern void cleanup P((void));
263
264/* nfs.c */
265extern void rpc_init(void);
266extern int nfs P((const char *name, int (*)(unsigned char *, unsigned int, unsigned int, int)));
267extern void nfs_umountall P((int));
268
269/* proto_slam.c */
270extern int url_slam P((const char *name, int (*fnc)(unsigned char *, unsigned int, unsigned int, int)));
271
272/* proto_tftm.c */
273extern int url_tftm P((const char *name, int (*fnc)(unsigned char *, unsigned int, unsigned int, int)));
274
275/* proto_fsp.c */
276extern int url_fsp P((const char *name, int (*fnc)(unsigned char *, unsigned int, unsigned int, int)));
277
278/* config.c */
279extern void print_config(void);
280
281/* isa_probe.c and pci_probe.c */
282struct dev;
283extern void isa_enumerate(void);
284extern int isa_probe(struct dev *, const char *);
285extern void pci_enumerate(void);
286extern int pci_probe(struct dev *, const char *);
287
288/* heap.c */
289extern void init_heap(void);
290extern void *allot(size_t size);
291extern void forget(void *ptr);
292extern void *allot2(size_t size, uint32_t mask);
293extern void forget2(void *ptr);
294/* Physical address of the heap */
295extern size_t heap_ptr, heap_top, heap_bot;
296
297/* osloader.c */
298/* Be careful with sector_t it is an unsigned long long on x86 */
299typedef uint64_t sector_t;
300typedef sector_t (*os_download_t)(unsigned char *data, unsigned int len, int eof);
301extern os_download_t probe_image(unsigned char *data, unsigned int len);
302extern int load_block P((unsigned char *, unsigned int, unsigned int, int ));
303
304/* misc.c */
305extern void twiddle P((void));
306extern void sleep P((int secs));
307extern void interruptible_sleep P((int secs));
308extern void poll_interruptions P((void));
309extern int strcasecmp P((const char *a, const char *b));
310extern char *substr P((const char *a, const char *b));
311extern unsigned long strtoul P((const char *p, const char **, int base));
312extern int printf P((const char *, ...));
313extern int sprintf P((char *, const char *, ...));
314extern int inet_aton P((const char *p, in_addr *i));
315#ifdef PCBIOS
316extern void gateA20_set P((void));
317#define gateA20_unset()
318#else
319#define gateA20_set()
320#define gateA20_unset()
321#endif
322extern void putchar P((int));
323extern int getchar P((void));
324extern int iskey P((void));
325
326/* pcbios.S */
327extern int console_getc P((void));
328extern void console_putc P((int));
329extern int console_ischar P((void));
330extern int getshift P((void));
331extern int int15 P((int));
332#ifdef POWERSAVE
333extern void cpu_nap P((void));
334#endif /* POWERSAVE */
335
336/* basemem.c */
337extern uint32_t get_free_base_memory ( void );
338extern void allot_real_mode_stack ( void );
339extern void forget_real_mode_stack ( void );
340extern void * allot_base_memory ( size_t );
341extern void forget_base_memory ( void*, size_t );
342extern void forget_prefix_base_memory ( void );
343extern void forget_runtime_base_memory ( uint32_t old_addr );
344
345struct e820entry {
346 uint64_t addr;
347 uint64_t size;
348 uint32_t type;
349#define E820_RAM 1
350#define E820_RESERVED 2
351#define E820_ACPI 3 /* usable as RAM once ACPI tables have been read */
352#define E820_NVS 4
353} PACKED;
354#define E820ENTRY_SIZE 20
355#define E820MAX 32
356struct meminfo {
357 uint16_t basememsize;
358 uint16_t pad;
359 uint32_t memsize;
360 uint32_t map_count;
361 struct e820entry map[E820MAX];
362} PACKED;
363extern struct meminfo meminfo;
364extern void get_memsizes(void);
365extern unsigned long get_boot_order(unsigned long order, unsigned *index);
366#ifndef NORELOCATE
367extern void relocate(void);
368extern void relocate_to(unsigned long phys_dest);
369#else
370#define relocate() do {} while(0)
371#endif
372extern void disk_init P((void));
373extern unsigned int pcbios_disk_read P((int drv,int c,int h,int s,char *buf));
374
375/* start32.S */
376struct os_entry_regs {
377 /* Be careful changing this structure
378 * as it is used by assembly language code.
379 */
380 uint32_t edi; /* 0 */
381 uint32_t esi; /* 4 */
382 uint32_t ebp; /* 8 */
383 uint32_t esp; /* 12 */
384 uint32_t ebx; /* 16 */
385 uint32_t edx; /* 20 */
386 uint32_t ecx; /* 24 */
387 uint32_t eax; /* 28 */
388
389 uint32_t saved_ebp; /* 32 */
390 uint32_t saved_esi; /* 36 */
391 uint32_t saved_edi; /* 40 */
392 uint32_t saved_ebx; /* 44 */
393 uint32_t saved_eip; /* 48 */
394 uint32_t saved_esp; /* 52 */
395};
396struct regs {
397 /* Be careful changing this structure
398 * as it is used by assembly language code.
399 */
400 uint32_t edi; /* 0 */
401 uint32_t esi; /* 4 */
402 uint32_t ebp; /* 8 */
403 uint32_t esp; /* 12 */
404 uint32_t ebx; /* 16 */
405 uint32_t edx; /* 20 */
406 uint32_t ecx; /* 24 */
407 uint32_t eax; /* 28 */
408};
409extern struct os_entry_regs os_regs;
410extern struct regs initial_regs;
411extern int xstart32(unsigned long entry_point, ...);
412extern int xstart_lm(unsigned long entry_point, unsigned long params);
413extern void xend32 P((void));
414extern struct Elf_Bhdr *prepare_boot_params(void *header);
415extern int elf_start(unsigned long machine, unsigned long entry, unsigned long params);
416extern unsigned long currticks P((void));
417extern void exit P((int status));
418extern void _stack;
419extern char _prefix_copy[512];
420extern uint32_t image_basemem;
421
422/* serial.c */
423extern int serial_getc P((void));
424extern void serial_putc P((int));
425extern int serial_ischar P((void));
426extern int serial_init P((void));
427extern void serial_fini P((void));
428
429/* floppy.c */
430extern int bootdisk P((int dev,int part));
431
432/* pxe_callbacks.c */
433extern int pxe_in_call ( in_call_data_t *in_call_data, va_list params );
434
435/***************************************************************************
436External variables
437***************************************************************************/
438/* main.c */
439extern jmp_buf restart_etherboot;
440extern int url_port;
441/* nic.c */
442extern struct rom_info rom;
443extern struct arptable_t arptable[MAX_ARP];
444extern struct igmptable_t igmptable[MAX_IGMP];
445extern char *hostname;
446extern int hostnamelen;
447extern unsigned char *addparam;
448extern int addparamlen;
449extern struct bootpd_t bootp_data;
450#ifdef VBOX
451extern struct bootp_t dhcp_cached_discover;
452extern struct bootpd_t dhcp_cached_reply;
453#endif /* VBOX */
454extern unsigned char *end_of_rfc1533;
455#ifdef IMAGE_FREEBSD
456extern int freebsd_howto;
457#define FREEBSD_KERNEL_ENV_SIZE 256
458extern char freebsd_kernel_env[FREEBSD_KERNEL_ENV_SIZE];
459#endif
460
461/* osloader.c */
462
463/* created by linker */
464extern char _virt_start[], _text[], _etext[], _text16[], _etext16[];
465extern char _data[], _edata[], _bss[], _ebss[], _end[];
466
467
468/*
469 * Local variables:
470 * c-basic-offset: 8
471 * End:
472 */
473
474#endif /* ETHERBOOT_H */
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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