1 // SPDX-License-Identifier: GPL-2.0+
4 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
9 DECLARE_GLOBAL_DATA_PTR
;
13 * At least on G2 PowerPC cores, sequential accesses to non-existent
14 * memory must be synchronized.
16 # include <asm/io.h> /* for sync() */
18 # define sync() /* nothing */
22 * Check memory range for valid RAM. A simple memory test determines
23 * the actually available RAM size between addresses `base' and
26 long get_ram_size(long *base
, long maxsize
)
29 long save
[BITS_PER_LONG
- 1];
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. */
55 for (cnt
= 1; cnt
< maxsize
/ sizeof(long); cnt
<<= 1) {
63 for (cnt
= 1; cnt
< maxsize
/ sizeof(long); cnt
<<= 1) {
64 addr
= base
+ cnt
; /* pointer arith! */
68 size
= cnt
* sizeof(long);
70 * Restore the original data
71 * before leaving the function.
74 cnt
< maxsize
/ sizeof(long);
79 /* warning: don't restore save_base in this case,
80 * it is already done in the loop because
81 * base and base+size share the same physical memory
82 * and *base is saved after *(base+size) modification
93 phys_size_t __weak
get_effective_memsize(void)
95 #ifndef CONFIG_VERY_BIG_RAM
98 /* limit stack to what we can reasonable map */
99 return ((gd
->ram_size
> CONFIG_MAX_MEM_MAPPED
) ?
100 CONFIG_MAX_MEM_MAPPED
: gd
->ram_size
);