From e38661634b3d60af80d85ce9eb570a45db4729ca Mon Sep 17 00:00:00 2001 From: York Sun Date: Tue, 11 Feb 2014 11:57:26 -0800 Subject: common: Add get_effective_memsize() to memsize.c This function has been around for powerpc. It is used for systems with memory more than CONFIG_MAX_MEM_MAPPED. In case of non-contiguous memory, this feature can limit U-boot to one block without going over the limit. Signed-off-by: York Sun Acked-by: Albert ARIBAUD --- common/board_f.c | 11 ----------- common/cmd_log.c | 2 +- common/memsize.c | 16 +++++++++++++++- 3 files changed, 16 insertions(+), 13 deletions(-) (limited to 'common') diff --git a/common/board_f.c b/common/board_f.c index 02965b0..a973b95 100644 --- a/common/board_f.c +++ b/common/board_f.c @@ -223,17 +223,6 @@ static int show_dram_config(void) return 0; } -ulong get_effective_memsize(void) -{ -#ifndef CONFIG_VERY_BIG_RAM - return gd->ram_size; -#else - /* limit stack to what we can reasonable map */ - return ((gd->ram_size > CONFIG_MAX_MEM_MAPPED) ? - CONFIG_MAX_MEM_MAPPED : gd->ram_size); -#endif -} - void __dram_init_banksize(void) { #if defined(CONFIG_NR_DRAM_BANKS) && defined(CONFIG_SYS_SDRAM_BASE) diff --git a/common/cmd_log.c b/common/cmd_log.c index 8164bdf..38d0f5e 100644 --- a/common/cmd_log.c +++ b/common/cmd_log.c @@ -52,7 +52,7 @@ static char *lbuf; unsigned long __logbuffer_base(void) { - return CONFIG_SYS_SDRAM_BASE + gd->ram_size - LOGBUFF_LEN; + return CONFIG_SYS_SDRAM_BASE + get_effective_memsize() - LOGBUFF_LEN; } unsigned long logbuffer_base(void) __attribute__((weak, alias("__logbuffer_base"))); diff --git a/common/memsize.c b/common/memsize.c index 73b92c8..589400d 100644 --- a/common/memsize.c +++ b/common/memsize.c @@ -5,7 +5,10 @@ * SPDX-License-Identifier: GPL-2.0+ */ -#include +#include + +DECLARE_GLOBAL_DATA_PTR; + #ifdef __PPC__ /* * At least on G2 PowerPC cores, sequential accesses to non-existent @@ -76,3 +79,14 @@ long get_ram_size(long *base, long maxsize) return (maxsize); } + +phys_size_t __weak get_effective_memsize(void) +{ +#ifndef CONFIG_VERY_BIG_RAM + return gd->ram_size; +#else + /* limit stack to what we can reasonable map */ + return ((gd->ram_size > CONFIG_MAX_MEM_MAPPED) ? + CONFIG_MAX_MEM_MAPPED : gd->ram_size); +#endif +} -- cgit v1.1