Browse Source

Dead code removal.

Kill off use of etherboot.h outside drivers/net.
tags/v0.9.3
Michael Brown 17 years ago
parent
commit
e330db3c74

+ 1
- 1
src/arch/i386/core/i386_timer.c View File

@@ -7,9 +7,9 @@
7 7
  * your option) any later version.
8 8
  */
9 9
 
10
-#include	"etherboot.h"
11 10
 #include	"timer.h"
12 11
 #include	"latch.h"
12
+#include	<io.h>
13 13
 #include	<gpxe/init.h>
14 14
 
15 15
 void __load_timer2(unsigned int ticks)

+ 0
- 1
src/core/btext.c View File

@@ -9,7 +9,6 @@
9 9
  *   move to Etherboot by LYH
10 10
  */
11 11
 
12
-#include "etherboot.h"
13 12
 #include "console.h"
14 13
 #include <gpxe/init.h>
15 14
 #include <gpxe/pci.h>

+ 0
- 4
src/core/config.c View File

@@ -5,10 +5,6 @@
5 5
  * your option) any later version.
6 6
  */
7 7
 
8
-#include "etherboot.h"
9
-#include "dev.h"
10
-#include "console.h"
11
-
12 8
 #include "config/general.h"
13 9
 
14 10
 /*

+ 0
- 176
src/core/dev.c View File

@@ -1,176 +0,0 @@
1
-#include <stdio.h>
2
-#include <etherboot.h>
3
-#include <stddef.h>
4
-#include <dev.h>
5
-
6
-/*
7
- * Each bus driver defines several methods, which are described in
8
- * dev.h.  This file provides a centralised, bus-independent mechanism
9
- * for locating devices and drivers.
10
- *
11
- */
12
-
13
-/* Linker symbols for the various tables */
14
-static struct bus_driver bus_drivers[0]
15
-	__table_start ( struct bus_driver, bus_driver );
16
-static struct bus_driver bus_drivers_end[0]
17
-	__table_end ( struct bus_driver, bus_driver );
18
-static struct device_driver device_drivers[0]
19
-	__table_start ( struct device_driver, device_driver );
20
-static struct device_driver device_drivers_end[0]
21
-	__table_end ( struct device_driver, device_driver );
22
-
23
-/* Current attempted boot device */
24
-struct dev dev = {
25
-	.bus_driver = bus_drivers,
26
-	.device_driver = device_drivers,
27
-};
28
-
29
-/*
30
- * Print all drivers 
31
- *
32
- */
33
-void print_drivers ( void ) {
34
-	struct device_driver *driver;
35
-
36
-	for ( driver = device_drivers ;
37
-	      driver < device_drivers_end ;
38
-	      driver++ ) {
39
-		printf ( "%s ", driver->name );
40
-	}
41
-}
42
-
43
-/*
44
- * Move to the next location on any bus
45
- *
46
- */
47
-static inline int next_location ( struct bus_driver **bus_driver,
48
-				  struct bus_loc *bus_loc ) {
49
-	/* Move to next location on this bus, if any */
50
-	if ( (*bus_driver)->next_location ( bus_loc ) )
51
-		return 1;
52
-
53
-	/* Move to first (zeroed) location on next bus, if any */
54
-	if ( ++(*bus_driver) < bus_drivers_end ) {
55
-		DBG ( "DEV scanning %s bus\n", (*bus_driver)->name );
56
-		return 1;
57
-	}
58
-
59
-	/* Reset to first bus, return "no more locations" */
60
-	*bus_driver = bus_drivers;
61
-	return 0;
62
-}
63
-
64
-/*
65
- * Find the next available device on any bus
66
- *
67
- * Set skip=1 to skip over the current device
68
- *
69
- */
70
-int find_any ( struct bus_driver **bus_driver, struct bus_loc *bus_loc,
71
-	       struct bus_dev *bus_dev, signed int skip ) {
72
-	DBG ( "DEV scanning %s bus\n", (*bus_driver)->name );
73
-	do {
74
-		if ( --skip >= 0 )
75
-			continue;
76
-		if ( ! (*bus_driver)->fill_device ( bus_dev, bus_loc ) )
77
-			continue;
78
-		DBG ( "DEV found device %s\n",
79
-		      (*bus_driver)->describe_device ( bus_dev ) );
80
-		return 1;
81
-	} while ( next_location ( bus_driver, bus_loc ) );
82
-
83
-	DBG ( "DEV found no more devices\n" );
84
-	return 0;
85
-}
86
-
87
-/*
88
- * Find a driver by specified device.
89
- *
90
- * Set skip=1 to skip over the current driver
91
- *
92
- */
93
-int find_by_device ( struct device_driver **device_driver,
94
-		     struct bus_driver *bus_driver, struct bus_dev *bus_dev,
95
-		     signed int skip ) {
96
-	do {
97
-		if ( --skip >= 0 )
98
-			continue;
99
-		if ( (*device_driver)->bus_driver != bus_driver )
100
-			continue;
101
-		if ( ! bus_driver->check_driver ( bus_dev, *device_driver ))
102
-			continue;
103
-		DBG ( "DEV found driver %s for device %s\n",
104
-		      (*device_driver)->name,
105
-		      bus_driver->describe_device ( bus_dev ) );
106
-		return 1;
107
-	} while ( ++(*device_driver) < device_drivers_end );
108
-	
109
-	/* Reset to first driver, return "not found" */
110
-	DBG ( "DEV found no driver for device %s\n",
111
-	      bus_driver->describe_device ( bus_dev ) );
112
-	*device_driver = device_drivers;
113
-	return 0;
114
-}
115
-
116
-/*
117
- * Find a device by specified driver.
118
- *
119
- * Set skip=1 to skip over the current device
120
- *
121
- */
122
-int find_by_driver ( struct bus_loc *bus_loc, struct bus_dev *bus_dev,
123
-		     struct device_driver *device_driver,
124
-		     signed int skip ) {
125
-	struct bus_driver *bus_driver = device_driver->bus_driver;
126
-	
127
-	do {
128
-		if ( --skip >= 0 )
129
-			continue;
130
-		if ( ! bus_driver->fill_device ( bus_dev, bus_loc ) )
131
-			continue;
132
-		if ( ! bus_driver->check_driver ( bus_dev, device_driver ) )
133
-			continue;
134
-		DBG ( "DEV found device %s for driver %s\n",
135
-		      bus_driver->describe_device ( bus_dev ),
136
-		      device_driver->name );
137
-		return 1;
138
-	} while ( bus_driver->next_location ( bus_loc ) );
139
-
140
-	DBG ( "DEV found no device for driver %s\n", device_driver->name );
141
-	return 0;
142
-}
143
-
144
-/*
145
- * Find the next available (device,driver) combination
146
- *
147
- * Set skip=1 to skip over the current (device,driver)
148
- *
149
- * Note that the struct dev may not have been previously used, and so
150
- * may not contain a valid (device,driver) combination.
151
- *
152
- */
153
-int find_any_with_driver ( struct dev *dev, signed int skip ) {
154
-	signed int skip_device = 0;
155
-	signed int skip_driver = skip;
156
-
157
-	while ( find_any ( &dev->bus_driver, &dev->bus_loc, &dev->bus_dev,
158
-			   skip_device ) ) {
159
-		if ( find_by_device ( &dev->device_driver, dev->bus_driver,
160
-				      &dev->bus_dev, skip_driver ) ) {
161
-			/* Set type_driver to be that of the device
162
-			 * driver
163
-			 */
164
-			dev->type_driver = dev->device_driver->type_driver;
165
-			/* Set type device instance to be the single
166
-			 * instance provided by the type driver
167
-			 */
168
-			dev->type_dev = dev->type_driver->type_dev;
169
-			return 1;
170
-		}
171
-		skip_driver = 0;
172
-		skip_device = 1;
173
-	}
174
-
175
-	return 0;
176
-}

+ 0
- 699
src/core/elf_loader.c View File

