diff options
Diffstat (limited to 'common')
-rw-r--r-- | common/cmd_bdinfo.c | 1 | ||||
-rw-r--r-- | common/cmd_elf.c | 62 | ||||
-rw-r--r-- | common/cmd_nvedit.c | 7 | ||||
-rw-r--r-- | common/cmd_otp.c | 13 | ||||
-rw-r--r-- | common/cmd_spi.c | 40 | ||||
-rw-r--r-- | common/env_common.c | 5 | ||||
-rw-r--r-- | common/env_mmc.c | 3 | ||||
-rw-r--r-- | common/fdt_support.c | 17 | ||||
-rw-r--r-- | common/main.c | 7 | ||||
-rw-r--r-- | common/serial.c | 1 |
10 files changed, 111 insertions, 45 deletions
diff --git a/common/cmd_bdinfo.c b/common/cmd_bdinfo.c index 6b611b1..1326c8f 100644 --- a/common/cmd_bdinfo.c +++ b/common/cmd_bdinfo.c @@ -385,7 +385,6 @@ int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) bd_t *bd = gd->bd; char buf[32]; - print_num ("env_t", (ulong)bd->bi_env); print_num ("boot_params", (ulong)bd->bi_boot_params); print_num ("bi_memstart", bd->bi_memstart); print_num ("bi_memsize", bd->bi_memsize); diff --git a/common/cmd_elf.c b/common/cmd_elf.c index 104d6e6..bf32612 100644 --- a/common/cmd_elf.c +++ b/common/cmd_elf.c @@ -25,7 +25,8 @@ DECLARE_GLOBAL_DATA_PTR; #endif int valid_elf_image (unsigned long addr); -unsigned long load_elf_image (unsigned long addr); +static unsigned long load_elf_image_phdr(unsigned long addr); +static unsigned long load_elf_image_shdr(unsigned long addr); /* Allow ports to override the default behavior */ __attribute__((weak)) @@ -61,19 +62,34 @@ int do_bootelf (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { unsigned long addr; /* Address of the ELF image */ unsigned long rc; /* Return value from user code */ + char *sload, *saddr; /* -------------------------------------------------- */ int rcode = 0; - if (argc < 2) - addr = load_addr; + sload = saddr = NULL; + if (argc == 3) { + sload = argv[1]; + saddr = argv[2]; + } else if (argc == 2) { + if (argv[1][0] == '-') + sload = argv[1]; + else + saddr = argv[1]; + } + + if (saddr) + addr = simple_strtoul(saddr, NULL, 16); else - addr = simple_strtoul (argv[1], NULL, 16); + addr = load_addr; if (!valid_elf_image (addr)) return 1; - addr = load_elf_image (addr); + if (sload && sload[1] == 'p') + addr = load_elf_image_phdr(addr); + else + addr = load_elf_image_shdr(addr); printf ("## Starting application at 0x%08lx ...\n", addr); @@ -204,7 +220,7 @@ int do_bootvx (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) */ if (valid_elf_image (addr)) { - addr = load_elf_image (addr); + addr = load_elf_image_shdr (addr); } else { puts ("## Not an ELF image, assuming binary\n"); /* leave addr as load_addr */ @@ -258,7 +274,33 @@ int valid_elf_image (unsigned long addr) * A very simple elf loader, assumes the image is valid, returns the * entry point address. * ====================================================================== */ -unsigned long load_elf_image (unsigned long addr) +static unsigned long load_elf_image_phdr(unsigned long addr) +{ + Elf32_Ehdr *ehdr; /* Elf header structure pointer */ + Elf32_Phdr *phdr; /* Program header structure pointer */ + int i; + + ehdr = (Elf32_Ehdr *) addr; + phdr = (Elf32_Phdr *) (addr + ehdr->e_phoff); + + /* Load each program header */ + for (i = 0; i < ehdr->e_phnum; ++i) { + void *dst = (void *) 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); + if (phdr->p_filesz) + memcpy(dst, src, phdr->p_filesz); + if (phdr->p_filesz != phdr->p_memsz) + memset(dst + phdr->p_filesz, 0x00, phdr->p_memsz - phdr->p_filesz); + flush_cache((unsigned long)dst, phdr->p_filesz); + ++phdr; + } + + return ehdr->e_entry; +} + +static unsigned long load_elf_image_shdr(unsigned long addr) { Elf32_Ehdr *ehdr; /* Elf header structure pointer */ Elf32_Shdr *shdr; /* Section header structure pointer */ @@ -312,9 +354,11 @@ unsigned long load_elf_image (unsigned long addr) /* ====================================================================== */ U_BOOT_CMD( - bootelf, 2, 0, do_bootelf, + bootelf, 3, 0, do_bootelf, "Boot from an ELF image in memory", - " [address] - load address of ELF image." + "[-p|-s] [address]\n" + "\t- load ELF image at [address] via program headers (-p)\n" + "\t or via section headers (-s)" ); U_BOOT_CMD( diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c index c3d63b8..3d30c32 100644 --- a/common/cmd_nvedit.c +++ b/common/cmd_nvedit.c @@ -837,6 +837,13 @@ static cmd_tbl_t cmd_env_sub[] = { U_BOOT_CMD_MKENT(set, CONFIG_SYS_MAXARGS, 0, do_env_set, "", ""), }; +#if !defined(CONFIG_RELOC_FIXUP_WORKS) +void env_reloc(void) +{ + fixup_cmdtable(cmd_env_sub, ARRAY_SIZE(cmd_env_sub)); +} +#endif + static int do_env (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { cmd_tbl_t *cp; diff --git a/common/cmd_otp.c b/common/cmd_otp.c index 56f08e0..eb93eb2 100644 --- a/common/cmd_otp.c +++ b/common/cmd_otp.c @@ -82,6 +82,7 @@ static void set_otp_timing(bool write) int do_otp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { + char *cmd; uint32_t ret, base_flags; bool prompt_user, force_read; uint32_t (*otp_func)(uint32_t page, uint32_t flags, uint64_t *page_content); @@ -93,21 +94,21 @@ int do_otp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) prompt_user = false; base_flags = 0; - if (!strcmp(argv[1], "read")) + cmd = argv[1]; + if (!strcmp(cmd, "read")) otp_func = bfrom_OtpRead; - else if (!strcmp(argv[1], "dump")) { + else if (!strcmp(cmd, "dump")) { otp_func = bfrom_OtpRead; force_read = true; - } else if (!strcmp(argv[1], "write")) { + } else if (!strcmp(cmd, "write")) { otp_func = bfrom_OtpWrite; base_flags = OTP_CHECK_FOR_PREV_WRITE; if (!strcmp(argv[2], "--force")) { - argv[2] = argv[1]; argv++; --argc; } else prompt_user = false; - } else if (!strcmp(argv[1], "lock")) { + } else if (!strcmp(cmd, "lock")) { if (argc != 4) goto usage; otp_func = bfrom_OtpWrite; @@ -175,7 +176,7 @@ int do_otp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) } printf("OTP memory %s: addr 0x%p page 0x%03X count %zu ... ", - argv[1], addr, page, count); + cmd, addr, page, count); set_otp_timing(otp_func == bfrom_OtpWrite); if (otp_func == bfrom_OtpWrite && check_voltage()) { diff --git a/common/cmd_spi.c b/common/cmd_spi.c index bafa217..8c623c9 100644 --- a/common/cmd_spi.c +++ b/common/cmd_spi.c @@ -47,7 +47,9 @@ /* * Values from last command. */ -static unsigned int device; +static unsigned int bus; +static unsigned int cs; +static unsigned int mode; static int bitlen; static uchar dout[MAX_SPI_BYTES]; static uchar din[MAX_SPI_BYTES]; @@ -78,8 +80,18 @@ int do_spi (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) if ((flag & CMD_FLAG_REPEAT) == 0) { - if (argc >= 2) - device = simple_strtoul(argv[1], NULL, 10); + if (argc >= 2) { + mode = CONFIG_DEFAULT_SPI_MODE; + bus = simple_strtoul(argv[1], &cp, 10); + if (*cp == ':') { + cs = simple_strtoul(cp+1, &cp, 10); + } else { + cs = bus; + bus = CONFIG_DEFAULT_SPI_BUS; + } + if (*cp == '.'); + mode = simple_strtoul(cp+1, NULL, 10); + } if (argc >= 3) bitlen = simple_strtoul(argv[2], NULL, 10); if (argc >= 4) { @@ -91,7 +103,7 @@ int do_spi (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) if(tmp > 15) tmp -= ('a' - 'A'); if(tmp > 15) { - printf("Hex conversion error on %c, giving up.\n", *cp); + printf("Hex conversion error on %c\n", *cp); return 1; } if((j % 2) == 0) @@ -103,24 +115,20 @@ int do_spi (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) } if ((bitlen < 0) || (bitlen > (MAX_SPI_BYTES * 8))) { - printf("Invalid bitlen %d, giving up.\n", bitlen); + printf("Invalid bitlen %d\n", bitlen); return 1; } - /* FIXME: Make these parameters run-time configurable */ - slave = spi_setup_slave(CONFIG_DEFAULT_SPI_BUS, device, 1000000, - CONFIG_DEFAULT_SPI_MODE); + slave = spi_setup_slave(bus, cs, 1000000, mode); if (!slave) { - printf("Invalid device %d, giving up.\n", device); + printf("Invalid device %d:%d\n", bus, cs); return 1; } - debug ("spi chipsel = %08X\n", device); - spi_claim_bus(slave); if(spi_xfer(slave, bitlen, dout, din, SPI_XFER_BEGIN | SPI_XFER_END) != 0) { - printf("Error with the SPI transaction.\n"); + printf("Error during SPI transaction\n"); rcode = 1; } else { for(j = 0; j < ((bitlen + 7) / 8); j++) { @@ -138,9 +146,11 @@ int do_spi (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) U_BOOT_CMD( sspi, 5, 1, do_spi, - "SPI utility commands", - "<device> <bit_len> <dout> - Send <bit_len> bits from <dout> out the SPI\n" - "<device> - Identifies the chip select of the device\n" + "SPI utility command", + "[<bus>:]<cs>[.<mode>] <bit_len> <dout> - Send and receive bits\n" + "<bus> - Identifies the SPI bus\n" + "<cs> - Identifies the chip select\n" + "<mode> - Identifies the SPI mode to use\n" "<bit_len> - Number of bits to send (base 10)\n" "<dout> - Hexadecimal string that gets sent" ); diff --git a/common/env_common.c b/common/env_common.c index a415ef8..88f068c 100644 --- a/common/env_common.c +++ b/common/env_common.c @@ -227,6 +227,11 @@ int env_import(const char *buf, int check) void env_relocate (void) { +#if !defined(CONFIG_RELOC_FIXUP_WORKS) + extern void env_reloc(void); + + env_reloc(); +#endif if (gd->env_valid == 0) { #if defined(CONFIG_ENV_IS_NOWHERE) /* Environment not changable */ set_default_env(NULL); diff --git a/common/env_mmc.c b/common/env_mmc.c index 14203b6..cc288d4 100644 --- a/common/env_mmc.c +++ b/common/env_mmc.c @@ -147,7 +147,6 @@ void env_relocate_spec(void) #if !defined(ENV_IS_EMBEDDED) static void use_default() { - puts ("*** Warning - bad CRC or MMC, using default environment\n\n"); - set_default_env(); + set_default_env(NULL); } #endif diff --git a/common/fdt_support.c b/common/fdt_support.c index 6f32e3f..0ed6e77 100644 --- a/common/fdt_support.c +++ b/common/fdt_support.c @@ -620,7 +620,7 @@ int fdt_fixup_nor_flash_size(void *blob) int off; int len; struct fdt_property *prop; - u32 *reg; + u32 *reg, *reg2; int i; for (i = 0; i < 2; i++) { @@ -640,18 +640,21 @@ int fdt_fixup_nor_flash_size(void *blob) * There might be multiple reg-tuples, * so loop through them all */ - len /= tuple_size; - reg = (u32 *)&prop->data[0]; - for (idx = 0; idx < len; idx++) { + reg = reg2 = (u32 *)&prop->data[0]; + for (idx = 0; idx < (len / tuple_size); idx++) { /* * Update size in reg property */ reg[2] = flash_get_bank_size(reg[0], idx); - fdt_setprop(blob, off, "reg", reg, - tuple_size); - reg += tuple_size; + + /* + * Point to next reg tuple + */ + reg += 3; } + + fdt_setprop(blob, off, "reg", reg2, len); } /* Move to next compatible node */ diff --git a/common/main.c b/common/main.c index 8d548db..d97ccd7 100644 --- a/common/main.c +++ b/common/main.c @@ -518,9 +518,6 @@ void reset_cmd_timeout(void) } while (0) #define CTL_CH(c) ((c) - 'a' + 1) - -#define MAX_CMDBUF_SIZE CONFIG_SYS_CBSIZE - #define CTL_BACKSPACE ('\b') #define DEL ((char)255) #define DEL7 ((char)127) @@ -531,7 +528,7 @@ void reset_cmd_timeout(void) #define getcmd_cbeep() getcmd_putch('\a') #define HIST_MAX 20 -#define HIST_SIZE MAX_CMDBUF_SIZE +#define HIST_SIZE CONFIG_SYS_CBSIZE static int hist_max = 0; static int hist_add_idx = 0; @@ -947,7 +944,7 @@ int readline_into_buffer (const char *const prompt, char * buffer) { char *p = buffer; #ifdef CONFIG_CMDLINE_EDITING - unsigned int len=MAX_CMDBUF_SIZE; + unsigned int len = CONFIG_SYS_CBSIZE; int rc; static int initted = 0; diff --git a/common/serial.c b/common/serial.c index 25b235a..7bebc12 100644 --- a/common/serial.c +++ b/common/serial.c @@ -54,6 +54,7 @@ struct serial_device *__default_serial_console (void) #else #error "Bad CONFIG_CONS_INDEX." #endif +#else return &serial0_device; #endif #elif defined(CONFIG_MPC512X) |