aboutsummaryrefslogtreecommitdiffstats
path: root/arch/m68k/mm/motorola.c
diff options
context:
space:
mode:
authorRoman Zippel <zippel@linux-m68k.org>2007-05-31 03:40:54 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-05-31 10:58:14 -0400
commit12d810c1b8c2b913d48e629e2b5c01d105029839 (patch)
treeb39162d3168f6173af3d0e5790e16eb45a70dfaf /arch/m68k/mm/motorola.c
parent00c541eae7a477e3d1adb1ebf27cccc0bdb5f824 (diff)
m68k: discontinuous memory support
Fix support for discontinuous memory Signed-off-by: Roman Zippel <zippel@linux-m68k.org> Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/m68k/mm/motorola.c')
-rw-r--r--arch/m68k/mm/motorola.c101
1 files changed, 69 insertions, 32 deletions
diff --git a/arch/m68k/mm/motorola.c b/arch/m68k/mm/motorola.c
index 98ef00547b37..7d571a2b44dd 100644
--- a/arch/m68k/mm/motorola.c
+++ b/arch/m68k/mm/motorola.c
@@ -43,6 +43,11 @@ unsigned long mm_cachebits;
43EXPORT_SYMBOL(mm_cachebits); 43EXPORT_SYMBOL(mm_cachebits);
44#endif 44#endif
45 45
46/* size of memory already mapped in head.S */
47#define INIT_MAPPED_SIZE (4UL<<20)
48
49extern unsigned long availmem;
50
46static pte_t * __init kernel_page_table(void) 51static pte_t * __init kernel_page_table(void)
47{ 52{
48 pte_t *ptablep; 53 pte_t *ptablep;
@@ -98,19 +103,20 @@ static pmd_t * __init kernel_ptr_table(void)
98 return last_pgtable; 103 return last_pgtable;
99} 104}
100 105
101static unsigned long __init 106static void __init map_node(int node)
102map_chunk (unsigned long addr, long size)
103{ 107{
104#define PTRTREESIZE (256*1024) 108#define PTRTREESIZE (256*1024)
105#define ROOTTREESIZE (32*1024*1024) 109#define ROOTTREESIZE (32*1024*1024)
106 static unsigned long virtaddr = PAGE_OFFSET; 110 unsigned long physaddr, virtaddr, size;
107 unsigned long physaddr;
108 pgd_t *pgd_dir; 111 pgd_t *pgd_dir;
109 pmd_t *pmd_dir; 112 pmd_t *pmd_dir;
110 pte_t *pte_dir; 113 pte_t *pte_dir;
111 114
112 physaddr = (addr | m68k_supervisor_cachemode | 115 size = m68k_memory[node].size;
113 _PAGE_PRESENT | _PAGE_ACCESSED | _PAGE_DIRTY); 116 physaddr = m68k_memory[node].addr;
117 virtaddr = (unsigned long)phys_to_virt(physaddr);
118 physaddr |= m68k_supervisor_cachemode |
119 _PAGE_PRESENT | _PAGE_ACCESSED | _PAGE_DIRTY;
114 if (CPU_IS_040_OR_060) 120 if (CPU_IS_040_OR_060)
115 physaddr |= _PAGE_GLOBAL040; 121 physaddr |= _PAGE_GLOBAL040;
116 122
@@ -190,8 +196,6 @@ map_chunk (unsigned long addr, long size)
190#ifdef DEBUG 196#ifdef DEBUG
191 printk("\n"); 197 printk("\n");
192#endif 198#endif
193
194 return virtaddr;
195} 199}
196 200
197/* 201/*
@@ -200,15 +204,16 @@ map_chunk (unsigned long addr, long size)
200 */ 204 */
201void __init paging_init(void) 205void __init paging_init(void)
202{ 206{
203 int chunk;
204 unsigned long mem_avail = 0;
205 unsigned long zones_size[MAX_NR_ZONES] = { 0, }; 207 unsigned long zones_size[MAX_NR_ZONES] = { 0, };
208 unsigned long min_addr, max_addr;
209 unsigned long addr, size, end;
210 int i;
206 211
207#ifdef DEBUG 212#ifdef DEBUG
208 { 213 {
209 extern unsigned long availmem; 214 extern unsigned long availmem;
210 printk ("start of paging_init (%p, %lx, %lx, %lx)\n", 215 printk ("start of paging_init (%p, %lx)\n",
211 kernel_pg_dir, availmem, start_mem, end_mem); 216 kernel_pg_dir, availmem);
212 } 217 }
213#endif 218#endif
214 219
@@ -222,27 +227,62 @@ void __init paging_init(void)
222 pgprot_val(protection_map[i]) |= _PAGE_CACHE040; 227 pgprot_val(protection_map[i]) |= _PAGE_CACHE040;
223 } 228 }
224 229
230 min_addr = m68k_memory[0].addr;
231 max_addr = min_addr + m68k_memory[0].size;
232 for (i = 1; i < m68k_num_memory;) {
233 if (m68k_memory[i].addr < min_addr) {
234 printk("Ignoring memory chunk at 0x%lx:0x%lx before the first chunk\n",
235 m68k_memory[i].addr, m68k_memory[i].size);
236 printk("Fix your bootloader or use a memfile to make use of this area!\n");
237 m68k_num_memory--;
238 memmove(m68k_memory + i, m68k_memory + i + 1,
239 (m68k_num_memory - i) * sizeof(struct mem_info));
240 continue;
241 }
242 addr = m68k_memory[i].addr + m68k_memory[i].size;
243 if (addr > max_addr)
244 max_addr = addr;
245 i++;
246 }
247 m68k_memoffset = min_addr - PAGE_OFFSET;
248 m68k_virt_to_node_shift = fls(max_addr - min_addr - 1) - 6;
249
225 module_fixup(NULL, __start_fixup, __stop_fixup); 250 module_fixup(NULL, __start_fixup, __stop_fixup);
226 flush_icache(); 251 flush_icache();
227 252
253 high_memory = phys_to_virt(max_addr);
254
255 min_low_pfn = availmem >> PAGE_SHIFT;
256 max_low_pfn = max_addr >> PAGE_SHIFT;
257
258 for (i = 0; i < m68k_num_memory; i++) {
259 addr = m68k_memory[i].addr;
260 end = addr + m68k_memory[i].size;
261 m68k_setup_node(i);
262 availmem = PAGE_ALIGN(availmem);
263 availmem += init_bootmem_node(NODE_DATA(i),
264 availmem >> PAGE_SHIFT,
265 addr >> PAGE_SHIFT,
266 end >> PAGE_SHIFT);
267 }
268
228 /* 269 /*
229 * Map the physical memory available into the kernel virtual 270 * Map the physical memory available into the kernel virtual
230 * address space. It may allocate some memory for page 271 * address space. First initialize the bootmem allocator with
231 * tables and thus modify availmem. 272 * the memory we already mapped, so map_node() has something
273 * to allocate.
232 */ 274 */
275 addr = m68k_memory[0].addr;
276 size = m68k_memory[0].size;
277 free_bootmem_node(NODE_DATA(0), availmem, min(INIT_MAPPED_SIZE, size) - (availmem - addr));
278 map_node(0);
279 if (size > INIT_MAPPED_SIZE)
280 free_bootmem_node(NODE_DATA(0), addr + INIT_MAPPED_SIZE, size - INIT_MAPPED_SIZE);
233 281
234 for (chunk = 0; chunk < m68k_num_memory; chunk++) { 282 for (i = 1; i < m68k_num_memory; i++)
235 mem_avail = map_chunk (m68k_memory[chunk].addr, 283 map_node(i);
236 m68k_memory[chunk].size);
237
238 }
239 284
240 flush_tlb_all(); 285 flush_tlb_all();
241#ifdef DEBUG
242 printk ("memory available is %ldKB\n", mem_avail >> 10);
243 printk ("start_mem is %#lx\nvirtual_end is %#lx\n",
244 start_mem, end_mem);
245#endif
246 286
247 /* 287 /*
248 * initialize the bad page table and bad page to point 288 * initialize the bad page table and bad page to point
@@ -259,14 +299,11 @@ void __init paging_init(void)
259#ifdef DEBUG 299#ifdef DEBUG
260 printk ("before free_area_init\n"); 300 printk ("before free_area_init\n");
261#endif 301#endif
262 zones_size[ZONE_DMA] = (mach_max_dma_address < (unsigned long)high_memory ? 302 for (i = 0; i < m68k_num_memory; i++) {
263 (mach_max_dma_address+1) : (unsigned long)high_memory); 303 zones_size[ZONE_DMA] = m68k_memory[i].size >> PAGE_SHIFT;
264 zones_size[ZONE_NORMAL] = (unsigned long)high_memory - zones_size[0]; 304 free_area_init_node(i, pg_data_map + i, zones_size,
265 305 m68k_memory[i].addr >> PAGE_SHIFT, NULL);
266 zones_size[ZONE_DMA] = (zones_size[ZONE_DMA] - PAGE_OFFSET) >> PAGE_SHIFT; 306 }
267 zones_size[ZONE_NORMAL] >>= PAGE_SHIFT;
268
269 free_area_init(zones_size);
270} 307}
271 308
272extern char __init_begin, __init_end; 309extern char __init_begin, __init_end;