@@ -1,699 +0,0 @@
1
-#include "elf.h"
2
-
3
-#ifndef ELF_CHECK_ARCH
4
-#error ELF_CHECK_ARCH not defined
5
-#endif
6
-
7
-#define ELF_NOTES 1
8
-#define ELF_DEBUG 0
9
-
10
-struct elf_state
11
-{
12
-	union {
13
-		Elf32_Ehdr elf32;
14
-		Elf64_Ehdr elf64;
15
-	} e;
16
-	union {
17
-		Elf32_Phdr phdr32[1];
18
-		Elf64_Phdr phdr64[1];
19
-		unsigned char dummy[1024];
20
-	} p;
21
-	unsigned long curaddr;
22
-	int segment;		/* current segment number, -1 for none */
23
-	uint64_t loc;		/* start offset of current block */
24
-	uint64_t skip;		/* padding to be skipped to current segment */
25
-	unsigned long toread;	/* remaining data to be read in the segment */
26
-#if ELF_NOTES
27
-	int check_ip_checksum;
28
-	uint16_t ip_checksum;
29
-	unsigned long ip_checksum_offset;
30
-#endif
31
-};
32
-
33
-static struct elf_state estate;
34
-
35
-static unsigned long find_segment(unsigned long size, unsigned long align)
36
-{
37
-	unsigned i;
38
-	/* Verify I have a power of 2 alignment */
39
-	if (align & (align - 1)) {
40
-		return ULONG_MAX;
41
-	}
42
-	for(i = 0; i < meminfo.map_count; i++) {
43
-		unsigned long r_start, r_end;
44
-		if (meminfo.map[i].type != E820_RAM)
45
-			continue;
46
-		if ((meminfo.map[i].addr + meminfo.map[i].size) > ULONG_MAX) {
47
-			continue;
48
-		}
49
-		r_start = meminfo.map[i].addr;
50
-		r_end = r_start + meminfo.map[i].size;
51
-		/* Don't allow the segment to overlap etherboot */
52
-		if ((r_end > virt_to_phys(_text)) && (r_start < virt_to_phys(_text))) {
53
-			r_end = virt_to_phys(_text);
54
-		}
55
-		if ((r_start > virt_to_phys(_text)) && (r_start < virt_to_phys(_end))) {
56
-			r_start = virt_to_phys(_end);
57
-		}
58
-		/* Don't allow the segment to overlap the heap */
59
-		if ((r_end > heap_ptr) && (r_start < heap_ptr)) {
60
-			r_end = heap_ptr;
61
-		}
62
-		if ((r_start > heap_ptr) && (r_start < heap_bot)) {
63
-			r_start = heap_ptr;
64
-		}
65
-		r_start = (r_start + align - 1) & ~(align - 1);
66
-		if ((r_end >= r_start) && ((r_end - r_start) >= size)) {
67
-			return r_start;
68
-		}
69
-	}
70
-	/* I did not find anything :( */
71
-	return ULONG_MAX;
72
-}
73
-
74
-static void elf_boot(unsigned long machine, unsigned long entry)
75
-{
76
-	int result;
77
-	struct Elf_Bhdr *hdr;
78
-	multiboot_boot(entry);
79
-	/* We cleanup unconditionally, and then reawaken the network
80
-	 * adapter after the longjmp.
81
-	 */
82
-	hdr = prepare_boot_params(&estate.e);
83
-	result = elf_start(machine, entry, virt_to_phys(hdr));
84
-	if (result == 0) {
85
-		result = -1;
86
-	}
87
-	printf("Secondary program returned %d\n", result);
88
-	longjmp(restart_etherboot, result);
89
-}
90
-
91
-#if ELF_NOTES
92
-static int elf_prep_segment(
93
-	unsigned long start __unused, unsigned long mid __unused, unsigned long end __unused,
94
-	unsigned long istart, unsigned long iend)
95
-
96
-{
97
-	if (estate.check_ip_checksum) {
98
-		if ((istart <= estate.ip_checksum_offset) && 
99
-			(iend > estate.ip_checksum_offset)) {
100
-			/* The checksum note is also loaded in a
101
-			 * PT_LOAD segment, so the computed checksum
102
-			 * should be 0.
103
-			 */
104
-			estate.ip_checksum = 0;
105
-		}
106
-	}
107
-	return 1;
108
-}
109
-#else
110
-#define elf_prep_segment(start, mid, end, istart, iend) (1)
111
-#endif
112
-
113
-
114
-#if ELF_NOTES
115
-static void process_elf_notes(unsigned char *header,
116
-	unsigned long offset, unsigned long length)
117
-{
118
-	unsigned char *note, *end;
119
-	char *program, *version;
120
-
121
-	estate.check_ip_checksum = 0;
122
-	note = header + offset;
123
-	end = note + length;
124
-	program = version = 0;
125
-	while(note < end) {
126
-		Elf_Nhdr *hdr;
127
-		unsigned char *n_name, *n_desc, *next;
128
-		hdr = (Elf_Nhdr *)note;
129
-		n_name = note + sizeof(*hdr);
130
-		n_desc = n_name + ((hdr->n_namesz + 3) & ~3);
131
-		next = n_desc + ((hdr->n_descsz + 3) & ~3);
132
-		if (next > end) {
133
-			break;
134
-		}
135
-		if ((hdr->n_namesz == sizeof(ELF_NOTE_BOOT)) && 
136
-			(memcmp(n_name, ELF_NOTE_BOOT, sizeof(ELF_NOTE_BOOT)) == 0)) {
137
-			switch(hdr->n_type) {
138
-			case EIN_PROGRAM_NAME:
139
-				if (n_desc[hdr->n_descsz -1] == 0) {
140
-					program = n_desc;
141
-				}
142
-				break;
143
-			case EIN_PROGRAM_VERSION:
144
-				if (n_desc[hdr->n_descsz -1] == 0) {
145
-					version = n_desc;
146
-				}
147
-				break;
148
-			case EIN_PROGRAM_CHECKSUM:
149
-				estate.check_ip_checksum = 1;
150
-				estate.ip_checksum = *((uint16_t *)n_desc);
151
-				/* Remember where the segment is so
152
-				 * I can detect segment overlaps.
153
-				 */
154
-				estate.ip_checksum_offset = n_desc - header;
155
-#if ELF_DEBUG
156
-				printf("Checksum: %hx\n", estate.ip_checksum);
157
-#endif
158
-
159
-				break;
160
-			}
161
-		}
162
-#if ELF_DEBUG
163
-		printf("n_type: %x n_name(%d): %s n_desc(%d): %s\n", 
164
-			hdr->n_type,
165
-			hdr->n_namesz, n_name,
166
-			hdr->n_descsz, n_desc);
167
-#endif
168
-		note = next;
169
-	}
170
-	if (program && version) {
171
-		printf("\nLoading %s version: %s\n", program, version);
172
-	}
173
-}
174
-#endif
175
-
176
-#ifdef	ELF_IMAGE
177
-static sector_t elf32_download(unsigned char *data, unsigned int len, int eof);
178
-static inline os_download_t elf32_probe(unsigned char *data, unsigned int len)
179
-{
180
-	unsigned long phdr_size;
181
-	if (len < sizeof(estate.e.elf32)) {
182
-		return 0;
183
-	}
184
-	memcpy(&estate.e.elf32, data, sizeof(estate.e.elf32));
185
-	if ((estate.e.elf32.e_ident[EI_MAG0] != ELFMAG0) ||
186
-		(estate.e.elf32.e_ident[EI_MAG1] != ELFMAG1) ||
187
-		(estate.e.elf32.e_ident[EI_MAG2] != ELFMAG2) ||
188
-		(estate.e.elf32.e_ident[EI_MAG3] != ELFMAG3) ||
189
-		(estate.e.elf32.e_ident[EI_CLASS] != ELFCLASS32) ||
190
-		(estate.e.elf32.e_ident[EI_DATA] != ELFDATA_CURRENT) ||
191
-		(estate.e.elf32.e_ident[EI_VERSION] != EV_CURRENT) ||
192
-		(	(estate.e.elf32.e_type != ET_EXEC) &&
193
-			(estate.e.elf32.e_type != ET_DYN)) ||
194
-		(estate.e.elf32.e_version != EV_CURRENT) ||
195
-		(estate.e.elf32.e_ehsize != sizeof(Elf32_Ehdr)) ||
196
-		(estate.e.elf32.e_phentsize != sizeof(Elf32_Phdr)) ||
197
-		!ELF_CHECK_ARCH(estate.e.elf32)) {
198
-		return 0;
199
-	}
200
-	printf("(ELF");
201
-	elf_freebsd_probe();
202
-	printf(")... ");
203
-	phdr_size = estate.e.elf32.e_phnum * estate.e.elf32.e_phentsize;
204
-	if (estate.e.elf32.e_phoff + phdr_size > len) {
205
-		printf("ELF header outside first block\n");
206
-		return dead_download;
207
-	}
208
-	if (phdr_size > sizeof(estate.p.dummy)) {
209
-		printf("Program header too big\n");
210
-		return dead_download;
211
-	}
212
-	memcpy(&estate.p.phdr32, data + estate.e.elf32.e_phoff, phdr_size);
213
-	if (estate.e.elf32.e_type == ET_DYN) {
214
-		Elf32_Addr min, max, base_addr, delta, align;
215
-		min = -1;
216
-		max = 0;
217
-		align = 1;
218
-		for(estate.segment = 0; estate.segment < estate.e.elf32.e_phnum; estate.segment++) {
219
-			Elf32_Addr val;
220
-			if (estate.p.phdr32[estate.segment].p_type != PT_LOAD)
221
-				continue;
222
-			val = estate.p.phdr32[estate.segment].p_paddr;
223
-			if (val < min) {
224
-				min = val;
225
-			}
226
-			val += estate.p.phdr32[estate.segment].p_memsz;
227
-			if (val > max) {
228
-				max = val;
229
-			}
230
-			if (estate.p.phdr32[estate.segment].p_align > align) {
231
-				align = estate.p.phdr32[estate.segment].p_align;
232
-			}
233
-		}
234
-		if (align & (align -1)) {
235
-			printf("ELF base address alignment is not a power of 2\n");
236
-			return dead_download;
237
-		}
238
-		base_addr = find_segment(max - min, align);
239
-		if (base_addr == ULONG_MAX) {
240
-			printf("ELF base address not available for size %ld\n", max - min);
241
-			return dead_download;
242
-		}
243
-		/* Compute the change in base address and fix up the addresses */
244
-		delta = base_addr - min;
245
-		for(estate.segment = 0; estate.segment < estate.e.elf32.e_phnum; estate.segment++) {
246
-			/* Change the base address of the object to load */
247
-			estate.p.phdr32[estate.segment].p_paddr += delta;
248
-		}
249
-		estate.e.elf32.e_entry += delta;
250
-	}
251
-#if ELF_NOTES
252
-	/* Load ELF notes from the image */
253
-	estate.check_ip_checksum = 0;
254
-	for(estate.segment = 0; estate.segment < estate.e.elf32.e_phnum; estate.segment++) {
255
-		if (estate.p.phdr32[estate.segment].p_type != PT_NOTE)
256
-			continue;
257
-		if (estate.p.phdr32[estate.segment].p_offset + estate.p.phdr32[estate.segment].p_filesz > len) {
258
-			/* Ignore ELF notes outside of the first block */
259
-			continue;
260
-		}
261
-		process_elf_notes(data, 
262
-			estate.p.phdr32[estate.segment].p_offset, estate.p.phdr32[estate.segment].p_filesz);
263
-	}
264
-#endif
265
-	/* Check for Etherboot related limitations.  Memory
266
-	 * between _text and _end is not allowed.
267
-	 * Reasons: the Etherboot code/data area.
268
-	 */
269
-	for (estate.segment = 0; estate.segment < estate.e.elf32.e_phnum; estate.segment++) {
270
-		unsigned long start, mid, end, istart, iend;
271
-		if (estate.p.phdr32[estate.segment].p_type != PT_LOAD)
272
-			continue;
273
-
274
-		elf_freebsd_fixup_segment();
275
-
276
-		start = estate.p.phdr32[estate.segment].p_paddr;
277
-		mid = start + estate.p.phdr32[estate.segment].p_filesz;
278
-		end = start + estate.p.phdr32[estate.segment].p_memsz;
279
-		istart = estate.p.phdr32[estate.segment].p_offset;
280
-		iend = istart + estate.p.phdr32[estate.segment].p_filesz;
281
-		if (!prep_segment(start, mid, end, istart, iend)) {
282
-			return dead_download;
283
-		}
284
-		if (!elf_prep_segment(start, mid, end, istart, iend)) {
285
-	                return dead_download;
286
-		}
287
-	}
288
-	estate.segment = -1;
289
-	estate.loc = 0;
290
-	estate.skip = 0;
291
-	estate.toread = 0;
292
-	multiboot_init();
293
-	return elf32_download;
294
-}
295
-
296
-static sector_t elf32_download(unsigned char *data, unsigned int len, int eof)
297
-{
298
-	unsigned long skip_sectors = 0;
299
-	unsigned int offset;	/* working offset in the current data block */
300
-	int i;
301
-
302
-	offset = 0;
303
-	do {
304
-		if (estate.segment != -1) {
305
-			if (estate.skip) {
306
-				if (estate.skip >= len - offset) {
307
-					estate.skip -= len - offset;
308
-					break;
309
-				}
310
-				offset += estate.skip;
311
-				estate.skip = 0;
312
-			}
313
-			
314
-			if (estate.toread) {
315
-				unsigned int cplen;
316
-				cplen = len - offset;
317
-				if (cplen >= estate.toread) {
318
-					cplen = estate.toread;
319
-				}
320
-				memcpy(phys_to_virt(estate.curaddr), data+offset, cplen);
321
-				estate.curaddr += cplen;
322
-				estate.toread -= cplen;
323
-				offset += cplen;
324
-				if (estate.toread)
325
-					break;
326
-				elf_freebsd_find_segment_end();
327
-			}
328
-		}
329
-		
330
-		/* Data left, but current segment finished - look for the next
331
-		 * segment (in file offset order) that needs to be loaded. 
332
-		 * We can only seek forward, so select the program headers,
333
-		 * in the correct order.
334
-		 */
335
-		estate.segment = -1;
336
-		for (i = 0; i < estate.e.elf32.e_phnum; i++) {
337
-			if (estate.p.phdr32[i].p_type != PT_LOAD)
338
-				continue;
339
-			if (estate.p.phdr32[i].p_filesz == 0)
340
-				continue;
341
-			if (estate.p.phdr32[i].p_offset < estate.loc + offset)
342
-				continue;	/* can't go backwards */
343
-			if ((estate.segment != -1) &&
344
-				(estate.p.phdr32[i].p_offset >= estate.p.phdr32[estate.segment].p_offset))
345
-				continue;	/* search minimum file offset */
346
-			estate.segment = i;
347
-		}
348
-		if (estate.segment == -1) {
349
-			if (elf_freebsd_debug_loader(offset)) {
350
-				estate.segment = 0; /* -1 makes it not read anymore */
351
-				continue;
352
-			}
353
-			/* No more segments to be loaded, so just start the
354
-			 * kernel.  This saves a lot of network bandwidth if
355
-			 * debug info is in the kernel but not loaded.  */
356
-			goto elf_startkernel;
357
-			break;
358
-		}
359
-		estate.curaddr = estate.p.phdr32[estate.segment].p_paddr;
360
-		estate.skip    = estate.p.phdr32[estate.segment].p_offset - (estate.loc + offset);
361
-		estate.toread  = estate.p.phdr32[estate.segment].p_filesz;
362
-#if ELF_DEBUG
363
-		printf("PHDR %d, size %#lX, curaddr %#lX\n",
364
-			estate.segment, estate.toread, estate.curaddr);
365
-#endif
366
-	} while (offset < len);
367
-
368
-	estate.loc += len + (estate.skip & ~0x1ff);
369
-	skip_sectors = estate.skip >> 9;
370
-	estate.skip &= 0x1ff;
371
-	
372
-	if (eof) {
373
-		unsigned long entry;
374
-		unsigned long machine;
375
-elf_startkernel:
376
-		entry = estate.e.elf32.e_entry;
377
-		machine = estate.e.elf32.e_machine;
378
-
379
-#if ELF_NOTES
380
-		if (estate.check_ip_checksum) {
381
-			unsigned long bytes = 0;
382
-			uint16_t sum, new_sum;
383
-
384
-			sum = ipchksum(&estate.e.elf32, sizeof(estate.e.elf32));
385
-			bytes = sizeof(estate.e.elf32);
386
-#if ELF_DEBUG
387
-			printf("Ehdr: %hx %hx sz: %lx bytes: %lx\n",
388
-				sum, sum, bytes, bytes);
389
-#endif
390
-
391
-			new_sum = ipchksum(estate.p.phdr32, sizeof(estate.p.phdr32[0]) * estate.e.elf32.e_phnum);
392
-			sum = add_ipchksums(bytes, sum, new_sum);
393
-			bytes += sizeof(estate.p.phdr32[0]) * estate.e.elf32.e_phnum;
394
-#if ELF_DEBUG
395
-			printf("Phdr: %hx %hx sz: %lx bytes: %lx\n",
396
-				new_sum, sum,
397
-				sizeof(estate.p.phdr32[0]) * estate.e.elf32.e_phnum, bytes);
398
-#endif
399
-
400
-			for(i = 0; i < estate.e.elf32.e_phnum; i++) {
401
-				if (estate.p.phdr32[i].p_type != PT_LOAD)
402
-					continue;
403
-				new_sum = ipchksum(phys_to_virt(estate.p.phdr32[i].p_paddr),
404
-						estate.p.phdr32[i].p_memsz);
405
-				sum = add_ipchksums(bytes, sum, new_sum);
406
-				bytes += estate.p.phdr32[i].p_memsz;
407
-#if ELF_DEBUG
408
-			printf("seg%d: %hx %hx sz: %x bytes: %lx\n",
409
-				i, new_sum, sum,
410
-				estate.p.phdr32[i].p_memsz, bytes);
411
-#endif
412
-
413
-			}
414
-			if (estate.ip_checksum != sum) {
415
-				printf("\nImage checksum: %hx != computed checksum: %hx\n",
416
-					estate.ip_checksum, sum);
417
-				longjmp(restart_etherboot, -2);
418
-			}
419
-		}
420
-#endif
421
-		done(1);
422
-		/* Fixup the offset to the program header so you can find the program headers from
423
-		 * the ELF header mknbi needs this.
424
-		 */
425
-		estate.e.elf32.e_phoff = (char *)&estate.p - (char *)&estate.e;
426
-		elf_freebsd_boot(entry);
427
-		elf_boot(machine,entry);
428
-	}
429
-	return skip_sectors;
430
-}
431
-#endif /* ELF_IMAGE */
432
-
433
-#ifdef  ELF64_IMAGE
434
-static sector_t elf64_download(unsigned char *data, unsigned int len, int eof);
435
-static inline os_download_t elf64_probe(unsigned char *data, unsigned int len)
436
-{
437
-	unsigned long phdr_size;
438
-	if (len < sizeof(estate.e.elf64)) {
439
-		return 0;
440
-	}
441
-	memcpy(&estate.e.elf64, data, sizeof(estate.e.elf64));
442
-	if ((estate.e.elf64.e_ident[EI_MAG0] != ELFMAG0) ||
443
-		(estate.e.elf64.e_ident[EI_MAG1] != ELFMAG1) ||
444
-		(estate.e.elf64.e_ident[EI_MAG2] != ELFMAG2) ||
445
-		(estate.e.elf64.e_ident[EI_MAG3] != ELFMAG3) ||
446
-		(estate.e.elf64.e_ident[EI_CLASS] != ELFCLASS64) ||
447
-		(estate.e.elf64.e_ident[EI_DATA] != ELFDATA_CURRENT) ||
448
-		(estate.e.elf64.e_ident[EI_VERSION] != EV_CURRENT) ||
449
-		(	(estate.e.elf64.e_type != ET_EXEC) &&
450
-			(estate.e.elf64.e_type != ET_DYN)) ||
451
-		(estate.e.elf64.e_version != EV_CURRENT) ||
452
-		(estate.e.elf64.e_ehsize != sizeof(Elf64_Ehdr)) ||
453
-		(estate.e.elf64.e_phentsize != sizeof(Elf64_Phdr)) ||
454
-		!ELF_CHECK_ARCH(estate.e.elf64)) {
455
-		return 0;
456
-	}
457
-	printf("(ELF64)... ");
458
-	phdr_size = estate.e.elf64.e_phnum * estate.e.elf64.e_phentsize;
459
-	if (estate.e.elf64.e_phoff + phdr_size > len) {
460
-		printf("ELF header outside first block\n");
461
-                return dead_download;
462
-	}
463
-	if (phdr_size > sizeof(estate.p.dummy)) {
464
-		printf("Program header to big\n");
465
-                return dead_download;
466
-	}
467
-	if (estate.e.elf64.e_entry > ULONG_MAX) {
468
-		printf("ELF entry point exceeds address space\n");
469
-                return dead_download;
470
-	}
471
-	memcpy(&estate.p.phdr64, data + estate.e.elf64.e_phoff, phdr_size);
472
-	if (estate.e.elf64.e_type == ET_DYN) {
473
-		Elf64_Addr min, max, base_addr, delta, align;
474
-		min = -1;
475
-		max = 0;
476
-		align = 1;
477
-		for(estate.segment = 0; estate.segment < estate.e.elf64.e_phnum; estate.segment++) {
478
-			Elf64_Addr val;
479
-			if (estate.p.phdr64[estate.segment].p_type != PT_LOAD)
480
-				continue;
481
-			val = estate.p.phdr64[estate.segment].p_paddr;
482
-			if (val < min) {
483
-				min = val;
484
-			}
485
-			val += estate.p.phdr64[estate.segment].p_memsz;
486
-			if (val > max) {
487
-				max = val;
488
-			}
489
-			if (estate.p.phdr64[estate.segment].p_align > align) {
490
-				align = estate.p.phdr64[estate.segment].p_align;
491
-			}
492
-		}
493
-		if (align > ULONG_MAX) {
494
-			printf("ELF base address alignment exceeds address space\n");
495
-			return dead_download;
496
-		}
497
-		if (align & (align -1)) {
498
-			printf("ELF base address alignment is not a power of 2\n");
499
-			return dead_download;
500
-		}
501
-		if ((max - min) > ULONG_MAX) {
502
-			printf("ELF size exceeds address space\n");
503
-			return dead_download;
504
-		}
505
-		base_addr = find_segment(max - min, align);
506
-		if (base_addr == ULONG_MAX) {
507
-			printf("ELF base address not available for size %ld\n", max - min);
508
-			return dead_download;
509
-		}
510
-		/* Compute the change in base address and fix up the addresses */
511
-		delta = base_addr - min;
512
-		for(estate.segment = 0; estate.segment < estate.e.elf64.e_phnum; estate.segment++) {
513
-			/* Change the base address of the object to load */
514
-			estate.p.phdr64[estate.segment].p_paddr += delta;
515
-		}
516
-		estate.e.elf64.e_entry += delta;
517
-	}
518
-#if ELF_NOTES
519
-	/* Load ELF notes from the image */
520
-	estate.check_ip_checksum = 0;
521
-	for(estate.segment = 0; estate.segment < estate.e.elf64.e_phnum; estate.segment++) {
522
-		if (estate.p.phdr64[estate.segment].p_type != PT_NOTE)
523
-			continue;
524
-		if (estate.p.phdr64[estate.segment].p_offset + estate.p.phdr64[estate.segment].p_filesz > len) {
525
-			/* Ignore ELF notes outside of the first block */
526
-			continue;
527
-		}
528
-		process_elf_notes(data, 
529
-			estate.p.phdr64[estate.segment].p_offset, estate.p.phdr64[estate.segment].p_filesz);
530
-	}
531
-#endif
532
-	/* Check for Etherboot related limitations.  Memory
533
-	 * between _text and _end is not allowed.  
534
-	 * Reasons: the Etherboot code/data area.
535
-	 */
536
-	for (estate.segment = 0; estate.segment < estate.e.elf64.e_phnum; estate.segment++) {
537
-		unsigned long start, mid, end, istart, iend;
538
-		if (estate.p.phdr64[estate.segment].p_type != PT_LOAD) 
539
-			continue;
540
-		if ((estate.p.phdr64[estate.segment].p_paddr > ULONG_MAX) ||
541
-			((estate.p.phdr64[estate.segment].p_paddr + estate.p.phdr64[estate.segment].p_filesz) > ULONG_MAX) ||
542
-			((estate.p.phdr64[estate.segment].p_paddr + estate.p.phdr64[estate.segment].p_memsz) > ULONG_MAX)) {
543
-			printf("ELF segment exceeds address space\n");
544
-                	return dead_download;
545
-		}
546
-		start = estate.p.phdr64[estate.segment].p_paddr;
547
-		mid = start + estate.p.phdr64[estate.segment].p_filesz;
548
-		end = start + estate.p.phdr64[estate.segment].p_memsz;
549
-		istart = iend = ULONG_MAX;
550
-		if ((estate.p.phdr64[estate.segment].p_offset < ULONG_MAX) &&
551
-			((estate.p.phdr64[estate.segment].p_offset + estate.p.phdr64[estate.segment].p_filesz) < ULONG_MAX))
552
-		{
553
-			istart = estate.p.phdr64[estate.segment].p_offset;
554
-			iend   = istart + estate.p.phdr64[estate.segment].p_filesz;
555
-		} 
556
-		if (!prep_segment(start, mid, end, istart, iend)) {
557
-                	return dead_download;
558
-		}
559
-		if (!elf_prep_segment(start, mid, end, istart, iend)) {
560
-                	return dead_download;
561
-		}
562
-	}
563
-	estate.segment = -1;
564
-	estate.loc = 0;
565
-	estate.skip = 0;
566
-	estate.toread = 0;
567
-	return elf64_download;
568
-}
569
-
570
-static sector_t elf64_download(unsigned char *data, unsigned int len, int eof)
571
-{
572
-	unsigned long skip_sectors = 0;
573
-	unsigned int offset;	/* working offset in the current data block */
574
-	int i;
575
-
576
-	offset = 0;
577
-	do {
578
-		if (estate.segment != -1) {
579
-			if (estate.skip) {
580
-				if (estate.skip >= len - offset) {
581
-					estate.skip -= len - offset;
582
-					break;
583
-				}
584
-				offset += estate.skip;
585
-				estate.skip = 0;
586
-			}
587
-			
588
-			if (estate.toread) {
589
-				unsigned int cplen;
590
-				cplen = len - offset;
591
-				if (cplen >= estate.toread) {
592
-					cplen = estate.toread;
593
-				}
594
-				memcpy(phys_to_virt(estate.curaddr), data+offset, cplen);
595
-				estate.curaddr += cplen;
596
-				estate.toread -= cplen;
597
-				offset += cplen;
598
-				if (estate.toread)
599
-					break;
600
-			}
601
-		}
602
-		
603
-		/* Data left, but current segment finished - look for the next
604
-		 * segment (in file offset order) that needs to be loaded. 
605
-		 * We can only seek forward, so select the program headers,
606
-		 * in the correct order.
607
-		 */
608
-		estate.segment = -1;
609
-		for (i = 0; i < estate.e.elf64.e_phnum; i++) {
610
-			if (estate.p.phdr64[i].p_type != PT_LOAD)
611
-				continue;
612
-			if (estate.p.phdr64[i].p_filesz == 0)
613
-				continue;
614
-			if (estate.p.phdr64[i].p_offset < estate.loc + offset)
615
-				continue;	/* can't go backwards */
616
-			if ((estate.segment != -1) &&
617
-				(estate.p.phdr64[i].p_offset >= estate.p.phdr64[estate.segment].p_offset))
618
-				continue;	/* search minimum file offset */
619
-			estate.segment = i;
620
-		}
621
-		if (estate.segment == -1) {
622
-			/* No more segments to be loaded, so just start the
623
-			 * kernel.  This saves a lot of network bandwidth if
624
-			 * debug info is in the kernel but not loaded.  */
625
-			goto elf_startkernel;
626
-			break;
627
-		}
628
-		estate.curaddr = estate.p.phdr64[estate.segment].p_paddr;
629
-		estate.skip    = estate.p.phdr64[estate.segment].p_offset - (estate.loc + offset);
630
-		estate.toread  = estate.p.phdr64[estate.segment].p_filesz;
631
-#if ELF_DEBUG
632
-		printf("PHDR %d, size %#lX, curaddr %#lX\n",
633
-			estate.segment, estate.toread, estate.curaddr);
634
-#endif
635
-	} while (offset < len);
636
-	
637
-	estate.loc += len + (estate.skip & ~0x1ff);
638
-	skip_sectors = estate.skip >> 9;
639
-	estate.skip &= 0x1ff;
640
-	
641
-	if (eof) {
642
-		unsigned long entry;
643
-		unsigned long machine;
644
-elf_startkernel:
645
-		entry = estate.e.elf64.e_entry;
646
-		machine = estate.e.elf64.e_machine;
647
-#if ELF_NOTES
648
-		if (estate.check_ip_checksum) {
649
-			unsigned long bytes = 0;
650
-			uint16_t sum, new_sum;
651
-
652
-			sum = ipchksum(&estate.e.elf64, sizeof(estate.e.elf64));
653
-			bytes = sizeof(estate.e.elf64);
654
-#if ELF_DEBUG
655
-			printf("Ehdr: %hx %hx sz: %lx bytes: %lx\n",
656
-				sum, sum, bytes, bytes);
657
-#endif
658
-
659
-			new_sum = ipchksum(estate.p.phdr64, sizeof(estate.p.phdr64[0]) * estate.e.elf64.e_phnum);
660
-			sum = add_ipchksums(bytes, sum, new_sum);
661
-			bytes += sizeof(estate.p.phdr64[0]) * estate.e.elf64.e_phnum;
662
-#if ELF_DEBUG
663
-			printf("Phdr: %hx %hx sz: %lx bytes: %lx\n",
664
-				new_sum, sum,
665
-				sizeof(estate.p.phdr64[0]) * estate.e.elf64.e_phnum, bytes);
666
-#endif
667
-
668
-			for(i = 0; i < estate.e.elf64.e_phnum; i++) {
669
-				if (estate.p.phdr64[i].p_type != PT_LOAD)
670
-					continue;
671
-				new_sum = ipchksum(phys_to_virt(estate.p.phdr64[i].p_paddr),
672
-						estate.p.phdr64[i].p_memsz);
673
-				sum = add_ipchksums(bytes, sum, new_sum);
674
-				bytes += estate.p.phdr64[i].p_memsz;
675
-#if ELF_DEBUG
676
-			printf("seg%d: %hx %hx sz: %x bytes: %lx\n",
677
-				i, new_sum, sum,
678
-				estate.p.phdr64[i].p_memsz, bytes);
679
-#endif
680
-
681
-			}
682
-			if (estate.ip_checksum != sum) {
683
-				printf("\nImage checksum: %hx != computed checksum: %hx\n",
684
-					estate.ip_checksum, sum);
685
-				longjmp(restart_etherboot, -2);
686
-			}
687
-		}
688
-#endif
689
-		done(1);
690
-		/* Fixup the offset to the program header so you can find the program headers from
691
-		 * the ELF header mknbi needs this.
692
-		 */
693
-		estate.e.elf64.e_phoff = (char *)&estate.p - (char *)&estate.e;
694
-		elf_boot(machine,entry);
695
-	}
696
-	return skip_sectors;
697
-}
698
-
699
-#endif /* ELF64_IMAGE */

