Merge tag 'linux-kselftest-kunit-fixes-5.11-rc3' of git://git.kernel.org/pub/scm...
[linux/fpc-iii.git] / arch / m68k / mm / init.c
blob14c1e541451cad3cf23620a05b59afd3825856d3
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * linux/arch/m68k/mm/init.c
5 * Copyright (C) 1995 Hamish Macdonald
7 * Contains common initialization routines, specific init code moved
8 * to motorola.c and sun3mmu.c
9 */
11 #include <linux/module.h>
12 #include <linux/signal.h>
13 #include <linux/sched.h>
14 #include <linux/mm.h>
15 #include <linux/swap.h>
16 #include <linux/kernel.h>
17 #include <linux/string.h>
18 #include <linux/types.h>
19 #include <linux/init.h>
20 #include <linux/memblock.h>
21 #include <linux/gfp.h>
23 #include <asm/setup.h>
24 #include <linux/uaccess.h>
25 #include <asm/page.h>
26 #include <asm/pgalloc.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>
37 * ZERO_PAGE is a special page that is used for zero-initialized
38 * data and COW.
40 void *empty_zero_page;
41 EXPORT_SYMBOL(empty_zero_page);
43 #ifdef CONFIG_MMU
45 int m68k_virt_to_node_shift;
47 #ifdef CONFIG_DISCONTIGMEM
48 pg_data_t pg_data_map[MAX_NUMNODES];
49 EXPORT_SYMBOL(pg_data_map);
51 pg_data_t *pg_data_table[65];
52 EXPORT_SYMBOL(pg_data_table);
53 #endif
55 void __init m68k_setup_node(int node)
57 #ifdef CONFIG_DISCONTIGMEM
58 struct m68k_mem_info *info = m68k_memory + node;
59 int i, end;
61 i = (unsigned long)phys_to_virt(info->addr) >> __virt_to_node_shift();
62 end = (unsigned long)phys_to_virt(info->addr + info->size - 1) >> __virt_to_node_shift();
63 for (; i <= end; i++) {
64 if (pg_data_table[i])
65 pr_warn("overlap at %u for chunk %u\n", i, node);
66 pg_data_table[i] = pg_data_map + node;
68 #endif
69 node_set_online(node);
72 #else /* CONFIG_MMU */
75 * paging_init() continues the virtual memory environment setup which
76 * was begun by the code in arch/head.S.
77 * The parameters are pointers to where to stick the starting and ending
78 * addresses of available kernel virtual memory.
80 void __init paging_init(void)
83 * Make sure start_mem is page aligned, otherwise bootmem and
84 * page_alloc get different views of the world.
86 unsigned long end_mem = memory_end & PAGE_MASK;
87 unsigned long max_zone_pfn[MAX_NR_ZONES] = { 0, };
89 high_memory = (void *) end_mem;
91 empty_zero_page = memblock_alloc(PAGE_SIZE, PAGE_SIZE);
92 if (!empty_zero_page)
93 panic("%s: Failed to allocate %lu bytes align=0x%lx\n",
94 __func__, PAGE_SIZE, PAGE_SIZE);
97 * Set up SFC/DFC registers (user data space).
99 set_fs (USER_DS);
101 max_zone_pfn[ZONE_DMA] = end_mem >> PAGE_SHIFT;
102 free_area_init(max_zone_pfn);
105 #endif /* CONFIG_MMU */
107 void free_initmem(void)
109 #ifndef CONFIG_MMU_SUN3
110 free_initmem_default(-1);
111 #endif /* CONFIG_MMU_SUN3 */
114 #if defined(CONFIG_MMU) && !defined(CONFIG_COLDFIRE)
115 #define VECTORS &vectors[0]
116 #else
117 #define VECTORS _ramvec
118 #endif
120 static inline void init_pointer_tables(void)
122 #if defined(CONFIG_MMU) && !defined(CONFIG_SUN3) && !defined(CONFIG_COLDFIRE)
123 int i, j;
125 /* insert pointer tables allocated so far into the tablelist */
126 init_pointer_table(kernel_pg_dir, TABLE_PGD);
127 for (i = 0; i < PTRS_PER_PGD; i++) {
128 pud_t *pud = (pud_t *)&kernel_pg_dir[i];
129 pmd_t *pmd_dir;
131 if (!pud_present(*pud))
132 continue;
134 pmd_dir = (pmd_t *)pgd_page_vaddr(kernel_pg_dir[i]);
135 init_pointer_table(pmd_dir, TABLE_PMD);
137 for (j = 0; j < PTRS_PER_PMD; j++) {
138 pmd_t *pmd = &pmd_dir[j];
139 pte_t *pte_dir;
141 if (!pmd_present(*pmd))
142 continue;
144 pte_dir = (pte_t *)pmd_page_vaddr(*pmd);
145 init_pointer_table(pte_dir, TABLE_PTE);
148 #endif
151 void __init mem_init(void)
153 /* this will put all memory onto the freelists */
154 memblock_free_all();
155 init_pointer_tables();
156 mem_init_print_info(NULL);