xref: /titanic_50/usr/src/grub/grub-0.97/netboot/grub.h (revision 32e0ab73531b6e6e8957e9ecdbbd42603865f2d0)
1 #ifndef GRUB_H
2 #define GRUB_H
3 
4 #include "osdep.h"
5 #include "byteswap.h"
6 #include "in.h"
7 #include "ip.h"
8 #include "udp.h"
9 #include "if_ether.h"
10 #include "latch.h"
11 #include "io.h"
12 #include "nic.h"
13 #include <shared.h>
14 
15 #define K_ESC		'\033'
16 #define K_EOF		'\04'  /* Ctrl-D */
17 #define K_INTR		'\03'  /* Ctrl-C */
18 
19 #ifndef	MAX_RPC_RETRIES
20 #define MAX_RPC_RETRIES		20
21 #endif
22 
23 
24 /* Inter-packet retry in ticks */
25 #ifndef TIMEOUT
26 #define TIMEOUT			(10*TICKS_PER_SEC)
27 #endif
28 
29 #ifndef	NULL
30 #define NULL	((void *)0)
31 #endif
32 
33 
34 #define ARP_CLIENT	0
35 #define ARP_SERVER	1
36 #define ARP_GATEWAY	2
37 #define MAX_ARP		ARP_GATEWAY+1
38 
39 #define IGMP_SERVER	0
40 #define MAX_IGMP	IGMP_SERVER+1
41 
42 #define	RARP_REQUEST	3
43 #define	RARP_REPLY	4
44 
45 
46 #define MULTICAST_MASK    0xF0000000
47 #define MULTICAST_NETWORK 0xE0000000
48 
49 struct arptable_t {
50 	in_addr ipaddr;
51 	uint8_t node[6];
52 };
53 
54 struct igmptable_t {
55 	in_addr group;
56 	unsigned long time;
57 };
58 
59 #define	KERNEL_BUF	(BOOTP_DATA_ADDR->bootp_reply.bp_file)
60 
61 #define	FLOPPY_BOOT_LOCATION	0x7c00
62 /* Must match offsets in loader.S */
63 #define ROM_SEGMENT		0x1fa
64 #define ROM_LENGTH		0x1fc
65 
66 #define	ROM_INFO_LOCATION	(FLOPPY_BOOT_LOCATION+ROM_SEGMENT)
67 /* at end of floppy boot block */
68 
69 
70 
71 /* Define a type for passing info to a loaded program */
72 struct ebinfo {
73 	uint8_t  major, minor;	/* Version */
74 	uint16_t flags;		/* Bit flags */
75 };
76 
77 /***************************************************************************
78 External prototypes
79 ***************************************************************************/
80 extern void rx_qdrain P((void));
81 extern int tftp P((const char *name, int (*)(unsigned char *, unsigned int, unsigned int, int)));
82 extern int ip_transmit P((int len, const void *buf));
83 extern void build_ip_hdr P((unsigned long destip, int ttl, int protocol,
84 	int option_len, int len, const void *buf));
85 extern void build_udp_hdr P((unsigned long destip,
86 	unsigned int srcsock, unsigned int destsock, int ttl,
87 	int len, const void *buf));
88 extern int udp_transmit P((unsigned long destip, unsigned int srcsock,
89 	unsigned int destsock, int len, const void *buf));
90 typedef int (*reply_t)(int ival, void *ptr, unsigned short ptype, struct iphdr *ip, struct udphdr *udp);
91 extern int await_reply P((reply_t reply,	int ival, void *ptr, long timeout));
92 extern int decode_rfc1533 P((unsigned char *, unsigned int, unsigned int, int));
93 extern void join_group(int slot, unsigned long group);
94 extern void leave_group(int slot);
95 #define RAND_MAX 2147483647L
96 extern uint16_t ipchksum P((const void *ip, unsigned long len));
97 extern uint16_t add_ipchksums P((unsigned long offset, uint16_t sum, uint16_t new));
98 extern int32_t random P((void));
99 extern long rfc2131_sleep_interval P((long base, int exp));
100 extern long rfc1112_sleep_interval P((long base, int exp));
101 #ifndef DOWNLOAD_PROTO_TFTP
102 #define	tftp(fname, load_block) 0
103 #endif
104 extern void cleanup P((void));
105 
106 /* misc.c */
107 extern void twiddle P((void));
108 extern void sleep P((int secs));
109 extern void interruptible_sleep P((int secs));
110 extern void poll_interruptions P((void));
111 extern int strcasecmp P((const char *a, const char *b));
112 extern char *substr P((const char *a, const char *b));
113 extern unsigned long strtoul P((const char *p, const char **, int base));
114 extern void printf P((const char *, ...));
115 extern int sprintf P((char *, const char *, ...));
116 extern int inet_aton P((char *p, in_addr *i));
117 extern void putchar P((int));
118 extern int getchar P((void));
119 extern int iskey P((void));
120 
121 extern void grub_printf(const char *, ...);
122 extern char config_file[128];
123 extern void etherboot_printf(const char *,  ...);
124 extern int etherboot_sprintf(char *, const char *, ...);
125 extern int getdec(char **s);
126 extern void cleanup_net(void);
127 extern void print_network_configuration (void);
128 extern int ifconfig (char *, char *, char *, char *);
129 extern struct arptable_t arptable[MAX_ARP];
130 
131 #undef printf
132 #undef sprintf
133 #define printf etherboot_printf
134 #define sprintf etherboot_sprintf
135 
136 #ifdef DEBUG
137 #define EnterFunction(func) printf("Enter: " func "\n");
138 #define LeaveFunction(func) printf("Leave: " func "\n");
139 #else
140 #define EnterFunction(func)
141 #define LeaveFunction(func)
142 #endif
143 
144 /*
145  * Some codes from etherboot use a level in DEBUG. Define it to be
146  * zero means no debug info output, that will make them silence in
147  * compiling. Up it as you want.
148  */
149 #ifndef DEBUG
150 #  define DEBUG 0
151 #endif
152 
153 /*#define RPC_DEBUG*/
154 
155 extern char *hostname;
156 
157 extern int hostnamelen;
158 /* Whether network is ready */
159 extern int network_ready;
160 
161 /* User aborted in await_reply if not zero */
162 extern int user_abort;
163 
164 extern int rarp(void);
165 extern int grub_eth_probe(void);
166 extern int bootp(void);
167 
168 extern int dhcp(void);
169 
170 extern struct nic nic;
171 #endif /* GRUB_H */
172