+ 3
- 70
src/core/misc.c View File

@@ -2,59 +2,10 @@
2 2
 MISC Support Routines
3 3
 **************************************************************************/
4 4
 
5
-#include <etherboot.h>
6
-#include <console.h>
7 5
 #include <stdlib.h>
8
-#include <stdio.h>
9
-
10
-/**************************************************************************
11
-IPCHKSUM - Checksum IP Header
12
-**************************************************************************/
13
-uint16_t ipchksum(const void *data, unsigned long length)
14
-{
15
-	unsigned long sum;
16
-	unsigned long i;
17
-	const uint8_t *ptr;
18
-
19
-	/* In the most straight forward way possible,
20
-	 * compute an ip style checksum.
21
-	 */
22
-	sum = 0;
23
-	ptr = data;
24
-	for(i = 0; i < length; i++) {
25
-		unsigned long value;
26
-		value = ptr[i];
27
-		if (i & 1) {
28
-			value <<= 8;
29
-		}
30
-		/* Add the new value */
31
-		sum += value;
32
-		/* Wrap around the carry */
33
-		if (sum > 0xFFFF) {
34
-			sum = (sum + (sum >> 16)) & 0xFFFF;
35
-		}
36
-	}
37
-	return (~cpu_to_le16(sum)) & 0xFFFF;
38
-}
39
-
40
-uint16_t add_ipchksums(unsigned long offset, uint16_t sum, uint16_t new)
41
-{
42
-	unsigned long checksum;
43
-	sum = ~sum & 0xFFFF;
44
-	new = ~new & 0xFFFF;
45
-	if (offset & 1) {
46
-		/* byte swap the sum if it came from an odd offset 
47
-		 * since the computation is endian independant this
48
-		 * works.
49
-		 */
50
-		new = bswap_16(new);
51
-	}
52
-	checksum = sum + new;
53
-	if (checksum > 0xFFFF) {
54
-		checksum -= 0xFFFF;
55
-	}
56
-	return (~checksum) & 0xFFFF;
57
-}
6
+#include <byteswap.h>
7
+#include <latch.h>
8
+#include <gpxe/in.h>
58 9
 
