This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
RedBoot: automatic load/execute of bootp file -- patch attached
- To: ecos-discuss at sources dot redhat dot com
- Subject: [ECOS] RedBoot: automatic load/execute of bootp file -- patch attached
- From: Grant Edwards <grante at visi dot com>
- Date: Thu, 15 Mar 2001 13:52:42 -0600
I've added code to net_io.c to load/execute the file specified
by the bootp server. It might be a good idea to add CDL code
to enable/disable this feature, but I haven't done that (I want
it enabled all the time).
IIRC, two of the routines (do_go and load_srec_image) may have
be static in the CVS sources -- so they have to be made global
for this patch to work.
Here it is if anybody wants it...
--
Grant Edwards
grante@visi.com
Index: net_io.c
===================================================================
RCS file: /cvs/ecos/ecos/packages/redboot/current/src/net/net_io.c,v
retrieving revision 1.8
diff -U5 -r1.8 net_io.c
--- net_io.c 2001/02/13 01:23:39 1.8
+++ net_io.c 2001/03/15 19:30:55
@@ -550,20 +544,49 @@
if (!__local_enet_sc) {
printf("No network interfaces found\n");
return;
}
// Initialize the network [if present]
- if (use_bootp) {
- if (__bootp_find_local_ip(&my_bootp_info) == 0) {
- have_net = true;
- } else {
+
+ memset(&my_bootp_info,0,sizeof my_bootp_info);
+
+ if (use_bootp && have_net) {
+ if (__bootp_find_local_ip(&my_bootp_info) != 0) {
printf("Can't get BOOTP info - network disabled!\n");
+ have_net = false;
+ return;
}
- } else {
- have_net = true; // Assume values in FLASH were OK
- }
- if (have_net) {
- printf("IP: %s", inet_ntoa((in_addr_t *)&__local_ip_addr));
- printf(", Default server: %s\n", inet_ntoa(&my_bootp_info.bp_siaddr));
- net_io_init();
- }
+ }
+
+
+ printf("IP: %s", inet_ntoa((in_addr_t *)&__local_ip_addr));
+ printf(", Default server: %s\n", inet_ntoa(&my_bootp_info.bp_siaddr));
+
+ if (my_bootp_info.bp_file[0]) {
+ // load boot file specified in bootp response
+ extern void load_srec_image(int (*getc)(void), unsigned long base);
+ extern void do_go(int argc, char *argv[]);
+ char *argv[] = {""};
+ int res,err;
+ struct sockaddr_in host;
+
+ memset((char *)&host, 0, sizeof(host));
+ host.sin_len = sizeof(host);
+ host.sin_family = AF_INET;
+ host.sin_addr = my_bootp_info.bp_siaddr;
+ host.sin_port = 0;
+ res = tftp_stream_open(my_bootp_info.bp_file,&host, TFTP_OCTET, &err);
+ if (res < 0) {
+ printf("Can't load '%s': %s\n", my_bootp_info.bp_file, tftp_error(err));
+ return;
+ }
+ printf("Loading '%s'\n", my_bootp_info.bp_file);
+ redboot_getc_init(tftp_stream_read, 0);
+ entry_address = (unsigned long*)0xffffffff;
+ load_srec_image(redboot_getc, 0);
+ tftp_stream_close(&err);
+ if (entry_address != (unsigned long*)0xffffffff) {
+ do_go(0,argv);
+ }
+ }
+ net_io_init();
}