x86, efi: Set runtime_version to the EFI spec revision
[linux/fpc-iii.git] / arch / m68k / mm / init.c
blobf0e05bce92f2533ee8dc78ade768595d825646df
1 /*
2 * linux/arch/m68k/mm/init.c
4 * Copyright (C) 1995 Hamish Macdonald
6 * Contains common initialization routines, specific init code moved
7 * to motorola.c and sun3mmu.c
8 */
10 #include <linux/module.h>
11 #include <linux/signal.h>
12 #include <linux/sched.h>
13 #include <linux/mm.h>
14 #include <linux/swap.h>
15 #include <linux/kernel.h>
16 #include <linux/string.h>
17 #include <linux/types.h>
18 #include <linux/init.h>
19 #include <linux/bootmem.h>
20 #include <linux/gfp.h>
22 #include <asm/setup.h>
23 #include <asm/uaccess.h>
24 #include <asm/page.h>
25 #include <asm/pgalloc.h>
26 #include <asm/traps.h>
27 #include <asm/machdep.h>
28 #include <asm/io.h>
29 #ifdef CONFIG_ATARI
30 #include <asm/atari_stram.h>
31 #endif
32 #include <asm/sections.h>
33 #include <asm/tlb.h>
36 * ZERO_PAGE is a special page that is used for zero-initialized
37 * data and COW.
39 void *empty_zero_page;
40 EXPORT_SYMBOL(empty_zero_page);
42 #ifdef CONFIG_MMU
44 pg_data_t pg_data_map[MAX_NUMNODES];
45 EXPORT_SYMBOL(pg_data_map);
47 int m68k_virt_to_node_shift;
49 #ifndef CONFIG_SINGLE_MEMORY_CHUNK
50 pg_data_t *pg_data_table[65];
51 EXPORT_SYMBOL(pg_data_table);
52 #endif
54 void __init m68k_setup_node(int node)
56 #ifndef CONFIG_SINGLE_MEMORY_CHUNK
57 struct mem_info *info = m68k_memory + node;
58 int i, end;
60 i = (unsigned long)phys_to_virt(info->addr) >> __virt_to_node_shift();
61 end = (unsigned long)phys_to_virt(info->addr + info->size - 1) >> __virt_to_node_shift();
62 for (; i <= end; i++) {
63 if (pg_data_table[i])
64 printk("overlap at %u for chunk %u\n", i, node);
65 pg_data_table[i] = pg_data_map + node;
67 #endif
68 pg_data_map[node].bdata = bootmem_node_data + node;
69 node_set_online(node);
72 extern void init_pointer_table(unsigned long ptable);
73 extern pmd_t *zero_pgtable;
75 #else /* CONFIG_MMU */
78 * paging_init() continues the virtual memory environment setup which
79 * was begun by the code in arch/head.S.
80 * The parameters are pointers to where to stick the starting and ending
81 * addresses of available kernel virtual memory.
83 void __init paging_init(void)
86 * Make sure start_mem is page aligned, otherwise bootmem and
87 * page_alloc get different views of the world.
89 unsigned long end_mem = memory_end & PAGE_MASK;
90 unsigned long zones_size[MAX_NR_ZONES] = { 0, };
92 high_memory = (void *) end_mem;
94 empty_zero_page = alloc_bootmem_pages(PAGE_SIZE);
95 memset(empty_zero_page, 0, PAGE_SIZE);
98 * Set up SFC/DFC registers (user data space).
100 set_fs (USER_DS);
102 zones_size[ZONE_DMA] = (end_mem - PAGE_OFFSET) >> PAGE_SHIFT;
103 free_area_init(zones_size);
106 #endif /* CONFIG_MMU */
108 void free_initmem(void)
110 #ifndef CONFIG_MMU_SUN3
111 unsigned long addr;
113 addr = (unsigned long) __init_begin;
114 for (; addr < ((unsigned long) __init_end); addr += PAGE_SIZE) {
115 ClearPageReserved(virt_to_page(addr));
116 init_page_count(virt_to_page(addr));
117 free_page(addr);
118 totalram_pages++;
120 pr_notice("Freeing unused kernel memory: %luk freed (0x%x - 0x%x)\n",
121 (addr - (unsigned long) __init_begin) >> 10,
122 (unsigned int) __init_begin, (unsigned int) __init_end);
123 #endif /* CONFIG_MMU_SUN3 */
126 #if defined(CONFIG_MMU) && !defined(CONFIG_COLDFIRE)
127 #define VECTORS &vectors[0]
128 #else
129 #define VECTORS _ramvec
130 #endif
132 void __init print_memmap(void)
134 #define UL(x) ((unsigned long) (x))
135 #define MLK(b, t) UL(b), UL(t), (UL(t) - UL(b)) >> 10
136 #define MLM(b, t) UL(b), UL(t), (UL(t) - UL(b)) >> 20
137 #define MLK_ROUNDUP(b, t) b, t, DIV_ROUND_UP(((t) - (b)), 1024)
139 pr_notice("Virtual kernel memory layout:\n"
140 " vector : 0x%08lx - 0x%08lx (%4ld KiB)\n"
141 " kmap : 0x%08lx - 0x%08lx (%4ld MiB)\n"
142 " vmalloc : 0x%08lx - 0x%08lx (%4ld MiB)\n"
143 " lowmem : 0x%08lx - 0x%08lx (%4ld MiB)\n"
144 " .init : 0x%p" " - 0x%p" " (%4d KiB)\n"
145 " .text : 0x%p" " - 0x%p" " (%4d KiB)\n"
146 " .data : 0x%p" " - 0x%p" " (%4d KiB)\n"
147 " .bss : 0x%p" " - 0x%p" " (%4d KiB)\n",
148 MLK(VECTORS, VECTORS + 256),
149 MLM(KMAP_START, KMAP_END),
150 MLM(VMALLOC_START, VMALLOC_END),
151 MLM(PAGE_OFFSET, (unsigned long)high_memory),
152 MLK_ROUNDUP(__init_begin, __init_end),
153 MLK_ROUNDUP(_stext, _etext),
154 MLK_ROUNDUP(_sdata, _edata),
155 MLK_ROUNDUP(__bss_start, __bss_stop));
158 void __init mem_init(void)
160 pg_data_t *pgdat;
161 int codepages = 0;
162 int datapages = 0;
163 int initpages = 0;
164 int i;
166 /* this will put all memory onto the freelists */
167 totalram_pages = num_physpages = 0;
168 for_each_online_pgdat(pgdat) {
169 num_physpages += pgdat->node_present_pages;
171 totalram_pages += free_all_bootmem_node(pgdat);
172 for (i = 0; i < pgdat->node_spanned_pages; i++) {
173 struct page *page = pgdat->node_mem_map + i;
174 char *addr = page_to_virt(page);
176 if (!PageReserved(page))
177 continue;
178 if (addr >= _text &&
179 addr < _etext)
180 codepages++;
181 else if (addr >= __init_begin &&
182 addr < __init_end)
183 initpages++;
184 else
185 datapages++;
189 #if !defined(CONFIG_SUN3) && !defined(CONFIG_COLDFIRE)
190 /* insert pointer tables allocated so far into the tablelist */
191 init_pointer_table((unsigned long)kernel_pg_dir);
192 for (i = 0; i < PTRS_PER_PGD; i++) {
193 if (pgd_present(kernel_pg_dir[i]))
194 init_pointer_table(__pgd_page(kernel_pg_dir[i]));
197 /* insert also pointer table that we used to unmap the zero page */
198 if (zero_pgtable)
199 init_pointer_table((unsigned long)zero_pgtable);
200 #endif
202 pr_info("Memory: %luk/%luk available (%dk kernel code, %dk data, %dk init)\n",
203 nr_free_pages() << (PAGE_SHIFT-10),
204 totalram_pages << (PAGE_SHIFT-10),
205 codepages << (PAGE_SHIFT-10),
206 datapages << (PAGE_SHIFT-10),
207 initpages << (PAGE_SHIFT-10));
208 print_memmap();
211 #ifdef CONFIG_BLK_DEV_INITRD
212 void free_initrd_mem(unsigned long start, unsigned long end)
214 int pages = 0;
215 for (; start < end; start += PAGE_SIZE) {
216 ClearPageReserved(virt_to_page(start));
217 init_page_count(virt_to_page(start));
218 free_page(start);
219 totalram_pages++;
220 pages++;
222 pr_notice("Freeing initrd memory: %dk freed\n",
223 pages << (PAGE_SHIFT - 10));
225 #endif