1 // SPDX-License-Identifier: GPL-2.0
3 * linux/arch/m32r/mm/init.c
5 * Copyright (c) 2001, 2002 Hitoshi Yamamoto
7 * Some code taken from sh version.
8 * Copyright (C) 1999 Niibe Yutaka
9 * Based on linux/arch/i386/mm/init.c:
10 * Copyright (C) 1995 Linus Torvalds
13 #include <linux/init.h>
14 #include <linux/kernel.h>
16 #include <linux/pagemap.h>
17 #include <linux/bootmem.h>
18 #include <linux/swap.h>
19 #include <linux/highmem.h>
20 #include <linux/bitops.h>
21 #include <linux/nodemask.h>
22 #include <linux/pfn.h>
23 #include <linux/gfp.h>
24 #include <asm/types.h>
25 #include <asm/processor.h>
27 #include <asm/pgtable.h>
28 #include <asm/pgalloc.h>
29 #include <asm/mmu_context.h>
30 #include <asm/setup.h>
32 #include <asm/sections.h>
34 pgd_t swapper_pg_dir
[1024];
37 * Cache of MMU context last used.
40 unsigned long mmu_context_cache_dat
;
42 unsigned long mmu_context_cache_dat
[NR_CPUS
];
48 void __init
paging_init(void);
49 void __init
mem_init(void);
50 void free_initmem(void);
51 #ifdef CONFIG_BLK_DEV_INITRD
52 void free_initrd_mem(unsigned long, unsigned long);
55 /* It'd be good if these lines were in the standard header file. */
56 #define START_PFN(nid) (NODE_DATA(nid)->bdata->node_min_pfn)
57 #define MAX_LOW_PFN(nid) (NODE_DATA(nid)->bdata->node_low_pfn)
59 #ifndef CONFIG_DISCONTIGMEM
60 void __init
zone_sizes_init(void)
62 unsigned long zones_size
[MAX_NR_ZONES
] = {0, };
63 unsigned long start_pfn
;
68 unsigned long max_dma
;
70 start_pfn
= START_PFN(0);
71 max_dma
= virt_to_phys((char *)MAX_DMA_ADDRESS
) >> PAGE_SHIFT
;
75 zones_size
[ZONE_DMA
] = low
- start_pfn
;
76 zones_size
[ZONE_NORMAL
] = 0;
78 zones_size
[ZONE_DMA
] = low
- start_pfn
;
79 zones_size
[ZONE_NORMAL
] = low
- max_dma
;
83 zones_size
[ZONE_DMA
] = 0 >> PAGE_SHIFT
;
84 zones_size
[ZONE_NORMAL
] = __MEMORY_SIZE
>> PAGE_SHIFT
;
85 start_pfn
= __MEMORY_START
>> PAGE_SHIFT
;
86 #endif /* CONFIG_MMU */
88 free_area_init_node(0, zones_size
, start_pfn
, 0);
90 #else /* CONFIG_DISCONTIGMEM */
91 extern void zone_sizes_init(void);
92 #endif /* CONFIG_DISCONTIGMEM */
94 /*======================================================================*
95 * paging_init() : sets up the page tables
96 *======================================================================*/
97 void __init
paging_init(void)
103 /* We don't need kernel mapping as hardware support that. */
104 pg_dir
= swapper_pg_dir
;
106 for (i
= 0 ; i
< USER_PTRS_PER_PGD
* 2 ; i
++)
107 pgd_val(pg_dir
[i
]) = 0;
108 #endif /* CONFIG_MMU */
112 /*======================================================================*
114 * orig : arch/sh/mm/init.c
115 *======================================================================*/
116 void __init
mem_init(void)
119 extern unsigned long memory_end
;
121 high_memory
= (void *)(memory_end
& PAGE_MASK
);
123 high_memory
= (void *)__va(PFN_PHYS(MAX_LOW_PFN(0)));
124 #endif /* CONFIG_MMU */
126 /* clear the zero-page */
127 memset(empty_zero_page
, 0, PAGE_SIZE
);
129 set_max_mapnr(get_num_physpages());
131 mem_init_print_info(NULL
);
134 /*======================================================================*
136 * orig : arch/sh/mm/init.c
137 *======================================================================*/
138 void free_initmem(void)
140 free_initmem_default(-1);
143 #ifdef CONFIG_BLK_DEV_INITRD
144 /*======================================================================*
145 * free_initrd_mem() :
146 * orig : arch/sh/mm/init.c
147 *======================================================================*/
148 void free_initrd_mem(unsigned long start
, unsigned long end
)
150 free_reserved_area((void *)start
, (void *)end
, -1, "initrd");