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