Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
prom.c
Go to the documentation of this file.
1 /*
2  * OpenRISC prom.c
3  *
4  * Linux architectural port borrowing liberally from similar works of
5  * others. All original copyrights apply as per the original source
6  * declaration.
7  *
8  * Modifications for the OpenRISC architecture:
9  * Copyright (C) 2010-2011 Jonas Bonn <[email protected]>
10  *
11  * This program is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU General Public License
13  * as published by the Free Software Foundation; either version
14  * 2 of the License, or (at your option) any later version.
15  *
16  * Architecture specific procedures for creating, accessing and
17  * interpreting the device tree.
18  *
19  */
20 
21 #include <stdarg.h>
22 #include <linux/kernel.h>
23 #include <linux/string.h>
24 #include <linux/init.h>
25 #include <linux/threads.h>
26 #include <linux/spinlock.h>
27 #include <linux/types.h>
28 #include <linux/pci.h>
29 #include <linux/stringify.h>
30 #include <linux/delay.h>
31 #include <linux/initrd.h>
32 #include <linux/bitops.h>
33 #include <linux/module.h>
34 #include <linux/kexec.h>
35 #include <linux/debugfs.h>
36 #include <linux/irq.h>
37 #include <linux/memblock.h>
38 #include <linux/of_fdt.h>
39 
40 #include <asm/prom.h>
41 #include <asm/page.h>
42 #include <asm/processor.h>
43 #include <asm/irq.h>
44 #include <linux/io.h>
45 #include <asm/mmu.h>
46 #include <asm/pgtable.h>
47 #include <asm/sections.h>
48 #include <asm/setup.h>
49 
50 extern char cmd_line[COMMAND_LINE_SIZE];
51 
53 {
54  size &= PAGE_MASK;
55  memblock_add(base, size);
56 }
57 
59 {
60  return __va(memblock_alloc(size, align));
61 }
62 
64 {
65  void *alloc;
66 
67  /* Setup flat device-tree pointer */
69 
70 
71  /* Retrieve various informations from the /chosen node of the
72  * device-tree, including the platform type, initrd location and
73  * size, TCE reserve, and more ...
74  */
75  of_scan_flat_dt(early_init_dt_scan_chosen, cmd_line);
76 
77  /* Scan memory nodes and rebuild MEMBLOCKs */
78  of_scan_flat_dt(early_init_dt_scan_root, NULL);
79  of_scan_flat_dt(early_init_dt_scan_memory, NULL);
80 
81  /* Save command line for /proc/cmdline and then parse parameters */
83 
85 
86  /* We must copy the flattend device tree from init memory to regular
87  * memory because the device tree references the strings in it
88  * directly.
89  */
90 
91  alloc = __va(memblock_alloc(initial_boot_params->totalsize, PAGE_SIZE));
92 
94 
95  initial_boot_params = alloc;
96 }
97 
98 #ifdef CONFIG_BLK_DEV_INITRD
100  unsigned long end)
101 {
102  initrd_start = (unsigned long)__va(start);
103  initrd_end = (unsigned long)__va(end);
105 }
106 #endif