spi-topcliff-pch: add recovery processing in case wait-event timeout
[zen-stable.git] / arch / m68k / mm / init_mm.c
blob89f3b203814b5cc4cf51038429271cb4c27df408
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/system.h>
27 #include <asm/traps.h>
28 #include <asm/machdep.h>
29 #include <asm/io.h>
30 #ifdef CONFIG_ATARI
31 #include <asm/atari_stram.h>
32 #endif
33 #include <asm/sections.h>
34 #include <asm/tlb.h>
36 pg_data_t pg_data_map[MAX_NUMNODES];
37 EXPORT_SYMBOL(pg_data_map);
39 int m68k_virt_to_node_shift;
41 #ifndef CONFIG_SINGLE_MEMORY_CHUNK
42 pg_data_t *pg_data_table[65];
43 EXPORT_SYMBOL(pg_data_table);
44 #endif
46 void __init m68k_setup_node(int node)
48 #ifndef CONFIG_SINGLE_MEMORY_CHUNK
49 struct mem_info *info = m68k_memory + node;
50 int i, end;
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;
59 #endif
60 pg_data_map[node].bdata = bootmem_node_data + node;
61 node_set_online(node);
66 * ZERO_PAGE is a special page that is used for zero-initialized
67 * data and COW.
70 void *empty_zero_page;
71 EXPORT_SYMBOL(empty_zero_page);
73 extern void init_pointer_table(unsigned long ptable);
75 /* References to section boundaries */
77 extern pmd_t *zero_pgtable;
79 #if defined(CONFIG_MMU) && !defined(CONFIG_COLDFIRE)
80 #define VECTORS &vectors[0]
81 #else
82 #define VECTORS _ramvec
83 #endif
85 void __init print_memmap(void)
87 #define UL(x) ((unsigned long) (x))
88 #define MLK(b, t) UL(b), UL(t), (UL(t) - UL(b)) >> 10
89 #define MLM(b, t) UL(b), UL(t), (UL(t) - UL(b)) >> 20
90 #define MLK_ROUNDUP(b, t) b, t, DIV_ROUND_UP(((t) - (b)), 1024)
92 pr_notice("Virtual kernel memory layout:\n"
93 " vector : 0x%08lx - 0x%08lx (%4ld KiB)\n"
94 " kmap : 0x%08lx - 0x%08lx (%4ld MiB)\n"
95 " vmalloc : 0x%08lx - 0x%08lx (%4ld MiB)\n"
96 " lowmem : 0x%08lx - 0x%08lx (%4ld MiB)\n"
97 " .init : 0x%p" " - 0x%p" " (%4d KiB)\n"
98 " .text : 0x%p" " - 0x%p" " (%4d KiB)\n"
99 " .data : 0x%p" " - 0x%p" " (%4d KiB)\n"
100 " .bss : 0x%p" " - 0x%p" " (%4d KiB)\n",
101 MLK(VECTORS, VECTORS + 256),
102 MLM(KMAP_START, KMAP_END),
103 MLM(VMALLOC_START, VMALLOC_END),
104 MLM(PAGE_OFFSET, (unsigned long)high_memory),
105 MLK_ROUNDUP(__init_begin, __init_end),
106 MLK_ROUNDUP(_stext, _etext),
107 MLK_ROUNDUP(_sdata, _edata),
108 MLK_ROUNDUP(_sbss, _ebss));
111 void __init mem_init(void)
113 pg_data_t *pgdat;
114 int codepages = 0;
115 int datapages = 0;
116 int initpages = 0;
117 int i;
119 /* this will put all memory onto the freelists */
120 totalram_pages = num_physpages = 0;
121 for_each_online_pgdat(pgdat) {
122 num_physpages += pgdat->node_present_pages;
124 totalram_pages += free_all_bootmem_node(pgdat);
125 for (i = 0; i < pgdat->node_spanned_pages; i++) {
126 struct page *page = pgdat->node_mem_map + i;
127 char *addr = page_to_virt(page);
129 if (!PageReserved(page))
130 continue;
131 if (addr >= _text &&
132 addr < _etext)
133 codepages++;
134 else if (addr >= __init_begin &&
135 addr < __init_end)
136 initpages++;
137 else
138 datapages++;
142 #if !defined(CONFIG_SUN3) && !defined(CONFIG_COLDFIRE)
143 /* insert pointer tables allocated so far into the tablelist */
144 init_pointer_table((unsigned long)kernel_pg_dir);
145 for (i = 0; i < PTRS_PER_PGD; i++) {
146 if (pgd_present(kernel_pg_dir[i]))
147 init_pointer_table(__pgd_page(kernel_pg_dir[i]));
150 /* insert also pointer table that we used to unmap the zero page */
151 if (zero_pgtable)
152 init_pointer_table((unsigned long)zero_pgtable);
153 #endif
155 printk("Memory: %luk/%luk available (%dk kernel code, %dk data, %dk init)\n",
156 nr_free_pages() << (PAGE_SHIFT-10),
157 totalram_pages << (PAGE_SHIFT-10),
158 codepages << (PAGE_SHIFT-10),
159 datapages << (PAGE_SHIFT-10),
160 initpages << (PAGE_SHIFT-10));
161 print_memmap();
164 #ifdef CONFIG_BLK_DEV_INITRD
165 void free_initrd_mem(unsigned long start, unsigned long end)
167 int pages = 0;
168 for (; start < end; start += PAGE_SIZE) {
169 ClearPageReserved(virt_to_page(start));
170 init_page_count(virt_to_page(start));
171 free_page(start);
172 totalram_pages++;
173 pages++;
175 printk ("Freeing initrd memory: %dk freed\n", pages);
177 #endif