2 * linux/arch/m32r/mm/init.c
4 * Copyright (c) 2001, 2002 Hitoshi Yamamoto
6 * Some code taken from sh version.
7 * Copyright (C) 1999 Niibe Yutaka
8 * Based on linux/arch/i386/mm/init.c:
9 * Copyright (C) 1995 Linus Torvalds
12 #include <linux/init.h>
13 #include <linux/kernel.h>
15 #include <linux/pagemap.h>
16 #include <linux/bootmem.h>
17 #include <linux/swap.h>
18 #include <linux/highmem.h>
19 #include <linux/bitops.h>
20 #include <linux/nodemask.h>
21 #include <linux/pfn.h>
22 #include <linux/gfp.h>
23 #include <asm/types.h>
24 #include <asm/processor.h>
26 #include <asm/pgtable.h>
27 #include <asm/pgalloc.h>
28 #include <asm/mmu_context.h>
29 #include <asm/setup.h>
31 #include <asm/sections.h>
33 pgd_t swapper_pg_dir
[1024];
36 * Cache of MMU context last used.
39 unsigned long mmu_context_cache_dat
;
41 unsigned long mmu_context_cache_dat
[NR_CPUS
];
47 void __init
paging_init(void);
48 void __init
mem_init(void);
49 void free_initmem(void);
50 #ifdef CONFIG_BLK_DEV_INITRD
51 void free_initrd_mem(unsigned long, unsigned long);
54 /* It'd be good if these lines were in the standard header file. */
55 #define START_PFN(nid) (NODE_DATA(nid)->bdata->node_min_pfn)
56 #define MAX_LOW_PFN(nid) (NODE_DATA(nid)->bdata->node_low_pfn)
58 #ifndef CONFIG_DISCONTIGMEM
59 void __init
zone_sizes_init(void)
61 unsigned long zones_size
[MAX_NR_ZONES
] = {0, };
62 unsigned long start_pfn
;
67 unsigned long max_dma
;
69 start_pfn
= START_PFN(0);
70 max_dma
= virt_to_phys((char *)MAX_DMA_ADDRESS
) >> PAGE_SHIFT
;
74 zones_size
[ZONE_DMA
] = low
- start_pfn
;
75 zones_size
[ZONE_NORMAL
] = 0;
77 zones_size
[ZONE_DMA
] = low
- start_pfn
;
78 zones_size
[ZONE_NORMAL
] = low
- max_dma
;
82 zones_size
[ZONE_DMA
] = 0 >> PAGE_SHIFT
;
83 zones_size
[ZONE_NORMAL
] = __MEMORY_SIZE
>> PAGE_SHIFT
;
84 start_pfn
= __MEMORY_START
>> PAGE_SHIFT
;
85 #endif /* CONFIG_MMU */
87 free_area_init_node(0, zones_size
, start_pfn
, 0);
89 #else /* CONFIG_DISCONTIGMEM */
90 extern void zone_sizes_init(void);
91 #endif /* CONFIG_DISCONTIGMEM */
93 /*======================================================================*
94 * paging_init() : sets up the page tables
95 *======================================================================*/
96 void __init
paging_init(void)
102 /* We don't need kernel mapping as hardware support that. */
103 pg_dir
= swapper_pg_dir
;
105 for (i
= 0 ; i
< USER_PTRS_PER_PGD
* 2 ; i
++)
106 pgd_val(pg_dir
[i
]) = 0;
107 #endif /* CONFIG_MMU */
111 /*======================================================================*
113 * orig : arch/sh/mm/init.c
114 *======================================================================*/
115 void __init
mem_init(void)
118 extern unsigned long memory_end
;
120 high_memory
= (void *)(memory_end
& PAGE_MASK
);
122 high_memory
= (void *)__va(PFN_PHYS(MAX_LOW_PFN(0)));
123 #endif /* CONFIG_MMU */
125 /* clear the zero-page */
126 memset(empty_zero_page
, 0, PAGE_SIZE
);
128 set_max_mapnr(get_num_physpages());
130 mem_init_print_info(NULL
);
133 /*======================================================================*
135 * orig : arch/sh/mm/init.c
136 *======================================================================*/
137 void free_initmem(void)
139 free_initmem_default(-1);
142 #ifdef CONFIG_BLK_DEV_INITRD
143 /*======================================================================*
144 * free_initrd_mem() :
145 * orig : arch/sh/mm/init.c
146 *======================================================================*/
147 void free_initrd_mem(unsigned long start
, unsigned long end
)
149 free_reserved_area((void *)start
, (void *)end
, -1, "initrd");