From: wdenk Date: Sun, 29 Oct 2000 21:30:50 +0000 (+0000) Subject: Fix violation of BOOTP message format. X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=955bf98f74cadc60f3f8a8b585536d3af00824b2;p=users%2Frw%2Fppcboot.git Fix violation of BOOTP message format. Allow for configurations which don't define some environment variables. Unified handling of (default) load address. Change compiler options to reduce code size. --- diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c index 8b8c224..0e51418 100644 --- a/common/cmd_bootm.c +++ b/common/cmd_bootm.c @@ -41,6 +41,7 @@ static void print_type (image_header_t *hdr); image_header_t header; +ulong load_addr = CFG_LOAD_ADDR; /* Default Load Address */ void do_bootm (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]) { @@ -59,15 +60,14 @@ void do_bootm (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]) void (*kernel)(bd_t *, ulong, ulong, ulong, ulong); image_header_t *hdr = &header; - if (argc < 2) { - printf ("Usage:\n%s\n", cmdtp->usage); - return; - } - s = getenv ("verify"); verify = (s && (*s == 'n')) ? 0 : 1; - addr = simple_strtoul(argv[1], NULL, 16); + if (argc < 2) { + addr = load_addr; + } else { + addr = simple_strtoul(argv[1], NULL, 16); + } printf ("## Booting Linux kernel at %08lx ...\n", addr); diff --git a/common/cmd_ide.c b/common/cmd_ide.c index b691f23..367ebb5 100644 --- a/common/cmd_ide.c +++ b/common/cmd_ide.c @@ -379,7 +379,7 @@ void do_diskboot (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]) switch (argc) { case 1: - addr = CFG_TFTP_LOADADDR; + addr = CFG_LOAD_ADDR; boot_device = getenv ("bootdevice"); break; case 2: @@ -459,21 +459,21 @@ void do_diskboot (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]) } - /* Loading ok, check if we should attempt an auto-start */ + /* Loading ok, update default load address */ + + load_addr = addr; + + /* Check if we should attempt an auto-start */ if (((ep = getenv("autostart")) != NULL) && (strcmp(ep,"yes") == 0)) { - char *local_args[3]; - char local_str[32]; + char *local_args[2]; extern void do_bootm (cmd_tbl_t *, bd_t *, int, int, char *[]); - sprintf (local_str, "%lX", addr); local_args[0] = argv[0]; - local_args[1] = local_str; - local_args[2] = NULL; + local_args[1] = NULL; - printf ("Automatic boot of image at addr 0x%08lX ...\n", - addr); + printf ("Automatic boot of image at addr 0x%08lX ...\n", addr); - do_bootm (cmdtp, bd, 0, 2, local_args); + do_bootm (cmdtp, bd, 0, 1, local_args); } } diff --git a/common/cmd_net.c b/common/cmd_net.c index 89d679f..cb520e9 100644 --- a/common/cmd_net.c +++ b/common/cmd_net.c @@ -61,7 +61,7 @@ static void netboot_update_env(void) if (NetOurSubnetMask) { NetIPaddr (NetOurSubnetMask, tmp); - setenv("subnetmask", tmp); + setenv("netmask", tmp); } if (NetOurHostName[0]) @@ -87,7 +87,6 @@ netboot_common (int proto, cmd_tbl_t *cmdtp, bd_t *bd, int argc, char *argv[]) ulong addr; int rc; char *s; - extern ulong TftpLoadAddress; switch (argc) { case 1: rc = NetLoop(bd, proto, "", -1); @@ -109,17 +108,14 @@ netboot_common (int proto, cmd_tbl_t *cmdtp, bd_t *bd, int argc, char *argv[]) /* Loading ok, check if we should attempt an auto-start */ if (((s = getenv("autostart")) != NULL) && (strcmp(s,"yes") == 0)) { - char *local_args[3]; - char local_str[32]; - sprintf (local_str, "%lX", TftpLoadAddress); + char *local_args[2]; local_args[0] = argv[0]; - local_args[1] = local_str; - local_args[2] = NULL; + local_args[1] = NULL; printf ("Automatic boot of image at addr 0x%08lX ...\n", - TftpLoadAddress); + load_addr); - do_bootm (cmdtp, bd, 0, 2, local_args); + do_bootm (cmdtp, bd, 0, 1, local_args); } } diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c index b1ef037..009b846 100644 --- a/common/cmd_nvedit.c +++ b/common/cmd_nvedit.c @@ -86,8 +86,12 @@ static void env_init(void); #define MK_STR(x) XMK_STR(x) static uchar default_environment[] = { +#ifdef CONFIG_BOOTARGS "bootargs=" CONFIG_BOOTARGS "\0" +#endif +#ifdef CONFIG_BOOTCOMMAND "bootcmd=" CONFIG_BOOTCOMMAND "\0" +#endif #if (CONFIG_BOOTDELAY >= 0) "bootdelay=" MK_STR(CONFIG_BOOTDELAY) "\0" #endif diff --git a/common/environment.S b/common/environment.S index 2c651bc..52b8573 100644 --- a/common/environment.S +++ b/common/environment.S @@ -14,12 +14,16 @@ #endif .globl environment environment: +#ifdef CONFIG_BOOTARGS .ascii "bootargs=" .ascii CONFIG_BOOTARGS .ascii "\0" +#endif +#ifdef CONFIG_BOOTCOMMAND .ascii "bootcmd=" .ascii CONFIG_BOOTCOMMAND .ascii "\0" +#endif #if (CONFIG_BOOTDELAY >= 0) .ascii "bootdelay=" .ascii MK_STR(CONFIG_BOOTDELAY) diff --git a/config.mk b/config.mk index 0f690ac..3e34010 100644 --- a/config.mk +++ b/config.mk @@ -63,7 +63,7 @@ RANLIB = $(CROSS_COMPILE)RANLIB RELFLAGS= $(PLATFORM_RELFLAGS) DBGFLAGS= #-g -DDEBUG -OPTFLAGS= -O2 -fomit-frame-pointer +OPTFLAGS= -Os -fomit-frame-pointer #LDSCRIPT := $(BOARD)/ppcboot.lds.debug LDSCRIPT := $(BOARD)/ppcboot.lds diff --git a/include/cmd_bootm.h b/include/cmd_bootm.h index 5abf649..1f672db 100644 --- a/include/cmd_bootm.h +++ b/include/cmd_bootm.h @@ -32,7 +32,7 @@ void do_bootm (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]); #define CMD_TBL_BOOTM MK_CMD_TBL_ENTRY( \ "bootm", 5, CFG_MAXARGS, 1, do_bootm, \ "bootm - boot application image from memory\n", \ - "addr [arg ...]\n - boot application image stored in memory\n" \ + "[addr [arg ...]]\n - boot application image stored in memory\n" \ " passing arguments 'arg ...'; when booting a Linux kernel,\n" \ " 'arg' can be the address of an initrd image\n" \ ), diff --git a/include/config_ADCIOP.h b/include/config_ADCIOP.h index 01dfd7d..52b9afb 100644 --- a/include/config_ADCIOP.h +++ b/include/config_ADCIOP.h @@ -82,7 +82,7 @@ #define CFG_BAUDRATE_MAX 115200 /* highest possible baudrate */ #define CFG_BAUDRATE_DEFAULT CONFIG_BAUDRATE /* default baudrate */ -#define CFG_TFTP_LOADADDR 0x100000 /* default load address */ +#define CFG_LOAD_ADDR 0x100000 /* default load address */ /*----------------------------------------------------------------------- * Definitions for initial stack pointer and data area (in DPRAM) diff --git a/include/config_CPCI405.h b/include/config_CPCI405.h index 5d9c6de..d804db4 100644 --- a/include/config_CPCI405.h +++ b/include/config_CPCI405.h @@ -105,7 +105,7 @@ #define CFG_BAUDRATE_MAX 115200 /* highest possible baudrate */ #define CFG_BAUDRATE_DEFAULT CONFIG_BAUDRATE /* default baudrate */ -#define CFG_TFTP_LOADADDR 0x100000 /* default load address */ +#define CFG_LOAD_ADDR 0x100000 /* default load address */ #define CFG_EXTBDINFO 1 /* To use extended board_into (bd_t) */ /*----------------------------------------------------------------------- diff --git a/include/config_ETX094.h b/include/config_ETX094.h index 0dc3267..c41df9d 100644 --- a/include/config_ETX094.h +++ b/include/config_ETX094.h @@ -76,7 +76,7 @@ #define CFG_MEMTEST_START 0x0300000 /* memtest works on */ #define CFG_MEMTEST_END 0x0700000 /* 3 ... 7 MB in DRAM */ -#define CFG_TFTP_LOADADDR 0x100000 /* default load address */ +#define CFG_LOAD_ADDR 0x100000 /* default load address */ /* * Low Level Configuration Settings diff --git a/include/config_FADS823.h b/include/config_FADS823.h index c33e229..c84037f 100644 --- a/include/config_FADS823.h +++ b/include/config_FADS823.h @@ -91,7 +91,7 @@ "bootp ;" \ "setenv bootargs console=tty0 console=ttyS0 " \ "root=/dev/nfs nfsroot=$(serverip):$(rootpath) " \ -"ip=$(ipaddr):$(serverip):$(gatewayip):$(subnetmask):$(hostname):eth0:off ;" \ +"ip=$(ipaddr):$(serverip):$(gatewayip):$(netmask):$(hostname):eth0:off ;" \ "bootm" #else #define CONFIG_BOOTDELAY 0 /* autoboot disabled */ @@ -119,7 +119,7 @@ #define CFG_MEMTEST_START 0x00000000 /* memtest works on */ #define CFG_MEMTEST_END 0x01000000 /* 4 ... 16 MB in DRAM */ -#define CFG_TFTP_LOADADDR 0x00100000 /* default load address */ +#define CFG_LOAD_ADDR 0x00100000 /* default load address */ /* * Low Level Configuration Settings * (address mappings, register initial values, etc.) diff --git a/include/config_FADS850SAR.h b/include/config_FADS850SAR.h index e91191b..271007d 100644 --- a/include/config_FADS850SAR.h +++ b/include/config_FADS850SAR.h @@ -81,7 +81,7 @@ #define CFG_MEMTEST_START 0x00000000 /* memtest works on */ #define CFG_MEMTEST_END 0x00800000 /* 4 ... 8 MB in DRAM */ -#define CFG_TFTP_LOADADDR 0x00100000 /* default load address */ +#define CFG_LOAD_ADDR 0x00100000 /* default load address */ /* * Low Level Configuration Settings diff --git a/include/config_FADS860T.h b/include/config_FADS860T.h index 8aeb815..5e0e06b 100644 --- a/include/config_FADS860T.h +++ b/include/config_FADS860T.h @@ -81,7 +81,7 @@ #define CFG_MEMTEST_START 0x0100000 /* memtest works on */ #define CFG_MEMTEST_END 0x0400000 /* 1 ... 4 MB in DRAM */ -#define CFG_TFTP_LOADADDR 0x00100000 +#define CFG_LOAD_ADDR 0x00100000 /* diff --git a/include/config_FPS850L.h b/include/config_FPS850L.h index 53a4f36..5938b74 100644 --- a/include/config_FPS850L.h +++ b/include/config_FPS850L.h @@ -76,7 +76,7 @@ #define CFG_MEMTEST_START 0x0400000 /* memtest works on */ #define CFG_MEMTEST_END 0x0C00000 /* 4 ... 12 MB in DRAM */ -#define CFG_TFTP_LOADADDR 0x100000 /* default load address */ +#define CFG_LOAD_ADDR 0x100000 /* default load address */ /* * Low Level Configuration Settings diff --git a/include/config_GENIETV.h b/include/config_GENIETV.h index cfc3d77..4689476 100644 --- a/include/config_GENIETV.h +++ b/include/config_GENIETV.h @@ -109,7 +109,7 @@ #define CFG_MEMTEST_START 0x00000000 /* memtest works on */ #define CFG_MEMTEST_END 0x00800000 /* 4 ... 8 MB in DRAM */ -#define CFG_TFTP_LOADADDR 0x00100000 /* default load address */ +#define CFG_LOAD_ADDR 0x00100000 /* default load address */ /* * Low Level Configuration Settings * (address mappings, register initial values, etc.) diff --git a/include/config_MBX.h b/include/config_MBX.h index dd39277..634a790 100644 --- a/include/config_MBX.h +++ b/include/config_MBX.h @@ -80,7 +80,7 @@ #define CFG_MEMTEST_START 0x0400000 /* memtest works on */ #define CFG_MEMTEST_END 0x0C00000 /* 4 ... 12 MB in DRAM */ -#define CFG_TFTP_LOADADDR 0x100000 /* default load address */ +#define CFG_LOAD_ADDR 0x100000 /* default load address */ /* * Low Level Configuration Settings diff --git a/include/config_SPD823TS.h b/include/config_SPD823TS.h index 2644f04..1caadb1 100644 --- a/include/config_SPD823TS.h +++ b/include/config_SPD823TS.h @@ -88,7 +88,7 @@ #define CFG_MEMTEST_START 0x00100000 /* memtest works on */ #define CFG_MEMTEST_END 0x00F00000 /* 1 ... 15MB in DRAM */ -#define CFG_TFTP_LOADADDR 0x00100000 /* default load address */ +#define CFG_LOAD_ADDR 0x00100000 /* default load address */ #define CFG_PIO_MODE 0 /* IDE interface in PIO Mode 0 */ diff --git a/include/config_TQM823L.h b/include/config_TQM823L.h index 111490f..9060b27 100644 --- a/include/config_TQM823L.h +++ b/include/config_TQM823L.h @@ -76,7 +76,7 @@ #define CFG_MEMTEST_START 0x0400000 /* memtest works on */ #define CFG_MEMTEST_END 0x0C00000 /* 4 ... 12 MB in DRAM */ -#define CFG_TFTP_LOADADDR 0x100000 /* default load address */ +#define CFG_LOAD_ADDR 0x100000 /* default load address */ /* * Low Level Configuration Settings diff --git a/include/config_TQM850L.h b/include/config_TQM850L.h index 7339ef1..3a07464 100644 --- a/include/config_TQM850L.h +++ b/include/config_TQM850L.h @@ -45,11 +45,13 @@ #else #define CONFIG_BOOTDELAY 5 /* autoboot after 5 seconds */ #endif -#define CONFIG_BOOTCOMMAND "bootm 40020000" /* autoboot command */ -#define CONFIG_BOOTARGS "root=/dev/nfs rw " \ - "nfsroot=10.0.0.2:/LinuxPPC " \ - "nfsaddrs=10.0.0.99:10.0.0.2" +#undef CONFIG_BOOTARGS +#define CONFIG_BOOTCOMMAND \ + "bootp; " \ + "setenv bootargs root=/dev/nfs nfsroot=$(serverip):$(rootpath) " \ + "ip=$(ipaddr):$(serverip):$(gatewayip):$(netmask):$(hostname)::off; " \ + "bootm" #define CONFIG_LOADS_ECHO 1 /* echo on for serial download */ #undef CFG_LOADS_BAUD_CHANGE /* don't allow baudrate change */ @@ -76,7 +78,7 @@ #define CFG_MEMTEST_START 0x0400000 /* memtest works on */ #define CFG_MEMTEST_END 0x0C00000 /* 4 ... 12 MB in DRAM */ -#define CFG_TFTP_LOADADDR 0x100000 /* default load address */ +#define CFG_LOAD_ADDR 0x100000 /* default load address */ /* * Low Level Configuration Settings diff --git a/include/config_TQM855L.h b/include/config_TQM855L.h index 7af4888..43adab4 100644 --- a/include/config_TQM855L.h +++ b/include/config_TQM855L.h @@ -78,7 +78,7 @@ #define CFG_MEMTEST_START 0x0400000 /* memtest works on */ #define CFG_MEMTEST_END 0x0C00000 /* 4 ... 12 MB in DRAM */ -#define CFG_TFTP_LOADADDR 0x100000 /* default load address */ +#define CFG_LOAD_ADDR 0x100000 /* default load address */ /* * Low Level Configuration Settings diff --git a/include/config_TQM860L.h b/include/config_TQM860L.h index ae8dd2c..1987d67 100644 --- a/include/config_TQM860L.h +++ b/include/config_TQM860L.h @@ -76,7 +76,7 @@ #define CFG_MEMTEST_START 0x0400000 /* memtest works on */ #define CFG_MEMTEST_END 0x0C00000 /* 4 ... 12 MB in DRAM */ -#define CFG_TFTP_LOADADDR 0x100000 /* default load address */ +#define CFG_LOAD_ADDR 0x100000 /* default load address */ /* * Low Level Configuration Settings diff --git a/include/ppcboot.h b/include/ppcboot.h index 642da81..77b2eea 100644 --- a/include/ppcboot.h +++ b/include/ppcboot.h @@ -140,6 +140,8 @@ void misc_init_r (bd_t *); /* common/cmd_bootm.c */ void print_image_hdr (image_header_t *hdr); +extern ulong load_addr; /* Default Load Address */ + /* common/cmd_nvedit.c */ char *getenv (uchar *); void inline setenv (char *, char *); diff --git a/net/bootp.c b/net/bootp.c index 7a40722..1e9836a 100644 --- a/net/bootp.c +++ b/net/bootp.c @@ -134,23 +134,33 @@ void BootpVendorProcess(u8 *ext, int size) #ifdef DEBUG_BOOTP_EXT printf("[BOOTP] Received fields: \n"); - if (NetOurSubnetMask) - printf(" NetOurSubnetMask : "); NetPrintIPaddr (NetOurSubnetMask); putc("\n"); + if (NetOurSubnetMask) { + puts ("NetOurSubnetMask : "); + NetPrintIPaddr (NetOurSubnetMask); + putc('\n'); + } - if (NetOurGatewayIP) - printf("\n NetOurGatewayIP : "); NetPrintIPaddr (NetOurGatewayIP); putc("\n"); + if (NetOurGatewaysIP[0]) { + puts ("NetOurGatewaysIP : "); + NetPrintIPaddr (NetOurGatewaysIP[0]); + putc('\n'); + } - if (NetBootFileSize) - printf(" NetBootFileSize : %d\n", NetBootFileSize); + if (NetBootFileSize) { + printf("NetBootFileSize : %d\n", NetBootFileSize); + } - if (NetOurHostName[0]) - printf(" NetOurHostName : %s\n", NetOurHostName); + if (NetOurHostName[0]) { + printf("NetOurHostName : %s\n", NetOurHostName); + } - if (NetOurRootPath[0]) - printf(" NetOurRootPath : %s\n", NetOurRootPath); + if (NetOurRootPath[0]) { + printf("NetOurRootPath : %s\n", NetOurRootPath); + } - if (NetOurNISDomain[0]) - printf(" NetOurNISDomain : %s\n", NetOurNISDomain); + if (NetOurNISDomain[0]) { + printf("NetOurNISDomain : %s\n", NetOurNISDomain); + } #endif } @@ -162,8 +172,9 @@ BootpHandler(uchar * pkt, unsigned dest, unsigned src, unsigned len) { Bootp_t * bp; -#if 0 - printf("got BOOTP packet (src=%d, dst=%d, len=%d)\n", src, dest, len); +#ifdef DEBUG + printf("got BOOTP packet (src=%d, dst=%d, len=%d want_len=%d)\n", + src, dest, len, sizeof (Bootp_t)); #endif /* DEBUG */ bp = (Bootp_t *)pkt; diff --git a/net/bootp.h b/net/bootp.h index 3c63127..0e7dc18 100644 --- a/net/bootp.h +++ b/net/bootp.h @@ -38,7 +38,7 @@ typedef struct uchar bp_chaddr[16]; /* Client hardware address */ char bp_sname[64]; /* Server host name */ char bp_file[128]; /* Boot file name */ - char bp_vend[128]; /* Vendor information */ + char bp_vend[64]; /* Vendor information */ } Bootp_t; #define BOOTP_HDR_SIZE sizeof (Bootp_t) diff --git a/net/tftp.c b/net/tftp.c index 7f1abfb..97a232f 100644 --- a/net/tftp.c +++ b/net/tftp.c @@ -40,12 +40,11 @@ static int TftpState; #define STATE_DATA 2 #define STATE_TOO_LARGE 3 #define STATE_BAD_MAGIC 4 -ulong TftpLoadAddress; /* Place to load the image into */ static __inline__ void store_block (unsigned block, uchar * src, unsigned len) { - (void)memcpy((void *)(TftpLoadAddress + block * 512), src, len); + (void)memcpy((void *)(load_addr + block * 512), src, len); } /**********************************************************************/ @@ -256,11 +255,11 @@ TftpStart (ulong loadAdr) printf ("\n"); if (loadAdr == ~0) { - TftpLoadAddress = CFG_TFTP_LOADADDR; - printf ("No load address; using 0x%lx\n", TftpLoadAddress); + load_addr = CFG_LOAD_ADDR; + printf ("No load address; using 0x%lx\n", load_addr); } else { - TftpLoadAddress = loadAdr; - printf ("Load address: 0x%lx\n", TftpLoadAddress); + load_addr = loadAdr; + printf ("Load address: 0x%lx\n", load_addr); } printf ("Loading: *\b");