.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * Memory subsystem initialization for Hexagon |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright (c) 2010-2013, The Linux Foundation. All rights reserved. |
---|
5 | | - * |
---|
6 | | - * This program is free software; you can redistribute it and/or modify |
---|
7 | | - * it under the terms of the GNU General Public License version 2 and |
---|
8 | | - * only version 2 as published by the Free Software Foundation. |
---|
9 | | - * |
---|
10 | | - * This program is distributed in the hope that it will be useful, |
---|
11 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
12 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
13 | | - * GNU General Public License for more details. |
---|
14 | | - * |
---|
15 | | - * You should have received a copy of the GNU General Public License |
---|
16 | | - * along with this program; if not, write to the Free Software |
---|
17 | | - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
---|
18 | | - * 02110-1301, USA. |
---|
19 | 6 | */ |
---|
20 | 7 | |
---|
21 | 8 | #include <linux/init.h> |
---|
22 | 9 | #include <linux/mm.h> |
---|
23 | | -#include <linux/bootmem.h> |
---|
| 10 | +#include <linux/memblock.h> |
---|
24 | 11 | #include <asm/atomic.h> |
---|
25 | 12 | #include <linux/highmem.h> |
---|
26 | 13 | #include <asm/tlb.h> |
---|
.. | .. |
---|
67 | 54 | void __init mem_init(void) |
---|
68 | 55 | { |
---|
69 | 56 | /* No idea where this is actually declared. Seems to evade LXR. */ |
---|
70 | | - free_all_bootmem(); |
---|
| 57 | + memblock_free_all(); |
---|
71 | 58 | mem_init_print_info(NULL); |
---|
72 | 59 | |
---|
73 | 60 | /* |
---|
.. | .. |
---|
82 | 69 | * kernel segment table's physical address. |
---|
83 | 70 | */ |
---|
84 | 71 | init_mm.context.ptbase = __pa(init_mm.pgd); |
---|
85 | | -} |
---|
86 | | - |
---|
87 | | -/* |
---|
88 | | - * free_initmem - frees memory used by stuff declared with __init |
---|
89 | | - * |
---|
90 | | - * Todo: free pages between __init_begin and __init_end; possibly |
---|
91 | | - * some devtree related stuff as well. |
---|
92 | | - */ |
---|
93 | | -void __ref free_initmem(void) |
---|
94 | | -{ |
---|
95 | | -} |
---|
96 | | - |
---|
97 | | -/* |
---|
98 | | - * free_initrd_mem - frees... initrd memory. |
---|
99 | | - * @start - start of init memory |
---|
100 | | - * @end - end of init memory |
---|
101 | | - * |
---|
102 | | - * Apparently has to be passed the address of the initrd memory. |
---|
103 | | - * |
---|
104 | | - * Wrapped by #ifdef CONFIG_BLKDEV_INITRD |
---|
105 | | - */ |
---|
106 | | -void free_initrd_mem(unsigned long start, unsigned long end) |
---|
107 | | -{ |
---|
108 | 72 | } |
---|
109 | 73 | |
---|
110 | 74 | void sync_icache_dcache(pte_t pte) |
---|
.. | .. |
---|
127 | 91 | */ |
---|
128 | 92 | void __init paging_init(void) |
---|
129 | 93 | { |
---|
130 | | - unsigned long zones_sizes[MAX_NR_ZONES] = {0, }; |
---|
| 94 | + unsigned long max_zone_pfn[MAX_NR_ZONES] = {0, }; |
---|
131 | 95 | |
---|
132 | 96 | /* |
---|
133 | 97 | * This is not particularly well documented anywhere, but |
---|
.. | .. |
---|
137 | 101 | * adjust accordingly. |
---|
138 | 102 | */ |
---|
139 | 103 | |
---|
140 | | - zones_sizes[ZONE_NORMAL] = max_low_pfn; |
---|
| 104 | + max_zone_pfn[ZONE_NORMAL] = max_low_pfn; |
---|
141 | 105 | |
---|
142 | | - free_area_init(zones_sizes); /* sets up the zonelists and mem_map */ |
---|
| 106 | + free_area_init(max_zone_pfn); /* sets up the zonelists and mem_map */ |
---|
143 | 107 | |
---|
144 | 108 | /* |
---|
145 | 109 | * Start of high memory area. Will probably need something more |
---|
.. | .. |
---|
176 | 140 | |
---|
177 | 141 | void __init setup_arch_memory(void) |
---|
178 | 142 | { |
---|
179 | | - int bootmap_size; |
---|
180 | 143 | /* XXX Todo: this probably should be cleaned up */ |
---|
181 | 144 | u32 *segtable = (u32 *) &swapper_pg_dir[0]; |
---|
182 | 145 | u32 *segtable_end; |
---|
.. | .. |
---|
195 | 158 | bootmem_lastpg = PFN_DOWN((bootmem_lastpg << PAGE_SHIFT) & |
---|
196 | 159 | ~((BIG_KERNEL_PAGE_SIZE) - 1)); |
---|
197 | 160 | |
---|
| 161 | + memblock_add(PHYS_OFFSET, |
---|
| 162 | + (bootmem_lastpg - ARCH_PFN_OFFSET) << PAGE_SHIFT); |
---|
| 163 | + |
---|
| 164 | + /* Reserve kernel text/data/bss */ |
---|
| 165 | + memblock_reserve(PHYS_OFFSET, |
---|
| 166 | + (bootmem_startpg - ARCH_PFN_OFFSET) << PAGE_SHIFT); |
---|
198 | 167 | /* |
---|
199 | 168 | * Reserve the top DMA_RESERVE bytes of RAM for DMA (uncached) |
---|
200 | 169 | * memory allocation |
---|
201 | 170 | */ |
---|
202 | | - |
---|
203 | 171 | max_low_pfn = bootmem_lastpg - PFN_DOWN(DMA_RESERVED_BYTES); |
---|
204 | 172 | min_low_pfn = ARCH_PFN_OFFSET; |
---|
205 | | - bootmap_size = init_bootmem_node(NODE_DATA(0), bootmem_startpg, min_low_pfn, max_low_pfn); |
---|
| 173 | + memblock_reserve(PFN_PHYS(max_low_pfn), DMA_RESERVED_BYTES); |
---|
206 | 174 | |
---|
207 | 175 | printk(KERN_INFO "bootmem_startpg: 0x%08lx\n", bootmem_startpg); |
---|
208 | 176 | printk(KERN_INFO "bootmem_lastpg: 0x%08lx\n", bootmem_lastpg); |
---|
209 | | - printk(KERN_INFO "bootmap_size: %d\n", bootmap_size); |
---|
210 | 177 | printk(KERN_INFO "min_low_pfn: 0x%08lx\n", min_low_pfn); |
---|
211 | 178 | printk(KERN_INFO "max_low_pfn: 0x%08lx\n", max_low_pfn); |
---|
212 | 179 | |
---|
.. | .. |
---|
255 | 222 | __HVM_PDE_S_4KB; |
---|
256 | 223 | printk(KERN_INFO "*segtable = 0x%08x\n", *segtable); |
---|
257 | 224 | #endif |
---|
258 | | - |
---|
259 | | - /* |
---|
260 | | - * Free all the memory that wasn't taken up by the bootmap, the DMA |
---|
261 | | - * reserve, or kernel itself. |
---|
262 | | - */ |
---|
263 | | - free_bootmem(PFN_PHYS(bootmem_startpg) + bootmap_size, |
---|
264 | | - PFN_PHYS(bootmem_lastpg - bootmem_startpg) - bootmap_size - |
---|
265 | | - DMA_RESERVED_BYTES); |
---|
266 | 225 | |
---|
267 | 226 | /* |
---|
268 | 227 | * The bootmem allocator seemingly just lives to feed memory |
---|