init.c (20c7775aecea04d8ca322039969d49dcf568e0e9) init.c (05cdf457477d6603b207d91873f0a3d4c7f8c1cd)
1/*
2 * Copyright (C) 2007-2008 Michal Simek <monstr@monstr.eu>
3 * Copyright (C) 2006 Atmark Techno, Inc.
4 *
5 * This file is subject to the terms and conditions of the GNU General Public
6 * License. See the file "COPYING" in the main directory of this archive
7 * for more details.
8 */

--- 15 unchanged lines hidden (view full) ---

24#include <asm/pgalloc.h>
25#include <asm/sections.h>
26#include <asm/tlb.h>
27#include <asm/fixmap.h>
28
29/* Use for MMU and noMMU because of PCI generic code */
30int mem_init_done;
31
1/*
2 * Copyright (C) 2007-2008 Michal Simek <monstr@monstr.eu>
3 * Copyright (C) 2006 Atmark Techno, Inc.
4 *
5 * This file is subject to the terms and conditions of the GNU General Public
6 * License. See the file "COPYING" in the main directory of this archive
7 * for more details.
8 */

--- 15 unchanged lines hidden (view full) ---

24#include <asm/pgalloc.h>
25#include <asm/sections.h>
26#include <asm/tlb.h>
27#include <asm/fixmap.h>
28
29/* Use for MMU and noMMU because of PCI generic code */
30int mem_init_done;
31
32#ifndef CONFIG_MMU
33unsigned int __page_offset;
34EXPORT_SYMBOL(__page_offset);
35#endif /* CONFIG_MMU */
36
37char *klimit = _end;
38
39/*
40 * Initialize the bootmem system and give it all the memory we
41 * have available.
42 */
43unsigned long memory_start;
44EXPORT_SYMBOL(memory_start);

--- 32 unchanged lines hidden (view full) ---

