Sfoglia il codice sorgente

Added back in the actual call to load().

tags/v0.9.3
Michael Brown 19 anni fa
parent
commit
fda36a0c1a
4 ha cambiato i file con 59 aggiunte e 22 eliminazioni
  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 Vedi File

@@ -187,24 +187,36 @@ int main ( void ) {
187 187
 		/* Skip this device the next time we encounter it */
188 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 192
 			 dev.bus_driver->name_device ( &dev.bus_dev ),
193
+			 dev.device_driver->name,
194 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 197
 		/* Probe boot device */
199 198
 		if ( ! probe ( &dev ) ) {
200 199
 			/* Device found on bus, but probe failed */
201
-			printf ( "...probe failed on %s\n" );
200
+			printf ( "...probe failed\n" );
202 201
 			continue;
203 202
 		}
204
-		
205
-		printf ( "%s: %s\n",
203
+
204
+		/* Print out device information */
205
+		printf ( "%s %s has %s\n",
206 206
 			 dev.bus_driver->name_device ( &dev.bus_dev ),
207
+			 dev.type_driver->name,
207 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 222
 	/* Call registered per-object exit functions */
@@ -391,8 +403,10 @@ static const struct proto protos[] = {
391 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 410
 	static const struct proto * const last_proto = 
397 411
 		&protos[sizeof(protos)/sizeof(protos[0])];
398 412
 	const struct proto *proto;

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

@@ -234,7 +234,8 @@ static unsigned short tcpudpchksum(struct iphdr *ip);
234 234
 /*
235 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 239
 	int server_found;
239 240
 
240 241
 	if ( ! nic->nic_op->connect ( nic ) ) {
@@ -262,16 +263,7 @@ static int nic_load_configuration ( struct nic *nic ) {
262 263
 		printf("No Server found\n");
263 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 267
 	printf("\nMe: %@", arptable[ARP_CLIENT].ipaddr.s_addr );
276 268
 #ifndef NO_DHCP_SUPPORT
277 269
 	printf(", DHCP: %@", dhcp_server );
@@ -297,6 +289,19 @@ static int nic_load(struct dev *dev __unused)
297 289
 	printf("\n=>>"); getchar();
298 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 305
 	/* Now use TFTP to load file */
301 306
 #ifdef	DOWNLOAD_PROTO_NFS
302 307
 	rpc_init();
@@ -309,7 +314,7 @@ static int nic_load(struct dev *dev __unused)
309 314
 #endif
310 315
 		: KERNEL_BUF;
311 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 318
 		printf("Unable to load file.\n");
314 319
 	} else {	
315 320
 		printf("No filename\n");
@@ -343,6 +348,8 @@ struct type_driver nic_driver = {
343 348
 	.name			= "NIC",
344 349
 	.type_dev		= ( struct type_dev * ) &nic,
345 350
 	.describe_device	= nic_describe_device,
351
+	.configure		= nic_configure,
352
+	.load			= nic_load,
346 353
 };
347 354
 
348 355
 /* Careful.  We need an aligned buffer to avoid problems on machines

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

@@ -180,6 +180,11 @@ struct type_driver {
180 180
 	char *name;
181 181
 	struct type_dev *type_dev; /* single instance */
182 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 190
 #define __type_driver __attribute__ (( used, __section__ ( ".drivers.type" ) ))
@@ -266,6 +271,17 @@ static inline void select_device ( struct dev *dev,
266 271
 	dev->bus_driver = bus_driver;
267 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 286
 /* Linker symbols for the various tables */
271 287
 extern struct bus_driver bus_drivers[];

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

@@ -182,7 +182,7 @@ External prototypes
182 182
 /* main.c */
183 183
 struct Elf_Bhdr;
184 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 186
 extern char as_main_program;
187 187
 /* nic.c */
188 188
 extern void rx_qdrain P((void));

Loading…
Annulla
Salva