]>
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
)
37 for (cnt
= (maxsize
/ sizeof(long)) >> 1; cnt
> 0; cnt
>>= 1) {
38 addr
= base
+ cnt
; /* pointer arith! */
52 if ((val
= *addr
) != 0) {
53 /* 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);
71 * Restore the original data
72 * before leaving the function.
75 cnt
< maxsize
/ sizeof(long);
87 phys_size_t __weak
get_effective_memsize(void)
89 #ifndef CONFIG_VERY_BIG_RAM
92 /* limit stack to what we can reasonable map */
93 return ((gd
->ram_size
> CONFIG_MAX_MEM_MAPPED
) ?
94 CONFIG_MAX_MEM_MAPPED
: gd
->ram_size
);