.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * OpenRISC idle.c |
---|
3 | 4 | * |
---|
.. | .. |
---|
8 | 9 | * Modifications for the OpenRISC architecture: |
---|
9 | 10 | * Copyright (C) 2003 Matjaz Breskvar <phoenix@bsemi.com> |
---|
10 | 11 | * Copyright (C) 2010-2011 Jonas Bonn <jonas@southpole.se> |
---|
11 | | - * |
---|
12 | | - * This program is free software; you can redistribute it and/or |
---|
13 | | - * modify it under the terms of the GNU General Public License |
---|
14 | | - * as published by the Free Software Foundation; either version |
---|
15 | | - * 2 of the License, or (at your option) any later version. |
---|
16 | 12 | */ |
---|
17 | 13 | |
---|
18 | 14 | #include <linux/signal.h> |
---|
.. | .. |
---|
26 | 22 | #include <linux/mm.h> |
---|
27 | 23 | #include <linux/swap.h> |
---|
28 | 24 | #include <linux/smp.h> |
---|
29 | | -#include <linux/bootmem.h> |
---|
| 25 | +#include <linux/memblock.h> |
---|
30 | 26 | #include <linux/init.h> |
---|
31 | 27 | #include <linux/delay.h> |
---|
32 | 28 | #include <linux/blkdev.h> /* for initrd_* */ |
---|
33 | 29 | #include <linux/pagemap.h> |
---|
34 | | -#include <linux/memblock.h> |
---|
35 | 30 | |
---|
36 | | -#include <asm/segment.h> |
---|
37 | 31 | #include <asm/pgalloc.h> |
---|
38 | | -#include <asm/pgtable.h> |
---|
39 | 32 | #include <asm/dma.h> |
---|
40 | 33 | #include <asm/io.h> |
---|
41 | 34 | #include <asm/tlb.h> |
---|
.. | .. |
---|
51 | 44 | |
---|
52 | 45 | static void __init zone_sizes_init(void) |
---|
53 | 46 | { |
---|
54 | | - unsigned long zones_size[MAX_NR_ZONES]; |
---|
55 | | - |
---|
56 | | - /* Clear the zone sizes */ |
---|
57 | | - memset(zones_size, 0, sizeof(zones_size)); |
---|
| 47 | + unsigned long max_zone_pfn[MAX_NR_ZONES] = { 0 }; |
---|
58 | 48 | |
---|
59 | 49 | /* |
---|
60 | 50 | * We use only ZONE_NORMAL |
---|
61 | 51 | */ |
---|
62 | | - zones_size[ZONE_NORMAL] = max_low_pfn; |
---|
| 52 | + max_zone_pfn[ZONE_NORMAL] = max_low_pfn; |
---|
63 | 53 | |
---|
64 | | - free_area_init(zones_size); |
---|
| 54 | + free_area_init(max_zone_pfn); |
---|
65 | 55 | } |
---|
66 | 56 | |
---|
67 | 57 | extern const char _s_kernel_ro[], _e_kernel_ro[]; |
---|
.. | .. |
---|
74 | 64 | */ |
---|
75 | 65 | static void __init map_ram(void) |
---|
76 | 66 | { |
---|
| 67 | + phys_addr_t start, end; |
---|
77 | 68 | unsigned long v, p, e; |
---|
78 | 69 | pgprot_t prot; |
---|
79 | 70 | pgd_t *pge; |
---|
| 71 | + p4d_t *p4e; |
---|
80 | 72 | pud_t *pue; |
---|
81 | 73 | pmd_t *pme; |
---|
82 | 74 | pte_t *pte; |
---|
| 75 | + u64 i; |
---|
83 | 76 | /* These mark extents of read-only kernel pages... |
---|
84 | 77 | * ...from vmlinux.lds.S |
---|
85 | 78 | */ |
---|
86 | | - struct memblock_region *region; |
---|
87 | 79 | |
---|
88 | 80 | v = PAGE_OFFSET; |
---|
89 | 81 | |
---|
90 | | - for_each_memblock(memory, region) { |
---|
91 | | - p = (u32) region->base & PAGE_MASK; |
---|
92 | | - e = p + (u32) region->size; |
---|
| 82 | + for_each_mem_range(i, &start, &end) { |
---|
| 83 | + p = (u32) start & PAGE_MASK; |
---|
| 84 | + e = (u32) end; |
---|
93 | 85 | |
---|
94 | 86 | v = (u32) __va(p); |
---|
95 | 87 | pge = pgd_offset_k(v); |
---|
96 | 88 | |
---|
97 | 89 | while (p < e) { |
---|
98 | 90 | int j; |
---|
99 | | - pue = pud_offset(pge, v); |
---|
| 91 | + p4e = p4d_offset(pge, v); |
---|
| 92 | + pue = pud_offset(p4e, v); |
---|
100 | 93 | pme = pmd_offset(pue, v); |
---|
101 | 94 | |
---|
102 | 95 | if ((u32) pue != (u32) pge || (u32) pme != (u32) pge) { |
---|
.. | .. |
---|
106 | 99 | } |
---|
107 | 100 | |
---|
108 | 101 | /* Alloc one page for holding PTE's... */ |
---|
109 | | - pte = (pte_t *) __va(memblock_alloc(PAGE_SIZE, PAGE_SIZE)); |
---|
| 102 | + pte = memblock_alloc_raw(PAGE_SIZE, PAGE_SIZE); |
---|
| 103 | + if (!pte) |
---|
| 104 | + panic("%s: Failed to allocate page for PTEs\n", |
---|
| 105 | + __func__); |
---|
110 | 106 | set_pmd(pme, __pmd(_KERNPG_TABLE + __pa(pte))); |
---|
111 | 107 | |
---|
112 | 108 | /* Fill the newly allocated page with PTE'S */ |
---|
.. | .. |
---|
125 | 121 | } |
---|
126 | 122 | |
---|
127 | 123 | printk(KERN_INFO "%s: Memory: 0x%x-0x%x\n", __func__, |
---|
128 | | - region->base, region->base + region->size); |
---|
| 124 | + start, end); |
---|
129 | 125 | } |
---|
130 | 126 | } |
---|
131 | 127 | |
---|
.. | .. |
---|
213 | 209 | memset((void *)empty_zero_page, 0, PAGE_SIZE); |
---|
214 | 210 | |
---|
215 | 211 | /* this will put all low memory onto the freelists */ |
---|
216 | | - free_all_bootmem(); |
---|
| 212 | + memblock_free_all(); |
---|
217 | 213 | |
---|
218 | 214 | mem_init_print_info(NULL); |
---|
219 | 215 | |
---|
220 | 216 | printk("mem_init_done ...........................................\n"); |
---|
221 | 217 | mem_init_done = 1; |
---|
222 | 218 | return; |
---|
223 | | -} |
---|
224 | | - |
---|
225 | | -#ifdef CONFIG_BLK_DEV_INITRD |
---|
226 | | -void free_initrd_mem(unsigned long start, unsigned long end) |
---|
227 | | -{ |
---|
228 | | - free_reserved_area((void *)start, (void *)end, -1, "initrd"); |
---|
229 | | -} |
---|
230 | | -#endif |
---|
231 | | - |
---|
232 | | -void free_initmem(void) |
---|
233 | | -{ |
---|
234 | | - free_initmem_default(-1); |
---|
235 | 219 | } |
---|