1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20#include <linux/module.h>
21#include <linux/sched.h>
22#include <linux/kernel.h>
23#include <linux/errno.h>
24#include <linux/string.h>
25#include <linux/types.h>
26#include <linux/mm.h>
27#include <linux/stddef.h>
28#include <linux/init.h>
29#include <linux/bootmem.h>
30#include <linux/highmem.h>
31#include <linux/initrd.h>
32#include <linux/pagemap.h>
33#include <linux/memblock.h>
34#include <linux/gfp.h>
35#include <linux/slab.h>
36#include <linux/hugetlb.h>
37
38#include <asm/pgalloc.h>
39#include <asm/prom.h>
40#include <asm/io.h>
41#include <asm/pgtable.h>
42#include <asm/mmu.h>
43#include <asm/smp.h>
44#include <asm/machdep.h>
45#include <asm/btext.h>
46#include <asm/tlb.h>
47#include <asm/sections.h>
48#include <asm/hugetlb.h>
49
50#include "mmu_decl.h"
51
52#if defined(CONFIG_KERNEL_START_BOOL) || defined(CONFIG_LOWMEM_SIZE_BOOL)
53
54#if (CONFIG_LOWMEM_SIZE > (0xF0000000 - PAGE_OFFSET))
55#error "You must adjust CONFIG_LOWMEM_SIZE or CONFIG_START_KERNEL"
56#endif
57#endif
58#define MAX_LOW_MEM CONFIG_LOWMEM_SIZE
59
60phys_addr_t total_memory;
61phys_addr_t total_lowmem;
62
63phys_addr_t memstart_addr = (phys_addr_t)~0ull;
64EXPORT_SYMBOL(memstart_addr);
65phys_addr_t kernstart_addr;
66EXPORT_SYMBOL(kernstart_addr);
67
68#ifdef CONFIG_RELOCATABLE_PPC32
69
70long long virt_phys_offset;
71EXPORT_SYMBOL(virt_phys_offset);
72#endif
73
74phys_addr_t lowmem_end_addr;
75
76int boot_mapsize;
77#ifdef CONFIG_PPC_PMAC
78unsigned long agp_special_page;
79EXPORT_SYMBOL(agp_special_page);
80#endif
81
82void MMU_init(void);
83
84
85extern struct task_struct *current_set[NR_CPUS];
86
87
88
89
90
91
92int __map_without_bats;
93int __map_without_ltlbs;
94
95
96
97
98int __allow_ioremap_reserved;
99
100
101unsigned long __max_low_memory = MAX_LOW_MEM;
102
103
104
105
106void MMU_setup(void)
107{
108
109 if (strstr(cmd_line, "nobats")) {
110 __map_without_bats = 1;
111 }
112
113 if (strstr(cmd_line, "noltlbs")) {
114 __map_without_ltlbs = 1;
115 }
116#ifdef CONFIG_DEBUG_PAGEALLOC
117 __map_without_bats = 1;
118 __map_without_ltlbs = 1;
119#endif
120}
121
122
123
124
125
126
127void __init MMU_init(void)
128{
129 if (ppc_md.progress)
130 ppc_md.progress("MMU:enter", 0x111);
131
132
133 MMU_setup();
134
135
136
137
138
139 reserve_hugetlb_gpages();
140
141 if (memblock.memory.cnt > 1) {
142#ifndef CONFIG_WII
143 memblock_enforce_memory_limit(memblock.memory.regions[0].size);
144 printk(KERN_WARNING "Only using first contiguous memory region");
145#else
146 wii_memory_fixups();
147#endif
148 }
149
150 total_lowmem = total_memory = memblock_end_of_DRAM() - memstart_addr;
151 lowmem_end_addr = memstart_addr + total_lowmem;
152
153#ifdef CONFIG_FSL_BOOKE
154
155
156
157 adjust_total_lowmem();
158#endif
159
160 if (total_lowmem > __max_low_memory) {
161 total_lowmem = __max_low_memory;
162 lowmem_end_addr = memstart_addr + total_lowmem;
163#ifndef CONFIG_HIGHMEM
164 total_memory = total_lowmem;
165 memblock_enforce_memory_limit(total_lowmem);
166#endif
167 }
168
169
170 if (ppc_md.progress)
171 ppc_md.progress("MMU:hw init", 0x300);
172 MMU_init_hw();
173
174
175 if (ppc_md.progress)
176 ppc_md.progress("MMU:mapin", 0x301);
177 mapin_ram();
178
179
180 ioremap_bot = IOREMAP_TOP;
181
182
183 if (ppc_md.progress)
184 ppc_md.progress("MMU:setio", 0x302);
185
186 if (ppc_md.progress)
187 ppc_md.progress("MMU:exit", 0x211);
188
189
190#ifdef CONFIG_BOOTX_TEXT
191 btext_unmap();
192#endif
193
194
195 memblock_set_current_limit(lowmem_end_addr);
196}
197
198
199void __init *early_get_page(void)
200{
201 if (init_bootmem_done)
202 return alloc_bootmem_pages(PAGE_SIZE);
203 else
204 return __va(memblock_alloc(PAGE_SIZE, PAGE_SIZE));
205}
206
207#ifdef CONFIG_8xx
208void setup_initial_memory_limit(phys_addr_t first_memblock_base,
209 phys_addr_t first_memblock_size)
210{
211
212
213
214 BUG_ON(first_memblock_base != 0);
215
216
217 memblock_set_current_limit(min_t(u64, first_memblock_size, 0x00800000));
218}
219#endif
220