12 #include <linux/sched.h>
17 #include <linux/module.h>
21 #include <linux/kernel.h>
23 #include <asm/sections.h>
24 #include <asm/processor.h>
25 #include <asm/pgtable.h>
26 #include <asm/setup.h>
29 #include <mach/board.h>
39 .loops_per_jiffy = 5000000
49 .name =
"Kernel data",
55 .name =
"Kernel code",
76 static unsigned int __initdata res_cache_next_free;
78 static void __init resource_init(
void)
85 for (mem = system_ram;
mem; mem = mem->
sibling) {
102 "Bad reserved resource %s (%08x-%08x)\n",
112 for (pprev = &system_ram, next = system_ram;
next;
114 if (end < next->start)
116 if (start <= next->end) {
118 "Warning: Physical memory map is broken\n");
120 "Warning: %08x-%08x overlaps %08x-%08x\n",
121 start, end, next->
start, next->
end);
126 if (res_cache_next_free >=
ARRAY_SIZE(res_cache)) {
128 "Warning: Failed to add physical memory %08x-%08x\n",
133 new = &res_cache[res_cache_next_free++];
136 new->name =
"System RAM";
151 if (res_cache_next_free >=
ARRAY_SIZE(res_cache))
156 if (end < next->start)
158 if (start <= next->end)
162 new = &res_cache[res_cache_next_free++];
174 static unsigned long __init
183 if ((target + size) <= res->
start)
185 if (target <= res->end)
186 target =
ALIGN(res->
end + 1, align);
189 if ((target + size) > (mem->
end + 1))
203 for (mem = system_ram;
mem; mem = mem->
sibling) {
204 target = find_free_region(mem, size, align);
205 if (target <= mem->end) {
206 ret = add_reserved_region(target, target + size - 1,
245 static int __init early_parse_fbmem(
char *
p)
253 ret = add_reserved_region(fbmem_start,
254 fbmem_start + fbmem_size - 1,
258 "Failed to reserve framebuffer memory\n");
264 if ((fbmem_size & 0x000fffffUL) == 0)
266 else if ((fbmem_size & 0x0000ffffUL) == 0)
271 ret = alloc_reserved_region(&fbmem_start, fbmem_size,
272 align,
"Framebuffer");
275 "Failed to allocate framebuffer memory\n");
290 static int __init early_mem(
char *
p)
294 start = system_ram->start;
299 system_ram->start =
start;
300 system_ram->end = system_ram->start + size - 1;
307 if (tag->
hdr.size > 2) {
308 if ((tag->
u.
core.flags & 1) == 0)
316 static int __init parse_tag_mem(
struct tag *tag)
331 add_physical_memory(start, end);
336 static int __init parse_tag_rdimg(
struct tag *tag)
338 #ifdef CONFIG_BLK_DEV_INITRD
344 "Warning: Only the first initrd image will be used\n");
348 ret = add_reserved_region(mem->
addr, mem->
addr + mem->
size - 1,
352 "Warning: Failed to reserve initrd memory\n");
360 "no initrd support in kernel, ignoring\n");
367 static int __init parse_tag_rsvd_mem(
struct tag *tag)
371 return add_reserved_region(mem->
addr, mem->
addr + mem->
size - 1,
376 static int __init parse_tag_cmdline(
struct tag *tag)
383 static int __init parse_tag_clock(
struct tag *tag)
400 static int __init parse_tag_boardinfo(
struct tag *tag)
413 static int __init parse_tag(
struct tag *tag)
415 extern struct tagtable __tagtable_begin, __tagtable_end;
418 for (t = &__tagtable_begin; t < &__tagtable_end; t++)
419 if (tag->
hdr.tag == t->
tag) {
424 return t < &__tagtable_end;
430 static void __init parse_tags(
struct tag *t)
435 "Ignoring unrecognised tag 0x%08x\n",
443 static unsigned long __init
444 find_bootmap_pfn(
const struct resource *mem)
446 unsigned long bootmap_pages, bootmap_len;
447 unsigned long node_pages =
PFN_UP(resource_size(mem));
462 bootmap_start = find_free_region(mem, bootmap_len,
PAGE_SIZE);
467 #define MAX_LOWMEM HIGHMEM_START
468 #define MAX_LOWMEM_PFN PFN_DOWN(MAX_LOWMEM)
470 static void __init setup_bootmem(
void)
472 unsigned bootmap_size;
473 unsigned long first_pfn, bootmap_pfn,
pages;
479 for (res = system_ram;
res; res = res->
sibling)
483 printk(
" %08x-%08x: %s\n",
488 if (system_ram->sibling)
491 for (res = system_ram;
res; res =
NULL) {
494 bootmap_pfn = find_bootmap_pfn(res);
495 if (bootmap_pfn > max_pfn)
496 panic(
"No space for bootmem bitmap!\n");
500 #ifndef CONFIG_HIGHMEM
506 "Node %u: Only %ld MiB of memory will be used.\n",
510 #error HIGHMEM is not supported by AVR32 yet
516 first_pfn, max_low_pfn);
522 pages = max_low_pfn - first_pfn;
579 if (IS_ERR(cpu_clk)) {
590 boot_cpu_data.
clk = cpu_clk;
592 printk(
"CPU: Running at %lu.%03lu MHz\n",
593 ((cpu_hz + 500) / 1000) / 1000,
594 ((cpu_hz + 500) / 1000) % 1000);
598 *cmdline_p = command_line;