diff options
author | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-04-16 18:20:36 -0400 |
commit | 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch) | |
tree | 0bba044c4ce775e45a88a51686b5d9f90697ea9d /arch/m32r/mm/init.c |
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history,
even though we have it. We can create a separate "historical" git
archive of that later if we want to, and in the meantime it's about
3.2GB when imported into git - space that would just make the early
git days unnecessarily complicated, when we don't have a lot of good
infrastructure for it.
Let it rip!
Diffstat (limited to 'arch/m32r/mm/init.c')
-rw-r--r-- | arch/m32r/mm/init.c | 247 |
1 files changed, 247 insertions, 0 deletions
diff --git a/arch/m32r/mm/init.c b/arch/m32r/mm/init.c new file mode 100644 index 000000000000..bc423d838fb8 --- /dev/null +++ b/arch/m32r/mm/init.c | |||
@@ -0,0 +1,247 @@ | |||
1 | /* | ||
2 | * linux/arch/m32r/mm/init.c | ||
3 | * | ||
4 | * Copyright (c) 2001, 2002 Hitoshi Yamamoto | ||
5 | * | ||
6 | * Some code taken from sh version. | ||
7 | * Copyright (C) 1999 Niibe Yutaka | ||
8 | * Based on linux/arch/i386/mm/init.c: | ||
9 | * Copyright (C) 1995 Linus Torvalds | ||
10 | */ | ||
11 | |||
12 | #include <linux/init.h> | ||
13 | #include <linux/kernel.h> | ||
14 | #include <linux/mm.h> | ||
15 | #include <linux/pagemap.h> | ||
16 | #include <linux/bootmem.h> | ||
17 | #include <linux/swap.h> | ||
18 | #include <linux/highmem.h> | ||
19 | #include <linux/bitops.h> | ||
20 | #include <linux/nodemask.h> | ||
21 | #include <asm/types.h> | ||
22 | #include <asm/processor.h> | ||
23 | #include <asm/page.h> | ||
24 | #include <asm/pgtable.h> | ||
25 | #include <asm/pgalloc.h> | ||
26 | #include <asm/mmu_context.h> | ||
27 | #include <asm/setup.h> | ||
28 | #include <asm/tlb.h> | ||
29 | |||
30 | /* References to section boundaries */ | ||
31 | extern char _text, _etext, _edata; | ||
32 | extern char __init_begin, __init_end; | ||
33 | |||
34 | pgd_t swapper_pg_dir[1024]; | ||
35 | |||
36 | DEFINE_PER_CPU(struct mmu_gather, mmu_gathers); | ||
37 | |||
38 | void show_mem(void) | ||
39 | { | ||
40 | int total = 0, reserved = 0; | ||
41 | int shared = 0, cached = 0; | ||
42 | int highmem = 0; | ||
43 | struct page *page; | ||
44 | pg_data_t *pgdat; | ||
45 | unsigned long i; | ||
46 | |||
47 | printk("Mem-info:\n"); | ||
48 | show_free_areas(); | ||
49 | printk("Free swap: %6ldkB\n",nr_swap_pages<<(PAGE_SHIFT-10)); | ||
50 | for_each_pgdat(pgdat) { | ||
51 | for (i = 0; i < pgdat->node_spanned_pages; ++i) { | ||
52 | page = pgdat->node_mem_map + i; | ||
53 | total++; | ||
54 | if (PageHighMem(page)) | ||
55 | highmem++; | ||
56 | if (PageReserved(page)) | ||
57 | reserved++; | ||
58 | else if (PageSwapCache(page)) | ||
59 | cached++; | ||
60 | else if (page_count(page)) | ||
61 | shared += page_count(page) - 1; | ||
62 | } | ||
63 | } | ||
64 | printk("%d pages of RAM\n", total); | ||
65 | printk("%d pages of HIGHMEM\n",highmem); | ||
66 | printk("%d reserved pages\n",reserved); | ||
67 | printk("%d pages shared\n",shared); | ||
68 | printk("%d pages swap cached\n",cached); | ||
69 | } | ||
70 | |||
71 | /* | ||
72 | * Cache of MMU context last used. | ||
73 | */ | ||
74 | #ifndef CONFIG_SMP | ||
75 | unsigned long mmu_context_cache_dat; | ||
76 | #else | ||
77 | unsigned long mmu_context_cache_dat[NR_CPUS]; | ||
78 | #endif | ||
79 | static unsigned long hole_pages; | ||
80 | |||
81 | /* | ||
82 | * function prototype | ||
83 | */ | ||
84 | void __init paging_init(void); | ||
85 | void __init mem_init(void); | ||
86 | void free_initmem(void); | ||
87 | #ifdef CONFIG_BLK_DEV_INITRD | ||
88 | void free_initrd_mem(unsigned long, unsigned long); | ||
89 | #endif | ||
90 | |||
91 | /* It'd be good if these lines were in the standard header file. */ | ||
92 | #define START_PFN(nid) \ | ||
93 | (NODE_DATA(nid)->bdata->node_boot_start >> PAGE_SHIFT) | ||
94 | #define MAX_LOW_PFN(nid) (NODE_DATA(nid)->bdata->node_low_pfn) | ||
95 | |||
96 | #ifndef CONFIG_DISCONTIGMEM | ||
97 | unsigned long __init zone_sizes_init(void) | ||
98 | { | ||
99 | unsigned long zones_size[MAX_NR_ZONES] = {0, 0, 0}; | ||
100 | unsigned long max_dma; | ||
101 | unsigned long low; | ||
102 | unsigned long start_pfn; | ||
103 | |||
104 | #ifdef CONFIG_MMU | ||
105 | start_pfn = START_PFN(0); | ||
106 | max_dma = virt_to_phys((char *)MAX_DMA_ADDRESS) >> PAGE_SHIFT; | ||
107 | low = MAX_LOW_PFN(0); | ||
108 | |||
109 | if (low < max_dma){ | ||
110 | zones_size[ZONE_DMA] = low - start_pfn; | ||
111 | zones_size[ZONE_NORMAL] = 0; | ||
112 | } else { | ||
113 | zones_size[ZONE_DMA] = low - start_pfn; | ||
114 | zones_size[ZONE_NORMAL] = low - max_dma; | ||
115 | } | ||
116 | #else | ||
117 | zones_size[ZONE_DMA] = 0 >> PAGE_SHIFT; | ||
118 | zones_size[ZONE_NORMAL] = __MEMORY_SIZE >> PAGE_SHIFT; | ||
119 | start_pfn = __MEMORY_START >> PAGE_SHIFT; | ||
120 | #endif /* CONFIG_MMU */ | ||
121 | |||
122 | free_area_init_node(0, NODE_DATA(0), zones_size, start_pfn, 0); | ||
123 | |||
124 | return 0; | ||
125 | } | ||
126 | #else /* CONFIG_DISCONTIGMEM */ | ||
127 | extern unsigned long zone_sizes_init(void); | ||
128 | #endif /* CONFIG_DISCONTIGMEM */ | ||
129 | |||
130 | /*======================================================================* | ||
131 | * paging_init() : sets up the page tables | ||
132 | *======================================================================*/ | ||
133 | void __init paging_init(void) | ||
134 | { | ||
135 | #ifdef CONFIG_MMU | ||
136 | int i; | ||
137 | pgd_t *pg_dir; | ||
138 | |||
139 | /* We don't need kernel mapping as hardware support that. */ | ||
140 | pg_dir = swapper_pg_dir; | ||
141 | |||
142 | for (i = 0 ; i < USER_PTRS_PER_PGD * 2 ; i++) | ||
143 | pgd_val(pg_dir[i]) = 0; | ||
144 | #endif /* CONFIG_MMU */ | ||
145 | hole_pages = zone_sizes_init(); | ||
146 | } | ||
147 | |||
148 | int __init reservedpages_count(void) | ||
149 | { | ||
150 | int reservedpages, nid, i; | ||
151 | |||
152 | reservedpages = 0; | ||
153 | for_each_online_node(nid) | ||
154 | for (i = 0 ; i < MAX_LOW_PFN(nid) - START_PFN(nid) ; i++) | ||
155 | if (PageReserved(NODE_DATA(nid)->node_mem_map + i)) | ||
156 | reservedpages++; | ||
157 | |||
158 | return reservedpages; | ||
159 | } | ||
160 | |||
161 | /*======================================================================* | ||
162 | * mem_init() : | ||
163 | * orig : arch/sh/mm/init.c | ||
164 | *======================================================================*/ | ||
165 | void __init mem_init(void) | ||
166 | { | ||
167 | int codesize, reservedpages, datasize, initsize; | ||
168 | int nid; | ||
169 | #ifndef CONFIG_MMU | ||
170 | extern unsigned long memory_end; | ||
171 | #endif | ||
172 | |||
173 | num_physpages = 0; | ||
174 | for_each_online_node(nid) | ||
175 | num_physpages += MAX_LOW_PFN(nid) - START_PFN(nid) + 1; | ||
176 | |||
177 | num_physpages -= hole_pages; | ||
178 | |||
179 | #ifndef CONFIG_DISCONTIGMEM | ||
180 | max_mapnr = num_physpages; | ||
181 | #endif /* CONFIG_DISCONTIGMEM */ | ||
182 | |||
183 | #ifdef CONFIG_MMU | ||
184 | high_memory = (void *)__va(PFN_PHYS(MAX_LOW_PFN(0))); | ||
185 | #else | ||
186 | high_memory = (void *)(memory_end & PAGE_MASK); | ||
187 | #endif /* CONFIG_MMU */ | ||
188 | |||
189 | /* clear the zero-page */ | ||
190 | memset(empty_zero_page, 0, PAGE_SIZE); | ||
191 | |||
192 | /* this will put all low memory onto the freelists */ | ||
193 | for_each_online_node(nid) | ||
194 | totalram_pages += free_all_bootmem_node(NODE_DATA(nid)); | ||
195 | |||
196 | reservedpages = reservedpages_count() - hole_pages; | ||
197 | codesize = (unsigned long) &_etext - (unsigned long)&_text; | ||
198 | datasize = (unsigned long) &_edata - (unsigned long)&_etext; | ||
199 | initsize = (unsigned long) &__init_end - (unsigned long)&__init_begin; | ||
200 | |||
201 | printk(KERN_INFO "Memory: %luk/%luk available (%dk kernel code, " | ||
202 | "%dk reserved, %dk data, %dk init)\n", | ||
203 | (unsigned long) nr_free_pages() << (PAGE_SHIFT-10), | ||
204 | num_physpages << (PAGE_SHIFT-10), | ||
205 | codesize >> 10, | ||
206 | reservedpages << (PAGE_SHIFT-10), | ||
207 | datasize >> 10, | ||
208 | initsize >> 10); | ||
209 | } | ||
210 | |||
211 | /*======================================================================* | ||
212 | * free_initmem() : | ||
213 | * orig : arch/sh/mm/init.c | ||
214 | *======================================================================*/ | ||
215 | void free_initmem(void) | ||
216 | { | ||
217 | unsigned long addr; | ||
218 | |||
219 | addr = (unsigned long)(&__init_begin); | ||
220 | for (; addr < (unsigned long)(&__init_end); addr += PAGE_SIZE) { | ||
221 | ClearPageReserved(virt_to_page(addr)); | ||
222 | set_page_count(virt_to_page(addr), 1); | ||
223 | free_page(addr); | ||
224 | totalram_pages++; | ||
225 | } | ||
226 | printk (KERN_INFO "Freeing unused kernel memory: %dk freed\n", \ | ||
227 | (int)(&__init_end - &__init_begin) >> 10); | ||
228 | } | ||
229 | |||
230 | #ifdef CONFIG_BLK_DEV_INITRD | ||
231 | /*======================================================================* | ||
232 | * free_initrd_mem() : | ||
233 | * orig : arch/sh/mm/init.c | ||
234 | *======================================================================*/ | ||
235 | void free_initrd_mem(unsigned long start, unsigned long end) | ||
236 | { | ||
237 | unsigned long p; | ||
238 | for (p = start; p < end; p += PAGE_SIZE) { | ||
239 | ClearPageReserved(virt_to_page(p)); | ||
240 | set_page_count(virt_to_page(p), 1); | ||
241 | free_page(p); | ||
242 | totalram_pages++; | ||
243 | } | ||
244 | printk (KERN_INFO "Freeing initrd memory: %ldk freed\n", (end - start) >> 10); | ||
245 | } | ||
246 | #endif | ||
247 | |||