Message ID | 20190801154715.225318-37-sjg@chromium.org |
---|---|
State | Accepted |
Commit | f030b7b2607013a1b05a696e7f010d5f8dbe4fcd |
Delegated to: | Tom Rini |
Headers | show |
Series | env: common: Remove environment definitions from common.h | expand |
Am 01.08.2019 um 17:47 schrieb Simon Glass: > 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> > --- > > Changes in v2: None > > arch/x86/cpu/qemu/e820.c | 1 + > include/common.h | 10 ---------- > include/environment.h | 14 ++++++++++++++ > 3 files changed, 15 insertions(+), 10 deletions(-) > > diff --git a/arch/x86/cpu/qemu/e820.c b/arch/x86/cpu/qemu/e820.c > index 0a690fde68..7b3bc7db5e 100644 > --- a/arch/x86/cpu/qemu/e820.c > +++ b/arch/x86/cpu/qemu/e820.c > @@ -4,6 +4,7 @@ > */ > > #include <common.h> > +#include <environment.h> > #include <asm/e820.h> > > DECLARE_GLOBAL_DATA_PTR; > diff --git a/include/common.h b/include/common.h > index 70f40daa9e..34ae514805 100644 > --- a/include/common.h > +++ b/include/common.h > @@ -45,16 +45,6 @@ typedef void (interrupt_handler_t)(void *); > #include <asm/u-boot.h> /* boot information for Linux kernel */ > #include <asm/global_data.h> /* global data used for startup functions */ > > -#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 > - > /* startup functions, used in: > * common/board_f.c > * common/init/board_init.c > 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 >
On Thu, Aug 01, 2019 at 09:47:11AM -0600, Simon Glass wrote: > 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> Applied to u-boot/master, thanks!
diff --git a/arch/x86/cpu/qemu/e820.c b/arch/x86/cpu/qemu/e820.c index 0a690fde68..7b3bc7db5e 100644 --- a/arch/x86/cpu/qemu/e820.c +++ b/arch/x86/cpu/qemu/e820.c @@ -4,6 +4,7 @@ */ #include <common.h> +#include <environment.h> #include <asm/e820.h> DECLARE_GLOBAL_DATA_PTR; diff --git a/include/common.h b/include/common.h index 70f40daa9e..34ae514805 100644 --- a/include/common.h +++ b/include/common.h @@ -45,16 +45,6 @@ typedef void (interrupt_handler_t)(void *); #include <asm/u-boot.h> /* boot information for Linux kernel */ #include <asm/global_data.h> /* global data used for startup functions */ -#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 - /* startup functions, used in: * common/board_f.c * common/init/board_init.c 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