Merge branch 'master' of /home/wd/git/u-boot/lwmon5
[platform/kernel/u-boot.git] / common / env_common.c
index 3201135..f366fdb 100644 (file)
 #include <linux/stddef.h>
 #include <malloc.h>
 
-#ifdef CONFIG_SHOW_BOOT_PROGRESS
-# include <status_led.h>
-# define SHOW_BOOT_PROGRESS(arg)       show_boot_progress(arg)
-#else
-# define SHOW_BOOT_PROGRESS(arg)
-#endif
+DECLARE_GLOBAL_DATA_PTR;
 
 #ifdef CONFIG_AMIGAONEG3SE
        extern void enable_nvram(void);
@@ -55,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
@@ -150,7 +144,6 @@ void env_crc_update (void)
 
 static uchar env_get_char_init (int index)
 {
-       DECLARE_GLOBAL_DATA_PTR;
        uchar c;
 
        /* if crc was bad, use the default environment */
@@ -167,7 +160,6 @@ static uchar env_get_char_init (int index)
 #ifdef CONFIG_AMIGAONEG3SE
 uchar env_get_char_memory (int index)
 {
-       DECLARE_GLOBAL_DATA_PTR;
        uchar retval;
        enable_nvram();
        if (gd->env_valid) {
@@ -181,8 +173,6 @@ uchar env_get_char_memory (int index)
 #else
 uchar env_get_char_memory (int index)
 {
-       DECLARE_GLOBAL_DATA_PTR;
-
        if (gd->env_valid) {
                return ( *((uchar *)(gd->env_addr + index)) );
        } else {
@@ -191,10 +181,21 @@ uchar env_get_char_memory (int index)
 }
 #endif
 
-uchar *env_get_addr (int index)
+uchar env_get_char (int index)
 {
-       DECLARE_GLOBAL_DATA_PTR;
+       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) {
                return ( ((uchar *)(gd->env_addr + index)) );
        } else {
@@ -204,8 +205,6 @@ uchar *env_get_addr (int index)
 
 void env_relocate (void)
 {
-       DECLARE_GLOBAL_DATA_PTR;
-
        DEBUGF ("%s[%d] offset = 0x%lx\n", __FUNCTION__,__LINE__,
                gd->reloc_off);
 
@@ -228,17 +227,12 @@ 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");
 #else
                puts ("*** Warning - bad CRC, using default environment\n\n");
-               SHOW_BOOT_PROGRESS (-1);
+               show_boot_progress (-60);
 #endif
 
                if (sizeof(default_environment) > ENV_SIZE)