]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - common/env_common.c
ppc/85xx: Fix inclusion of 83xx immap in 85xx builds
[karo-tx-uboot.git] / common / env_common.c
index 0462cad6d7256b6c3e0d2f07f438d6233bd6157f..439a4a905b937a66dd098a6505e144b67dc0c713 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
@@ -57,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
@@ -99,14 +91,20 @@ uchar default_environment[] = {
 #ifdef CONFIG_ETH3ADDR
        "eth3addr="     MK_STR(CONFIG_ETH3ADDR)         "\0"
 #endif
+#ifdef CONFIG_ETH4ADDR
+       "eth4addr="     MK_STR(CONFIG_ETH4ADDR)         "\0"
+#endif
+#ifdef CONFIG_ETH5ADDR
+       "eth5addr="     MK_STR(CONFIG_ETH5ADDR)         "\0"
+#endif
 #ifdef CONFIG_IPADDR
        "ipaddr="       MK_STR(CONFIG_IPADDR)           "\0"
 #endif
 #ifdef CONFIG_SERVERIP
        "serverip="     MK_STR(CONFIG_SERVERIP)         "\0"
 #endif
-#ifdef CFG_AUTOLOAD
-       "autoload="     CFG_AUTOLOAD                    "\0"
+#ifdef CONFIG_SYS_AUTOLOAD
+       "autoload="     CONFIG_SYS_AUTOLOAD                     "\0"
 #endif
 #ifdef CONFIG_PREBOOT
        "preboot="      CONFIG_PREBOOT                  "\0"
@@ -141,10 +139,6 @@ uchar default_environment[] = {
        "\0"
 };
 
-#if defined(CFG_ENV_IS_IN_NAND)                /* Environment is in Nand Flash */
-int default_environment_size = sizeof(default_environment);
-#endif
-
 void env_crc_update (void)
 {
        env_ptr->crc = crc32(0, env_ptr->data, ENV_SIZE);
@@ -189,6 +183,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) {
@@ -198,10 +205,29 @@ 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 CONFIG_SYS_REDUNDAND_ENVIRONMENT
+       env_ptr->flags = 0xFF;
+#endif
+       env_crc_update ();
+       gd->env_valid = 1;
+}
+
 void env_relocate (void)
 {
+#ifndef CONFIG_RELOC_FIXUP_WORKS
        DEBUGF ("%s[%d] offset = 0x%lx\n", __FUNCTION__,__LINE__,
                gd->reloc_off);
+#endif
 
 #ifdef CONFIG_AMIGAONEG3SE
        enable_nvram();
@@ -212,44 +238,26 @@ void env_relocate (void)
         * The environment buffer is embedded with the text segment,
         * just relocate the environment pointer
         */
+#ifndef CONFIG_RELOC_FIXUP_WORKS
        env_ptr = (env_t *)((ulong)env_ptr + gd->reloc_off);
+#endif
        DEBUGF ("%s[%d] embedded ENV at %p\n", __FUNCTION__,__LINE__,env_ptr);
 #else
        /*
         * We must allocate a buffer for the environment
         */
-       env_ptr = (env_t *)malloc (CFG_ENV_SIZE);
+       env_ptr = (env_t *)malloc (CONFIG_ENV_SIZE);
        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 */
+#if defined(CONFIG_GTH)        || defined(CONFIG_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 (-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;
+               show_boot_progress (-60);
 #endif
-               env_crc_update ();
-               gd->env_valid = 1;
+               set_default_env();
        }
        else {
                env_relocate_spec ();