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