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! */
52 addr = base + cnt; /* pointer arith! */
56 if (((cnt == 0) && (val != 0)) ||
57 ((cnt != 0) && (val != ~cnt))) {
58 size = cnt * sizeof(long);
60 * Restore the original data
61 * before leaving the function.
64 cnt < maxsize / sizeof(long);
76 } while (cnt < maxsize / sizeof(long));
81 phys_size_t __weak get_effective_memsize(void)
83 #ifndef CONFIG_VERY_BIG_RAM
86 /* limit stack to what we can reasonable map */
87 return ((gd->ram_size > CONFIG_MAX_MEM_MAPPED) ?
88 CONFIG_MAX_MEM_MAPPED : gd->ram_size);