]>
Commit | Line | Data |
---|---|---|
dd1cb3a7 GU |
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 | ||
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> | |
21 | ||
22 | #include <asm/setup.h> | |
7c0f6ba6 | 23 | #include <linux/uaccess.h> |
dd1cb3a7 GU |
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> | |
34 | ||
35 | /* | |
36 | * ZERO_PAGE is a special page that is used for zero-initialized | |
37 | * data and COW. | |
38 | */ | |
39 | void *empty_zero_page; | |
40 | EXPORT_SYMBOL(empty_zero_page); | |
41 | ||
d6fccc75 GU |
42 | #if !defined(CONFIG_SUN3) && !defined(CONFIG_COLDFIRE) |
43 | extern void init_pointer_table(unsigned long ptable); | |
44 | extern pmd_t *zero_pgtable; | |
45 | #endif | |
46 | ||
66d857b0 | 47 | #ifdef CONFIG_MMU |
dd1cb3a7 GU |
48 | |
49 | pg_data_t pg_data_map[MAX_NUMNODES]; | |
50 | EXPORT_SYMBOL(pg_data_map); | |
51 | ||
52 | int m68k_virt_to_node_shift; | |
53 | ||
54 | #ifndef CONFIG_SINGLE_MEMORY_CHUNK | |
55 | pg_data_t *pg_data_table[65]; | |
56 | EXPORT_SYMBOL(pg_data_table); | |
57 | #endif | |
58 | ||
59 | void __init m68k_setup_node(int node) | |
60 | { | |
61 | #ifndef CONFIG_SINGLE_MEMORY_CHUNK | |
79930084 | 62 | struct m68k_mem_info *info = m68k_memory + node; |
dd1cb3a7 GU |
63 | int i, end; |
64 | ||
65 | i = (unsigned long)phys_to_virt(info->addr) >> __virt_to_node_shift(); | |
66 | end = (unsigned long)phys_to_virt(info->addr + info->size - 1) >> __virt_to_node_shift(); | |
67 | for (; i <= end; i++) { | |
68 | if (pg_data_table[i]) | |
e6991137 | 69 | pr_warn("overlap at %u for chunk %u\n", i, node); |
dd1cb3a7 GU |
70 | pg_data_table[i] = pg_data_map + node; |
71 | } | |
72 | #endif | |
73 | pg_data_map[node].bdata = bootmem_node_data + node; | |
74 | node_set_online(node); | |
75 | } | |
76 | ||
dd1cb3a7 GU |
77 | #else /* CONFIG_MMU */ |
78 | ||
79 | /* | |
80 | * paging_init() continues the virtual memory environment setup which | |
81 | * was begun by the code in arch/head.S. | |
82 | * The parameters are pointers to where to stick the starting and ending | |
83 | * addresses of available kernel virtual memory. | |
84 | */ | |
85 | void __init paging_init(void) | |
86 | { | |
87 | /* | |
88 | * Make sure start_mem is page aligned, otherwise bootmem and | |
89 | * page_alloc get different views of the world. | |
90 | */ | |
91 | unsigned long end_mem = memory_end & PAGE_MASK; | |
92 | unsigned long zones_size[MAX_NR_ZONES] = { 0, }; | |
93 | ||
94 | high_memory = (void *) end_mem; | |
95 | ||
96 | empty_zero_page = alloc_bootmem_pages(PAGE_SIZE); | |
dd1cb3a7 GU |
97 | |
98 | /* | |
99 | * Set up SFC/DFC registers (user data space). | |
100 | */ | |
101 | set_fs (USER_DS); | |
102 | ||
103 | zones_size[ZONE_DMA] = (end_mem - PAGE_OFFSET) >> PAGE_SHIFT; | |
104 | free_area_init(zones_size); | |
105 | } | |
106 | ||
f50bf88d GU |
107 | #endif /* CONFIG_MMU */ |
108 | ||
dd1cb3a7 GU |
109 | void free_initmem(void) |
110 | { | |
f50bf88d | 111 | #ifndef CONFIG_MMU_SUN3 |
dbe67df4 | 112 | free_initmem_default(-1); |
f50bf88d | 113 | #endif /* CONFIG_MMU_SUN3 */ |
dd1cb3a7 GU |
114 | } |
115 | ||
dd1cb3a7 GU |
116 | #if defined(CONFIG_MMU) && !defined(CONFIG_COLDFIRE) |
117 | #define VECTORS &vectors[0] | |
66d857b0 | 118 | #else |
dd1cb3a7 GU |
119 | #define VECTORS _ramvec |
120 | #endif | |
121 | ||
122 | void __init print_memmap(void) | |
123 | { | |
124 | #define UL(x) ((unsigned long) (x)) | |
125 | #define MLK(b, t) UL(b), UL(t), (UL(t) - UL(b)) >> 10 | |
126 | #define MLM(b, t) UL(b), UL(t), (UL(t) - UL(b)) >> 20 | |
127 | #define MLK_ROUNDUP(b, t) b, t, DIV_ROUND_UP(((t) - (b)), 1024) | |
128 | ||
129 | pr_notice("Virtual kernel memory layout:\n" | |
130 | " vector : 0x%08lx - 0x%08lx (%4ld KiB)\n" | |
131 | " kmap : 0x%08lx - 0x%08lx (%4ld MiB)\n" | |
132 | " vmalloc : 0x%08lx - 0x%08lx (%4ld MiB)\n" | |
133 | " lowmem : 0x%08lx - 0x%08lx (%4ld MiB)\n" | |
134 | " .init : 0x%p" " - 0x%p" " (%4d KiB)\n" | |
135 | " .text : 0x%p" " - 0x%p" " (%4d KiB)\n" | |
136 | " .data : 0x%p" " - 0x%p" " (%4d KiB)\n" | |
137 | " .bss : 0x%p" " - 0x%p" " (%4d KiB)\n", | |
138 | MLK(VECTORS, VECTORS + 256), | |
139 | MLM(KMAP_START, KMAP_END), | |
140 | MLM(VMALLOC_START, VMALLOC_END), | |
141 | MLM(PAGE_OFFSET, (unsigned long)high_memory), | |
142 | MLK_ROUNDUP(__init_begin, __init_end), | |
143 | MLK_ROUNDUP(_stext, _etext), | |
144 | MLK_ROUNDUP(_sdata, _edata), | |
145 | MLK_ROUNDUP(__bss_start, __bss_stop)); | |
146 | } | |
147 | ||
3e548a9e | 148 | static inline void init_pointer_tables(void) |
dd1cb3a7 | 149 | { |
3e548a9e | 150 | #if defined(CONFIG_MMU) && !defined(CONFIG_SUN3) && !defined(CONFIG_COLDFIRE) |
dd1cb3a7 GU |
151 | int i; |
152 | ||
dd1cb3a7 GU |
153 | /* insert pointer tables allocated so far into the tablelist */ |
154 | init_pointer_table((unsigned long)kernel_pg_dir); | |
155 | for (i = 0; i < PTRS_PER_PGD; i++) { | |
156 | if (pgd_present(kernel_pg_dir[i])) | |
157 | init_pointer_table(__pgd_page(kernel_pg_dir[i])); | |
158 | } | |
159 | ||
160 | /* insert also pointer table that we used to unmap the zero page */ | |
161 | if (zero_pgtable) | |
162 | init_pointer_table((unsigned long)zero_pgtable); | |
163 | #endif | |
3e548a9e | 164 | } |
dd1cb3a7 | 165 | |
3e548a9e JL |
166 | void __init mem_init(void) |
167 | { | |
168 | /* this will put all memory onto the freelists */ | |
169 | free_all_bootmem(); | |
170 | init_pointer_tables(); | |
9671468f | 171 | mem_init_print_info(NULL); |
dd1cb3a7 GU |
172 | print_memmap(); |
173 | } | |
174 | ||
175 | #ifdef CONFIG_BLK_DEV_INITRD | |
176 | void free_initrd_mem(unsigned long start, unsigned long end) | |
177 | { | |
dbe67df4 | 178 | free_reserved_area((void *)start, (void *)end, -1, "initrd"); |
dd1cb3a7 | 179 | } |
1da177e4 | 180 | #endif |