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