3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5 * SPDX-License-Identifier: GPL-2.0+
10 DECLARE_GLOBAL_DATA_PTR;
14 * At least on G2 PowerPC cores, sequential accesses to non-existent
15 * memory must be synchronized.
17 # include <asm/io.h> /* for sync() */
19 # define sync() /* nothing */
23 * Check memory range for valid RAM. A simple memory test determines
24 * the actually available RAM size between addresses `base' and
27 long get_ram_size(long *base, long maxsize)
36 for (cnt = (maxsize / sizeof (long)) >> 1; cnt > 0; cnt >>= 1) {
37 addr = base + cnt; /* pointer arith! */
51 if ((val = *addr) != 0) {
52 /* Restore the original data before leaving the function.
56 for (cnt = 1; cnt < maxsize / sizeof(long); cnt <<= 1) {
64 for (cnt = 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
65 addr = base + cnt; /* pointer arith! */
69 size = cnt * sizeof (long);
70 /* Restore the original data before leaving the function.
72 for (cnt <<= 1; cnt < maxsize / sizeof (long); cnt <<= 1) {
83 phys_size_t __weak get_effective_memsize(void)
85 #ifndef CONFIG_VERY_BIG_RAM
88 /* limit stack to what we can reasonable map */
89 return ((gd->ram_size > CONFIG_MAX_MEM_MAPPED) ?
90 CONFIG_MAX_MEM_MAPPED : gd->ram_size);