1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21#include <linux/init.h>
22#include <linux/mm.h>
23#include <linux/bootmem.h>
24#include <asm/atomic.h>
25#include <linux/highmem.h>
26#include <asm/tlb.h>
27#include <asm/sections.h>
28#include <asm/vm_mmu.h>
29
30
31
32
33
34#define bootmem_startpg (PFN_UP(((unsigned long) _end) - PAGE_OFFSET + PHYS_OFFSET))
35
36unsigned long bootmem_lastpg;
37unsigned long __phys_offset;
38
39
40int max_kernel_seg = 0x303;
41
42
43unsigned long zero_page_mask;
44
45
46unsigned long highstart_pfn, highend_pfn;
47
48DEFINE_PER_CPU(struct mmu_gather, mmu_gathers);
49
50
51unsigned long _dflt_cache_att = CACHEDEF;
52
53
54
55
56
57
58DEFINE_SPINLOCK(kmap_gen_lock);
59
60
61unsigned long long kmap_generation;
62
63
64
65
66
67
68
69
70void __init mem_init(void)
71{
72
73 free_all_bootmem();
74 mem_init_print_info(NULL);
75
76
77
78
79
80
81
82
83
84
85
86
87 init_mm.context.ptbase = __pa(init_mm.pgd);
88}
89
90
91
92
93
94
95
96void __ref free_initmem(void)
97{
98}
99
100
101
102
103
104
105
106
107
108
109void free_initrd_mem(unsigned long start, unsigned long end)
110{
111}
112
113void sync_icache_dcache(pte_t pte)
114{
115 unsigned long addr;
116 struct page *page;
117
118 page = pte_page(pte);
119 addr = (unsigned long) page_address(page);
120
121 __vmcache_idsync(addr, PAGE_SIZE);
122}
123
124
125
126
127
128
129
130
131void __init paging_init(void)
132{
133 unsigned long zones_sizes[MAX_NR_ZONES] = {0, };
134
135
136
137
138
139
140
141
142
143 zones_sizes[ZONE_NORMAL] = max_low_pfn;
144
145 free_area_init(zones_sizes);
146
147
148
149
150
151 high_memory = (void *)((bootmem_lastpg + 1) << PAGE_SHIFT);
152}
153
154#ifndef DMA_RESERVE
155#define DMA_RESERVE (4)
156#endif
157
158#define DMA_CHUNKSIZE (1<<22)
159#define DMA_RESERVED_BYTES (DMA_RESERVE * DMA_CHUNKSIZE)
160
161
162
163
164
165static int __init early_mem(char *p)
166{
167 unsigned long size;
168 char *endp;
169
170 size = memparse(p, &endp);
171
172 bootmem_lastpg = PFN_DOWN(size);
173
174 return 0;
175}
176early_param("mem", early_mem);
177
178size_t hexagon_coherent_pool_size = (size_t) (DMA_RESERVE << 22);
179
180void __init setup_arch_memory(void)
181{
182 int bootmap_size;
183
184 u32 *segtable = (u32 *) &swapper_pg_dir[0];
185 u32 *segtable_end;
186
187
188
189
190
191
192
193
194
195 bootmem_lastpg += ARCH_PFN_OFFSET;
196
197
198 bootmem_lastpg = PFN_DOWN((bootmem_lastpg << PAGE_SHIFT) &
199 ~((BIG_KERNEL_PAGE_SIZE) - 1));
200
201
202
203
204
205
206 max_low_pfn = bootmem_lastpg - PFN_DOWN(DMA_RESERVED_BYTES);
207 min_low_pfn = ARCH_PFN_OFFSET;
208 bootmap_size = init_bootmem_node(NODE_DATA(0), bootmem_startpg, min_low_pfn, max_low_pfn);
209
210 printk(KERN_INFO "bootmem_startpg: 0x%08lx\n", bootmem_startpg);
211 printk(KERN_INFO "bootmem_lastpg: 0x%08lx\n", bootmem_lastpg);
212 printk(KERN_INFO "bootmap_size: %d\n", bootmap_size);
213 printk(KERN_INFO "min_low_pfn: 0x%08lx\n", min_low_pfn);
214 printk(KERN_INFO "max_low_pfn: 0x%08lx\n", max_low_pfn);
215
216
217
218
219
220
221
222
223 segtable = segtable + (PAGE_OFFSET >> 22);
224
225
226 segtable_end = segtable + (1<<(30-22));
227
228
229
230
231
232
233 segtable += (bootmem_lastpg-ARCH_PFN_OFFSET)>>(22-PAGE_SHIFT);
234 {
235 int i;
236
237 for (i = 1 ; i <= DMA_RESERVE ; i++)
238 segtable[-i] = ((segtable[-i] & __HVM_PTE_PGMASK_4MB)
239 | __HVM_PTE_R | __HVM_PTE_W | __HVM_PTE_X
240 | __HEXAGON_C_UNC << 6
241 | __HVM_PDE_S_4MB);
242 }
243
244 printk(KERN_INFO "clearing segtable from %p to %p\n", segtable,
245 segtable_end);
246 while (segtable < (segtable_end-8))
247 *(segtable++) = __HVM_PDE_S_INVALID;
248
249
250 printk(KERN_INFO "segtable = %p (should be equal to _K_io_map)\n",
251 segtable);
252
253#if 0
254
255 printk(KERN_INFO "&_K_init_devicetable = 0x%08x\n",
256 (unsigned long) _K_init_devicetable-PAGE_OFFSET);
257 *segtable = ((u32) (unsigned long) _K_init_devicetable-PAGE_OFFSET) |
258 __HVM_PDE_S_4KB;
259 printk(KERN_INFO "*segtable = 0x%08x\n", *segtable);
260#endif
261
262
263
264
265
266 free_bootmem(PFN_PHYS(bootmem_startpg) + bootmap_size,
267 PFN_PHYS(bootmem_lastpg - bootmem_startpg) - bootmap_size -
268 DMA_RESERVED_BYTES);
269
270
271
272
273
274 printk(KERN_INFO "PAGE_SIZE=%lu\n", PAGE_SIZE);
275 paging_init();
276
277
278
279
280
281
282
283}
284