]> www.infradead.org Git - users/rw/ppcboot.git/commitdiff
Fix violation of BOOTP message format.
authorwdenk <wdenk>
Sun, 29 Oct 2000 21:30:50 +0000 (21:30 +0000)
committerwdenk <wdenk>
Sun, 29 Oct 2000 21:30:50 +0000 (21:30 +0000)
Allow for configurations which don't define some environment variables.
Unified handling of (default) load address.
Change compiler options to reduce code size.

25 files changed:
common/cmd_bootm.c
common/cmd_ide.c
common/cmd_net.c
common/cmd_nvedit.c
common/environment.S
config.mk
include/cmd_bootm.h
include/config_ADCIOP.h
include/config_CPCI405.h
include/config_ETX094.h
include/config_FADS823.h
include/config_FADS850SAR.h
include/config_FADS860T.h
include/config_FPS850L.h
include/config_GENIETV.h
include/config_MBX.h
include/config_SPD823TS.h
include/config_TQM823L.h
include/config_TQM850L.h
include/config_TQM855L.h
include/config_TQM860L.h
include/ppcboot.h
net/bootp.c
net/bootp.h
net/tftp.c

index 8b8c2244cf57c033008e8b2b27104a510b3391ff..0e51418724e91b4ae72856e62b584cf8aaa45ac2 100644 (file)
@@ -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);
 
index b691f235fef540f4a419813cabadb2a58ab126c1..367ebb555e6be59f0f74d0c7338adcf8bec1945a 100644 (file)
@@ -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);
        }
 }
 
index 89d679fbf88923414e53c9b81c026b01c25670bb..cb520e9a1afd30e99b91d4a40380752a92d06e8c 100644 (file)
@@ -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);
        }
 }
 
index b1ef037a12d6a41072b40530f69eb7632b946ea1..009b8469d3c6d4542d24304c4ab1912923992800 100644 (file)
@@ -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
index 2c651bcef3cd14f6d82e9ea8f50da90dfea7b531..52b8573b3f0bee149e3cb5b5b9ca1ebc071a21d6 100644 (file)
 #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)
index 0f690ac7493bd2f5ea1d10cee1e46903c3740067..3e34010f70e6a39f25d348b3cc4fc4b560b0fee8 100644 (file)
--- 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
 
index 5abf6494b29847e3ec077c402a7451ca788d4fa0..1f672dbd66ce575e1a139e4cb25df70a6d9402d7 100644 (file)
@@ -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"                 \
 ),
index 01dfd7d28106951965ff970162fe63cfc1bf4031..52b9afbe5821a380ee534d95b8d2ba557f0e32b8 100644 (file)
@@ -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)
index 5d9c6debe07acfdd2411dd0f5ef2a40dcad82c61..d804db412ddf3401bf80c8e6f9d9c8669b4fde1c 100644 (file)
 #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) */
 
 /*-----------------------------------------------------------------------
index 0dc32673ff0a84c400d3eb29aa5bbd2ef0f72f7c..c41df9df2fd6c95770cc8bd4e9ebc10c0af3ed2f 100644 (file)
@@ -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
index c33e229cb08654bb38c376ee5b72adaca308c140..c84037fea976829feab74a7941f0158c71aaa319 100644 (file)
@@ -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            */
 #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.)
index e91191b6232b9d71894385ea2bef069b8f8e95c5..271007dd47512104e5c152605ca10bd2e356ce38 100644 (file)
@@ -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
index 8aeb815cf26083eba332161db26e188f05c21008..5e0e06b27a73a458602a5f0d4cc3b3f4486f096a 100644 (file)
@@ -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
 
 
 /*
index 53a4f368f2e204fd63f1ab68d7588d3275ccfae5..5938b744ce465608153cb02f7fbbc50eddc8a610 100644 (file)
@@ -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
index cfc3d7778860fdba7302632288a6d754589223af..4689476ecfba888fac0c9e5d2c6e40734dffcf98 100644 (file)
 #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.)
index dd392774331ecf82dce08c0c21999663c5580b83..634a7902587e96304794d20e9350f488c29c5b47 100644 (file)
@@ -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
index 2644f04ddb03e55af75ac4cd7b53eae04f4218bc..1caadb172ea9539f508c69695be28eafc5ef2d73 100644 (file)
@@ -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  */
 
index 111490fd8fc8d18eb231570a0b7ba694e9a4d068..9060b27c58d4499434c0a4cf67a9c0821a55b9d4 100644 (file)
@@ -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
index 7339ef1cb887b096698f470466c2283e2fca6e06..3a074645a4ecce4585bfb5265d992c929639a7b5 100644 (file)
 #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
index 7af488833fc32bbbb760f5e43ee3e8fd285d9468..43adab4555c38411f053f930b5387a033ef3c6a0 100644 (file)
@@ -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
index ae8dd2c3f6642cbad27b44def93018ed15830e6d..1987d67f542e5ca37a33b599ca09c505c099f511 100644 (file)
@@ -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
index 642da810a58e411af5e1201197d4782a7a6e13d0..77b2eea96f299dd02a88591bb371f4f1e1eb67dc 100644 (file)
@@ -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 *);
index 7a40722330bc07a53605d0af9bff70da5cd3518f..1e9836a348e5ad0b253924347d778c765b53ffc7 100644 (file)
@@ -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;
index 3c63127e14ff583522705df5a497af1075be9a8c..0e7dc18a422999d990edc54eb8b542867f5b62c2 100644 (file)
@@ -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)
index 7f1abfbabfe69748ad8dca9fb193bd3a95c9cf0e..97a232fe2b78b13193c8d89d9225c2acd122f181 100644 (file)
@@ -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");