1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18#include <linux/signal.h>
19#include <linux/sched.h>
20#include <linux/kernel.h>
21#include <linux/errno.h>
22#include <linux/string.h>
23#include <linux/types.h>
24#include <linux/ptrace.h>
25#include <linux/mman.h>
26#include <linux/mm.h>
27#include <linux/swap.h>
28#include <linux/stddef.h>
29#include <linux/vmalloc.h>
30#include <linux/init.h>
31#include <linux/delay.h>
32#include <linux/highmem.h>
33#include <linux/memblock.h>
34
35#include <asm/prom.h>
36#include <asm/io.h>
37#include <asm/mmu_context.h>
38#include <asm/mmu.h>
39#include <linux/uaccess.h>
40#include <asm/smp.h>
41#include <asm/bootx.h>
42#include <asm/machdep.h>
43#include <asm/setup.h>
44
45#include <mm/mmu_decl.h>
46
47extern int __map_without_ltlbs;
48
49
50
51void __init MMU_init_hw(void)
52{
53
54
55
56
57
58
59
60
61
62
63
64
65
66 mtspr(SPRN_ZPR, 0x10000000);
67
68 flush_instruction_cache();
69
70
71
72
73
74
75 mtspr(SPRN_DCWR, 0x00000000);
76
77
78
79
80
81
82 mtspr(SPRN_DCCR, 0xFFFF0000);
83 mtspr(SPRN_ICCR, 0xFFFF0000);
84}
85
86#define LARGE_PAGE_SIZE_16M (1<<24)
87#define LARGE_PAGE_SIZE_4M (1<<22)
88
89unsigned long __init mmu_mapin_ram(unsigned long base, unsigned long top)
90{
91 unsigned long v, s, mapped;
92 phys_addr_t p;
93
94 v = KERNELBASE;
95 p = 0;
96 s = total_lowmem;
97
98 if (__map_without_ltlbs)
99 return 0;
100
101 while (s >= LARGE_PAGE_SIZE_16M) {
102 pmd_t *pmdp;
103 unsigned long val = p | _PMD_SIZE_16M | _PAGE_EXEC | _PAGE_RW;
104
105 pmdp = pmd_off_k(v);
106 *pmdp++ = __pmd(val);
107 *pmdp++ = __pmd(val);
108 *pmdp++ = __pmd(val);
109 *pmdp++ = __pmd(val);
110
111 v += LARGE_PAGE_SIZE_16M;
112 p += LARGE_PAGE_SIZE_16M;
113 s -= LARGE_PAGE_SIZE_16M;
114 }
115
116 while (s >= LARGE_PAGE_SIZE_4M) {
117 pmd_t *pmdp;
118 unsigned long val = p | _PMD_SIZE_4M | _PAGE_EXEC | _PAGE_RW;
119
120 pmdp = pmd_off_k(v);
121 *pmdp = __pmd(val);
122
123 v += LARGE_PAGE_SIZE_4M;
124 p += LARGE_PAGE_SIZE_4M;
125 s -= LARGE_PAGE_SIZE_4M;
126 }
127
128 mapped = total_lowmem - s;
129
130
131
132
133
134
135
136
137 memblock_set_current_limit(mapped);
138
139 return mapped;
140}
141
142void setup_initial_memory_limit(phys_addr_t first_memblock_base,
143 phys_addr_t first_memblock_size)
144{
145
146
147
148 BUG_ON(first_memblock_base != 0);
149
150
151 memblock_set_current_limit(min_t(u64, first_memblock_size, 0x00800000));
152}
153