summaryrefslogtreecommitdiffstats
path: root/include/environment.h
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2019-08-01 09:47:11 -0600
committerTom Rini <trini@konsulko.com>2019-08-11 16:43:41 -0400
commitf030b7b2607013a1b05a696e7f010d5f8dbe4fcd (patch)
tree5421db4a03b2a0fff3f53358ce416aee6008fefe /include/environment.h
parentcb2ba9db5f2ab575d40d95e76a0ab94c7ccb9bac (diff)
downloadu-boot-f030b7b2607013a1b05a696e7f010d5f8dbe4fcd.tar.gz
u-boot-f030b7b2607013a1b05a696e7f010d5f8dbe4fcd.tar.xz
u-boot-f030b7b2607013a1b05a696e7f010d5f8dbe4fcd.zip
env: Move TOTAL_MALLOC_LEN to environment.h
This declaration is only used in three files. Although it relates to malloc() it is actually only used during malloc() init. It uses CONFIG options including CONFIG_ENV_ADDR which are defined only in environment.h so this header must be included anyway, for TOTAL_MALLOC_LEN to be correct. Nove it to environment.h to simplify the common file. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: Joe Hershberger <joe.hershberger@ni.com> Reviewed-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
Diffstat (limited to 'include/environment.h')
-rw-r--r--include/environment.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/include/environment.h b/include/environment.h
index 70ee0fdb19..cc8c0546c2 100644
--- a/include/environment.h
+++ b/include/environment.h
@@ -141,6 +141,20 @@ extern unsigned long nand_env_oob_offset;
#define ENV_SIZE (CONFIG_ENV_SIZE - ENV_HEADER_SIZE)
+/*
+ * If the environment is in RAM, allocate extra space for it in the malloc
+ * region.
+ */
+#if defined(CONFIG_ENV_IS_EMBEDDED)
+#define TOTAL_MALLOC_LEN CONFIG_SYS_MALLOC_LEN
+#elif (CONFIG_ENV_ADDR + CONFIG_ENV_SIZE < CONFIG_SYS_MONITOR_BASE) || \
+ (CONFIG_ENV_ADDR >= CONFIG_SYS_MONITOR_BASE + CONFIG_SYS_MONITOR_LEN) || \
+ defined(CONFIG_ENV_IS_IN_NVRAM)
+#define TOTAL_MALLOC_LEN (CONFIG_SYS_MALLOC_LEN + CONFIG_ENV_SIZE)
+#else
+#define TOTAL_MALLOC_LEN CONFIG_SYS_MALLOC_LEN
+#endif
+
typedef struct environment_s {
uint32_t crc; /* CRC32 over data bytes */
#ifdef CONFIG_SYS_REDUNDAND_ENVIRONMENT