diff options
Diffstat (limited to 'common')
-rw-r--r-- | common/cmd_bdinfo.c | 4 | ||||
-rw-r--r-- | common/cmd_bmp.c | 2 | ||||
-rw-r--r-- | common/cmd_bootm.c | 2 | ||||
-rw-r--r-- | common/cmd_date.c | 6 | ||||
-rw-r--r-- | common/cmd_fpga.c | 50 | ||||
-rw-r--r-- | common/cmd_i2c.c | 2 | ||||
-rw-r--r-- | common/cmd_nvedit.c | 2 | ||||
-rw-r--r-- | common/cmd_onenand.c | 9 | ||||
-rw-r--r-- | common/cmd_pci.c | 13 | ||||
-rw-r--r-- | common/command.c | 2 | ||||
-rw-r--r-- | common/dlmalloc.c | 2 | ||||
-rw-r--r-- | common/env_common.c | 2 | ||||
-rw-r--r-- | common/env_flash.c | 3 | ||||
-rw-r--r-- | common/env_sf.c | 172 | ||||
-rw-r--r-- | common/fdt_support.c | 1 | ||||
-rw-r--r-- | common/hush.c | 4 | ||||
-rw-r--r-- | common/hwconfig.c | 21 | ||||
-rw-r--r-- | common/image.c | 91 | ||||
-rw-r--r-- | common/serial.c | 4 | ||||
-rw-r--r-- | common/stdio.c | 4 | ||||
-rw-r--r-- | common/usb_storage.c | 2 |
21 files changed, 208 insertions, 190 deletions
diff --git a/common/cmd_bdinfo.c b/common/cmd_bdinfo.c index 1326c8f..bba7374 100644 --- a/common/cmd_bdinfo.c +++ b/common/cmd_bdinfo.c @@ -192,7 +192,7 @@ int do_bdinfo(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) printf("CONFIG_SYS_PROM_OFFSET = 0x%lx (%d)\n", CONFIG_SYS_PROM_OFFSET, CONFIG_SYS_PROM_SIZE); printf("CONFIG_SYS_GBL_DATA_OFFSET = 0x%lx (%d)\n", CONFIG_SYS_GBL_DATA_OFFSET, - CONFIG_SYS_GBL_DATA_SIZE); + GENERATED_GBL_DATA_SIZE); #if defined(CONFIG_CMD_NET) print_eth(0); @@ -343,7 +343,6 @@ int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) printf ("ip_addr = %pI4\n", &bd->bi_ip_addr); #endif printf ("baudrate = %d bps\n", bd->bi_baudrate); -#if !defined(CONFIG_SYS_ARM_WITHOUT_RELOC) #if !(defined(CONFIG_SYS_NO_ICACHE) && defined(CONFIG_SYS_NO_DCACHE)) print_num ("TLB addr", gd->tlb_addr); #endif @@ -352,7 +351,6 @@ int do_bdinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) print_num ("irq_sp", gd->irq_sp); /* irq stack pointer */ print_num ("sp start ", gd->start_addr_sp); print_num ("FB base ", gd->fb_base); -#endif return 0; } diff --git a/common/cmd_bmp.c b/common/cmd_bmp.c index 6fa8a15..f2a48f7 100644 --- a/common/cmd_bmp.c +++ b/common/cmd_bmp.c @@ -137,7 +137,7 @@ static cmd_tbl_t cmd_bmp_sub[] = { U_BOOT_CMD_MKENT(display, 5, 0, do_bmp_display, "", ""), }; -#ifndef CONFIG_RELOC_FIXUP_WORKS +#ifdef CONFIG_NEEDS_MANUAL_RELOC void bmp_reloc(void) { fixup_cmdtable(cmd_bmp_sub, ARRAY_SIZE(cmd_bmp_sub)); } diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c index ce3c77c..1a024f1 100644 --- a/common/cmd_bootm.c +++ b/common/cmd_bootm.c @@ -590,7 +590,7 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) ulong load_end = 0; int ret; boot_os_fn *boot_fn; -#ifndef CONFIG_RELOC_FIXUP_WORKS +#ifdef CONFIG_NEEDS_MANUAL_RELOC static int relocated = 0; /* relocate boot function table */ diff --git a/common/cmd_date.c b/common/cmd_date.c index 50b4240..8dbf16d 100644 --- a/common/cmd_date.c +++ b/common/cmd_date.c @@ -35,10 +35,10 @@ const char *weekdays[] = { "Sun", "Mon", "Tues", "Wednes", "Thurs", "Fri", "Satur", }; -#ifdef CONFIG_RELOC_FIXUP_WORKS -#define RELOC(a) a -#else +#ifdef CONFIG_NEEDS_MANUAL_RELOC #define RELOC(a) ((typeof(a))((unsigned long)(a) + gd->reloc_off)) +#else +#define RELOC(a) a #endif int mk_date (char *, struct rtc_time *); diff --git a/common/cmd_fpga.c b/common/cmd_fpga.c index e50c9de..0ad310f 100644 --- a/common/cmd_fpga.c +++ b/common/cmd_fpga.c @@ -163,6 +163,7 @@ int do_fpga (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) char *devstr = getenv ("fpga"); char *datastr = getenv ("fpgadata"); int rc = FPGA_FAIL; + int wrong_parms = 0; #if defined (CONFIG_FIT) const char *fit_uname = NULL; ulong fit_addr; @@ -229,6 +230,32 @@ int do_fpga (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) break; } + if (dev == FPGA_INVALID_DEVICE) { + puts("FPGA device not specified\n"); + op = FPGA_NONE; + } + + switch (op) { + case FPGA_NONE: + case FPGA_INFO: + break; + case FPGA_LOAD: + case FPGA_LOADB: + case FPGA_DUMP: + if (!fpga_data || !data_size) + wrong_parms = 1; + break; + case FPGA_LOADMK: + if (!fpga_data) + wrong_parms = 1; + break; + } + + if (wrong_parms) { + puts("Wrong parameters for FPGA request\n"); + op = FPGA_NONE; + } + switch (op) { case FPGA_NONE: return cmd_usage(cmdtp); @@ -342,17 +369,18 @@ static int fpga_get_op (char *opstr) } U_BOOT_CMD (fpga, 6, 1, do_fpga, - "loadable FPGA image support", - "fpga [operation type] [device number] [image address] [image size]\n" - "fpga operations:\n" - "\tinfo\tlist known device information\n" - "\tload\tLoad device from memory buffer\n" - "\tloadb\tLoad device from bitstream buffer (Xilinx devices only)\n" - "\tloadmk\tLoad device generated with mkimage\n" - "\tdump\tLoad device to memory buffer" + "loadable FPGA image support", + "[operation type] [device number] [image address] [image size]\n" + "fpga operations:\n" + " dump\t[dev]\t\t\tLoad device to memory buffer\n" + " info\t[dev]\t\t\tlist known device information\n" + " load\t[dev] [address] [size]\tLoad device from memory buffer\n" + " loadb\t[dev] [address] [size]\t" + "Load device from bitstream buffer (Xilinx only)\n" + " loadmk [dev] [address]\tLoad device generated with mkimage" #if defined(CONFIG_FIT) - "\n" - "\tFor loadmk operating on FIT format uImage address must include\n" - "\tsubimage unit name in the form of addr:<subimg_uname>" + "\n" + "\tFor loadmk operating on FIT format uImage address must include\n" + "\tsubimage unit name in the form of addr:<subimg_uname>" #endif ); diff --git a/common/cmd_i2c.c b/common/cmd_i2c.c index 0a0cfce..c272b0d 100644 --- a/common/cmd_i2c.c +++ b/common/cmd_i2c.c @@ -1284,7 +1284,7 @@ static cmd_tbl_t cmd_i2c_sub[] = { U_BOOT_CMD_MKENT(speed, 1, 1, do_i2c_bus_speed, "", ""), }; -#ifndef CONFIG_RELOC_FIXUP_WORKS +#ifdef CONFIG_NEEDS_MANUAL_RELOC void i2c_reloc(void) { fixup_cmdtable(cmd_i2c_sub, ARRAY_SIZE(cmd_i2c_sub)); } diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c index 3d30c32..3fd8abc 100644 --- a/common/cmd_nvedit.c +++ b/common/cmd_nvedit.c @@ -837,7 +837,7 @@ 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) +#if defined(CONFIG_NEEDS_MANUAL_RELOC) void env_reloc(void) { fixup_cmdtable(cmd_env_sub, ARRAY_SIZE(cmd_env_sub)); diff --git a/common/cmd_onenand.c b/common/cmd_onenand.c index 83d967b..33108f1 100644 --- a/common/cmd_onenand.c +++ b/common/cmd_onenand.c @@ -525,10 +525,19 @@ static cmd_tbl_t cmd_onenand_sub[] = { U_BOOT_CMD_MKENT(markbad, CONFIG_SYS_MAXARGS, 0, do_onenand_markbad, "", ""), }; +#ifdef CONFIG_NEEDS_MANUAL_RELOC +void onenand_reloc(void) { + fixup_cmdtable(cmd_onenand_sub, ARRAY_SIZE(cmd_onenand_sub)); +} +#endif + static int do_onenand(cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[]) { cmd_tbl_t *c; + if (argc < 2) + return cmd_usage(cmdtp); + mtd = &onenand_mtd; /* Strip off leading 'onenand' command argument */ diff --git a/common/cmd_pci.c b/common/cmd_pci.c index 4bde059..ccf5ada 100644 --- a/common/cmd_pci.c +++ b/common/cmd_pci.c @@ -497,6 +497,10 @@ int do_pci (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) if ((bdf = get_pci_dev(argv[2])) == -1) return 1; break; +#ifdef CONFIG_CMD_PCI_ENUM + case 'e': + break; +#endif default: /* scan bus */ value = 1; /* short listing */ bdf = 0; /* bus number */ @@ -518,6 +522,11 @@ int do_pci (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) return 0; case 'd': /* display */ return pci_cfg_display(bdf, addr, size, value); +#ifdef CONFIG_CMD_PCI_ENUM + case 'e': + pci_init(); + return 0; +#endif case 'n': /* next */ if (argc < 4) goto usage; @@ -545,6 +554,10 @@ U_BOOT_CMD( "list and access PCI Configuration Space", "[bus] [long]\n" " - short or long list of PCI devices on bus 'bus'\n" +#ifdef CONFIG_CMD_PCI_ENUM + "pci enum\n" + " - re-enumerate PCI buses\n" +#endif "pci header b.d.f\n" " - show header of PCI device 'bus.device.function'\n" "pci display[.b, .w, .l] b.d.f [address] [# of objects]\n" diff --git a/common/command.c b/common/command.c index d47d719..0020eac 100644 --- a/common/command.c +++ b/common/command.c @@ -466,7 +466,7 @@ int cmd_get_data_size(char* arg, int default_size) } #endif -#if !defined(CONFIG_RELOC_FIXUP_WORKS) +#if defined(CONFIG_NEEDS_MANUAL_RELOC) DECLARE_GLOBAL_DATA_PTR; void fixup_cmdtable(cmd_tbl_t *cmdtp, int size) diff --git a/common/dlmalloc.c b/common/dlmalloc.c index fce7a76..4871f4b 100644 --- a/common/dlmalloc.c +++ b/common/dlmalloc.c @@ -1491,7 +1491,7 @@ static mbinptr av_[NAV * 2 + 2] = { IAV(120), IAV(121), IAV(122), IAV(123), IAV(124), IAV(125), IAV(126), IAV(127) }; -#ifndef CONFIG_RELOC_FIXUP_WORKS +#ifdef CONFIG_NEEDS_MANUAL_RELOC void malloc_bin_reloc (void) { unsigned long *p = (unsigned long *)(&av_[2]); diff --git a/common/env_common.c b/common/env_common.c index 5acda4d..a276efc 100644 --- a/common/env_common.c +++ b/common/env_common.c @@ -227,7 +227,7 @@ int env_import(const char *buf, int check) void env_relocate (void) { -#if !defined(CONFIG_RELOC_FIXUP_WORKS) +#if defined(CONFIG_NEEDS_MANUAL_RELOC) extern void env_reloc(void); env_reloc(); diff --git a/common/env_flash.c b/common/env_flash.c index 1da78b7..54c0bfe 100644 --- a/common/env_flash.c +++ b/common/env_flash.c @@ -82,9 +82,6 @@ uchar env_get_char_spec(int index) return (*((uchar *)(gd->env_addr + index))); } -#undef debug -#define debug printf - #ifdef CONFIG_ENV_ADDR_REDUND int env_init(void) diff --git a/common/env_sf.c b/common/env_sf.c index fb0c39b..a597b24 100644 --- a/common/env_sf.c +++ b/common/env_sf.c @@ -51,7 +51,7 @@ static ulong env_new_offset = CONFIG_ENV_OFFSET_REDUND; #define ACTIVE_FLAG 1 #define OBSOLETE_FLAG 0 -#endif /* CONFIG_ENV_ADDR_REDUND */ +#endif /* CONFIG_ENV_OFFSET_REDUND */ DECLARE_GLOBAL_DATA_PTR; @@ -69,13 +69,6 @@ uchar env_get_char_spec(int index) } #if defined(CONFIG_ENV_OFFSET_REDUND) -void swap_env(void) -{ - ulong tmp_offset = env_offset; - - env_offset = env_new_offset; - env_new_offset = tmp_offset; -} int saveenv(void) { @@ -89,8 +82,13 @@ int saveenv(void) char flag = OBSOLETE_FLAG, new_flag = ACTIVE_FLAG; if (!env_flash) { - puts("Environment SPI flash not initialized\n"); - return 1; + env_flash = spi_flash_probe(CONFIG_ENV_SPI_BUS, + CONFIG_ENV_SPI_CS, + CONFIG_ENV_SPI_MAX_HZ, CONFIG_ENV_SPI_MODE); + if (!env_flash) { + set_default_env("!spi_flash_probe() failed"); + return 1; + } } res = (char *)&env_new.data; @@ -102,6 +100,14 @@ int saveenv(void) env_new.crc = crc32(0, env_new.data, ENV_SIZE); env_new.flags = ACTIVE_FLAG; + if (gd->env_valid == 1) { + env_new_offset = CONFIG_ENV_OFFSET_REDUND; + env_offset = CONFIG_ENV_OFFSET; + } else { + env_new_offset = CONFIG_ENV_OFFSET; + env_offset = CONFIG_ENV_OFFSET_REDUND; + } + /* Is the sector larger than the env (i.e. embedded) */ if (CONFIG_ENV_SECT_SIZE > CONFIG_ENV_SIZE) { saved_size = CONFIG_ENV_SECT_SIZE - CONFIG_ENV_SIZE; @@ -130,27 +136,9 @@ int saveenv(void) goto done; puts("Writing to SPI flash..."); - ret = spi_flash_write(env_flash, - env_new_offset + offsetof(env_t, data), - sizeof(env_new.data), env_new.data); - if (ret) - goto done; - - ret = spi_flash_write(env_flash, - env_new_offset + offsetof(env_t, crc), - sizeof(env_new.crc), &env_new.crc); - if (ret) - goto done; - ret = spi_flash_write(env_flash, - env_offset + offsetof(env_t, flags), - sizeof(env_new.flags), &flag); - if (ret) - goto done; - - ret = spi_flash_write(env_flash, - env_new_offset + offsetof(env_t, flags), - sizeof(env_new.flags), &new_flag); + ret = spi_flash_write(env_flash, env_new_offset, + CONFIG_ENV_SIZE, &env_new); if (ret) goto done; @@ -161,11 +149,18 @@ int saveenv(void) goto done; } - swap_env(); + ret = spi_flash_write(env_flash, + env_offset + offsetof(env_t, flags), + sizeof(env_new.flags), &flag); + if (ret) + goto done; - ret = 0; puts("done\n"); + gd->env_valid = (gd->env_valid == 2 ? 1 : 2); + + printf("Valid environment: %d\n", gd->env_valid); + done: if (saved_buffer) free(saved_buffer); @@ -178,7 +173,7 @@ void env_relocate_spec(void) int crc1_ok = 0, crc2_ok = 0; env_t *tmp_env1 = NULL; env_t *tmp_env2 = NULL; - env_t ep; + env_t *ep = NULL; uchar flag1, flag2; /* current_env is set only in case both areas are valid! */ int current_env = 0; @@ -219,90 +214,57 @@ void env_relocate_spec(void) flag2 = tmp_env2->flags; } - if (!crc1_ok && !crc2_ok) - goto err_crc; - else if (crc1_ok && !crc2_ok) { + if (!crc1_ok && !crc2_ok) { + free(tmp_env1); + free(tmp_env2); + set_default_env("!bad CRC"); + return; + } else if (crc1_ok && !crc2_ok) { gd->env_valid = 1; ep = tmp_env1; } else if (!crc1_ok && crc2_ok) { gd->env_valid = 1; - ep = tmp_env2; - swap_env(); } else if (flag1 == ACTIVE_FLAG && flag2 == OBSOLETE_FLAG) { gd->env_valid = 1; - ep = tmp_env1; } else if (flag1 == OBSOLETE_FLAG && flag2 == ACTIVE_FLAG) { - gd->env_valid = 1; - ep = tmp_env2; - swap_env(); + gd->env_valid = 2; } else if (flag1 == flag2) { gd->env_valid = 2; - ep = tmp_env1; - current_env = 1; } else if (flag1 == 0xFF) { gd->env_valid = 2; - ep = tmp_env1; - current_env = 1; } else { /* * this differs from code in env_flash.c, but I think a sane * default path is desirable. */ gd->env_valid = 2; - ep = tmp_env2; - swap_env(); - current_env = 2; } - rc = env_import((char *)ep, 0); - if (!rc) { - error("Cannot import environment: errno = %d\n", errno); - goto out; - } + free(env_ptr); - if (current_env == 1) { - if (flag2 != OBSOLETE_FLAG) { - flag2 = OBSOLETE_FLAG; - spi_flash_write(env_flash, - env_new_offset + offsetof(env_t, flags), - sizeof(env_new.flags), &flag2); - } - if (flag1 != ACTIVE_FLAG) { - flag1 = ACTIVE_FLAG; - spi_flash_write(env_flash, - env_offset + offsetof(env_t, flags), - sizeof(env_new.flags), &flag1); - } - } else if (current_env == 2) { - if (flag1 != OBSOLETE_FLAG) { - flag1 = OBSOLETE_FLAG; - spi_flash_write(env_flash, - env_new_offset + offsetof(env_t, flags), - sizeof(env_new.flags), &flag1); - } - if (flag2 != ACTIVE_FLAG) { - flag2 = ACTIVE_FLAG; - spi_flash_write(env_flash, - env_offset + offsetof(env_t, flags), - sizeof(env_new.flags), &flag2); - } - } - if (gd->env_valid == 2) { - puts("*** Warning - some problems detected " - "reading environment; recovered successfully\n\n"); + if (gd->env_valid == 1) + ep = tmp_env1; + else + ep = tmp_env2; + + ret = env_import((char *)ep, 0); + if (!ret) { + error("Cannot import environment: errno = %d\n", errno); + set_default_env("env_import failed"); } - if (tmp_env1) - free(tmp_env1); - if (tmp_env2) - free(tmp_env2); - return; err_read: spi_flash_free(env_flash); env_flash = NULL; out: + if (tmp_env1) + free(tmp_env1); + if (tmp_env2) + free(tmp_env2); free(tmp_env1); free(tmp_env2); + + return; } #else int saveenv(void) @@ -311,10 +273,18 @@ int saveenv(void) char *saved_buffer = NULL; u32 sector = 1; int ret; + env_t env_new; + char *res; + ssize_t len; if (!env_flash) { - puts("Environment SPI flash not initialized\n"); - return 1; + env_flash = spi_flash_probe(CONFIG_ENV_SPI_BUS, + CONFIG_ENV_SPI_CS, + CONFIG_ENV_SPI_MAX_HZ, CONFIG_ENV_SPI_MODE); + if (!env_flash) { + set_default_env("!spi_flash_probe() failed"); + return 1; + } } /* Is the sector larger than the env (i.e. embedded) */ @@ -326,7 +296,8 @@ int saveenv(void) ret = 1; goto done; } - ret = spi_flash_read(env_flash, saved_offset, saved_size, saved_buffer); + ret = spi_flash_read(env_flash, saved_offset, + saved_size, saved_buffer); if (ret) goto done; } @@ -337,18 +308,29 @@ int saveenv(void) sector++; } + res = (char *)&env_new.data; + len = hexport('\0', &res, ENV_SIZE); + if (len < 0) { + error("Cannot export environment: errno = %d\n", errno); + goto done; + } + env_new.crc = crc32(0, env_new.data, ENV_SIZE); + puts("Erasing SPI flash..."); - ret = spi_flash_erase(env_flash, CONFIG_ENV_OFFSET, sector * CONFIG_ENV_SECT_SIZE); + ret = spi_flash_erase(env_flash, CONFIG_ENV_OFFSET, + sector * CONFIG_ENV_SECT_SIZE); if (ret) goto done; puts("Writing to SPI flash..."); - ret = spi_flash_write(env_flash, CONFIG_ENV_OFFSET, CONFIG_ENV_SIZE, env_ptr); + ret = spi_flash_write(env_flash, CONFIG_ENV_OFFSET, + CONFIG_ENV_SIZE, &env_new); if (ret) goto done; if (CONFIG_ENV_SECT_SIZE > CONFIG_ENV_SIZE) { - ret = spi_flash_write(env_flash, saved_offset, saved_size, saved_buffer); + ret = spi_flash_write(env_flash, saved_offset, + saved_size, saved_buffer); if (ret) goto done; } diff --git a/common/fdt_support.c b/common/fdt_support.c index 90e9097..5829afd 100644 --- a/common/fdt_support.c +++ b/common/fdt_support.c @@ -396,7 +396,6 @@ int fdt_fixup_memory_banks(void *blob, u64 start[], u64 size[], int banks) int addr_cell_len, size_cell_len, len; u8 tmp[banks * 8]; int bank; - const u32 *addrcell, *sizecell; err = fdt_check_header(blob); if (err < 0) { diff --git a/common/hush.c b/common/hush.c index 4dd9513..2188fd4 100644 --- a/common/hush.c +++ b/common/hush.c @@ -3268,7 +3268,7 @@ int parse_file_outer(void) } #ifdef __U_BOOT__ -#ifndef CONFIG_RELOC_FIXUP_WORKS +#ifdef CONFIG_NEEDS_MANUAL_RELOC static void u_boot_hush_reloc(void) { unsigned long addr; @@ -3290,7 +3290,7 @@ int u_boot_hush_start(void) top_vars->next = 0; top_vars->flg_export = 0; top_vars->flg_read_only = 1; -#ifndef CONFIG_RELOC_FIXUP_WORKS +#ifdef CONFIG_NEEDS_MANUAL_RELOC u_boot_hush_reloc(); #endif } diff --git a/common/hwconfig.c b/common/hwconfig.c index 1f9f4a0..3c9759f 100644 --- a/common/hwconfig.c +++ b/common/hwconfig.c @@ -26,6 +26,8 @@ #define min(a, b) (((a) < (b)) ? (a) : (b)) #endif /* HWCONFIG_TEST */ +DECLARE_GLOBAL_DATA_PTR; + static const char *hwconfig_parse(const char *opts, size_t maxlen, const char *opt, char *stopchs, char eqch, size_t *arglen) @@ -69,9 +71,26 @@ next: const char *cpu_hwconfig __attribute__((weak)); const char *board_hwconfig __attribute__((weak)); +#define HWCONFIG_PRE_RELOC_BUF_SIZE 128 + static const char *__hwconfig(const char *opt, size_t *arglen) { - const char *env_hwconfig = getenv("hwconfig"); + const char *env_hwconfig = NULL; + char buf[HWCONFIG_PRE_RELOC_BUF_SIZE]; + + if (gd->flags & GD_FLG_ENV_READY) { + env_hwconfig = getenv("hwconfig"); + } else { + /* + * Use our own on stack based buffer before relocation to allow + * accessing longer hwconfig strings that might be in the + * environment before we've relocated. This is pretty fragile + * on both the use of stack and if the buffer is big enough. + * However we will get a warning from getenv_f for the later. + */ + if ((getenv_f("hwconfig", buf, sizeof(buf))) > 0) + env_hwconfig = buf; + } if (env_hwconfig) return hwconfig_parse(env_hwconfig, strlen(env_hwconfig), diff --git a/common/image.c b/common/image.c index 385464d..42f5b79 100644 --- a/common/image.c +++ b/common/image.c @@ -520,7 +520,7 @@ char *get_table_entry_name (table_entry_t *table, char *msg, int id) { for (; table->id >= 0; ++table) { if (table->id == id) -#if defined(USE_HOSTCC) || defined(CONFIG_RELOC_FIXUP_WORKS) +#if defined(USE_HOSTCC) || !defined(CONFIG_NEEDS_MANUAL_RELOC) return table->lname; #else return table->lname + gd->reloc_off; @@ -585,10 +585,10 @@ int get_table_entry_id (table_entry_t *table, fprintf (stderr, "\n"); #else for (t = table; t->id >= 0; ++t) { -#ifdef CONFIG_RELOC_FIXUP_WORKS - if (t->sname && strcmp(t->sname, name) == 0) -#else +#ifdef CONFIG_NEEDS_MANUAL_RELOC if (t->sname && strcmp(t->sname + gd->reloc_off, name) == 0) +#else + if (t->sname && strcmp(t->sname, name) == 0) #endif return (t->id); } @@ -1176,8 +1176,10 @@ static int fit_check_fdt (const void *fit, int fdt_noffset, int verify) * @of_flat_tree: pointer to a char* variable, will hold fdt start address * @of_size: pointer to a ulong variable, will hold fdt length * - * boot_relocate_fdt() determines if the of_flat_tree address is within - * the bootmap and if not relocates it into that region + * boot_relocate_fdt() allocates a region of memory within the bootmap and + * relocates the of_flat_tree into that region, even if the fdt is already in + * the bootmap. It also expands the size of the fdt by CONFIG_SYS_FDT_PAD + * bytes. * * of_flat_tree and of_size are set to final (after relocation) values * @@ -1189,9 +1191,10 @@ static int fit_check_fdt (const void *fit, int fdt_noffset, int verify) int boot_relocate_fdt (struct lmb *lmb, ulong bootmap_base, char **of_flat_tree, ulong *of_size) { - char *fdt_blob = *of_flat_tree; - ulong relocate = 0; + void *fdt_blob = *of_flat_tree; + void *of_start = 0; ulong of_len = 0; + int err; /* nothing to do */ if (*of_size == 0) @@ -1202,62 +1205,32 @@ int boot_relocate_fdt (struct lmb *lmb, ulong bootmap_base, goto error; } -#ifndef CONFIG_SYS_NO_FLASH - /* move the blob if it is in flash (set relocate) */ - if (addr2info ((ulong)fdt_blob) != NULL) - relocate = 1; -#endif - - /* - * The blob needs to be inside the boot mapping. - */ - if (fdt_blob < (char *)bootmap_base) - relocate = 1; - - if ((fdt_blob + *of_size + CONFIG_SYS_FDT_PAD) >= - ((char *)CONFIG_SYS_BOOTMAPSZ + bootmap_base)) - relocate = 1; - - /* move flattend device tree if needed */ - if (relocate) { - int err; - ulong of_start = 0; - - /* position on a 4K boundary before the alloc_current */ - /* Pad the FDT by a specified amount */ - of_len = *of_size + CONFIG_SYS_FDT_PAD; - of_start = (unsigned long)lmb_alloc_base(lmb, of_len, 0x1000, - (CONFIG_SYS_BOOTMAPSZ + bootmap_base)); - - if (of_start == 0) { - puts("device tree - allocation error\n"); - goto error; - } - - debug ("## device tree at 0x%08lX ... 0x%08lX (len=%ld=0x%lX)\n", - (ulong)fdt_blob, (ulong)fdt_blob + *of_size - 1, - of_len, of_len); + /* position on a 4K boundary before the alloc_current */ + /* Pad the FDT by a specified amount */ + of_len = *of_size + CONFIG_SYS_FDT_PAD; + of_start = (void *)(unsigned long)lmb_alloc_base(lmb, of_len, 0x1000, + (CONFIG_SYS_BOOTMAPSZ + bootmap_base)); - printf (" Loading Device Tree to %08lx, end %08lx ... ", - of_start, of_start + of_len - 1); + if (of_start == 0) { + puts("device tree - allocation error\n"); + goto error; + } - err = fdt_open_into (fdt_blob, (void *)of_start, of_len); - if (err != 0) { - fdt_error ("fdt move failed"); - goto error; - } - puts ("OK\n"); + debug ("## device tree at %p ... %p (len=%ld [0x%lX])\n", + fdt_blob, fdt_blob + *of_size - 1, of_len, of_len); - *of_flat_tree = (char *)of_start; - *of_size = of_len; - } else { - *of_flat_tree = fdt_blob; - of_len = *of_size + CONFIG_SYS_FDT_PAD; - lmb_reserve(lmb, (ulong)fdt_blob, of_len); - fdt_set_totalsize(*of_flat_tree, of_len); + printf (" Loading Device Tree to %p, end %p ... ", + of_start, of_start + of_len - 1); - *of_size = of_len; + err = fdt_open_into (fdt_blob, of_start, of_len); + if (err != 0) { + fdt_error ("fdt move failed"); + goto error; } + puts ("OK\n"); + + *of_flat_tree = of_start; + *of_size = of_len; set_working_fdt_addr(*of_flat_tree); return 0; diff --git a/common/serial.c b/common/serial.c index 7bebc12..051ae4e 100644 --- a/common/serial.c +++ b/common/serial.c @@ -30,7 +30,7 @@ DECLARE_GLOBAL_DATA_PTR; static struct serial_device *serial_devices = NULL; static struct serial_device *serial_current = NULL; -#if !defined(CONFIG_LWMON) && !defined(CONFIG_PXA27X) +#if !defined(CONFIG_LWMON) && !defined(CONFIG_PXA250) && !defined(CONFIG_PXA27X) struct serial_device *__default_serial_console (void) { #if defined(CONFIG_8xx_CONS_SMC1) || defined(CONFIG_8xx_CONS_SMC2) @@ -99,7 +99,7 @@ struct serial_device *default_serial_console(void) __attribute__((weak, alias("_ int serial_register (struct serial_device *dev) { -#ifndef CONFIG_RELOC_FIXUP_WORKS +#ifdef CONFIG_NEEDS_MANUAL_RELOC dev->init += gd->reloc_off; dev->setbrg += gd->reloc_off; dev->getc += gd->reloc_off; diff --git a/common/stdio.c b/common/stdio.c index 2501369..ab7c5ab 100644 --- a/common/stdio.c +++ b/common/stdio.c @@ -193,7 +193,7 @@ int stdio_deregister(char *devname) int stdio_init (void) { -#if !defined(CONFIG_RELOC_FIXUP_WORKS) +#if defined(CONFIG_NEEDS_MANUAL_RELOC) /* already relocated for current ARM implementation */ ulong relocation_offset = gd->reloc_off; int i; @@ -203,7 +203,7 @@ int stdio_init (void) stdio_names[i] = (char *) (((ulong) stdio_names[i]) + relocation_offset); } -#endif /* !CONFIG_RELOC_FIXUP_WORKS */ +#endif /* CONFIG_NEEDS_MANUAL_RELOC */ /* Initialize the list */ INIT_LIST_HEAD(&(devs.list)); diff --git a/common/usb_storage.c b/common/usb_storage.c index 613c4f0..1e6cd6a 100644 --- a/common/usb_storage.c +++ b/common/usb_storage.c @@ -70,7 +70,7 @@ /* direction table -- this indicates the direction of the data * transfer for each command code -- a 1 indicates input */ -unsigned char us_direction[256/8] = { +static const unsigned char us_direction[256/8] = { 0x28, 0x81, 0x14, 0x14, 0x20, 0x01, 0x90, 0x77, 0x0C, 0x20, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, |