]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - arch/frv/mm/init.c
UBUNTU: Ubuntu-4.15.0-96.97
[mirror_ubuntu-bionic-kernel.git] / arch / frv / mm / init.c
CommitLineData
1da177e4
LT
1/* init.c: memory initialisation for FRV
2 *
3 * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 *
11 * Derived from:
12 * - linux/arch/m68knommu/mm/init.c
13 * - Copyright (C) 1998 D. Jeff Dionne <jeff@lineo.ca>, Kenneth Albanowski <kjahds@kjahds.com>,
14 * - Copyright (C) 2000 Lineo, Inc. (www.lineo.com)
15 * - linux/arch/m68k/mm/init.c
16 * - Copyright (C) 1995 Hamish Macdonald
17 */
18
1da177e4
LT
19#include <linux/signal.h>
20#include <linux/sched.h>
9164bb4a 21#include <linux/sched/task.h>
1da177e4 22#include <linux/pagemap.h>
5a0e3ad6 23#include <linux/gfp.h>
1da177e4
LT
24#include <linux/swap.h>
25#include <linux/mm.h>
26#include <linux/kernel.h>
27#include <linux/string.h>
28#include <linux/types.h>
29#include <linux/bootmem.h>
30#include <linux/highmem.h>
fb56f0f9 31#include <linux/module.h>
1da177e4
LT
32
33#include <asm/setup.h>
34#include <asm/segment.h>
35#include <asm/page.h>
36#include <asm/pgtable.h>
1da177e4
LT
37#include <asm/mmu_context.h>
38#include <asm/virtconvert.h>
39#include <asm/sections.h>
40#include <asm/tlb.h>
41
42#undef DEBUG
43
1da177e4 44/*
1da177e4
LT
45 * ZERO_PAGE is a special page that is used for zero-initialized
46 * data and COW.
47 */
1da177e4 48unsigned long empty_zero_page;
fb56f0f9 49EXPORT_SYMBOL(empty_zero_page);
1da177e4
LT
50
51/*****************************************************************************/
1da177e4
LT
52/*
53 * paging_init() continues the virtual memory environment setup which
54 * was begun by the code in arch/head.S.
55 * The parameters are pointers to where to stick the starting and ending
56 * addresses of available kernel virtual memory.
57 */
58void __init paging_init(void)
59{
f06a9684 60 unsigned long zones_size[MAX_NR_ZONES] = {0, };
1da177e4
LT
61
62 /* allocate some pages for kernel housekeeping tasks */
1da177e4
LT
63 empty_zero_page = (unsigned long) alloc_bootmem_pages(PAGE_SIZE);
64
65 memset((void *) empty_zero_page, 0, PAGE_SIZE);
66
8080f231 67#ifdef CONFIG_HIGHMEM
3f2b73c3 68 if (get_num_physpages() - num_mappedpages) {
1da177e4
LT
69 pgd_t *pge;
70 pud_t *pue;
71 pmd_t *pme;
72
73 pkmap_page_table = alloc_bootmem_pages(PAGE_SIZE);
74
1da177e4
LT
75 pge = swapper_pg_dir + pgd_index_k(PKMAP_BASE);
76 pue = pud_offset(pge, PKMAP_BASE);
77 pme = pmd_offset(pue, PKMAP_BASE);
78 __set_pmd(pme, virt_to_phys(pkmap_page_table) | _PAGE_TABLE);
79 }
80#endif
81
82 /* distribute the allocatable pages across the various zones and pass them to the allocator
83 */
fa642754 84 zones_size[ZONE_NORMAL] = max_low_pfn - min_low_pfn;
1da177e4 85#ifdef CONFIG_HIGHMEM
3f2b73c3 86 zones_size[ZONE_HIGHMEM] = get_num_physpages() - num_mappedpages;
1da177e4
LT
87#endif
88
89 free_area_init(zones_size);
90
91#ifdef CONFIG_MMU
92 /* initialise init's MMU context */
93 init_new_context(&init_task, &init_mm);
94#endif
95
96} /* end paging_init() */
97
98/*****************************************************************************/
99/*
100 *
101 */
102void __init mem_init(void)
103{
3f2b73c3 104 unsigned long code_size = _etext - _stext;
1da177e4 105
0516f884 106 /* this will put all low memory onto the freelists */
0c988534 107 free_all_bootmem();
3f2b73c3
JL
108#if defined(CONFIG_MMU) && defined(CONFIG_HIGHMEM)
109 {
110 unsigned long pfn;
1da177e4 111
3f2b73c3
JL
112 for (pfn = get_num_physpages() - 1;
113 pfn >= num_mappedpages; pfn--)
114 free_highmem_page(&mem_map[pfn]);
115 }
1da177e4
LT
116#endif
117
3f2b73c3
JL
118 mem_init_print_info(NULL);
119 if (rom_length > 0 && rom_length >= code_size)
120 printk("Memory available: %luKiB/%luKiB ROM\n",
121 (rom_length - code_size) >> 10, rom_length >> 10);
1da177e4
LT
122} /* end mem_init() */
123
124/*****************************************************************************/
125/*
126 * free the memory that was only required for initialisation
127 */
e4fc5a1a 128void free_initmem(void)
1da177e4
LT
129{
130#if defined(CONFIG_RAMKERNEL) && !defined(CONFIG_PROTECT_KERNEL)
dbe67df4 131 free_initmem_default(-1);
1da177e4
LT
132#endif
133} /* end free_initmem() */
134
135/*****************************************************************************/
136/*
137 * free the initial ramdisk memory
138 */
139#ifdef CONFIG_BLK_DEV_INITRD
140void __init free_initrd_mem(unsigned long start, unsigned long end)
141{
dbe67df4 142 free_reserved_area((void *)start, (void *)end, -1, "initrd");
1da177e4
LT
143} /* end free_initrd_mem() */
144#endif