Browse Source

Added back in the actual call to load().

tags/v0.9.3
Michael Brown 19 years ago
parent
commit
fda36a0c1a
4 changed files with 59 additions and 22 deletions
  1. 24
    10
      src/core/main.c
  2. 18
    11
      src/core/nic.c
  3. 16
    0
      src/include/dev.h
  4. 1
    1
      src/include/etherboot.h

+ 24
- 10
src/core/main.c View File

187
 		/* Skip this device the next time we encounter it */
187
 		/* Skip this device the next time we encounter it */
188
 		skip = 1;
188
 		skip = 1;
189
 
189
 
190
-		/* Print out what we're doing */
191
-		printf ( "Booting from %s %s at %s "
192
-			 "using the %s driver\n",
190
+		/* Print out device information */
191
+		printf ( "%s (%s) %s at %s\n",
193
 			 dev.bus_driver->name_device ( &dev.bus_dev ),
192
 			 dev.bus_driver->name_device ( &dev.bus_dev ),
193
+			 dev.device_driver->name,
194
 			 dev.type_driver->name,
194
 			 dev.type_driver->name,
195
-			 dev.bus_driver->describe_device ( &dev.bus_dev ),
196
-			 dev.device_driver->name );
195
+			 dev.bus_driver->describe_device ( &dev.bus_dev ) );
197
 
196
 
198
 		/* Probe boot device */
197
 		/* Probe boot device */
199
 		if ( ! probe ( &dev ) ) {
198
 		if ( ! probe ( &dev ) ) {
200
 			/* Device found on bus, but probe failed */
199
 			/* Device found on bus, but probe failed */
201
-			printf ( "...probe failed on %s\n" );
200
+			printf ( "...probe failed\n" );
202
 			continue;
201
 			continue;
203
 		}
202
 		}
204
-		
205
-		printf ( "%s: %s\n",
203
+
204
+		/* Print out device information */
205
+		printf ( "%s %s has %s\n",
206
 			 dev.bus_driver->name_device ( &dev.bus_dev ),
206
 			 dev.bus_driver->name_device ( &dev.bus_dev ),
207
+			 dev.type_driver->name,
207
 			 dev.type_driver->describe_device ( dev.type_dev ) );
208
 			 dev.type_driver->describe_device ( dev.type_dev ) );
209
+
210
+		/* Configure boot device */
211
+		if ( ! configure ( &dev ) ) {
212
+			/* Configuration (e.g. DHCP) failed */
213
+			printf ( "...configuration failed\n" );
214
+			continue;
215
+		}
216
+
217
+		/* Boot from the device */
218
+		load ( &dev, load_block );
219
+
208
 	}
220
 	}
209
 
221
 
210
 	/* Call registered per-object exit functions */
222
 	/* Call registered per-object exit functions */
391
 #endif
403
 #endif
392
 };
404
 };
393
 
405
 
