| 1 |
// SPDX-License-Identifier: GPL-2.0 |
| 2 |
/* |
| 3 |
* linux/arch/m68k/mm/init.c |
| 4 |
* |
| 5 |
* Copyright (C) 1995 Hamish Macdonald |
| 6 |
* |
| 7 |
* Contains common initialization routines, specific init code moved |
| 8 |
* to motorola.c and sun3mmu.c |
| 9 |
*/ |
| 10 |
|
| 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> |
| 22 |
|
| 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> |
| 35 |
|
| 36 |
/* |
| 37 |
* ZERO_PAGE is a special page that is used for zero-initialized |
| 38 |
* data and COW. |
| 39 |
*/ |
| 40 |
void *empty_zero_page; |
| 41 |
EXPORT_SYMBOL(empty_zero_page); |
| 42 |
|
| 43 |
void __init arch_zone_limits_init(unsigned long *max_zone_pfns) |
| 44 |
{ |
| 45 |
max_zone_pfns[ZONE_DMA] = PFN_DOWN(memblock_end_of_DRAM()); |
| 46 |
} |
| 47 |
|
| 48 |
#ifdef CONFIG_MMU |
| 49 |
|
| 50 |
int m68k_virt_to_node_shift; |
| 51 |
|
| 52 |
void __init m68k_setup_node(int node) |
| 53 |
{ |
| 54 |
node_set_online(node); |
| 55 |
} |
| 56 |
|
| 57 |
#else /* CONFIG_MMU */ |
| 58 |
|
| 59 |
/* |
| 60 |
* paging_init() continues the virtual memory environment setup which |
| 61 |
* was begun by the code in arch/head.S. |
| 62 |
* The parameters are pointers to where to stick the starting and ending |
| 63 |
* addresses of available kernel virtual memory. |
| 64 |
*/ |
| 65 |
void __init paging_init(void) |
| 66 |
{ |
| 67 |
/* |
| 68 |
* Make sure start_mem is page aligned, otherwise bootmem and |
| 69 |
* page_alloc get different views of the world. |
| 70 |
*/ |
| 71 |
unsigned long end_mem = memory_end & PAGE_MASK; |
| 72 |
|
| 73 |
high_memory = (void *) end_mem; |
| 74 |
|
| 75 |
empty_zero_page = memblock_alloc_or_panic(PAGE_SIZE, PAGE_SIZE); |
| 76 |
} |
| 77 |
|
| 78 |
#endif /* CONFIG_MMU */ |
| 79 |
|
| 80 |
void free_initmem(void) |
| 81 |
{ |
| 82 |
#ifndef CONFIG_MMU_SUN3 |
| 83 |
free_initmem_default(-1); |
| 84 |
#endif /* CONFIG_MMU_SUN3 */ |
| 85 |
} |
| 86 |
|
| 87 |
#if defined(CONFIG_MMU) && !defined(CONFIG_COLDFIRE) |
| 88 |
#define VECTORS &vectors[0] |
| 89 |
#else |
| 90 |
#define VECTORS _ramvec |
| 91 |
#endif |
| 92 |
|
| 93 |
static inline void init_pointer_tables(void) |
| 94 |
{ |
| 95 |
#if defined(CONFIG_MMU) && !defined(CONFIG_SUN3) && !defined(CONFIG_COLDFIRE) |
| 96 |
int i, j; |
| 97 |
|
| 98 |
/* insert pointer tables allocated so far into the tablelist */ |
| 99 |
init_pointer_table(kernel_pg_dir, TABLE_PGD); |
| 100 |
for (i = 0; i < PTRS_PER_PGD; i++) { |
| 101 |
pud_t *pud = (pud_t *)&kernel_pg_dir[i]; |
| 102 |
pmd_t *pmd_dir; |
| 103 |
|
| 104 |
if (!pud_present(*pud)) |
| 105 |
continue; |
| 106 |
|
| 107 |
pmd_dir = (pmd_t *)pgd_page_vaddr(kernel_pg_dir[i]); |
| 108 |
init_pointer_table(pmd_dir, TABLE_PMD); |
| 109 |
|
| 110 |
for (j = 0; j < PTRS_PER_PMD; j++) { |
| 111 |
pmd_t *pmd = &pmd_dir[j]; |
| 112 |
pte_t *pte_dir; |
| 113 |
|
| 114 |
if (!pmd_present(*pmd)) |
| 115 |
continue; |
| 116 |
|
| 117 |
pte_dir = (pte_t *)pmd_page_vaddr(*pmd); |
| 118 |
init_pointer_table(pte_dir, TABLE_PTE); |
| 119 |
} |
| 120 |
} |
| 121 |
#endif |
| 122 |
} |
| 123 |
|
| 124 |
void __init mem_init(void) |
| 125 |
{ |
| 126 |
init_pointer_tables(); |
| 127 |
} |