arm64: booti: allow to place kernel image anywhere in physical memory
[oweals/u-boot.git] / board / esd / pmc440 / cmd_pmc440.c
index 476e94096291855806cd46cc04adbb558c07429a..b7cd595362c3c25f7f26b9c43e579ea30fd0acc6 100644 (file)
@@ -2,27 +2,11 @@
  * (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>
+#include <console.h>
 #include <asm/io.h>
 #include <asm/cache.h>
 #include <asm/processor.h>
@@ -67,7 +51,7 @@ int fpga_interrupt(u32 arg)
        return rc;
 }
 
-int do_waithci(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
+int do_waithci(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
        pmc440_fpga_t *fpga = (pmc440_fpga_t *)FPGA_BA;
 
@@ -118,7 +102,7 @@ void dump_fifo(pmc440_fpga_t *fpga, int f, int *n)
        }
 }
 
-int do_fifo(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
+int do_fifo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
        pmc440_fpga_t *fpga = (pmc440_fpga_t *)FPGA_BA;
        int i;
@@ -269,7 +253,7 @@ U_BOOT_CMD(
        "'fifo' or 'address'"
 );
 
-int do_setup_bootstrap_eeprom(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
+int do_setup_bootstrap_eeprom(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
        ulong sdsdp[5];
        ulong delay;
@@ -342,15 +326,20 @@ 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 *argv[])
+int do_painit(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
        u32 pram, nextbase, base;
        char *v;
        u32 param;
        ulong *lptr;
 
+       env_t *envp;
+       char *res;
+       int len;
+
        v = getenv("pram");
        if (v)
                pram = simple_strtoul(v, NULL, 10);
@@ -359,16 +348,16 @@ int do_painit(cmd_tbl_t *cmdtp, int flag, int argc, char *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", 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 +373,15 @@ int do_painit(cmd_tbl_t *cmdtp, int flag, int argc, char *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 */
 
@@ -404,7 +401,7 @@ U_BOOT_CMD(
 );
 #endif /* CONFIG_PRAM */
 
-int do_selfreset(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
+int do_selfreset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
        in_be32((void*)CONFIG_SYS_RESET_BASE);
        return 0;
@@ -415,7 +412,7 @@ U_BOOT_CMD(
        ""
 );
 
-int do_resetout(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
+int do_resetout(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
        pmc440_fpga_t *fpga = (pmc440_fpga_t *)FPGA_BA;
 
@@ -452,7 +449,7 @@ U_BOOT_CMD(
        ""
 );
 
-int do_inta(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
+int do_inta(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
        if (is_monarch()) {
                printf("This command is only supported in non-monarch mode\n");
@@ -485,7 +482,7 @@ U_BOOT_CMD(
 );
 
 /* test-only */
-int do_pmm(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
+int do_pmm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
        ulong pciaddr;
 
@@ -518,7 +515,7 @@ U_BOOT_CMD(
 );
 
 #if defined(CONFIG_SYS_EEPROM_WREN)
-int do_eep_wren(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
+int do_eep_wren(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
        int query = argc == 1;
        int state = 0;