59 10
 /**************************************************************************
60 11
 SLEEP
@@ -68,24 +19,6 @@ unsigned int sleep(unsigned int secs)
68 19
 	return 0;
69 20
 }
70 21
 
71
-/**************************************************************************
72
-INTERRUPTIBLE SLEEP
73
-**************************************************************************/
74
-void interruptible_sleep(int secs)
75
-{
76
-	printf("<sleep>\n");
77
-	sleep(secs);
78
-}
79
-
80
-/**************************************************************************
81
-STRCASECMP (not entirely correct, but this will do for our purposes)
82
-**************************************************************************/
83
-int strcasecmp(const char *a, const char *b)
84
-{
85
-	while (*a && *b && (*a & ~0x20) == (*b & ~0x20)) {a++; b++; }
86
-	return((*a & ~0x20) - (*b & ~0x20));
87
-}
88
-
89 22
 /**************************************************************************
90 23
 INET_ATON - Convert an ascii x.x.x.x to binary form
91 24
 **************************************************************************/

+ 0
- 25
src/core/proto.c View File

@@ -1,25 +0,0 @@
1
-#include "stddef.h"
2
-#include "string.h"
3
-#include "proto.h"
4
-
5
-static struct protocol protocols[0] __protocol_start;
6
-static struct protocol default_protocols[0] __default_protocol_start;
7
-static struct protocol protocols_end[0] __protocol_end;
8
-
9
-/*
10
- * Identify protocol given a name.  name may be NULL, in which case
11
- * the first default protocol (if any) will be used.
12
- *
13
- */
14
-struct protocol * identify_protocol ( const char *name ) {
15
-	struct protocol *proto = default_protocols;
16
-
17
-	if ( name ) {
18
-		for ( proto = protocols ; proto < protocols_end ; proto++ ) {
19
-			if ( strcmp ( name, proto->name ) == 0 )
20
-				break;
21
-		}
22
-	}
23
-
24
-	return proto < protocols_end ? proto : NULL;
25
-}

