]> www.infradead.org Git - users/rw/ppcboot.git/commitdiff
Add pRAM feature / Memory size detection / test must be non-destructive to
authorwdenk <wdenk>
Thu, 5 Jul 2001 20:59:49 +0000 (20:59 +0000)
committerwdenk <wdenk>
Thu, 5 Jul 2001 20:59:49 +0000 (20:59 +0000)
make pRAM feature work.

18 files changed:
CHANGELOG
README
board/RPXlite/RPXlite.c
board/etx094/etx094.c
board/flagadm/flagadm.c
board/hermes/hermes.c
board/ip860/ip860.c
board/ivms8/ivms8.c
board/lantec/lantec.c
board/lwmon/lwmon.c
board/pcu_e/pcu_e.c
board/spd8xx/spd8xx.c
board/tqm8260/tqm8260.c
board/tqm8xx/tqm8xx.c
common/board.c
common/cmd_nvedit.c
include/config_ETX094.h
include/config_pcu_e.h

index d63c19d1164b0f1b719525ae0ee2396bb780d37e..21e45728fb040a3ca9ab9bbff8ed4fde42a1aeb6 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -70,14 +70,24 @@ Modifications for 1.0.2:
 - Added IH_OS_PPCBOOT and IH_TYPE_FIRMWARE to the image definitions
   to allow PPCBoot updates with CRC check.
 
+* Added CONFIG_PRAM option which allows to reserve some memory at the
+  upper end of memory which will remain unchanged by PPCBoot and
+  Linux ("protected RAM")
+
+* Added CONFIG_OVERWRITE_ETHADDR_ONCE option, which allows for a
+  default ethernet address that can be overwritten exactly ONCE by
+  the user
+
 * Added keyboard support to LWMON board (uses special I2C keyboard)
 
-* Fix bug in calculation of initrd size
+* Fixed bug in calculation of initrd size
   Patch by Hannes Fertala, 2 Jul 2001
 
-* Fix bug in environment offset handling
+* Fixed bug in environment offset handling
   (when environment starts not at the beginning of EEPROM).
 
+* Fixed bug in printenv command (when called with list of names)
+
 ======================================================================
 Modifications for 1.0.1:
 ======================================================================
diff --git a/README b/README
index a0e8dc84e629180fb827f5c4c73d77f90ea917b6..81cc0d2f7e9236df0207e73f0454b2b7156ed509 100644 (file)
--- a/README
+++ b/README
@@ -467,6 +467,63 @@ The following options need to be configured:
                 If defined, this string will be added to the PPCBoot
                 version information (PPCBOOT_VERSION)
 
+- Vendor Parameter Protection:
+                
+                PPCBoot considers the values of the environment
+                variables "serial#" (Board Serial Number) and
+                "ethaddr" (Ethernet Address) to bb parameters that
+                are set once by the board vendor / manufacturer, and
+                protects these variables from casual modification by
+                the user. Once set, these variables are read-only,
+                and write or delete attempts are rejected. You can
+                change this behviour:
+
+                If CONFIG_ENV_OVERWRITE is #defined in your config
+                file, the write protection for vendor parameters is
+                completely disabled. Anybody can change or delte
+                these parameters.
+
+                Alternatively, if you #define _both_ CONFIG_ETHADDR
+                _and_ CONFIG_OVERWRITE_ETHADDR_ONCE, a default
+                ethernet address is installed in the environment,
+                which can be changed exactly ONCE by the user. [The
+                serial# is unaffected by this, i. e. it remains
+                read-only.]
+
+- Protected RAM:
+               CONFIG_PRAM
+
+                Define this variable to enable the reservation of
+                "protected RAM", i. e. RAM which is not overwritten
+                by PPCBoot. Define CONFIG_PRAM to hold the number of
+                kB you want to reserve for pRAM. You can overwrite
+                this default value by defining an environment
+                variable "pram" to the number of kB you want to
+                reserve. Note that the board info structure will
+                still show the full amount of RAM. If pRAM is
+                reserved, a new environment variable "mem" will
+                automatically be defined to hold the amount of
+                remaining RAM in a form that can be passed as boot
+                argument to Linux, for instance like that:
+
+                       setenv bootargs ... mem=\$(mem)
+                       saveenv
+
+                This way you can tell Linux not to use this memory,
+                either, which results in a memory region that will
+                not be affected by reboots.
+
+                *WARNING* If your board configuration uses automatic
+                detection of the RAM size, you must make sure that
+                this memory test is non-destructive. So far, the
+                following board configurations are known to be
+                "pRAM-clean":
+
+                       ETX094, IVMS8, IVML24, SPD8xx, TQM8xxL,
+                       HERMES, IP860, RPXlite, LWMON, LANTEC,
+                       PCU_E, FLAGADM, TQM8260
+
+
 Configuration Settings:
 -----------------------
 
