GNU Linux-libre 4.19.211-gnu1
[releases.git] / arch / riscv / mm / init.c
1 /*
2  * Copyright (C) 2012 Regents of the University of California
3  *
4  *   This program is free software; you can redistribute it and/or
5  *   modify it under the terms of the GNU General Public License
6  *   as published by the Free Software Foundation, version 2.
7  *
8  *   This program is distributed in the hope that it will be useful,
9  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
10  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11  *   GNU General Public License for more details.
12  */
13
14 #include <linux/init.h>
15 #include <linux/mm.h>
16 #include <linux/bootmem.h>
17 #include <linux/initrd.h>
18 #include <linux/memblock.h>
19 #include <linux/swap.h>
20 #include <linux/sizes.h>
21
22 #include <asm/tlbflush.h>
23 #include <asm/sections.h>
24 #include <asm/pgtable.h>
25 #include <asm/io.h>
26
27 static void __init zone_sizes_init(void)
28 {
29         unsigned long max_zone_pfns[MAX_NR_ZONES] = { 0, };
30
31 #ifdef CONFIG_ZONE_DMA32
32         max_zone_pfns[ZONE_DMA32] = PFN_DOWN(min(4UL * SZ_1G,
33                         (unsigned long) PFN_PHYS(max_low_pfn)));
34 #endif
35         max_zone_pfns[ZONE_NORMAL] = max_low_pfn;
36
37         free_area_init_nodes(max_zone_pfns);
38 }
39
40 void setup_zero_page(void)
41 {
42         memset((void *)empty_zero_page, 0, PAGE_SIZE);
43 }
44
45 void __init paging_init(void)
46 {
47         setup_zero_page();
48         local_flush_tlb_all();
49         zone_sizes_init();
50 }
51
52 void __init mem_init(void)
53 {
54 #ifdef CONFIG_FLATMEM
55         BUG_ON(!mem_map);
56 #endif /* CONFIG_FLATMEM */
57
58         high_memory = (void *)(__va(PFN_PHYS(max_low_pfn)));
59         free_all_bootmem();
60
61         mem_init_print_info(NULL);
62 }
63
64 void free_initmem(void)
65 {
66         free_initmem_default(0);
67 }
68
69 #ifdef CONFIG_BLK_DEV_INITRD
70 void free_initrd_mem(unsigned long start, unsigned long end)
71 {
72 }
73 #endif /* CONFIG_BLK_DEV_INITRD */