init.c (44b56603c4c476b845a824cff6fe905c6268b2a1) init.c (95f72d1ed41a66f1c1c29c24d479de81a0bea36f)
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 */
9
10#include <linux/bootmem.h>
11#include <linux/init.h>
12#include <linux/kernel.h>
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 */
9
10#include <linux/bootmem.h>
11#include <linux/init.h>
12#include <linux/kernel.h>
13#include <linux/lmb.h>
13#include <linux/memblock.h>
14#include <linux/mm.h> /* mem_init */
15#include <linux/initrd.h>
16#include <linux/pagemap.h>
17#include <linux/pfn.h>
18#include <linux/slab.h>
19#include <linux/swap.h>
20
21#include <asm/page.h>

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

71void __init setup_memory(void)
72{
73 int i;
74 unsigned long map_size;
75#ifndef CONFIG_MMU
76 u32 kernel_align_start, kernel_align_size;
77
78 /* Find main memory where is the kernel */
14#include <linux/mm.h> /* mem_init */
15#include <linux/initrd.h>
16#include <linux/pagemap.h>
17#include <linux/pfn.h>
18#include <linux/slab.h>
19#include <linux/swap.h>
20
21#include <asm/page.h>

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

71void __init setup_memory(void)
72{
73 int i;
74 unsigned long map_size;
75#ifndef CONFIG_MMU
76 u32 kernel_align_start, kernel_align_size;
77
78 /* Find main memory where is the kernel */
79 for (i = 0; i < lmb.memory.cnt; i++) {
80 memory_start = (u32) lmb.memory.region[i].base;
81 memory_end = (u32) lmb.memory.region[i].base
82 + (u32) lmb.memory.region[i].size;
79 for (i = 0; i < memblock.memory.cnt; i++) {
80 memory_start = (u32) memblock.memory.region[i].base;
81 memory_end = (u32) memblock.memory.region[i].base
82 + (u32) memblock.memory.region[i].size;
83 if ((memory_start <= (u32)_text) &&
84 ((u32)_text <= memory_end)) {
85 memory_size = memory_end - memory_start;
86 PAGE_OFFSET = memory_start;
87 printk(KERN_INFO "%s: Main mem: 0x%x-0x%x, "
88 "size 0x%08x\n", __func__, (u32) memory_start,
89 (u32) memory_end, (u32) memory_size);
90 break;

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

95 panic("%s: Missing memory setting 0x%08x-0x%08x\n",
96 __func__, (u32) memory_start, (u32) memory_end);
97 }
98
99 /* reservation of region where is the kernel */
100 kernel_align_start = PAGE_DOWN((u32)_text);
101 /* ALIGN can be remove because _end in vmlinux.lds.S is align */
102 kernel_align_size = PAGE_UP((u32)klimit) - kernel_align_start;
83 if ((memory_start <= (u32)_text) &&
84 ((u32)_text <= memory_end)) {
85 memory_size = memory_end - memory_start;
86 PAGE_OFFSET = memory_start;
87 printk(KERN_INFO "%s: Main mem: 0x%x-0x%x, "
88 "size 0x%08x\n", __func__, (u32) memory_start,
89 (u32) memory_end, (u32) memory_size);
90 break;

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

95 panic("%s: Missing memory setting 0x%08x-0x%08x\n",
96 __func__, (u32) memory_start, (u32) memory_end);
97 }
98
99 /* reservation of region where is the kernel */
100 kernel_align_start = PAGE_DOWN((u32)_text);
101 /* ALIGN can be remove because _end in vmlinux.lds.S is align */
102 kernel_align_size = PAGE_UP((u32)klimit) - kernel_align_start;
103 lmb_reserve(kernel_align_start, kernel_align_size);
103 memblock_reserve(kernel_align_start, kernel_align_size);
104 printk(KERN_INFO "%s: kernel addr=0x%08x-0x%08x size=0x%08x\n",
105 __func__, kernel_align_start, kernel_align_start
106 + kernel_align_size, kernel_align_size);
107
108#endif
109 /*
110 * Kernel:
111 * start: base phys address of kernel - page align

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

136 */
137#ifndef CONFIG_MMU
138 map_size = init_bootmem_node(NODE_DATA(0), PFN_UP(TOPHYS((u32)klimit)),
139 min_low_pfn, max_low_pfn);
140#else
141 map_size = init_bootmem_node(&contig_page_data,
142 PFN_UP(TOPHYS((u32)klimit)), min_low_pfn, max_low_pfn);
143#endif
104 printk(KERN_INFO "%s: kernel addr=0x%08x-0x%08x size=0x%08x\n",
105 __func__, kernel_align_start, kernel_align_start
106 + kernel_align_size, kernel_align_size);
107
108#endif
109 /*
110 * Kernel:
111 * start: base phys address of kernel - page align

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

136 */
137#ifndef CONFIG_MMU
138 map_size = init_bootmem_node(NODE_DATA(0), PFN_UP(TOPHYS((u32)klimit)),
139 min_low_pfn, max_low_pfn);
140#else
141 map_size = init_bootmem_node(&contig_page_data,
142 PFN_UP(TOPHYS((u32)klimit)), min_low_pfn, max_low_pfn);
143#endif
144 lmb_reserve(PFN_UP(TOPHYS((u32)klimit)) << PAGE_SHIFT, map_size);
144 memblock_reserve(PFN_UP(TOPHYS((u32)klimit)) << PAGE_SHIFT, map_size);
145
146 /* free bootmem is whole main memory */
147 free_bootmem(memory_start, memory_size);
148
149 /* reserve allocate blocks */
145
146 /* free bootmem is whole main memory */
147 free_bootmem(memory_start, memory_size);
148
149 /* reserve allocate blocks */
150 for (i = 0; i < lmb.reserved.cnt; i++) {
150 for (i = 0; i < memblock.reserved.cnt; i++) {
151 pr_debug("reserved %d - 0x%08x-0x%08x\n", i,
151 pr_debug("reserved %d - 0x%08x-0x%08x\n", i,
152 (u32) lmb.reserved.region[i].base,
153 (u32) lmb_size_bytes(&lmb.reserved, i));
154 reserve_bootmem(lmb.reserved.region[i].base,
155 lmb_size_bytes(&lmb.reserved, i) - 1, BOOTMEM_DEFAULT);
152 (u32) memblock.reserved.region[i].base,
153 (u32) memblock_size_bytes(&memblock.reserved, i));
154 reserve_bootmem(memblock.reserved.region[i].base,
155 memblock_size_bytes(&memblock.reserved, i) - 1, BOOTMEM_DEFAULT);
156 }
157#ifdef CONFIG_MMU
158 init_bootmem_done = 1;
159#endif
160 paging_init();
161}
162
163void free_init_pages(char *what, unsigned long begin, unsigned long end)

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

230 /* Look for mem= option on command line */
231 p = strstr(cmd_line, "mem=");
232 if (p) {
233 p += 4;
234 maxmem = memparse(p, &p);
235 if (maxmem && memory_size > maxmem) {
236 memory_size = maxmem;
237 memory_end = memory_start + memory_size;
156 }
157#ifdef CONFIG_MMU
158 init_bootmem_done = 1;
159#endif
160 paging_init();
161}
162
163void free_init_pages(char *what, unsigned long begin, unsigned long end)

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

230 /* Look for mem= option on command line */
231 p = strstr(cmd_line, "mem=");
232 if (p) {
233 p += 4;
234 maxmem = memparse(p, &p);
235 if (maxmem && memory_size > maxmem) {
236 memory_size = maxmem;
237 memory_end = memory_start + memory_size;
238 lmb.memory.region[0].size = memory_size;
238 memblock.memory.region[0].size = memory_size;
239 }
240 }
241}
242
243/*
244 * MMU_init_hw does the chip-specific initialization of the MMU hardware.
245 */
246static void __init mmu_init_hw(void)

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

268 * and sets up the page tables and the MMU hardware ready to go.
269 */
270
271/* called from head.S */
272asmlinkage void __init mmu_init(void)
273{
274 unsigned int kstart, ksize;
275
239 }
240 }
241}
242
243/*
244 * MMU_init_hw does the chip-specific initialization of the MMU hardware.
245 */
246static void __init mmu_init_hw(void)

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

268 * and sets up the page tables and the MMU hardware ready to go.
269 */
270
271/* called from head.S */
272asmlinkage void __init mmu_init(void)
273{
274 unsigned int kstart, ksize;
275
276 if (!lmb.reserved.cnt) {
276 if (!memblock.reserved.cnt) {
277 printk(KERN_EMERG "Error memory count\n");
278 machine_restart(NULL);
279 }
280
277 printk(KERN_EMERG "Error memory count\n");
278 machine_restart(NULL);
279 }
280
281 if ((u32) lmb.memory.region[0].size < 0x1000000) {
281 if ((u32) memblock.memory.region[0].size < 0x1000000) {
282 printk(KERN_EMERG "Memory must be greater than 16MB\n");
283 machine_restart(NULL);
284 }
285 /* Find main memory where the kernel is */
282 printk(KERN_EMERG "Memory must be greater than 16MB\n");
283 machine_restart(NULL);
284 }
285 /* Find main memory where the kernel is */
286 memory_start = (u32) lmb.memory.region[0].base;
287 memory_end = (u32) lmb.memory.region[0].base +
288 (u32) lmb.memory.region[0].size;
286 memory_start = (u32) memblock.memory.region[0].base;
287 memory_end = (u32) memblock.memory.region[0].base +
288 (u32) memblock.memory.region[0].size;
289 memory_size = memory_end - memory_start;
290
291 mm_cmdline_setup(); /* FIXME parse args from command line - not used */
292
293 /*
294 * Map out the kernel text/data/bss from the available physical
295 * memory.
296 */
297 kstart = __pa(CONFIG_KERNEL_START); /* kernel start */
298 /* kernel size */
299 ksize = PAGE_ALIGN(((u32)_end - (u32)CONFIG_KERNEL_START));
289 memory_size = memory_end - memory_start;
290
291 mm_cmdline_setup(); /* FIXME parse args from command line - not used */
292
293 /*
294 * Map out the kernel text/data/bss from the available physical
295 * memory.
296 */
297 kstart = __pa(CONFIG_KERNEL_START); /* kernel start */
298 /* kernel size */
299 ksize = PAGE_ALIGN(((u32)_end - (u32)CONFIG_KERNEL_START));
300 lmb_reserve(kstart, ksize);
300 memblock_reserve(kstart, ksize);
301
302#if defined(CONFIG_BLK_DEV_INITRD)
303 /* Remove the init RAM disk from the available memory. */
304/* if (initrd_start) {
305 mem_pieces_remove(&phys_avail, __pa(initrd_start),
306 initrd_end - initrd_start, 1);
307 }*/
308#endif /* CONFIG_BLK_DEV_INITRD */

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

330 void *p;
331 if (init_bootmem_done) {
332 p = alloc_bootmem_pages(PAGE_SIZE);
333 } else {
334 /*
335 * Mem start + 32MB -> here is limit
336 * because of mem mapping from head.S
337 */
301
302#if defined(CONFIG_BLK_DEV_INITRD)
303 /* Remove the init RAM disk from the available memory. */
304/* if (initrd_start) {
305 mem_pieces_remove(&phys_avail, __pa(initrd_start),
306 initrd_end - initrd_start, 1);
307 }*/
308#endif /* CONFIG_BLK_DEV_INITRD */

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

330 void *p;
331 if (init_bootmem_done) {
332 p = alloc_bootmem_pages(PAGE_SIZE);
333 } else {
334 /*
335 * Mem start + 32MB -> here is limit
336 * because of mem mapping from head.S
337 */
338 p = __va(lmb_alloc_base(PAGE_SIZE, PAGE_SIZE,
338 p = __va(memblock_alloc_base(PAGE_SIZE, PAGE_SIZE,
339 memory_start + 0x2000000));
340 }
341 return p;
342}
343
344#endif /* CONFIG_MMU */
345
346void * __init_refok alloc_maybe_bootmem(size_t size, gfp_t mask)

--- 20 unchanged lines hidden ---
339 memory_start + 0x2000000));
340 }
341 return p;
342}
343
344#endif /* CONFIG_MMU */
345
346void * __init_refok alloc_maybe_bootmem(size_t size, gfp_t mask)

--- 20 unchanged lines hidden ---