+ 0
- 1
src/core/proto_eth_slow.c View File

@@ -1,7 +1,6 @@
1 1
 /* Copyright 2004 Linux Networx */
2 2
 #ifdef PROTO_LACP
3 3
 #if 0
4
-#include "etherboot.h"
5 4
 #include "nic.h"
6 5
 #include "timer.h"
7 6
 #endif

+ 1
- 1
src/core/random.c View File

@@ -5,7 +5,7 @@
5 5
  */
6 6
 
7 7
 #include <stdlib.h>
8
-#include <etherboot.h>
8
+#include <latch.h>
9 9
 
10 10
 static int32_t rnd_seed = 0;
11 11
 

+ 8
- 0
src/core/string.c View File

@@ -189,6 +189,14 @@ int strncmp(const char * cs,const char * ct,size_t count)
189 189
 }
190 190
 #endif
191 191
 
192
+#ifndef __HAVE_ARCH_STRCASECMP
193
+int strcasecmp(const char *a, const char *b)
194
+{
195
+	while (*a && *b && (*a & ~0x20) == (*b & ~0x20)) {a++; b++; }
196
+	return((*a & ~0x20) - (*b & ~0x20));
197
+}
198
+#endif
199
+
192 200
 #ifndef __HAVE_ARCH_STRCHR
