diff --git a/arch/arm/lib/board.c b/arch/arm/lib/board.c index c320a35166b82009a7cc623b7460754294bf3ba5..ba62394a9d49d72638bc0896f1d81c2631bcb8d6 100644 --- a/arch/arm/lib/board.c +++ b/arch/arm/lib/board.c @@ -318,7 +318,7 @@ void board_init_f(ulong bootflag) gd->ram_size -= CONFIG_SYS_MEM_TOP_HIDE; #endif - addr = CONFIG_SYS_SDRAM_BASE + gd->ram_size; + addr = CONFIG_SYS_SDRAM_BASE + get_effective_memsize(); #ifdef CONFIG_LOGBUFFER #ifndef CONFIG_ALT_LB_ADDR diff --git a/arch/powerpc/cpu/mpc512x/traps.c b/arch/powerpc/cpu/mpc512x/traps.c index 10169912b7f2e614e180d025aa61810c3664a62d..9f5bcd7fc3350a5fa9b1b44496b9cac0e921872e 100644 --- a/arch/powerpc/cpu/mpc512x/traps.c +++ b/arch/powerpc/cpu/mpc512x/traps.c @@ -27,7 +27,6 @@ extern unsigned long search_exception_table(unsigned long); * amount of memory on the system if we're unable to keep all * the memory mapped in. */ -extern ulong get_effective_memsize(void); #define END_OF_MEM (gd->bd->bi_memstart + get_effective_memsize()) /* diff --git a/arch/powerpc/cpu/mpc85xx/traps.c b/arch/powerpc/cpu/mpc85xx/traps.c index 3ef6e4ae160ffc2bd8739bb6c229ec13f1d09557..24adbc3078f5d2b77926fa2f759051475d9e538d 100644 --- a/arch/powerpc/cpu/mpc85xx/traps.c +++ b/arch/powerpc/cpu/mpc85xx/traps.c @@ -35,7 +35,6 @@ extern unsigned long search_exception_table(unsigned long); * amount of memory on the system if we're unable to keep all * the memory mapped in. */ -extern ulong get_effective_memsize(void); #define END_OF_MEM (gd->bd->bi_memstart + get_effective_memsize()) static __inline__ void set_tsr(unsigned long val) diff --git a/arch/powerpc/cpu/mpc86xx/traps.c b/arch/powerpc/cpu/mpc86xx/traps.c index 0b7ea3b184de0db93e0c8a9abe99783cd2d71e3c..92fb537453b5f6412c259acb033e018b69b78512 100644 --- a/arch/powerpc/cpu/mpc86xx/traps.c +++ b/arch/powerpc/cpu/mpc86xx/traps.c @@ -29,7 +29,6 @@ extern unsigned long search_exception_table(unsigned long); * amount of memory on the system if we're unable to keep all * the memory mapped in. */ -extern ulong get_effective_memsize(void); #define END_OF_MEM (gd->bd->bi_memstart + get_effective_memsize()) /* diff --git a/arch/powerpc/lib/board.c b/arch/powerpc/lib/board.c index 34bbfca5544d8d5bde5bff3be5ebc64f275dddfa..13d761c1f755bd2fe8922f70b3ec7b4d8d337726 100644 --- a/arch/powerpc/lib/board.c +++ b/arch/powerpc/lib/board.c @@ -312,17 +312,6 @@ static init_fnc_t *init_sequence[] = { NULL, /* Terminate this list */ }; -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 -} - static int __fixup_cpu(void) { return 0; @@ -343,13 +332,6 @@ int fixup_cpu(void) __attribute__((weak, alias("__fixup_cpu"))); * initialized, and stack space is limited to a few kB. */ -#ifdef CONFIG_LOGBUFFER -unsigned long logbuffer_base(void) -{ - return CONFIG_SYS_SDRAM_BASE + get_effective_memsize() - LOGBUFF_LEN; -} -#endif - void board_init_f(ulong bootflag) { bd_t *bd; diff --git a/arch/powerpc/lib/bootm.c b/arch/powerpc/lib/bootm.c index 41fc8f7ff7a355ec3a2cbbd548e63022324489d0..c08b62c47e353b277e033085d0df29a3092794e6 100644 --- a/arch/powerpc/lib/bootm.c +++ b/arch/powerpc/lib/bootm.c @@ -30,7 +30,6 @@ DECLARE_GLOBAL_DATA_PTR; -extern ulong get_effective_memsize(void); static ulong get_sp (void); extern void ft_fixup_num_cores(void *blob); static void set_clocks_in_mhz (bd_t *kbd); diff --git a/board/freescale/c29xpcie/spl.c b/board/freescale/c29xpcie/spl.c index 3cfdb723b97e5a731799d6047c812afb378a94b0..211171140084fbe52c4d6b5ccbe4b7faad7f6b80 100644 --- a/board/freescale/c29xpcie/spl.c +++ b/board/freescale/c29xpcie/spl.c @@ -12,7 +12,7 @@ DECLARE_GLOBAL_DATA_PTR; -ulong get_effective_memsize(void) +phys_size_t get_effective_memsize(void) { return CONFIG_SYS_L2_SIZE; } diff --git a/board/freescale/p1022ds/spl.c b/board/freescale/p1022ds/spl.c index 7f151e38cf911b05521f7a53cbf048ad5820cf51..7bd9d296ee0d072dbde263c73857df000bbec686 100644 --- a/board/freescale/p1022ds/spl.c +++ b/board/freescale/p1022ds/spl.c @@ -21,7 +21,7 @@ static const u32 sysclk_tbl[] = { 99999000, 11111000, 12499800, 13333200 }; -ulong get_effective_memsize(void) +phys_size_t get_effective_memsize(void) { return CONFIG_SYS_L2_SIZE; } diff --git a/board/freescale/p1_p2_rdb_pc/spl.c b/board/freescale/p1_p2_rdb_pc/spl.c index 9bb071692d54fc7e5531098aec79ca6a0267068b..8d0d850480212c881e0a8b3eb94518e7af8a27a7 100644 --- a/board/freescale/p1_p2_rdb_pc/spl.c +++ b/board/freescale/p1_p2_rdb_pc/spl.c @@ -20,7 +20,7 @@ static const u32 sysclk_tbl[] = { 99999000, 11111000, 12499800, 13333200 }; -ulong get_effective_memsize(void) +phys_size_t get_effective_memsize(void) { return CONFIG_SYS_L2_SIZE; } diff --git a/common/board_f.c b/common/board_f.c index 02965b0df76a36a2218264d82365d087816d831f..a973b95334131717b0ee0896b18bce0906922bce 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 8164bdf4886460f535b9831da167ef6a90c66b97..38d0f5edfd7872d50af20b5e38173b0871c39f19 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 73b92c8a00e4f76ebde34a50b5da4847e4599455..589400d3b14d8a8c53e9908ca2aec7cce66f0e11 100644 --- a/common/memsize.c +++ b/common/memsize.c @@ -5,7 +5,10 @@ * SPDX-License-Identifier: GPL-2.0+ */ -#include <config.h> +#include <common.h> + +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 +} diff --git a/include/common.h b/include/common.h index 033b5d946d11b76040a37bf9db13ef16df129ba9..96a45a6cf70ea0a312aa8733f5f0d010a20c08ed 100644 --- a/include/common.h +++ b/include/common.h @@ -461,6 +461,7 @@ void api_init (void); /* common/memsize.c */ long get_ram_size (long *, long); +phys_size_t get_effective_memsize(void); /* $(BOARD)/$(BOARD).c */ void reset_phy (void);