aboutsummaryrefslogtreecommitdiffstats
path: root/arch/m68k/mm/init.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/init.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/init.c')
-rw-r--r--arch/m68k/mm/init.c119
1 files changed, 78 insertions, 41 deletions
diff --git a/arch/m68k/mm/init.c b/arch/m68k/mm/init.c
index ab90213e5c54..f1de19e1dde6 100644
--- a/arch/m68k/mm/init.c
+++ b/arch/m68k/mm/init.c
@@ -7,6 +7,7 @@
7 * to motorola.c and sun3mmu.c 7 * to motorola.c and sun3mmu.c
8 */ 8 */
9 9
10#include <linux/module.h>
10#include <linux/signal.h> 11#include <linux/signal.h>
11#include <linux/sched.h> 12#include <linux/sched.h>
12#include <linux/mm.h> 13#include <linux/mm.h>
@@ -31,6 +32,37 @@
31 32
32DEFINE_PER_CPU(struct mmu_gather, mmu_gathers); 33DEFINE_PER_CPU(struct mmu_gather, mmu_gathers);
33 34
35static bootmem_data_t __initdata bootmem_data[MAX_NUMNODES];
36
37pg_data_t pg_data_map[MAX_NUMNODES];
38EXPORT_SYMBOL(pg_data_map);
39
40int m68k_virt_to_node_shift;
41
42#ifndef CONFIG_SINGLE_MEMORY_CHUNK
43pg_data_t *pg_data_table[65];
44EXPORT_SYMBOL(pg_data_table);
45#endif
46
47void m68k_setup_node(int node)
48{
49#ifndef CONFIG_SINGLE_MEMORY_CHUNK
50 struct mem_info *info = m68k_memory + node;
51 int i, end;
52
53 i = (unsigned long)phys_to_virt(info->addr) >> __virt_to_node_shift();
54 end = (unsigned long)phys_to_virt(info->addr + info->size - 1) >> __virt_to_node_shift();
55 for (; i <= end; i++) {
56 if (pg_data_table[i])
57 printk("overlap at %u for chunk %u\n", i, node);
58 pg_data_table[i] = pg_data_map + node;
59 }
60#endif
61 pg_data_map[node].bdata = bootmem_data + node;
62 node_set_online(node);
63}
64
65
34/* 66/*
35 * ZERO_PAGE is a special page that is used for zero-initialized 67 * ZERO_PAGE is a special page that is used for zero-initialized
36 * data and COW. 68 * data and COW.
@@ -40,52 +72,51 @@ void *empty_zero_page;
40 72
41void show_mem(void) 73void show_mem(void)
42{ 74{
43 unsigned long i; 75 pg_data_t *pgdat;
44 int free = 0, total = 0, reserved = 0, shared = 0; 76 int free = 0, total = 0, reserved = 0, shared = 0;
45 int cached = 0; 77 int cached = 0;
46 78 int i;
47 printk("\nMem-info:\n"); 79
48 show_free_areas(); 80 printk("\nMem-info:\n");
49 printk("Free swap: %6ldkB\n", nr_swap_pages<<(PAGE_SHIFT-10)); 81 show_free_areas();
50 i = max_mapnr; 82 printk("Free swap: %6ldkB\n", nr_swap_pages<<(PAGE_SHIFT-10));
51 while (i-- > 0) { 83 for_each_online_pgdat(pgdat) {
52 total++; 84 for (i = 0; i < pgdat->node_spanned_pages; i++) {
53 if (PageReserved(mem_map+i)) 85 struct page *page = pgdat->node_mem_map + i;
54 reserved++; 86 total++;
55 else if (PageSwapCache(mem_map+i)) 87 if (PageReserved(page))
56 cached++; 88 reserved++;
57 else if (!page_count(mem_map+i)) 89 else if (PageSwapCache(page))
58 free++; 90 cached++;
59 else 91 else if (!page_count(page))
60 shared += page_count(mem_map+i) - 1; 92 free++;
61 } 93 else
62 printk("%d pages of RAM\n",total); 94 shared += page_count(page) - 1;
63 printk("%d free pages\n",free); 95 }
64 printk("%d reserved pages\n",reserved); 96 }
65 printk("%d pages shared\n",shared); 97 printk("%d pages of RAM\n",total);
66 printk("%d pages swap cached\n",cached); 98 printk("%d free pages\n",free);
99 printk("%d reserved pages\n",reserved);
100 printk("%d pages shared\n",shared);
101 printk("%d pages swap cached\n",cached);
67} 102}
68 103
69extern void init_pointer_table(unsigned long ptable); 104extern void init_pointer_table(unsigned long ptable);
70 105
71/* References to section boundaries */ 106/* References to section boundaries */
72 107
73extern char _text, _etext, _edata, __bss_start, _end; 108extern char _text[], _etext[];
74extern char __init_begin, __init_end; 109extern char __init_begin[], __init_end[];
75 110
76extern pmd_t *zero_pgtable; 111extern pmd_t *zero_pgtable;
77 112
78void __init mem_init(void) 113void __init mem_init(void)
79{ 114{
115 pg_data_t *pgdat;
80 int codepages = 0; 116 int codepages = 0;
81 int datapages = 0; 117 int datapages = 0;
82 int initpages = 0; 118 int initpages = 0;
83 unsigned long tmp;
84#ifndef CONFIG_SUN3
85 int i; 119 int i;
86#endif
87
88 max_mapnr = num_physpages = (((unsigned long)high_memory - PAGE_OFFSET) >> PAGE_SHIFT);
89 120
90#ifdef CONFIG_ATARI 121#ifdef CONFIG_ATARI
91 if (MACH_IS_ATARI) 122 if (MACH_IS_ATARI)
@@ -93,19 +124,25 @@ void __init mem_init(void)
93#endif 124#endif
94 125
95 /* this will put all memory onto the freelists */ 126 /* this will put all memory onto the freelists */
96 totalram_pages = free_all_bootmem(); 127 totalram_pages = num_physpages = 0;
97 128 for_each_online_pgdat(pgdat) {
98 for (tmp = PAGE_OFFSET ; tmp < (unsigned long)high_memory; tmp += PAGE_SIZE) { 129 num_physpages += pgdat->node_present_pages;
99 if (PageReserved(virt_to_page(tmp))) { 130
100 if (tmp >= (unsigned long)&_text 131 totalram_pages += free_all_bootmem_node(pgdat);
101 && tmp < (unsigned long)&_etext) 132 for (i = 0; i < pgdat->node_spanned_pages; i++) {
133 struct page *page = pgdat->node_mem_map + i;
134 char *addr = page_to_virt(page);
135
136 if (!PageReserved(page))
137 continue;
138 if (addr >= _text &&
139 addr < _etext)
102 codepages++; 140 codepages++;
103 else if (tmp >= (unsigned long) &__init_begin 141 else if (addr >= __init_begin &&
104 && tmp < (unsigned long) &__init_end) 142 addr < __init_end)
105 initpages++; 143 initpages++;
106 else 144 else
107 datapages++; 145 datapages++;
108 continue;
109 } 146 }
110 } 147 }
111 148
@@ -124,7 +161,7 @@ void __init mem_init(void)
124 161
125 printk("Memory: %luk/%luk available (%dk kernel code, %dk data, %dk init)\n", 162 printk("Memory: %luk/%luk available (%dk kernel code, %dk data, %dk init)\n",
126 (unsigned long)nr_free_pages() << (PAGE_SHIFT-10), 163 (unsigned long)nr_free_pages() << (PAGE_SHIFT-10),
127 max_mapnr << (PAGE_SHIFT-10), 164 totalram_pages << (PAGE_SHIFT-10),
128 codepages << (PAGE_SHIFT-10), 165 codepages << (PAGE_SHIFT-10),
129 datapages << (PAGE_SHIFT-10), 166 datapages << (PAGE_SHIFT-10),
130 initpages << (PAGE_SHIFT-10)); 167 initpages << (PAGE_SHIFT-10));