193 201
 /**
194 202
  * strchr - Find the first occurrence of a character in a string

+ 0
- 1
src/core/timer.c View File

@@ -7,7 +7,6 @@
7 7
  * your option) any later version.
8 8
  */
9 9
 
10
-#include	"etherboot.h"
11 10
 #include	"timer.h"
12 11
 
13 12
 /* Machine Independant timer helper functions */

+ 6
- 5
src/drivers/net/sis900.c View File

@@ -44,7 +44,6 @@
44 44
 /* Includes */
45 45
 
46 46
 #include "etherboot.h"
47
-#include "dev.h"
48 47
 #include <gpxe/pci.h>
49 48
 #include "nic.h"
50 49
 #include "timer.h"
@@ -250,22 +249,19 @@ static int sis96x_get_mac_addr(struct pci_device * pci_dev __unused, struct nic
250 249
 
251 250
 static int sis630e_get_mac_addr(struct pci_device * pci_dev __unused, struct nic *nic)
252 251
 {
252
+#if 0
253 253
 	u8 reg;
254 254
 	int i;
255
-#if 0
256 255
 	struct bus_loc bus_loc;
257
-#endif
258 256
 	union {
259 257
 	    struct bus_dev bus_dev;
260 258
 	    struct pci_device isa_bridge;
261 259
 	} u;
262 260
 
263
-#if 0
264 261
 	/* find PCI to ISA bridge */
265 262
 	memset(&bus_loc, 0, sizeof(bus_loc));
266 263
 	if ( ! find_by_driver ( &bus_loc, &u.bus_dev, &sis_bridge_driver, 0 ) )
267 264
 	    return 0;
268
-#endif
269 265
 
270 266
 	pci_read_config_byte(&u.isa_bridge, 0x48, &reg);
271 267
 	pci_write_config_byte(&u.isa_bridge, 0x48, reg | 0x40);
@@ -278,6 +274,11 @@ static int sis630e_get_mac_addr(struct pci_device * pci_dev __unused, struct nic
278 274
 	pci_write_config_byte(&u.isa_bridge, 0x48, reg & ~0x40);
279 275
 
280 276
 	return 1;
277
+#endif
278
+
279
+	/* Does not work with current bus/device model */
280
+	memset ( nic->node_addr, 0, sizeof ( nic->node_addr ) );
281
+	return 0;
281 282
 }
282 283
 
283 284
 /**

+ 0
- 280
src/include/dev.h View File

@@ -1,280 +0,0 @@
1
-#ifndef DEV_H
2
-#define DEV_H
3
-
4
-#include "stdint.h"
5
-#include "string.h"
6
-#include <gpxe/buffer.h>
7
-#include "dhcp.h" /* for dhcp_dev_id */
8
-#include <gpxe/tables.h>
9
-#include <assert.h>
10
-
11
-/*
12
- * Forward declarations
13
- *
14
- */
15
-struct type_dev;
16
-struct type_driver;
17
-struct bus_driver;
18
-struct bus_dev;
19
-struct device_driver;
20
-
21
-/*
22
- * When looking at the following data structures, mentally substitute
23
- * "<bus>_" in place of "bus_" and everything will become clear.
24
- * "struct bus_location" becomes "struct <bus>_location", which means
25
- * "the location of a device on a <bus> bus", where <bus> is a
26
- * particular type of bus such as "pci" or "isapnp".
27
- *
28
- */
29
-
30
-/*
31
- * A physical device location on a bus.
32
- *
33
- */
34
-#define BUS_LOC_SIZE 8
35
-struct bus_loc {
36
-	char bytes[BUS_LOC_SIZE];
37
-};
38
-
39
-/* 
40
- * A structure fully describing a physical device on a bus.
41
- *
42
- */
43
-#define BUS_DEV_SIZE 32
44
-struct bus_dev {
45
-	char bytes[BUS_DEV_SIZE];
46
-};
47
-
48
-/*
49
- * Individual buses will have different sizes for their <bus>_location
50
- * and <bus>_device structures.  We need to be able to allocate static
51
- * storage that's large enough to contain these structures for any
52
- * bus type that's being used in the current binary.
53
- *
54
- * We can't just create a union of all the various types, because some
55
- * may be architecture-dependent (and some are even embedded in
56
- * specific drivers, e.g. 3c509), so this would quickly get messy.
57
- *
58
- * We could use the magic of common symbols.  Each bus could declare a
59
- * common symbol with the name "_bus_dev" of the correct size; this
60
- * is easily done using code like
61
- *	struct pci_device _bus_dev;
62
- * The linker would then use the largest size of the "_bus_dev" symbol
63
- * in any included object, thus giving us a single _bus_dev symbol of
64
- * *exactly* the required size.  However, there's no way to extract
65
- * the size of this symbol, either directly as a linker symbol
66
- * ("_bus_dev_size = SIZEOF(_bus_dev)"; the linker language just
67
- * doesn't provide this construct) or via any linker trickery I can
68
- * think of (such as creating a special common symbol section just for
69
- * this symbol then using SIZE(section) to read the size of the
70
- * section; ld recognises only a single common symbol section called
71
- * "COMMON").
72
- *
73
- * Since there's no way to get the size of the symbol, this
74
- * effectively limits us to just one instance of the symbol.  This is
75
- * all very well for the simple case of "just boot from any single
76
- * device you can", but becomes limiting when you want to do things
77
- * like introducing PCMCIA buses (which must instantiate other devices
78
- * such as PCMCIA controllers).
79
- *
80
- * So, we declare the maximum sizes of these constructions to be
81
- * compile-time constants.  Each individual bus driver should define
82
- * its own struct <bus>_location and struct <bus>_device however it
83
- * likes, and can freely cast pointers from struct bus_loc to
84
- * struct <bus>_location (and similarly for bus_dev).  To guard
85
- * against bounding errors, each bus driver *MUST* use the macros
86
- * BUS_LOC_CHECK() and BUS_DEV_CHECK(), as in:
87
- *
88
- *   BUS_LOC_CHECK ( struct pci_location );
89
- *   BUS_DEV_CHECK ( struct pci_device );
90
- *
91
- * These macros will generate a link-time error if the size of the
92
- * <bus> structure exceeds the declared maximum size.
93
- *
94
- * The macros will generate no binary object code, but must be placed
95
- * inside a function (in order to generate syntactically valid C).
96
- * The easiest wy to do this is to place them in the
97
- * <bus>_next_location() function.
98
- *
99
- * If anyone can think of a better way of doing this that avoids *ALL*
100
- * of the problems described above, please implement it!
101
- *
102
- */
103
-
104
-#define BUS_LOC_CHECK(datatype)					      \
105
-	linker_assert( ( sizeof (datatype) <= sizeof (struct bus_loc) ),  \
106
-		       __BUS_LOC_SIZE_is_too_small__see_dev_h )
107
-#define BUS_DEV_CHECK(datatype)					      \
108
-	linker_assert( ( sizeof (datatype) <= sizeof (struct bus_dev) ),    \
109
-		       __BUS_DEV_SIZE_is_too_small__see_dev_h )
110
-
111
-/*
112
- * Bus-level operations.
113
- *
114
- * int next_location ( struct bus_loc * bus_loc )
115
- *
116
- *	Increment bus_loc to point to the next possible device on
117
- *	the bus (e.g. the next PCI busdevfn, or the next ISAPnP CSN).
118
- *	If there are no more valid locations, return 0 and leave
119
- *	struct bus_loc zeroed, otherwise return true.
120
- *
121
- * int fill_device ( struct bus_dev *bus_dev,
122
- *		     struct bus_loc *bus_loc )
123
- *
124
- *	Fill out a bus_dev structure with the parameters for the
125
- *	device at bus_loc.  (For example, fill in the PCI vendor
126
- *	and device IDs).  Return true if there is a device physically
127
- *	present at this location, otherwise 0.
128
- *
129
- * int check_driver ( struct bus_dev *bus_dev,
130
- *		      struct device_driver *device_driver )
131
- *
132
- *	Test whether or not the specified driver is capable of driving
133
- *	the specified device by, for example, comparing the device's
134
- *	PCI IDs against the list of PCI IDs claimed by the driver.
135
- *
136
- * char * describe ( struct bus_dev *bus_dev )
137
- *
138
- *	Return a text string describing the bus device bus_dev
139
- *	(e.g. "PCI 00:01.2")
140
- *
141
- * char * name ( struct bus_dev *bus_dev )
142
- *
143
- *	Return a text string describing the bus device bus_dev
144
- *	(e.g. "dfe538")
145
- *
146
- */
147
-struct bus_driver {
148
-	const char *name;
149
-	int ( *next_location ) ( struct bus_loc *bus_loc );
150
-	int ( *fill_device ) ( struct bus_dev *bus_dev,
151
-			       struct bus_loc *bus_loc );
152
-	int ( *check_driver ) ( struct bus_dev *bus_dev,
153
-				struct device_driver *device_driver );
154
-	char * ( *describe_device ) ( struct bus_dev *bus_dev );
155
-	const char * ( *name_device ) ( struct bus_dev *bus_dev );
156
-};
157
-
158
-#define __bus_driver __table ( struct bus_driver, bus_driver, 01 )
159
-
160
-/*
161
- * A structure fully describing the bus-independent parts of a
162
- * particular type (e.g. nic or disk) of device.
163
- *
164
- * Unlike struct bus_dev, e can limit ourselves to having no more than
165
- * one instance of this data structure.  We therefore place an
166
- * instance in each type driver file (e.g. nic.c), and simply use a
167
- * pointer to the struct type_dev in the struct dev.
168
- *
169
- */
170
-struct type_dev;
171
-
172
-/*
173
- * A type driver (e.g. nic, disk)
174
- *
175
- */
176
-struct type_driver {
177
-	char *name;
178
-	struct type_dev *type_dev; /* single instance */
179
-	char * ( * describe_device ) ( struct type_dev *type_dev );
180
-	int ( * configure ) ( struct type_dev *type_dev );
181
-	int ( * load ) ( struct type_dev *type_dev, struct buffer *buffer );
182
-};
183
-
184
-#define __type_driver __table ( struct type_driver, type_driver, 01 )
185
-
186
-/*
187
- * A driver for a device.
188
- *
189
- */
190
-struct device_driver {
191
-	const char *name;
192
-	struct type_driver *type_driver;
193
-	struct bus_driver *bus_driver;
194
-	struct bus_driver_info *bus_driver_info;
195
-	int ( * probe ) ( struct type_dev *type_dev,
196
-			  struct bus_dev *bus_dev );
197
-	void ( * disable ) ( struct type_dev *type_dev,
198
-			     struct bus_dev *bus_dev );
199
-};
200
-
201
-#define __device_driver __table ( struct device_driver, device_driver, 01 )
202
-
203
-#if 0
204
-#define DRIVER(_name,_type_driver,_bus_driver,_bus_info,	 	      \
205
-	       _probe,_disable) 		 			      \
206
-	struct device_driver device_ ## _bus_info __device_driver = {  \
207
-		.name = _name,						      \
208
-		.type_driver = &_type_driver,				      \
209
-		.bus_driver = &_bus_driver,				      \
210
-		.bus_driver_info = ( struct bus_driver_info * ) &_bus_info,   \
211
-		.probe = ( int (*) () ) _probe,				      \
212
-		.disable = ( void (*) () ) _disable,			      \
213
-	};
214
-#endif
215
-
216
-#define DRIVER(a,b,c,d,e,f)
217
-
218
-/*
219
- * A bootable device, comprising a physical device on a bus, a driver
220
- * for that device, and a type device
221
- *
222
- */
223
-struct dev {
224
-	struct bus_driver	*bus_driver;
225
-	struct bus_loc		bus_loc;
226
-	struct bus_dev		bus_dev;
227
-	struct device_driver	*device_driver;
228
-	struct type_driver	*type_driver;
229
-	struct type_dev		*type_dev;
230
-};
231
-
232
-/* The current boot device */
233
-extern struct dev dev;
234
-
235
-/*
236
- * Functions in dev.c 
237
- *
238
- */
239
-extern void print_drivers ( void );
240
-extern int find_any ( struct bus_driver **bus_driver, struct bus_loc *bus_loc,
241
-		      struct bus_dev *bus_dev, signed int skip );
242
-extern int find_by_device ( struct device_driver **device_driver,
243
-			    struct bus_driver *bus_driver,
244
-			    struct bus_dev *bus_dev,
245
-			    signed int skip );
246
-extern int find_by_driver ( struct bus_loc *bus_loc, struct bus_dev *bus_dev,
247
-			    struct device_driver *device_driver,
248
-			    signed int skip );
249
-extern int find_any_with_driver ( struct dev *dev, signed int skip );
250
-
251
-/*
252
- * Functions inlined to save space
253
- *
254
- */
255
-
256
-/* Probe a device */
257
-static inline int probe ( struct dev *dev ) {
258
-	return dev->device_driver->probe ( dev->type_dev, &dev->bus_dev );
259
-}
260
-/* Disable a device */
261
-static inline void disable ( struct dev *dev ) {
262
-	dev->device_driver->disable ( dev->type_dev, &dev->bus_dev );
263
-}
264
-/* Set the default boot device */
265
-static inline void select_device ( struct dev *dev,
266
-				   struct bus_driver *bus_driver,
267
-				   struct bus_loc *bus_loc ) {
268
-	dev->bus_driver = bus_driver;
269
-	memcpy ( &dev->bus_loc, bus_loc, sizeof ( dev->bus_loc ) );
270
-}
271
-/* Configure a device */
272
-static inline int configure ( struct dev *dev ) {
273
-	return dev->type_driver->configure ( dev->type_dev );
274
-}
275
-/* Boot from a device */
276
-static inline int load ( struct dev *dev, struct buffer *buffer ) {
277
-	return dev->type_driver->load ( dev->type_dev, buffer );
278
-}
279
-
280
-#endif /* DEV_H */