index e900de179166f0348f9f61abbb0935708e677a27..d02a836b9792e07a29689658ce5860bf55e0e9fa 100644 (file)
@@ -160,33 +160,39 @@ static long int dram_size (long int mamr_value, long int *base, long int maxsize
     volatile immap_t     *immap  = (immap_t *)CFG_IMMR;
     volatile memctl8xx_t *memctl = &immap->im_memctl;
     volatile long int   *addr;
-    long int             cnt, val;
+    ulong                cnt, val;
+    ulong                save[32];     /* to make test non-destructive */
+    unsigned char        i = 0;
 
     memctl->memc_mamr = mamr_value;
 
     for (cnt = maxsize/sizeof(long); cnt > 0; cnt >>= 1) {
        addr = base + cnt;      /* pointer arith! */
 
+       save[i++] = *addr;
        *addr = ~cnt;
     }
 
     /* write 0 to base address */
     addr = base;
+    save[i] = *addr;
     *addr = 0;
 
     /* check at base address */
     if ((val = *addr) != 0) {
+       *addr = save[i];
        return (0);
     }
 
-    for (cnt = 1; ; cnt <<= 1) {
+    for (cnt = 1; cnt <= maxsize/sizeof(long); cnt <<= 1) {
        addr = base + cnt;      /* pointer arith! */
 
        val = *addr;
+       *addr = save[--i];
 
        if (val != (~cnt)) {
            return (cnt * sizeof(long));
        }
     }
-    /* NOTREACHED */
+    return (maxsize);
 }
index 0f4c7e27c29447a35ad16bf4b80b518c5daed3a2..c8fb9cd03853fe76a845b3b65698c1df8ee9c501 100644 (file)
@@ -308,35 +308,41 @@ static long int dram_size (long int mamr_value, long int *base, long int maxsize
     volatile immap_t    *immap  = (immap_t *)CFG_IMMR;
     volatile memctl8xx_t *memctl = &immap->im_memctl;
     volatile long int   *addr;
-    long int             cnt, val;
+    ulong                cnt, val;
+    ulong                save[32];     /* to make test non-destructive */
+    unsigned char        i = 0;
 
     memctl->memc_mamr = mamr_value;
 
     for (cnt = maxsize/sizeof(long); cnt > 0; cnt >>= 1) {
        addr = base + cnt;      /* pointer arith! */
 
+       save[i++] = *addr;
        *addr = ~cnt;
     }
 
     /* write 0 to base address */
     addr = base;
+    save[i] = *addr;
     *addr = 0;
 
     /* check at base address */
     if ((val = *addr) != 0) {
+       *addr = save[i];
        return (0);
     }
 
-    for (cnt = 1; ; cnt <<= 1) {
+    for (cnt = 1; cnt <= maxsize/sizeof(long); cnt <<= 1) {
        addr = base + cnt;      /* pointer arith! */
 
        val = *addr;
+       *addr = save[--i];
 
        if (val != (~cnt)) {
            return (cnt * sizeof(long));
        }
     }
-    /* NOTREACHED */
+    return (maxsize);
 }
 
 /* ------------------------------------------------------------------------- */
index 75a454ac3ea31ab9f845d332fdd734f362b6a180..5922b61cc386805d1a28d596ef548cc972e22e7d 100644 (file)
@@ -127,33 +127,39 @@ static long int dram_size (long int mamr_value, long int *base, long int maxsize
     volatile immap_t     *immap  = (immap_t *)CFG_IMMR;
     volatile memctl8xx_t *memctl = &immap->im_memctl;
     volatile long int   *addr;
-    long int             cnt, val;
+    ulong                cnt, val;
+    ulong                save[32];     /* to make test non-destructive */
+    unsigned char        i = 0;
 
     memctl->memc_mamr = mamr_value;
 
     for (cnt = maxsize/sizeof(long); cnt > 0; cnt >>= 1) {
        addr = base + cnt;      /* pointer arith! */
 
+       save[i++] = *addr;
        *addr = ~cnt;
     }
 
     /* write 0 to base address */
     addr = base;
+    save[i] = *addr;
     *addr = 0;
 
     /* check at base address */
     if ((val = *addr) != 0) {
+       *addr = save[i];
        return (0);
     }
 
-    for (cnt = 1; ; cnt <<= 1) {
+    for (cnt = 1; cnt <= maxsize/sizeof(long); cnt <<= 1) {
        addr = base + cnt;      /* pointer arith! */
 
        val = *addr;
+       *addr = save[--i];
 
        if (val != (~cnt)) {
            return (cnt * sizeof(long));
        }
     }
-    /* NOTREACHED */
+    return (maxsize);
 }
index e25e34db5767b23044cc5be7f9ca81583b318e94..12e25304af84065191c9b321349bb82ac7ae2578 100644 (file)
@@ -212,35 +212,41 @@ static long int dram_size (long int mamr_value, long int *base, long int maxsize
     volatile immap_t     *immap  = (immap_t *)CFG_IMMR;
     volatile memctl8xx_t *memctl = &immap->im_memctl;
     volatile long int   *addr;
-    long int             cnt, val;
+    ulong                cnt, val;
+    ulong                save[32];     /* to make test non-destructive */
+    unsigned char        i = 0;
 
     memctl->memc_mamr = mamr_value;
 
     for (cnt = maxsize/sizeof(long); cnt > 0; cnt >>= 1) {
        addr = base + cnt;      /* pointer arith! */
 
+       save[i++] = *addr;
        *addr = ~cnt;
     }
 
     /* write 0 to base address */
     addr = base;
+    save[i] = *addr;
     *addr = 0;
 
     /* check at base address */
     if ((val = *addr) != 0) {
+       *addr = save[i];
        return (0);
     }
 
-    for (cnt = 1; ; cnt <<= 1) {
+    for (cnt = 1; cnt <= maxsize/sizeof(long); cnt <<= 1) {
        addr = base + cnt;      /* pointer arith! */
 
        val = *addr;
+       *addr = save[--i];
 
        if (val != (~cnt)) {
            return (cnt * sizeof(long));
        }
     }
-    /* NOTREACHED */
+    return (maxsize);
 }
 
 /* ------------------------------------------------------------------------- */
index e20df2f0369b9e4db3269e8c907464581b7ec4f1..8b7c13ac3a8a26fc685ff411c4f8c1adea403287 100644 (file)
@@ -223,35 +223,41 @@ static long int dram_size (long int mamr_value, long int *base, long int maxsize
     volatile immap_t     *immap  = (immap_t *)CFG_IMMR;
     volatile memctl8xx_t *memctl = &immap->im_memctl;
     volatile long int   *addr;
-    long int             cnt, val;
+    ulong                cnt, val;
+    ulong                save[32];     /* to make test non-destructive */
+    unsigned char        i = 0;
 
     memctl->memc_mamr = mamr_value;
 
     for (cnt = maxsize/sizeof(long); cnt > 0; cnt >>= 1) {
        addr = base + cnt;      /* pointer arith! */
 
+       save[i++] = *addr;
        *addr = ~cnt;
     }
 
     /* write 0 to base address */
     addr = base;
+    save[i] = *addr;
     *addr = 0;
 
     /* check at base address */
     if ((val = *addr) != 0) {
+       *addr = save[i];
        return (0);
     }
 
-    for (cnt = 1; ; cnt <<= 1) {
+    for (cnt = 1; cnt <= maxsize/sizeof(long); cnt <<= 1) {
        addr = base + cnt;      /* pointer arith! */
 
        val = *addr;
+       *addr = save[--i];
 
        if (val != (~cnt)) {
            return (cnt * sizeof(long));
        }
     }
-    /* NOTREACHED */
+    return (maxsize);
 }
 
 /* ------------------------------------------------------------------------- */
index 9e805e3e220a0c6021cd6f5a7ec86aaa07a8cfef..1c9fbdd0d9adfd4ee9c103ef56666ca2f2668b37 100644 (file)
@@ -252,35 +252,41 @@ static long int dram_size (long int mamr_value, long int *base, long int maxsize
     volatile immap_t     *immr  = (immap_t *)CFG_IMMR;
     volatile memctl8xx_t *memctl = &immr->im_memctl;
     volatile long int   *addr;
-    long int             cnt, val;
+    ulong                cnt, val;
+    ulong                save[32];     /* to make test non-destructive */
+    unsigned char        i = 0;
 
     memctl->memc_mbmr = mamr_value;
 
     for (cnt = maxsize/sizeof(long); cnt > 0; cnt >>= 1) {
        addr = base + cnt;      /* pointer arith! */
 
+       save[i++] = *addr;
        *addr = ~cnt;
     }
 
     /* write 0 to base address */
     addr = base;
+    save[i] = *addr;
     *addr = 0;
 
     /* check at base address */
     if ((val = *addr) != 0) {
+       *addr = save[i];
        return (0);
     }
 
-    for (cnt = 1; ; cnt <<= 1) {
+    for (cnt = 1; cnt <= maxsize/sizeof(long); cnt <<= 1) {
        addr = base + cnt;      /* pointer arith! */
 
        val = *addr;
+       *addr = save[--i];
 
        if (val != (~cnt)) {
            return (cnt * sizeof(long));
        }
     }
-    /* NOTREACHED */
+    return (maxsize);
 }
 
 /* ------------------------------------------------------------------------- */
index bfef05f3808d1a54dd6dc36a6bfa4183ab345b11..69da0034b55e81e0d384ef2113fe9f2f1a46b8ef 100644 (file)
@@ -198,33 +198,39 @@ static long int dram_size (long int mamr_value, long int *base, long int maxsize
     volatile immap_t     *immap  = (immap_t *)CFG_IMMR;
     volatile memctl8xx_t *memctl = &immap->im_memctl;
     volatile long int   *addr;
-    long int             cnt, val;
+    ulong                cnt, val;
+    ulong                save[32];     /* to make test non-destructive */
+    unsigned char        i = 0;
 
     memctl->memc_mamr = mamr_value;
 
     for (cnt = maxsize/sizeof(long); cnt > 0; cnt >>= 1) {
        addr = base + cnt;      /* pointer arith! */
 
+       save[i++] = *addr;
        *addr = ~cnt;
     }
 
     /* write 0 to base address */
     addr = base;
+    save[i] = *addr;
     *addr = 0;
 
     /* check at base address */
     if ((val = *addr) != 0) {
+       *addr = save[i];
        return (0);
     }
 
-    for (cnt = 1; ; cnt <<= 1) {
+    for (cnt = 1; cnt <= maxsize/sizeof(long); cnt <<= 1) {
        addr = base + cnt;      /* pointer arith! */
 
        val = *addr;
+       *addr = save[--i];
 
        if (val != (~cnt)) {
            return (cnt * sizeof(long));
        }
     }
-    /* NOTREACHED */
+    return (maxsize);
 }
index c12f7f812da24f5d1d0f6d2397cdf97f7550f6a0..85066ab5220013de7992860e032ba1e6e1aa7025 100644 (file)
@@ -192,35 +192,41 @@ static long int dram_size (long int mamr_value, long int *base, long int maxsize
     volatile immap_t     *immr  = (immap_t *)CFG_IMMR;
     volatile memctl8xx_t *memctl = &immr->im_memctl;
     volatile long int   *addr;
-    long int             cnt, val;
+    ulong                cnt, val;
+    ulong                save[32];     /* to make test non-destructive */
+    unsigned char        i = 0;
 
     memctl->memc_mamr = mamr_value;
 
     for (cnt = maxsize/sizeof(long); cnt > 0; cnt >>= 1) {
        addr = base + cnt;      /* pointer arith! */
 
+       save[i++] = *addr;
        *addr = ~cnt;
     }
 
     /* write 0 to base address */
     addr = base;
+    save[i] = *addr;
     *addr = 0;
 
     /* check at base address */
     if ((val = *addr) != 0) {
+       *addr = save[i];
        return (0);
     }
 
-    for (cnt = 1; ; cnt <<= 1) {
+    for (cnt = 1; cnt <= maxsize/sizeof(long); cnt <<= 1) {
        addr = base + cnt;      /* pointer arith! */
 
        val = *addr;
+       *addr = save[--i];
 
        if (val != (~cnt)) {
            return (cnt * sizeof(long));
        }
     }
-    /* NOTREACHED */
+    return (maxsize);
 }
 
 /* ------------------------------------------------------------------------- */
index d255749dfe6f45adef6a35e1190d7d66b89c3ec0..d90c7659bfca5e6cb38b5b289fe8fabb76f1ec46 100644 (file)
@@ -285,35 +285,41 @@ static long int dram_size (long int mamr_value, long int *base, long int maxsize
     volatile immap_t     *immr  = (immap_t *)CFG_IMMR;
     volatile memctl8xx_t *memctl = &immr->im_memctl;
     volatile long int   *addr;
-    long int             cnt, val;
+    ulong                cnt, val;
+    ulong                save[32];     /* to make test non-destructive */
+    unsigned char        i = 0;
 
     memctl->memc_mamr = mamr_value;
 
     for (cnt = maxsize/sizeof(long); cnt > 0; cnt >>= 1) {
        addr = base + cnt;      /* pointer arith! */
 
+       save[i++] = *addr;
        *addr = ~cnt;
     }
 
     /* write 0 to base address */
     addr = base;
+    save[i] = *addr;
     *addr = 0;
 
     /* check at base address */
     if ((val = *addr) != 0) {
+       *addr = save[i];
        return (0);
     }
 
-    for (cnt = 1; ; cnt <<= 1) {
+    for (cnt = 1; cnt <= maxsize/sizeof(long); cnt <<= 1) {
        addr = base + cnt;      /* pointer arith! */
 
        val = *addr;
+       *addr = save[--i];
 
        if (val != (~cnt)) {
            return (cnt * sizeof(long));
        }
     }
-    /* NOTREACHED */
+    return (maxsize);
 }
 
 /* ------------------------------------------------------------------------- */
index 2f658e285b726ba3efe1ab518ba5abe634ead0f0..27c2f040f8cbd06bf7497ba76f063af92b6fd82b 100644 (file)
@@ -227,35 +227,41 @@ static long int dram_size (long int mamr_value, long int *base, long int maxsize
     volatile immap_t     *immap  = (immap_t *)CFG_IMMR;
     volatile memctl8xx_t *memctl = &immap->im_memctl;
     volatile long int   *addr;
-    long int             cnt, val;
+    ulong                cnt, val;
+    ulong                save[32];     /* to make test non-destructive */
+    unsigned char        i = 0;
 
     memctl->memc_mbmr = mamr_value;
 
     for (cnt = maxsize/sizeof(long); cnt > 0; cnt >>= 1) {
        addr = base + cnt;      /* pointer arith! */
 
+       save[i++] = *addr;
        *addr = ~cnt;
     }
 
     /* write 0 to base address */
     addr = base;
+    save[i] = *addr;
     *addr = 0;
 
     /* check at base address */
     if ((val = *addr) != 0) {
+       *addr = save[i];
        return (0);
     }
 
-    for (cnt = 1; ; cnt <<= 1) {
+    for (cnt = 1; cnt <= maxsize/sizeof(long); cnt <<= 1) {
        addr = base + cnt;      /* pointer arith! */
 
        val = *addr;
+       *addr = save[--i];
 
        if (val != (~cnt)) {
            return (cnt * sizeof(long));
        }
     }
-    /* NOTREACHED */
+    return (maxsize);
 }
 
 /* ------------------------------------------------------------------------- */
index 4574df3ca6b0c20e39e45b9cfa731fceed5e3645..c2e2a52a3c2457c411d5178a9ca37051868d3ef0 100644 (file)
@@ -207,12 +207,13 @@ long int try_init(volatile memctl8260_t *memctl, ulong sdmr, ulong orx,
     volatile uint *    sdmr_ptr;
     volatile uint *    orx_ptr;
     int                        i;
+    ulong              save[32];       /* to make test non-destructive */
 
     /* Since CFG_SDRAM_BASE is always 0 (??), we assume that
      * we are configuring CS1 if base != 0
      */
     sdmr_ptr = base ? &memctl->memc_lsdmr : &memctl->memc_psdmr;
-    orx_ptr = base ? &memctl->memc_or2 : &memctl->memc_or1;
+    orx_ptr  = base ? &memctl->memc_or2   : &memctl->memc_or1;
 
     *orx_ptr = orx;
 
@@ -256,33 +257,39 @@ long int try_init(volatile memctl8260_t *memctl, ulong sdmr, ulong orx,
      * - short between address lines
      * - short between data lines
      */
-    for (cnt = 0x04000000/sizeof(long); cnt > 0; cnt >>= 1)
-    {
+#define        MAXSIZE 0x04000000
+    i = 0;
+    for (cnt = MAXSIZE/sizeof(long); cnt > 0; cnt >>= 1) {
        addr = (volatile ulong *)base + cnt;    /* pointer arith! */
+       save[i++] = *addr;
        *addr = ~cnt;
     }
 
     addr = (volatile ulong *)base;
+    save[i] = *addr;
     *addr = 0;
 
-    if ((val = *addr) != 0)
-    {
+    if ((val = *addr) != 0) {
+       *addr = save[i];
+       return (0);
+    }
+
+    for (cnt = 1; cnt <= MAXSIZE/sizeof(long); cnt <<= 1) {
        return (0);
     }
 
-    for (cnt = 1; ; cnt <<=1)
-    {
+    for (cnt = 1; ; cnt <<=1) {
         addr = (volatile ulong *)base + cnt;   /* pointer arith! */
        val = *addr;
-       if (val != ~cnt)
-       {
+       *addr = save[--i];
+       if (val != ~cnt) {
            /* Write the actual size to ORx
             */
            *orx_ptr = orx | ~(cnt * sizeof(long) - 1);
            return (cnt * sizeof(long));
        }
     }
-    /* NOTREACHED */
+    return (MAXSIZE);
 }
 
 long int initdram(int board_type)
@@ -308,13 +315,10 @@ long int initdram(int board_type)
     size9 = try_init(memctl, CFG_PSDMR_9COL, CFG_OR1_9COL,
                (uchar *) CFG_SDRAM_BASE);
 
-    if (size8 < size9)
-    {
+    if (size8 < size9) {
        psize = size9;
        printf("(60x:9COL - %ld MB, ", psize >> 20);
-    }
-    else
-    {
+    } else {
        psize = try_init(memctl, CFG_PSDMR_8COL, CFG_OR1_8COL,
                (uchar *) CFG_SDRAM_BASE);
        printf("(60x:8COL - %ld MB, ", psize >> 20);
@@ -329,13 +333,10 @@ long int initdram(int board_type)
     size9 = try_init(memctl, CFG_LSDMR_9COL, CFG_OR2_9COL,
                (uchar *) SDRAM_BASE2_PRELIM);
 
-    if (size8 < size9)
-    {
+    if (size8 < size9) {
        lsize = size9;
        printf("Local:9COL - %ld MB) using ", lsize >> 20);
-    }
-    else
-    {
+    } else {
        lsize = try_init(memctl, CFG_LSDMR_8COL, CFG_OR2_8COL,
                (uchar *) SDRAM_BASE2_PRELIM);
        printf("Local:8COL - %ld MB) using ", lsize >> 20);
@@ -353,4 +354,3 @@ long int initdram(int board_type)
 
     return (psize);
 }
-
index 68bd7380dae45ca0b465024ecbd167f1f72b6a7c..978f6182e2460a57a97cf91edf39d47d84be4498 100644 (file)
@@ -356,33 +356,39 @@ static long int dram_size (long int mamr_value, long int *base, long int maxsize
     volatile immap_t     *immap  = (immap_t *)CFG_IMMR;
     volatile memctl8xx_t *memctl = &immap->im_memctl;
     volatile long int   *addr;
-    long int             cnt, val;
+    ulong                cnt, val;
+    ulong                save[32];     /* to make test non-destructive */
+    unsigned char        i = 0;
 
     memctl->memc_mamr = mamr_value;
 
     for (cnt = maxsize/sizeof(long); cnt > 0; cnt >>= 1) {
        addr = base + cnt;      /* pointer arith! */
 
+       save[i++] = *addr;
        *addr = ~cnt;
     }
 
     /* write 0 to base address */
     addr = base;
+    save[i] = *addr;
     *addr = 0;
 
     /* check at base address */
     if ((val = *addr) != 0) {
+       *addr = save[i];
        return (0);
     }
 
-    for (cnt = 1; ; cnt <<= 1) {
+    for (cnt = 1; cnt <= maxsize/sizeof(long); cnt <<= 1) {
        addr = base + cnt;      /* pointer arith! */
 
        val = *addr;
+       *addr = save[--i];
 
        if (val != (~cnt)) {
            return (cnt * sizeof(long));
        }
     }
-    /* NOTREACHED */
+    return (maxsize);
 }
index c47ae26cf630f996f4c89da8671750e76db8054e..3b647b05cb57475dd30de8c3d92bee862642b607 100644 (file)
@@ -269,8 +269,19 @@ board_init_f (ulong bootflag)
                len, CFG_MONITOR_LEN);
        hang();
     }
+
     if (CFG_MONITOR_LEN > len)
        len = CFG_MONITOR_LEN;
+
+#ifdef CONFIG_PRAM             /* reserve protected RAM at top of memory */
+    i = getenv_r ("pram", tmp, sizeof(tmp));
+    reg = (i > 0) ? simple_strtoul(tmp, NULL, 10) : CONFIG_PRAM;
+# ifdef DEBUG
+    printf ("  Reserving %ldk for protected RAM\n", reg);
+# endif
+    len += (reg << 10);                /* size is in kB */
+#endif /* CONFIG_PRAM */
+
     /* round up to next 4 kB limit */
     len = (len + (4096 - 1)) & ~(4096 - 1);
 
@@ -658,6 +669,26 @@ void    board_init_r  (bd_t *bd, ulong dest_addr)
     putc('\n');
 /**********************/
 
+#ifdef CONFIG_PRAM
+    /*
+     * Export available size of memory for Linux,
+     * taking into account the protected RAM at top of memory
+     */
+    {
+       ulong   pram;
+       char    *s;
+       uchar   memsz[32];
+
+       if ((s = getenv("pram")) != NULL) {
+               pram = simple_strtoul(s, NULL, 10);
+       } else {
+               pram = CONFIG_PRAM;
+       }
+       sprintf (memsz, "%ldk", (bd->bi_memsize / 1024) - pram);
+       setenv ("mem", memsz);
+    }
+#endif
+
     /* Initialization complete - start the monitor */
 
     /* main_loop() can return to retry autoboot, if so just run it again. */
index 7aba8595b102b5ce64d06447516114ef4282f57a..d82aabfcd00dab905a52aea9643ca695923ef9f2 100644 (file)
@@ -293,7 +293,7 @@ static uchar get_env_char_eeprom (int index)
 
 void do_printenv (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[])
 {
-       int i, k, nxt;
+       int i, j, k, nxt;
 
        if (argc == 1) {                /* Print all env variables      */
                for (i=0; get_env_char(i) != '\0'; i=nxt+1) {
@@ -319,11 +319,11 @@ void do_printenv (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[])
 
                k = -1;
 
-               for (i=0; get_env_char(i) != '\0'; i=nxt+1) {
+               for (j=0; get_env_char(j) != '\0'; j=nxt+1) {
 
-                       for (nxt=i; get_env_char(nxt) != '\0'; ++nxt)
+                       for (nxt=j; get_env_char(nxt) != '\0'; ++nxt)
                                ;
-                       k = envmatch(name, i);
+                       k = envmatch(name, j);
                        if (k < 0) {
                                continue;
                        }
@@ -376,11 +376,16 @@ void _do_setenv (bd_t *bd, int flag, int argc, char *argv[])
         */
        if (oldval >= 0) {
 #ifndef CONFIG_ENV_OVERWRITE
+
                /*
                 * Ethernet Address and serial# can be set only once
                 */
-               if ((strcmp (name, "ethaddr") == 0) ||
-                   (strcmp (name, "serial#") == 0) ) {
+               if ( (strcmp (name, "serial#") == 0) ||
+                   ((strcmp (name, "ethaddr") == 0)
+#if defined(CONFIG_OVERWRITE_ETHADDR_ONCE) && defined(CONFIG_ETHADDR)
+                    && (strcmp (get_env_addr(oldval),MK_STR(CONFIG_ETHADDR)) != 0)
+#endif /* CONFIG_OVERWRITE_ETHADDR_ONCE && CONFIG_ETHADDR */
+                   ) ) {
                        printf ("Can't overwrite \"%s\"\n", name);
                        return;
                }
@@ -688,8 +693,8 @@ int getenv_r (uchar *name, uchar *buf, unsigned len)
  * Match a name / name=value pair
  *
  * s1 is either a simple 'name', or a 'name=value' pair.
- * i2 is the environment index for a 'name=value' pair.
- * If the names match, return the value of s2, else NULL.
+ * i2 is the environment index for a 'name2=value2' pair.
+ * If the names match, return the index for the value2, else NULL.
  */
 
 static int
index fd91c58eb72188470cd990eb3ef983a22114e3ab..231aa3d244328be18b817e9660e4449cbfbfd9ee 100644 (file)
@@ -60,7 +60,7 @@
 #define CONFIG_RAMBOOTCOMMAND                                                  \
        "bootp; "                                                               \
        "setenv bootargs root=/dev/ram rw ramdisk_size=4690 "                   \
-       "ppcboot_version=ppcboot-1.0.0-June_14_2001 "                           \
+       "ppcboot_version=ppcboot-1.0.x-Date "                                   \
        "panic=1 "                                                              \
        "ip=$(ipaddr):$(serverip):$(gatewayip):$(netmask):$(hostname)::off; "   \
        "bootm"
index 69acb80a21eae3aeb2502ab19bca16de6f570f43..227d3c998c6c898c9555c918c0b1d914fb081dca 100644 (file)
@@ -64,6 +64,8 @@
 
 #define        CONFIG_STATUS_LED               /* Status LED enabled           */
 
+#define        CONFIG_PRAM             2048    /* reserve 2 MB "protected RAM" */
+
 #define        CONFIG_RTC_MPC8xx               /* use internal RTC of MPC8xx   */
 
 #define        CONFIG_SPI                      /* enable SPI driver            */