]>
git.ipfire.org Git - thirdparty/u-boot.git/blob - common/memsize.c
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. */
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);
86 phys_size_t __weak
get_effective_memsize(void)
88 #ifndef CONFIG_VERY_BIG_RAM
91 /* limit stack to what we can reasonable map */
92 return ((gd
->ram_size
> CONFIG_MAX_MEM_MAPPED
) ?
93 CONFIG_MAX_MEM_MAPPED
: gd
->ram_size
);