x86/mm/pat: Don't report PAT on CPUs that don't support it
[linux/fpc-iii.git] / arch / s390 / mm / mem_detect.c
blobe58dca05b9627cab38b16d5e9c6cfedb3c5a3043
1 /*
2 * Copyright IBM Corp. 2008, 2009
4 * Author(s): Heiko Carstens <heiko.carstens@de.ibm.com>
5 */
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>
12 #include <asm/ipl.h>
13 #include <asm/sclp.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;
30 int type;
32 rzm = sclp.rzm;
33 rnmax = sclp.rnmax;
34 memsize = rzm * rnmax;
35 if (!rzm)
36 rzm = 1UL << 17;
37 max_physmem_end = memsize;
38 addr = 0;
39 /* keep memblock lists close to the kernel */
40 memblock_set_bottom_up(true);
41 do {
42 size = 0;
43 /* assume lowcore is writable */
44 type = addr ? tprot(addr) : CHUNK_READ_WRITE;
45 do {
46 size += rzm;
47 if (max_physmem_end && addr + size >= max_physmem_end)
48 break;
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);
55 addr += size;
56 } while (addr < max_physmem_end);
57 memblock_set_bottom_up(false);
58 if (!max_physmem_end)
59 max_physmem_end = memblock_end_of_DRAM();
60 memblock_dump_all();