Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * linux/arch/m68k/mm/init.c |
| 3 | * |
| 4 | * Copyright (C) 1995 Hamish Macdonald |
| 5 | * |
| 6 | * Contains common initialization routines, specific init code moved |
| 7 | * to motorola.c and sun3mmu.c |
| 8 | */ |
| 9 | |
Roman Zippel | 12d810c | 2007-05-31 00:40:54 -0700 | [diff] [blame] | 10 | #include <linux/module.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | |
| 21 | #include <asm/setup.h> |
| 22 | #include <asm/uaccess.h> |
| 23 | #include <asm/page.h> |
| 24 | #include <asm/pgalloc.h> |
| 25 | #include <asm/system.h> |
| 26 | #include <asm/machdep.h> |
| 27 | #include <asm/io.h> |
| 28 | #ifdef CONFIG_ATARI |
| 29 | #include <asm/atari_stram.h> |
| 30 | #endif |
Geert Uytterhoeven | c85627f | 2008-12-21 12:03:37 +0100 | [diff] [blame] | 31 | #include <asm/sections.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | #include <asm/tlb.h> |
| 33 | |
| 34 | DEFINE_PER_CPU(struct mmu_gather, mmu_gathers); |
| 35 | |
Roman Zippel | 12d810c | 2007-05-31 00:40:54 -0700 | [diff] [blame] | 36 | pg_data_t pg_data_map[MAX_NUMNODES]; |
| 37 | EXPORT_SYMBOL(pg_data_map); |
| 38 | |
| 39 | int m68k_virt_to_node_shift; |
| 40 | |
| 41 | #ifndef CONFIG_SINGLE_MEMORY_CHUNK |
| 42 | pg_data_t *pg_data_table[65]; |
| 43 | EXPORT_SYMBOL(pg_data_table); |
| 44 | #endif |
| 45 | |
Al Viro | 66a3f82 | 2007-07-20 04:33:28 +0100 | [diff] [blame] | 46 | void __init m68k_setup_node(int node) |
Roman Zippel | 12d810c | 2007-05-31 00:40:54 -0700 | [diff] [blame] | 47 | { |
| 48 | #ifndef CONFIG_SINGLE_MEMORY_CHUNK |
| 49 | struct mem_info *info = m68k_memory + node; |
| 50 | int i, end; |
| 51 | |
| 52 | i = (unsigned long)phys_to_virt(info->addr) >> __virt_to_node_shift(); |
| 53 | end = (unsigned long)phys_to_virt(info->addr + info->size - 1) >> __virt_to_node_shift(); |
| 54 | for (; i <= end; i++) { |
| 55 | if (pg_data_table[i]) |
| 56 | printk("overlap at %u for chunk %u\n", i, node); |
| 57 | pg_data_table[i] = pg_data_map + node; |
| 58 | } |
| 59 | #endif |
Johannes Weiner | b61bfa3 | 2008-07-23 21:26:55 -0700 | [diff] [blame] | 60 | pg_data_map[node].bdata = bootmem_node_data + node; |
Roman Zippel | 12d810c | 2007-05-31 00:40:54 -0700 | [diff] [blame] | 61 | node_set_online(node); |
| 62 | } |
| 63 | |
| 64 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 65 | /* |
| 66 | * ZERO_PAGE is a special page that is used for zero-initialized |
| 67 | * data and COW. |
| 68 | */ |
| 69 | |
| 70 | void *empty_zero_page; |
Aneesh Kumar K.V | 5fcf430 | 2008-04-29 08:11:12 -0400 | [diff] [blame] | 71 | EXPORT_SYMBOL(empty_zero_page); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 72 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 73 | extern void init_pointer_table(unsigned long ptable); |
| 74 | |
| 75 | /* References to section boundaries */ |
| 76 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 77 | extern pmd_t *zero_pgtable; |
| 78 | |
| 79 | void __init mem_init(void) |
| 80 | { |
Roman Zippel | 12d810c | 2007-05-31 00:40:54 -0700 | [diff] [blame] | 81 | pg_data_t *pgdat; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 82 | int codepages = 0; |
| 83 | int datapages = 0; |
| 84 | int initpages = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | int i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 86 | |
| 87 | #ifdef CONFIG_ATARI |
| 88 | if (MACH_IS_ATARI) |
| 89 | atari_stram_mem_init_hook(); |
| 90 | #endif |
| 91 | |
| 92 | /* this will put all memory onto the freelists */ |
Roman Zippel | 12d810c | 2007-05-31 00:40:54 -0700 | [diff] [blame] | 93 | totalram_pages = num_physpages = 0; |
| 94 | for_each_online_pgdat(pgdat) { |
| 95 | num_physpages += pgdat->node_present_pages; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 96 | |
Roman Zippel | 12d810c | 2007-05-31 00:40:54 -0700 | [diff] [blame] | 97 | totalram_pages += free_all_bootmem_node(pgdat); |
| 98 | for (i = 0; i < pgdat->node_spanned_pages; i++) { |
| 99 | struct page *page = pgdat->node_mem_map + i; |
| 100 | char *addr = page_to_virt(page); |
| 101 | |
| 102 | if (!PageReserved(page)) |
| 103 | continue; |
| 104 | if (addr >= _text && |
| 105 | addr < _etext) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 106 | codepages++; |
Roman Zippel | 12d810c | 2007-05-31 00:40:54 -0700 | [diff] [blame] | 107 | else if (addr >= __init_begin && |
| 108 | addr < __init_end) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 109 | initpages++; |
| 110 | else |
| 111 | datapages++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 112 | } |
| 113 | } |
| 114 | |
| 115 | #ifndef CONFIG_SUN3 |
| 116 | /* insert pointer tables allocated so far into the tablelist */ |
| 117 | init_pointer_table((unsigned long)kernel_pg_dir); |
| 118 | for (i = 0; i < PTRS_PER_PGD; i++) { |
| 119 | if (pgd_present(kernel_pg_dir[i])) |
| 120 | init_pointer_table(__pgd_page(kernel_pg_dir[i])); |
| 121 | } |
| 122 | |
| 123 | /* insert also pointer table that we used to unmap the zero page */ |
| 124 | if (zero_pgtable) |
| 125 | init_pointer_table((unsigned long)zero_pgtable); |
| 126 | #endif |
| 127 | |
| 128 | printk("Memory: %luk/%luk available (%dk kernel code, %dk data, %dk init)\n", |
| 129 | (unsigned long)nr_free_pages() << (PAGE_SHIFT-10), |
Roman Zippel | 12d810c | 2007-05-31 00:40:54 -0700 | [diff] [blame] | 130 | totalram_pages << (PAGE_SHIFT-10), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 131 | codepages << (PAGE_SHIFT-10), |
| 132 | datapages << (PAGE_SHIFT-10), |
| 133 | initpages << (PAGE_SHIFT-10)); |
| 134 | } |
| 135 | |
| 136 | #ifdef CONFIG_BLK_DEV_INITRD |
| 137 | void free_initrd_mem(unsigned long start, unsigned long end) |
| 138 | { |
| 139 | int pages = 0; |
| 140 | for (; start < end; start += PAGE_SIZE) { |
| 141 | ClearPageReserved(virt_to_page(start)); |
Nick Piggin | 7835e98 | 2006-03-22 00:08:40 -0800 | [diff] [blame] | 142 | init_page_count(virt_to_page(start)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 143 | free_page(start); |
| 144 | totalram_pages++; |
| 145 | pages++; |
| 146 | } |
| 147 | printk ("Freeing initrd memory: %dk freed\n", pages); |
| 148 | } |
| 149 | #endif |