+ 0
- 11
src/include/main.h View File

@@ -1,11 +0,0 @@
1
-#ifndef MAIN_H
2
-#define MAIN_H
3
-
4
-#include "dev.h"
5
-
6
-extern struct dev dev;
7
-
8
-extern int main ( void );
9
-extern void set_pci_device ( uint16_t busdevfn );
10
-
11
-#endif /* MAIN_H */

+ 0
- 2
src/include/pcmcia.h View File

@@ -3,8 +3,6 @@
3 3
 #ifndef PCMCIA_H
4 4
 #define	PCMCIA_H
5 5
 
6
-#include "etherboot.h"
7
-
8 6
 typedef unsigned char	u_char;
9 7
 typedef unsigned short	u_short;
10 8
 typedef unsigned int	u_int;

+ 0
- 33
src/include/proto.h View File

@@ -1,33 +0,0 @@
1
-#ifndef PROTO_H
2
-#define PROTO_H
3
-
4
-#include <gpxe/tables.h>
5
-#include <gpxe/buffer.h>
6
-#include <gpxe/in.h>
7
-
8
-struct protocol {
9
-	char *name;
10
-	uint16_t default_port;
11
-	int ( * load ) ( char *url, struct sockaddr_in *server, char *file,
12
-			 struct buffer *buffer );
13
-};
14
-
15
-/*
16
- * Protocols that should be used if no explicit protocol is specified
17
- * (i.e. tftp) should use __default_protocol; all other protocols
18
- * should use __protocol.
19
- *
20
- */
21
-#define __protocol_start	 __table_start ( struct protocol, protocol )
22
-#define __protocol		 __table ( struct protocol, protocol, 01 )
23
-#define __default_protocol_start __table ( struct protocol, protocol, 02 )
24
-#define __default_protocol	 __table ( struct protocol, protocol, 03 )
25
-#define __protocol_end		 __table_end ( struct protocol, protocol )
26
-
27
-/*
28
- * Functions in proto.c
29
- *
30
- */
31
-extern struct protocol * identify_protocol ( const char *name );
32
-
33
-#endif /* PROTO_H */

