1 // SPDX-License-Identifier: GPL-2.0
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
11 #include <linux/module.h>
12 #include <linux/signal.h>
13 #include <linux/sched.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>
26 #include <asm/pgalloc.h>
27 #include <asm/traps.h>
28 #include <asm/machdep.h>
31 #include <asm/atari_stram.h>
33 #include <asm/sections.h>
37 * ZERO_PAGE is a special page that is used for zero-initialized
40 void *empty_zero_page;
41 EXPORT_SYMBOL(empty_zero_page);
45 int m68k_virt_to_node_shift;
47 void __init m68k_setup_node(int node)
49 node_set_online(node);
52 #else /* CONFIG_MMU */
55 * paging_init() continues the virtual memory environment setup which
56 * was begun by the code in arch/head.S.
57 * The parameters are pointers to where to stick the starting and ending
58 * addresses of available kernel virtual memory.
60 void __init paging_init(void)
63 * Make sure start_mem is page aligned, otherwise bootmem and
64 * page_alloc get different views of the world.
66 unsigned long end_mem = memory_end & PAGE_MASK;
67 unsigned long max_zone_pfn[MAX_NR_ZONES] = { 0, };
69 high_memory = (void *) end_mem;
71 empty_zero_page = memblock_alloc(PAGE_SIZE, PAGE_SIZE);
73 panic("%s: Failed to allocate %lu bytes align=0x%lx\n",
74 __func__, PAGE_SIZE, PAGE_SIZE);
75 max_zone_pfn[ZONE_DMA] = end_mem >> PAGE_SHIFT;
76 free_area_init(max_zone_pfn);
79 #endif /* CONFIG_MMU */
81 void free_initmem(void)
83 #ifndef CONFIG_MMU_SUN3
84 free_initmem_default(-1);
85 #endif /* CONFIG_MMU_SUN3 */
88 #if defined(CONFIG_MMU) && !defined(CONFIG_COLDFIRE)
89 #define VECTORS &vectors[0]
91 #define VECTORS _ramvec
94 static inline void init_pointer_tables(void)
96 #if defined(CONFIG_MMU) && !defined(CONFIG_SUN3) && !defined(CONFIG_COLDFIRE)
99 /* insert pointer tables allocated so far into the tablelist */
100 init_pointer_table(kernel_pg_dir, TABLE_PGD);
101 for (i = 0; i < PTRS_PER_PGD; i++) {
102 pud_t *pud = (pud_t *)&kernel_pg_dir[i];
105 if (!pud_present(*pud))
108 pmd_dir = (pmd_t *)pgd_page_vaddr(kernel_pg_dir[i]);
109 init_pointer_table(pmd_dir, TABLE_PMD);
111 for (j = 0; j < PTRS_PER_PMD; j++) {
112 pmd_t *pmd = &pmd_dir[j];
115 if (!pmd_present(*pmd))
118 pte_dir = (pte_t *)pmd_page_vaddr(*pmd);
119 init_pointer_table(pte_dir, TABLE_PTE);
125 void __init mem_init(void)
127 /* this will put all memory onto the freelists */
129 init_pointer_tables();