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
10 #include <linux/module.h>
11 #include <linux/signal.h>
12 #include <linux/sched.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>
21 #include <asm/setup.h>
22 #include <asm/uaccess.h>
24 #include <asm/pgalloc.h>
25 #include <asm/system.h>
26 #include <asm/machdep.h>
29 #include <asm/atari_stram.h>
33 DEFINE_PER_CPU(struct mmu_gather, mmu_gathers);
35 static bootmem_data_t __initdata bootmem_data[MAX_NUMNODES];
37 pg_data_t pg_data_map[MAX_NUMNODES];
38 EXPORT_SYMBOL(pg_data_map);
40 int m68k_virt_to_node_shift;
42 #ifndef CONFIG_SINGLE_MEMORY_CHUNK
43 pg_data_t *pg_data_table[65];
44 EXPORT_SYMBOL(pg_data_table);
47 void __init m68k_setup_node(int node)
49 #ifndef CONFIG_SINGLE_MEMORY_CHUNK
50 struct mem_info *info = m68k_memory + node;
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++) {
57 printk("overlap at %u for chunk %u\n", i, node);
58 pg_data_table[i] = pg_data_map + node;
61 pg_data_map[node].bdata = bootmem_data + node;
62 node_set_online(node);
67 * ZERO_PAGE is a special page that is used for zero-initialized
71 void *empty_zero_page;
76 int free = 0, total = 0, reserved = 0, shared = 0;
80 printk("\nMem-info:\n");
82 for_each_online_pgdat(pgdat) {
83 for (i = 0; i < pgdat->node_spanned_pages; i++) {
84 struct page *page = pgdat->node_mem_map + i;
86 if (PageReserved(page))
88 else if (PageSwapCache(page))
90 else if (!page_count(page))
93 shared += page_count(page) - 1;
96 printk("%d pages of RAM\n",total);
97 printk("%d free pages\n",free);
98 printk("%d reserved pages\n",reserved);
99 printk("%d pages shared\n",shared);
100 printk("%d pages swap cached\n",cached);
103 extern void init_pointer_table(unsigned long ptable);
105 /* References to section boundaries */
107 extern char _text[], _etext[];
108 extern char __init_begin[], __init_end[];
110 extern pmd_t *zero_pgtable;
112 void __init mem_init(void)
122 atari_stram_mem_init_hook();
125 /* this will put all memory onto the freelists */
126 totalram_pages = num_physpages = 0;
127 for_each_online_pgdat(pgdat) {
128 num_physpages += pgdat->node_present_pages;
130 totalram_pages += free_all_bootmem_node(pgdat);
131 for (i = 0; i < pgdat->node_spanned_pages; i++) {
132 struct page *page = pgdat->node_mem_map + i;
133 char *addr = page_to_virt(page);
135 if (!PageReserved(page))
140 else if (addr >= __init_begin &&
149 /* insert pointer tables allocated so far into the tablelist */
150 init_pointer_table((unsigned long)kernel_pg_dir);
151 for (i = 0; i < PTRS_PER_PGD; i++) {
152 if (pgd_present(kernel_pg_dir[i]))
153 init_pointer_table(__pgd_page(kernel_pg_dir[i]));
156 /* insert also pointer table that we used to unmap the zero page */
158 init_pointer_table((unsigned long)zero_pgtable);
161 printk("Memory: %luk/%luk available (%dk kernel code, %dk data, %dk init)\n",
162 (unsigned long)nr_free_pages() << (PAGE_SHIFT-10),
163 totalram_pages << (PAGE_SHIFT-10),
164 codepages << (PAGE_SHIFT-10),
165 datapages << (PAGE_SHIFT-10),
166 initpages << (PAGE_SHIFT-10));
169 #ifdef CONFIG_BLK_DEV_INITRD
170 void free_initrd_mem(unsigned long start, unsigned long end)
173 for (; start < end; start += PAGE_SIZE) {
174 ClearPageReserved(virt_to_page(start));
175 init_page_count(virt_to_page(start));
180 printk ("Freeing initrd memory: %dk freed\n", pages);