77#endif /* CONFIG_HIGHMEM */
78
79/*
80 * paging_init() sets up the page tables - in fact we've already done this.
81 */
82static void __init paging_init(void)
83{
84 unsigned long zones_size[MAX_NR_ZONES];
32char *klimit = _end;
33
34/*
35 * Initialize the bootmem system and give it all the memory we
36 * have available.
37 */
38unsigned long memory_start;
39EXPORT_SYMBOL(memory_start);

--- 32 unchanged lines hidden (view full) ---

72#endif /* CONFIG_HIGHMEM */
73
74/*
75 * paging_init() sets up the page tables - in fact we've already done this.
76 */
77static void __init paging_init(void)
78{
79 unsigned long zones_size[MAX_NR_ZONES];
85#ifdef CONFIG_MMU
86 int idx;
87
88 /* Setup fixmaps */
89 for (idx = 0; idx < __end_of_fixed_addresses; idx++)
90 clear_fixmap(idx);
80 int idx;
81
82 /* Setup fixmaps */
83 for (idx = 0; idx < __end_of_fixed_addresses; idx++)
84 clear_fixmap(idx);
91#endif
92
93 /* Clean every zones */
94 memset(zones_size, 0, sizeof(zones_size));
95
96#ifdef CONFIG_HIGHMEM
97 highmem_init();
98
99 zones_size[ZONE_DMA] = max_low_pfn;
100 zones_size[ZONE_HIGHMEM] = max_pfn;
101#else
102 zones_size[ZONE_DMA] = max_pfn;
103#endif
104
105 /* We don't have holes in memory map */
106 free_area_init(zones_size);
107}
108
109void __init setup_memory(void)
110{
85
86 /* Clean every zones */
87 memset(zones_size, 0, sizeof(zones_size));
88
89#ifdef CONFIG_HIGHMEM
90 highmem_init();
91
92 zones_size[ZONE_DMA] = max_low_pfn;
93 zones_size[ZONE_HIGHMEM] = max_pfn;
94#else
95 zones_size[ZONE_DMA] = max_pfn;
96#endif
97
98 /* We don't have holes in memory map */
99 free_area_init(zones_size);
100}
101
102void __init setup_memory(void)
103{
111#ifndef CONFIG_MMU
112 u32 kernel_align_start, kernel_align_size;
113 phys_addr_t start, end;
114 u64 i;
115
116 /* Find main memory where is the kernel */
117 for_each_mem_range(i, &start, &end) {
118 memory_start = start;
119 lowmem_size = end - start;
120 if ((memory_start <= (u32)_text) &&
121 ((u32)_text <= (memory_start + lowmem_size - 1))) {
122 memory_size = lowmem_size;
123 PAGE_OFFSET = memory_start;
124 pr_info("%s: Main mem: 0x%x, size 0x%08x\n",
125 __func__, (u32) memory_start,
126 (u32) memory_size);
127 break;
128 }
129 }
130
131 if (!memory_start || !memory_size) {
132 panic("%s: Missing memory setting 0x%08x, size=0x%08x\n",
133 __func__, (u32) memory_start, (u32) memory_size);
134 }
135
136 /* reservation of region where is the kernel */
137 kernel_align_start = PAGE_DOWN((u32)_text);
138 /* ALIGN can be remove because _end in vmlinux.lds.S is align */
139 kernel_align_size = PAGE_UP((u32)klimit) - kernel_align_start;
140 pr_info("%s: kernel addr:0x%08x-0x%08x size=0x%08x\n",
141 __func__, kernel_align_start, kernel_align_start
142 + kernel_align_size, kernel_align_size);
143 memblock_reserve(kernel_align_start, kernel_align_size);
144#endif
145 /*
146 * Kernel:
147 * start: base phys address of kernel - page align
148 * end: base phys address of kernel - page align
149 *
150 * min_low_pfn - the first page (mm/bootmem.c - node_boot_start)
151 * max_low_pfn
152 * max_mapnr - the first unused page (mm/bootmem.c - node_low_pfn)

--- 23 unchanged lines hidden (view full) ---

176#ifdef CONFIG_HIGHMEM
177 highmem_setup();
178#endif
179
180 mem_init_print_info(NULL);
181 mem_init_done = 1;
182}
183
104 /*
105 * Kernel:
106 * start: base phys address of kernel - page align
107 * end: base phys address of kernel - page align
108 *
109 * min_low_pfn - the first page (mm/bootmem.c - node_boot_start)
110 * max_low_pfn
111 * max_mapnr - the first unused page (mm/bootmem.c - node_low_pfn)

--- 23 unchanged lines hidden (view full) ---

135#ifdef CONFIG_HIGHMEM
136 highmem_setup();
137#endif
138
139 mem_init_print_info(NULL);
140 mem_init_done = 1;
141}
142
184#ifndef CONFIG_MMU
185int page_is_ram(unsigned long pfn)
186{
143int page_is_ram(unsigned long pfn)
144{
187 return __range_ok(pfn, 0);
188}
189#else
190int page_is_ram(unsigned long pfn)
191{
192 return pfn < max_low_pfn;
193}
194
195/*
196 * Check for command-line options that affect what MMU_init will do.
197 */
198static void mm_cmdline_setup(void)
199{

--- 125 unchanged lines hidden (view full) ---

325 * Mem start + kernel_tlb -> here is limit
326 * because of mem mapping from head.S
327 */
328 return memblock_alloc_try_nid_raw(PAGE_SIZE, PAGE_SIZE,
329 MEMBLOCK_LOW_LIMIT, memory_start + kernel_tlb,
330 NUMA_NO_NODE);
331}
332
145 return pfn < max_low_pfn;
146}
147
148/*
149 * Check for command-line options that affect what MMU_init will do.
150 */
151static void mm_cmdline_setup(void)
152{

--- 125 unchanged lines hidden (view full) ---

278 * Mem start + kernel_tlb -> here is limit
279 * because of mem mapping from head.S
280 */
281 return memblock_alloc_try_nid_raw(PAGE_SIZE, PAGE_SIZE,
282 MEMBLOCK_LOW_LIMIT, memory_start + kernel_tlb,
283 NUMA_NO_NODE);
284}
285
333#endif /* CONFIG_MMU */
334
335void * __ref zalloc_maybe_bootmem(size_t size, gfp_t mask)
336{
337 void *p;
338
339 if (mem_init_done) {
340 p = kzalloc(size, mask);
341 } else {
342 p = memblock_alloc(size, SMP_CACHE_BYTES);
343 if (!p)
344 panic("%s: Failed to allocate %zu bytes\n",
345 __func__, size);
346 }
347
348 return p;
349}
286void * __ref zalloc_maybe_bootmem(size_t size, gfp_t mask)
287{
288 void *p;
289
290 if (mem_init_done) {
291 p = kzalloc(size, mask);
292 } else {
293 p = memblock_alloc(size, SMP_CACHE_BYTES);
294 if (!p)
295 panic("%s: Failed to allocate %zu bytes\n",
296 __func__, size);
297 }
298
299 return p;
300}