]> git.sur5r.net Git - u-boot/blobdiff - common/cmd_source.c
sdhci: Add sdhci support for spear devices
[u-boot] / common / cmd_source.c
index c4cde982a546a0d6be8955ce3acaad5d1f5b6694..f0d7f52bcec0643f5e7ce89fe23b9dba6df96605 100644 (file)
@@ -36,6 +36,7 @@
 #include <image.h>
 #include <malloc.h>
 #include <asm/byteorder.h>
+#include <asm/io.h>
 #if defined(CONFIG_8xx)
 #include <mpc8xx.h>
 #endif
@@ -44,9 +45,10 @@ int
 source (ulong addr, const char *fit_uname)
 {
        ulong           len;
-       image_header_t  *hdr;
+       const image_header_t *hdr;
        ulong           *data;
        int             verify;
+       void *buf;
 #if defined(CONFIG_FIT)
        const void*     fit_hdr;
        int             noffset;
@@ -56,9 +58,10 @@ source (ulong addr, const char *fit_uname)
 
        verify = getenv_yesno ("verify");
 
-       switch (genimg_get_format ((void *)addr)) {
+       buf = map_sysmem(addr, 0);
+       switch (genimg_get_format(buf)) {
        case IMAGE_FORMAT_LEGACY:
-               hdr = (image_header_t *)addr;
+               hdr = buf;
 
                if (!image_check_magic (hdr)) {
                        puts ("Bad magic number\n");
@@ -104,7 +107,7 @@ source (ulong addr, const char *fit_uname)
                        return 1;
                }
 
-               fit_hdr = (const void *)addr;
+               fit_hdr = buf;
                if (!fit_check_format (fit_hdr)) {
                        puts ("Bad FIT image format\n");
                        return 1;
@@ -177,9 +180,8 @@ do_source (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
        return rcode;
 }
 
-U_BOOT_CMD(
-       source, 2, 0,   do_source,
-       "run script from memory",
+#ifdef CONFIG_SYS_LONGHELP
+static char source_help_text[] =
        "[addr]\n"
        "\t- run script starting at addr\n"
        "\t- A valid image header must be present"
@@ -188,5 +190,11 @@ U_BOOT_CMD(
        "For FIT format uImage addr must include subimage\n"
        "unit name in the form of addr:<subimg_uname>"
 #endif
+       "";
+#endif
+
+U_BOOT_CMD(
+       source, 2, 0,   do_source,
+       "run script from memory", source_help_text
 );
 #endif