env: move extern environment[] to environment.h
authorIgor Grinberg <grinberg@compulab.co.il>
Thu, 17 Nov 2011 06:07:23 +0000 (06:07 +0000)
committerStefano Babic <sbabic@denx.de>
Tue, 22 Nov 2011 07:39:25 +0000 (08:39 +0100)
Extract all extern declarations for environment out of c files
into the environment.h header.

Signed-off-by: Igor Grinberg <grinberg@compulab.co.il>
common/env_flash.c
common/env_mmc.c
common/env_nand.c
common/env_onenand.c
include/environment.h
tools/envcrc.c

index d9f8fcb1ef462ca1c51e5eef362373818743c3a7..e770ee6368de45264536540991ee8251cb441e8c 100644 (file)
@@ -49,9 +49,7 @@ DECLARE_GLOBAL_DATA_PTR;
 char * env_name_spec = "Flash";
 
 #ifdef ENV_IS_EMBEDDED
-
-extern uchar environment[];
-env_t *env_ptr = (env_t *)(&environment[0]);
+env_t *env_ptr = &environment;
 
 static env_t *flash_addr = (env_t *)CONFIG_ENV_ADDR;
 
index 78df808bbce402f644e128ebedd37b75612520e6..ef8186c2c7acb7631822aef429b4267e6a8e52ff 100644 (file)
@@ -35,8 +35,7 @@
 char *env_name_spec = "MMC";
 
 #ifdef ENV_IS_EMBEDDED
-extern uchar environment[];
-env_t *env_ptr = (env_t *)(&environment[0]);
+env_t *env_ptr = &environment;
 #else /* ! ENV_IS_EMBEDDED */
 env_t *env_ptr = NULL;
 #endif /* ENV_IS_EMBEDDED */
index 1b12c68d68806d4e49b66670de38408dec999aff..65a867d50014c34c8bb569b3e89af88e88e105b4 100644 (file)
@@ -59,8 +59,7 @@ char *env_name_spec = "NAND";
 
 
 #if defined(ENV_IS_EMBEDDED)
-extern uchar environment[];
-env_t *env_ptr = (env_t *)(&environment[0]);
+env_t *env_ptr = &environment;
 #elif defined(CONFIG_NAND_ENV_DST)
 env_t *env_ptr = (env_t *)CONFIG_NAND_ENV_DST;
 #else /* ! ENV_IS_EMBEDDED */
index b7170e6c455950d96123cc922e49ea51f502bf34..618c642f29cf350a775c6c902d34f081f4ff4fe5 100644 (file)
@@ -44,10 +44,6 @@ char *env_name_spec = "OneNAND";
 #define ONENAND_MAX_ENV_SIZE   4096
 #define ONENAND_ENV_SIZE(mtd)  (ONENAND_MAX_ENV_SIZE - ENV_HEADER_SIZE)
 
-#ifdef ENV_IS_EMBEDDED
-extern uchar environment[];
-#endif /* ENV_IS_EMBEDDED */
-
 DECLARE_GLOBAL_DATA_PTR;
 
 uchar env_get_char_spec(int index)
@@ -64,7 +60,7 @@ void env_relocate_spec(void)
        int rc;
        size_t retlen;
 #ifdef ENV_IS_EMBEDDED
-       char *buf = (char *)&environment[0];
+       char *buf = (char *)&environment;
 #else
        loff_t env_addr = CONFIG_ENV_ADDR;
        char onenand_env[ONENAND_MAX_ENV_SIZE];
index 20775da7015f6c48836c21fa406cf79d8602b0b9..951803f1b6cc7ed3825f01034e3650918fa3171a 100644 (file)
@@ -154,6 +154,10 @@ typedef struct environment_s {
        unsigned char   data[ENV_SIZE]; /* Environment data             */
 } env_t;
 
+#ifdef ENV_IS_EMBEDDED
+extern env_t environment;
+#endif /* ENV_IS_EMBEDDED */
+
 extern const unsigned char default_environment[];
 
 #ifndef DO_DEPS_ONLY
index feebbabea0be822abe514340404a1fca9da9d468..111d9f62897a4107d66cc884c3b231e4d837531f 100644 (file)
@@ -61,6 +61,7 @@
 #endif /* CONFIG_ENV_IS_IN_FLASH */
 
 #if defined(ENV_IS_EMBEDDED) && !defined(CONFIG_BUILD_ENVCRC)
+# include <environment.h>
 # define CONFIG_BUILD_ENVCRC 1
 #endif
 
@@ -77,7 +78,7 @@ extern uint32_t crc32 (uint32_t, const unsigned char *, unsigned int);
 
 #ifdef CONFIG_BUILD_ENVCRC
 extern unsigned int env_size;
-extern unsigned char environment;
+extern env_t environment;
 #endif /* CONFIG_BUILD_ENVCRC */
 
 int main (int argc, char **argv)
@@ -85,7 +86,7 @@ int main (int argc, char **argv)
 #ifdef CONFIG_BUILD_ENVCRC
        unsigned char pad = 0x00;
        uint32_t crc;
-       unsigned char *envptr = &environment,
+       unsigned char *envptr = (unsigned char *)&environment,
                *dataptr = envptr + ENV_HEADER_SIZE;
        unsigned int datasize = ENV_SIZE;
        unsigned int eoe;