+ 0
- 2
src/proto/fsp.c View File

@@ -33,8 +33,6 @@
33 33
     \*********************************************************************/
34 34
 
35 35
 #ifdef DOWNLOAD_PROTO_FSP
36
-#include "etherboot.h"
37
-#include "nic.h"
38 36
 
39 37
 #define FSP_PORT 21
40 38
 

+ 4
- 3
src/proto/igmp.c View File

@@ -5,9 +5,8 @@
5 5
 
6 6
 #include <ip.h>
7 7
 #include <igmp.h>
8
-#include <background.h>
9
-#include <nic.h>
10
-#include <etherboot.h>
8
+
9
+#if 0
11 10
 
12 11
 static unsigned long last_igmpv1 = 0;
13 12
 static struct igmptable_t igmptable[MAX_IGMP];
@@ -164,3 +163,5 @@ void join_group ( int slot, unsigned long group ) {
164 163
 		igmptable[slot].time = currticks();
165 164
 	}
166 165
 }
166
+
167
+#endif

+ 4
- 3
src/proto/nfs.c View File

@@ -1,8 +1,7 @@
1
-#include "etherboot.h"
1
+#if 0
2
+
2 3
 #include <gpxe/init.h>
3
-#include "proto.h"
4 4
 #include <gpxe/in.h>
5
-#include "nic.h"
6 5
 
7 6
 /* NOTE: the NFS code is heavily inspired by the NetBSD netboot code (read:
8 7
  * large portions are copied verbatim) as distributed in OSKit 0.97.  A few
@@ -613,3 +612,5 @@ struct protocol nfs_protocol __protocol = {
613 612
 	.default_port = SUNRPC_PORT,
614 613
 	.load = nfs,
615 614
 };
615
+
616
+#endif

+ 3
- 3
src/proto/slam.c View File

@@ -1,6 +1,4 @@
1
-#include "etherboot.h"
2
-#include "proto.h"
3
-#include "nic.h"
1
+#if 0
4 2
 
5 3
 /*
6 4
  * IMPORTANT
@@ -539,3 +537,5 @@ struct protocol slam_protocol __protocol = {
539 537
 	.default_port = SLAM_PORT,
540 538
 	.load = url_slam,
541 539
 };
540
+
541
+#endif

Loading…
Cancel
Save