efi_loader: limit output length for VenHw, VenMedia
[pandora-u-boot.git] / cmd / spl.c
index 057764a..472703f 100644 (file)
--- a/cmd/spl.c
+++ b/cmd/spl.c
@@ -1,13 +1,17 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright (C) 2011
  * Corscience GmbH & Co. KG - Simon Schwarz <schwarz@corscience.de>
- *
- * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #include <common.h>
 #include <command.h>
 #include <cmd_spl.h>
+#include <env.h>
+#include <image.h>
+#include <log.h>
+#include <asm/global_data.h>
+#include <linux/libfdt.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -48,7 +52,7 @@ static const char **subcmd_list[] = {
 };
 
 /* Calls bootm with the parameters given */
-static int call_bootm(int argc, char * const argv[], const char *subcommand[])
+static int call_bootm(int argc, char *const argv[], const char *subcommand[])
 {
        char *bootm_argv[5];
 
@@ -94,30 +98,38 @@ static int call_bootm(int argc, char * const argv[], const char *subcommand[])
        return 0;
 }
 
-static cmd_tbl_t cmd_spl_export_sub[] = {
+static struct cmd_tbl cmd_spl_export_sub[] = {
        U_BOOT_CMD_MKENT(fdt, 0, 1, (void *)SPL_EXPORT_FDT, "", ""),
        U_BOOT_CMD_MKENT(atags, 0, 1, (void *)SPL_EXPORT_ATAGS, "", ""),
 };
 
-static int spl_export(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int spl_export(struct cmd_tbl *cmdtp, int flag, int argc,
+                     char *const argv[])
 {
-       const cmd_tbl_t *c;
+       const struct cmd_tbl *c;
 
        if (argc < 2) /* no subcommand */
                return cmd_usage(cmdtp);
 
        c = find_cmd_tbl(argv[1], &cmd_spl_export_sub[0],
                ARRAY_SIZE(cmd_spl_export_sub));
-       if ((c) && ((int)c->cmd <= SPL_EXPORT_LAST)) {
+       if ((c) && ((long)c->cmd <= SPL_EXPORT_LAST)) {
                argc -= 2;
                argv += 2;
-               if (call_bootm(argc, argv, subcmd_list[(int)c->cmd]))
+               if (call_bootm(argc, argv, subcmd_list[(long)c->cmd]))
                        return -1;
-               switch ((int)c->cmd) {
+               switch ((long)c->cmd) {
 #ifdef CONFIG_OF_LIBFDT
                case SPL_EXPORT_FDT:
                        printf("Argument image is now in RAM: 0x%p\n",
                                (void *)images.ft_addr);
+                       env_set_addr("fdtargsaddr", images.ft_addr);
+                       env_set_hex("fdtargslen", fdt_totalsize(images.ft_addr));
+#ifdef CONFIG_CMD_SPL_WRITE_SIZE
+                       if (fdt_totalsize(images.ft_addr) >
+                           CONFIG_CMD_SPL_WRITE_SIZE)
+                               puts("WARN: FDT size > CMD_SPL_WRITE_SIZE\n");
+#endif
                        break;
 #endif
                case SPL_EXPORT_ATAGS:
@@ -133,13 +145,13 @@ static int spl_export(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
        return 0;
 }
 
-static cmd_tbl_t cmd_spl_sub[] = {
+static struct cmd_tbl cmd_spl_sub[] = {
        U_BOOT_CMD_MKENT(export, 0, 1, (void *)SPL_EXPORT, "", ""),
 };
 
-static int do_spl(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_spl(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 {
-       const cmd_tbl_t *c;
+       const struct cmd_tbl *c;
        int cmd;
 
        if (argc < 2) /* no subcommand */
@@ -147,7 +159,7 @@ static int do_spl(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 
        c = find_cmd_tbl(argv[1], &cmd_spl_sub[0], ARRAY_SIZE(cmd_spl_sub));
        if (c) {
-               cmd = (int)c->cmd;
+               cmd = (long)c->cmd;
                switch (cmd) {
                case SPL_EXPORT:
                        argc--;