Palmer Dabbelt | 76d2a04 | 2017-07-10 18:00:26 -0700 | [diff] [blame] | 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> |
Palmer Dabbelt | 76d2a04 | 2017-07-10 18:00:26 -0700 | [diff] [blame] | 16 | #include <linux/memblock.h> |
Mike Rapoport | 57c8a66 | 2018-10-30 15:09:49 -0700 | [diff] [blame^] | 17 | #include <linux/initrd.h> |
Palmer Dabbelt | 76d2a04 | 2017-07-10 18:00:26 -0700 | [diff] [blame] | 18 | #include <linux/swap.h> |
Christoph Hellwig | 5ec9c4f | 2018-01-16 09:37:50 +0100 | [diff] [blame] | 19 | #include <linux/sizes.h> |
Palmer Dabbelt | 76d2a04 | 2017-07-10 18:00:26 -0700 | [diff] [blame] | 20 | |
| 21 | #include <asm/tlbflush.h> |
| 22 | #include <asm/sections.h> |
| 23 | #include <asm/pgtable.h> |
| 24 | #include <asm/io.h> |
| 25 | |
| 26 | static void __init zone_sizes_init(void) |
| 27 | { |
Christoph Hellwig | 5ec9c4f | 2018-01-16 09:37:50 +0100 | [diff] [blame] | 28 | unsigned long max_zone_pfns[MAX_NR_ZONES] = { 0, }; |
Palmer Dabbelt | 76d2a04 | 2017-07-10 18:00:26 -0700 | [diff] [blame] | 29 | |
Zong Li | d5fad48 | 2018-06-25 16:49:37 +0800 | [diff] [blame] | 30 | #ifdef CONFIG_ZONE_DMA32 |
Christoph Hellwig | 5ec9c4f | 2018-01-16 09:37:50 +0100 | [diff] [blame] | 31 | max_zone_pfns[ZONE_DMA32] = PFN_DOWN(min(4UL * SZ_1G, max_low_pfn)); |
Zong Li | d5fad48 | 2018-06-25 16:49:37 +0800 | [diff] [blame] | 32 | #endif |
Christoph Hellwig | 5ec9c4f | 2018-01-16 09:37:50 +0100 | [diff] [blame] | 33 | max_zone_pfns[ZONE_NORMAL] = max_low_pfn; |
| 34 | |
| 35 | free_area_init_nodes(max_zone_pfns); |
Palmer Dabbelt | 76d2a04 | 2017-07-10 18:00:26 -0700 | [diff] [blame] | 36 | } |
| 37 | |
| 38 | void setup_zero_page(void) |
| 39 | { |
| 40 | memset((void *)empty_zero_page, 0, PAGE_SIZE); |
| 41 | } |
| 42 | |
| 43 | void __init paging_init(void) |
| 44 | { |
Palmer Dabbelt | 76d2a04 | 2017-07-10 18:00:26 -0700 | [diff] [blame] | 45 | setup_zero_page(); |
| 46 | local_flush_tlb_all(); |
| 47 | zone_sizes_init(); |
| 48 | } |
| 49 | |
| 50 | void __init mem_init(void) |
| 51 | { |
| 52 | #ifdef CONFIG_FLATMEM |
| 53 | BUG_ON(!mem_map); |
| 54 | #endif /* CONFIG_FLATMEM */ |
| 55 | |
| 56 | high_memory = (void *)(__va(PFN_PHYS(max_low_pfn))); |
Mike Rapoport | c6ffc5c | 2018-10-30 15:09:30 -0700 | [diff] [blame] | 57 | memblock_free_all(); |
Palmer Dabbelt | 76d2a04 | 2017-07-10 18:00:26 -0700 | [diff] [blame] | 58 | |
| 59 | mem_init_print_info(NULL); |
| 60 | } |
| 61 | |
| 62 | void free_initmem(void) |
| 63 | { |
| 64 | free_initmem_default(0); |
| 65 | } |
| 66 | |
| 67 | #ifdef CONFIG_BLK_DEV_INITRD |
| 68 | void free_initrd_mem(unsigned long start, unsigned long end) |
| 69 | { |
| 70 | } |
| 71 | #endif /* CONFIG_BLK_DEV_INITRD */ |