1
2
3
4
5
6
7
8
9
10
11
12#include <linux/signal.h>
13#include <linux/sched.h>
14#include <linux/kernel.h>
15#include <linux/errno.h>
16#include <linux/string.h>
17#include <linux/types.h>
18#include <linux/ptrace.h>
19#include <linux/mman.h>
20#include <linux/fs.h>
21#include <linux/mm.h>
22#include <linux/swap.h>
23#include <linux/smp.h>
24#include <linux/init.h>
25#include <linux/initrd.h>
26#include <linux/highmem.h>
27#include <linux/pagemap.h>
28#include <linux/bootmem.h>
29#include <linux/gfp.h>
30
31#include <asm/processor.h>
32#include <asm/uaccess.h>
33#include <asm/pgtable.h>
34#include <asm/pgalloc.h>
35#include <asm/dma.h>
36#include <asm/tlb.h>
37#include <asm/sections.h>
38
39unsigned long highstart_pfn, highend_pfn;
40
41#ifdef CONFIG_MN10300_HAS_ATOMIC_OPS_UNIT
42static struct vm_struct user_iomap_vm;
43#endif
44
45
46
47
48void __init paging_init(void)
49{
50 unsigned long zones_size[MAX_NR_ZONES] = {0,};
51 pte_t *ppte;
52 int loop;
53
54
55
56 memset(swapper_pg_dir, 0, sizeof(swapper_pg_dir));
57 memset(kernel_vmalloc_ptes, 0, sizeof(kernel_vmalloc_ptes));
58
59
60 ppte = kernel_vmalloc_ptes;
61 for (loop = VMALLOC_START / (PAGE_SIZE * PTRS_PER_PTE);
62 loop < VMALLOC_END / (PAGE_SIZE * PTRS_PER_PTE);
63 loop++
64 ) {
65 set_pgd(swapper_pg_dir + loop, __pgd(__pa(ppte) | _PAGE_TABLE));
66 ppte += PAGE_SIZE / sizeof(pte_t);
67 }
68
69
70 zones_size[ZONE_NORMAL] =
71 contig_page_data.bdata->node_low_pfn -
72 contig_page_data.bdata->node_min_pfn;
73
74
75 free_area_init(zones_size);
76
77#ifdef CONFIG_MN10300_HAS_ATOMIC_OPS_UNIT
78
79
80
81
82
83
84
85
86 user_iomap_vm.flags = VM_USERMAP;
87 user_iomap_vm.size = 1 << PAGE_SHIFT;
88 vm_area_register_early(&user_iomap_vm, PAGE_SIZE);
89 ppte = kernel_vmalloc_ptes;
90 set_pte(ppte, pfn_pte(USER_ATOMIC_OPS_PAGE_ADDR >> PAGE_SHIFT,
91 PAGE_USERIO));
92#endif
93
94 local_flush_tlb_all();
95}
96
97
98
99
100void __init mem_init(void)
101{
102 BUG_ON(!mem_map);
103
104#define START_PFN (contig_page_data.bdata->node_min_pfn)
105#define MAX_LOW_PFN (contig_page_data.bdata->node_low_pfn)
106
107 max_mapnr = MAX_LOW_PFN - START_PFN;
108 high_memory = (void *) __va(MAX_LOW_PFN * PAGE_SIZE);
109
110
111 memset(empty_zero_page, 0, PAGE_SIZE);
112
113
114 free_all_bootmem();
115
116 mem_init_print_info(NULL);
117}
118
119
120
121
122void free_initmem(void)
123{
124 free_initmem_default(POISON_FREE_INITMEM);
125}
126
127
128
129
130#ifdef CONFIG_BLK_DEV_INITRD
131void free_initrd_mem(unsigned long start, unsigned long end)
132{
133 free_reserved_area((void *)start, (void *)end, POISON_FREE_INITMEM,
134 "initrd");
135}
136#endif
137