]> git.sur5r.net Git - u-boot/blobdiff - common/cmd_elf.c
bootm: Correct the arguments for the ELF image loader
[u-boot] / common / cmd_elf.c
index 970426fb3fb69fa442aff89b76ff9e7b8215622b..f741f6b83f942d967f5b1280e15db9c72e891062 100644 (file)
@@ -156,16 +156,16 @@ int do_bootvx(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
         * If we don't know where the image is then we're done.
         */
 
-       if (argc < 2)
+       if (argc < 1)
                addr = load_addr;
        else
-               addr = simple_strtoul(argv[1], NULL, 16);
+               addr = simple_strtoul(argv[0], NULL, 16);
 
 #if defined(CONFIG_CMD_NET)
        /*
         * Check to see if we need to tftp the image ourselves before starting
         */
-       if ((argc == 2) && (strcmp(argv[1], "tftp") == 0)) {
+       if ((argc == 1) && (strcmp(argv[0], "tftp") == 0)) {
                if (NetLoop(TFTPGET) <= 0)
                        return 1;
                printf("Automatic boot of VxWorks image at address 0x%08lx ...\n",
@@ -198,7 +198,7 @@ int do_bootvx(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
         * defaults to 0x4200
         */
        tmp = getenv("bootaddr");
-       if (tmp)
+       if (!tmp)
                bootaddr = CONFIG_SYS_VXWORKS_BOOT_ADDR;
        else
                bootaddr = simple_strtoul(tmp, NULL, 16);
@@ -284,7 +284,7 @@ static unsigned long load_elf_image_phdr(unsigned long addr)
 
        /* Load each program header */
        for (i = 0; i < ehdr->e_phnum; ++i) {
-               void *dst = (void *) phdr->p_paddr;
+               void *dst = (void *)(uintptr_t) phdr->p_paddr;
                void *src = (void *) addr + phdr->p_offset;
                debug("Loading phdr %i to 0x%p (%i bytes)\n",
                        i, dst, phdr->p_filesz);
@@ -339,10 +339,11 @@ static unsigned long load_elf_image_shdr(unsigned long addr)
                }
 
                if (shdr->sh_type == SHT_NOBITS) {
-                       memset((void *)shdr->sh_addr, 0, shdr->sh_size);
+                       memset((void *)(uintptr_t) shdr->sh_addr, 0,
+                               shdr->sh_size);
                } else {
                        image = (unsigned char *) addr + shdr->sh_offset;
-                       memcpy((void *) shdr->sh_addr,
+                       memcpy((void *)(uintptr_t) shdr->sh_addr,
                                (const void *) image,
                                shdr->sh_size);
                }