diff options
Diffstat (limited to 'common')
-rw-r--r-- | common/cmd_fdt.c | 8 | ||||
-rw-r--r-- | common/env_common.c | 53 | ||||
-rw-r--r-- | common/env_nand.c | 14 | ||||
-rw-r--r-- | common/main.c | 2 |
4 files changed, 37 insertions, 40 deletions
diff --git a/common/cmd_fdt.c b/common/cmd_fdt.c index 97b9dd7..d3b19dd 100644 --- a/common/cmd_fdt.c +++ b/common/cmd_fdt.c @@ -451,14 +451,14 @@ static int fdt_valid(void) if (err == -FDT_ERR_BADVERSION) { if (fdt_version(working_fdt) < FDT_FIRST_SUPPORTED_VERSION) { - printf (" - too old, fdt $d < %d", + printf (" - too old, fdt %d < %d", fdt_version(working_fdt), FDT_FIRST_SUPPORTED_VERSION); working_fdt = NULL; } if (fdt_last_comp_version(working_fdt) > FDT_LAST_SUPPORTED_VERSION) { - printf (" - too new, fdt $d > %d", + printf (" - too new, fdt %d > %d", fdt_version(working_fdt), FDT_LAST_SUPPORTED_VERSION); working_fdt = NULL; @@ -546,7 +546,7 @@ static int fdt_parse_prop(char **newval, int count, char *data, int *len) newp = newval[++stridx]; } if (*newp != ']') { - printf("Unexpected character '%c'\n", *newval); + printf("Unexpected character '%c'\n", *newp); return 1; } } else { @@ -763,7 +763,7 @@ static int fdt_print(const char *pathp, char *prop, int depth) } break; case FDT_NOP: - printf("/* NOP */\n", &tabs[MAX_LEVEL - level]); + printf("%s/* NOP */\n", &tabs[MAX_LEVEL - level]); break; case FDT_END: return 1; diff --git a/common/env_common.c b/common/env_common.c index e6df9a5..d51c211 100644 --- a/common/env_common.c +++ b/common/env_common.c @@ -50,7 +50,6 @@ extern void env_relocate_spec (void); extern uchar env_get_char_spec(int); static uchar env_get_char_init (int index); -uchar (*env_get_char)(int) = env_get_char_init; /************************************************************************ * Default settings to be used when no valid environment is found @@ -183,6 +182,19 @@ uchar env_get_char_memory (int index) } #endif +uchar env_get_char (int index) +{ + uchar c; + + /* if relocated to RAM */ + if (gd->flags & GD_FLG_RELOC) + c = env_get_char_memory(index); + else + c = env_get_char_init(index); + + return (c); +} + uchar *env_get_addr (int index) { if (gd->env_valid) { @@ -192,6 +204,23 @@ uchar *env_get_addr (int index) } } +void set_default_env(void) +{ + if (sizeof(default_environment) > ENV_SIZE) { + puts ("*** Error - default environment is too large\n\n"); + return; + } + + memset(env_ptr, 0, sizeof(env_t)); + memcpy(env_ptr->data, default_environment, + sizeof(default_environment)); +#ifdef CFG_REDUNDAND_ENVIRONMENT + env_ptr->flags = 0xFF; +#endif + env_crc_update (); + gd->env_valid = 1; +} + void env_relocate (void) { DEBUGF ("%s[%d] offset = 0x%lx\n", __FUNCTION__,__LINE__, @@ -216,11 +245,6 @@ void env_relocate (void) DEBUGF ("%s[%d] malloced ENV at %p\n", __FUNCTION__,__LINE__,env_ptr); #endif - /* - * After relocation to RAM, we can always use the "memory" functions - */ - env_get_char = env_get_char_memory; - if (gd->env_valid == 0) { #if defined(CONFIG_GTH) || defined(CFG_ENV_IS_NOWHERE) /* Environment not changable */ puts ("Using default environment\n\n"); @@ -228,22 +252,7 @@ void env_relocate (void) puts ("*** Warning - bad CRC, using default environment\n\n"); show_boot_progress (-60); #endif - - if (sizeof(default_environment) > ENV_SIZE) - { - puts ("*** Error - default environment is too large\n\n"); - return; - } - - memset (env_ptr, 0, sizeof(env_t)); - memcpy (env_ptr->data, - default_environment, - sizeof(default_environment)); -#ifdef CFG_REDUNDAND_ENVIRONMENT - env_ptr->flags = 0xFF; -#endif - env_crc_update (); - gd->env_valid = 1; + set_default_env(); } else { env_relocate_spec (); diff --git a/common/env_nand.c b/common/env_nand.c index 1fe874a..104f085 100644 --- a/common/env_nand.c +++ b/common/env_nand.c @@ -363,19 +363,7 @@ void env_relocate_spec (void) static void use_default() { puts ("*** Warning - bad CRC or NAND, using default environment\n\n"); - - if (default_environment_size > CFG_ENV_SIZE){ - puts ("*** Error - default environment is too large\n\n"); - return; - } - - memset (env_ptr, 0, sizeof(env_t)); - memcpy (env_ptr->data, - default_environment, - default_environment_size); - env_ptr->crc = crc32(0, env_ptr->data, ENV_SIZE); - gd->env_valid = 1; - + set_default_env(); } #endif diff --git a/common/main.c b/common/main.c index 046da6f..79ad291 100644 --- a/common/main.c +++ b/common/main.c @@ -509,7 +509,7 @@ void reset_cmd_timeout(void) */ #define putnstr(str,n) do { \ - printf ("%.*s", n, str); \ + printf ("%.*s", (int)n, str); \ } while (0) #define CTL_CH(c) ((c) - 'a' + 1) |