RISC-V: Setup init_mm before parse_early_param()
[linux-2.6-block.git] / arch / riscv / mm / init.c
CommitLineData
76d2a049
PD
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>
76d2a049 16#include <linux/memblock.h>
57c8a661 17#include <linux/initrd.h>
76d2a049 18#include <linux/swap.h>
5ec9c4ff 19#include <linux/sizes.h>
76d2a049
PD
20
21#include <asm/tlbflush.h>
22#include <asm/sections.h>
23#include <asm/pgtable.h>
24#include <asm/io.h>
25
26static void __init zone_sizes_init(void)
27{
5ec9c4ff 28 unsigned long max_zone_pfns[MAX_NR_ZONES] = { 0, };
76d2a049 29
d5fad48c 30#ifdef CONFIG_ZONE_DMA32
28198c46
GR
31 max_zone_pfns[ZONE_DMA32] = PFN_DOWN(min(4UL * SZ_1G,
32 (unsigned long) PFN_PHYS(max_low_pfn)));
d5fad48c 33#endif
5ec9c4ff
CH
34 max_zone_pfns[ZONE_NORMAL] = max_low_pfn;
35
36 free_area_init_nodes(max_zone_pfns);
76d2a049
PD
37}
38
39void setup_zero_page(void)
40{
41 memset((void *)empty_zero_page, 0, PAGE_SIZE);
42}
43
44void __init paging_init(void)
45{
76d2a049
PD
46 setup_zero_page();
47 local_flush_tlb_all();
48 zone_sizes_init();
49}
50
51void __init mem_init(void)
52{
53#ifdef CONFIG_FLATMEM
54 BUG_ON(!mem_map);
55#endif /* CONFIG_FLATMEM */
56
57 high_memory = (void *)(__va(PFN_PHYS(max_low_pfn)));
c6ffc5ca 58 memblock_free_all();
76d2a049
PD
59
60 mem_init_print_info(NULL);
61}
62
63void free_initmem(void)
64{
65 free_initmem_default(0);
66}
67
68#ifdef CONFIG_BLK_DEV_INITRD
69void free_initrd_mem(unsigned long start, unsigned long end)
70{
71}
72#endif /* CONFIG_BLK_DEV_INITRD */