394
-int loadkernel(const char *fname)
395
-{
406
+int loadkernel ( const char *fname,
407
+		 int ( * load_block ) ( unsigned char *data,
408
+					unsigned int blocknum,
409
+					unsigned int len, int eof ) ) {
396
 	static const struct proto * const last_proto = 
410
 	static const struct proto * const last_proto = 
397
 		&protos[sizeof(protos)/sizeof(protos[0])];
411
 		&protos[sizeof(protos)/sizeof(protos[0])];
398
 	const struct proto *proto;
412
 	const struct proto *proto;

+ 18
- 11
src/core/nic.c View File

234
 /*
234
 /*
235
  * Find out what our boot parameters are
235
  * Find out what our boot parameters are
236
  */
236
  */
237
-static int nic_load_configuration ( struct nic *nic ) {
237
+static int nic_configure ( struct type_dev *type_dev ) {
238
+	struct nic *nic = ( struct nic * ) type_dev;
238
 	int server_found;
239
 	int server_found;
239
 
240
 
240
 	if ( ! nic->nic_op->connect ( nic ) ) {
241
 	if ( ! nic->nic_op->connect ( nic ) ) {
262
 		printf("No Server found\n");
263
 		printf("No Server found\n");
263
 		return 0;
264
 		return 0;
264
 	}
265
 	}
265
-	return 1;
266
-}
267
 
266
 
268
-
269
-/**************************************************************************
270
-LOAD - Try to get booted
271
-**************************************************************************/
272
-static int nic_load(struct dev *dev __unused)
273
-{
274
-	const char	*kernel;
275
 	printf("\nMe: %@", arptable[ARP_CLIENT].ipaddr.s_addr );
267
 	printf("\nMe: %@", arptable[ARP_CLIENT].ipaddr.s_addr );
276
 #ifndef NO_DHCP_SUPPORT
268
 #ifndef NO_DHCP_SUPPORT
277
 	printf(", DHCP: %@", dhcp_server );
269
 	printf(", DHCP: %@", dhcp_server );
297
 	printf("\n=>>"); getchar();
289
 	printf("\n=>>"); getchar();
298
 #endif
290
 #endif
299
 
291
 
292
+	return 1;
293
+}
294
+
295
+
296
+/**************************************************************************
297
+LOAD - Try to get booted
298
+**************************************************************************/
299
+static int nic_load ( struct type_dev *type_dev,
300
+		      int ( * process ) ( unsigned char *data,
301
+					  unsigned int blocknum,
302
+					  unsigned int size, int eof ) ) {
303
+	const char	*kernel;
304
+
300
 	/* Now use TFTP to load file */
305
 	/* Now use TFTP to load file */
301
 #ifdef	DOWNLOAD_PROTO_NFS
306
 #ifdef	DOWNLOAD_PROTO_NFS
302
 	rpc_init();
307
 	rpc_init();
309
 #endif
314
 #endif
310
 		: KERNEL_BUF;
315
 		: KERNEL_BUF;
311
 	if ( kernel ) {
316
 	if ( kernel ) {
312
-		loadkernel(kernel); /* We don't return except on error */
317
+		loadkernel(kernel,process); /* We don't return except on error */
313
 		printf("Unable to load file.\n");
318
 		printf("Unable to load file.\n");
314
 	} else {	
319
 	} else {	
315
 		printf("No filename\n");
320
 		printf("No filename\n");
343
 	.name			= "NIC",
348
 	.name			= "NIC",
344
 	.type_dev		= ( struct type_dev * ) &nic,
349
 	.type_dev		= ( struct type_dev * ) &nic,
345
 	.describe_device	= nic_describe_device,
350
 	.describe_device	= nic_describe_device,
351
+	.configure		= nic_configure,
352
+	.load			= nic_load,
346
 };
353
 };
347
 
354
 
348
 /* Careful.  We need an aligned buffer to avoid problems on machines
355
 /* Careful.  We need an aligned buffer to avoid problems on machines

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

180
 	char *name;
180
 	char *name;
181
 	struct type_dev *type_dev; /* single instance */
181
 	struct type_dev *type_dev; /* single instance */
182
 	char * ( * describe_device ) ( struct type_dev *type_dev );
182
 	char * ( * describe_device ) ( struct type_dev *type_dev );
183
+	int ( * configure ) ( struct type_dev *type_dev );
184
+	int ( * load ) ( struct type_dev *type_dev, 
185
+			 int ( * process ) ( unsigned char *data,
186
+					     unsigned int blocknum,
187
+					     unsigned int len, int eof ) );
183
 };
188
 };
184
 
189
 
185
 #define __type_driver __attribute__ (( used, __section__ ( ".drivers.type" ) ))
190
 #define __type_driver __attribute__ (( used, __section__ ( ".drivers.type" ) ))
266
 	dev->bus_driver = bus_driver;
271
 	dev->bus_driver = bus_driver;
267
 	memcpy ( &dev->bus_loc, bus_loc, sizeof ( dev->bus_loc ) );
272
 	memcpy ( &dev->bus_loc, bus_loc, sizeof ( dev->bus_loc ) );
268
 }
273
 }
274
+/* Configure a device */
275
+static inline int configure ( struct dev *dev ) {
276
+	return dev->type_driver->configure ( dev->type_dev );
277
+}
278
+/* Boot from a device */
279
+static inline int load ( struct dev *dev,
280
+			 int ( * process ) ( unsigned char *data,
281
+					     unsigned int blocknum, 
282
+					     unsigned int len, int eof ) ) {
283
+	return dev->type_driver->load ( dev->type_dev, process );
284
+}
269
 
285
 
270
 /* Linker symbols for the various tables */
286
 /* Linker symbols for the various tables */
271
 extern struct bus_driver bus_drivers[];
287
 extern struct bus_driver bus_drivers[];

+ 1
- 1
src/include/etherboot.h View File

182
 /* main.c */
182
 /* main.c */
183
 struct Elf_Bhdr;
183
 struct Elf_Bhdr;
184
 extern int main();
184
 extern int main();
185
-extern int loadkernel P((const char *fname));
185
+extern int loadkernel P((const char *fname, int (*)(unsigned char *, unsigned int, unsigned int, int)));
186
 extern char as_main_program;
186
 extern char as_main_program;
187
 /* nic.c */
187
 /* nic.c */
188
 extern void rx_qdrain P((void));
188
 extern void rx_qdrain P((void));

Loading…
Cancel
Save