]> git.karo-electronics.de Git - karo-tx-uboot.git/blobdiff - board/esd/pmc440/cmd_pmc440.c
Merge branch 'master' of git://git.denx.de/u-boot-arm
[karo-tx-uboot.git] / board / esd / pmc440 / cmd_pmc440.c
index 02028768f94e38dd15bf29575713359efd29e889..40b135f2ba0e15ee1fe267cd89e6d88f7bdf6de9 100644 (file)
@@ -2,24 +2,7 @@
  * (C) Copyright 2007-2008
  * Matthias Fuchs, esd Gmbh, matthias.fuchs@esd-electronics.com.
  *
- * See file CREDITS for list of people who contributed to this
- * project.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
- *
+ * SPDX-License-Identifier:    GPL-2.0+
  */
 #include <common.h>
 #include <command.h>
@@ -342,7 +325,8 @@ U_BOOT_CMD(
 
 #if defined(CONFIG_PRAM)
 #include <environment.h>
-extern env_t *env_ptr;
+#include <search.h>
+#include <errno.h>
 
 int do_painit(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
@@ -351,6 +335,10 @@ int do_painit(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
        u32 param;
        ulong *lptr;
 
+       env_t *envp;
+       char *res;
+       int len;
+
        v = getenv("pram");
        if (v)
                pram = simple_strtoul(v, NULL, 10);
@@ -359,16 +347,16 @@ int do_painit(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
                return 1;
        }
 
-       base = gd->bd->bi_memsize;
+       base = (u32)gd->ram_size;
 #if defined(CONFIG_LOGBUFFER)
        base -= LOGBUFF_LEN + LOGBUFF_OVERHEAD;
 #endif
        /*
-        * gd->bd->bi_memsize == physical ram size - CONFIG_SYS_MEM_TOP_HIDE
+        * gd->ram_size == physical ram size - CONFIG_SYS_MEM_TOP_HIDE
         */
        param = base - (pram << 10);
        printf("PARAM: @%08x\n", param);
-       debug("memsize=0x%08x, base=0x%08x\n", (u32)gd->bd->bi_memsize, base);
+       debug("memsize=0x%08x, base=0x%08x\n", (u32)gd->ram_size, base);
 
        /* clear entire PA ram */
        memset((void*)param, 0, (pram << 10));
@@ -384,7 +372,15 @@ int do_painit(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 
        /* env is first (4k aligned) */
        nextbase -= ((CONFIG_ENV_SIZE + 4096 - 1) & ~(4096 - 1));
-       memcpy((void*)nextbase, env_ptr, CONFIG_ENV_SIZE);
+       envp = (env_t *)nextbase;
+       res = (char *)envp->data;
+       len = hexport_r(&env_htab, '\0', 0, &res, ENV_SIZE, 0, NULL);
+       if (len < 0) {
+               error("Cannot export environment: errno = %d\n", errno);
+               return 1;
+       }
+       envp->crc = crc32(0, envp->data, ENV_SIZE);
+
        *(--lptr) = CONFIG_ENV_SIZE;     /* size */
        *(--lptr) = base - nextbase;  /* offset | type=0 */