2 * Copyright IBM Corp. 2008, 2009
4 * Author(s): Heiko Carstens <heiko.carstens@de.ibm.com>
7 #include <linux/kernel.h>
8 #include <linux/memblock.h>
9 #include <linux/init.h>
10 #include <linux/debugfs.h>
11 #include <linux/seq_file.h>
14 #include <asm/setup.h>
16 #define CHUNK_READ_WRITE 0
17 #define CHUNK_READ_ONLY 1
19 static inline void memblock_physmem_add(phys_addr_t start
, phys_addr_t size
)
21 memblock_dbg("memblock_physmem_add: [%#016llx-%#016llx]\n",
22 start
, start
+ size
- 1);
23 memblock_add_range(&memblock
.memory
, start
, size
, 0, 0);
24 memblock_add_range(&memblock
.physmem
, start
, size
, 0, 0);
27 void __init
detect_memory_memblock(void)
29 unsigned long memsize
, rnmax
, rzm
, addr
, size
;
34 memsize
= rzm
* rnmax
;
37 max_physmem_end
= memsize
;
39 /* keep memblock lists close to the kernel */
40 memblock_set_bottom_up(true);
43 /* assume lowcore is writable */
44 type
= addr
? tprot(addr
) : CHUNK_READ_WRITE
;
47 if (max_physmem_end
&& addr
+ size
>= max_physmem_end
)
49 } while (type
== tprot(addr
+ size
));
50 if (type
== CHUNK_READ_WRITE
|| type
== CHUNK_READ_ONLY
) {
51 if (max_physmem_end
&& (addr
+ size
> max_physmem_end
))
52 size
= max_physmem_end
- addr
;
53 memblock_physmem_add(addr
, size
);
56 } while (addr
< max_physmem_end
);
57 memblock_set_bottom_up(false);
59 max_physmem_end
= memblock_end_of_DRAM();