diff options
author | John Williams <john.williams@petalogix.com> | 2009-06-22 00:02:09 -0400 |
---|---|---|
committer | Michal Simek <monstr@monstr.eu> | 2009-07-27 01:39:53 -0400 |
commit | 909964ec89ba466d75d53250d5738d1891cc1a3d (patch) | |
tree | 5b0b2ce13b2d82e9193dd0398535f634d8c4d8e7 /arch/microblaze | |
parent | 1170902b343053f50d4caf8ec2aa745fd0ce5c84 (diff) |
microblaze: Final support for statically linked DTB
If r7 is zero at kernel boot, or does not point to a valid DTB, then
we fall back to a DTB (assumed to be) linked statically in the kernel, instead
of blindly copying bogus cruft into the kernel DTB memory region
Signed-off-by: John Williams <john.williams@petalogix.com>
Signed-off-by: Michal Simek <monstr@monstr.eu>
Diffstat (limited to 'arch/microblaze')
-rw-r--r-- | arch/microblaze/include/asm/prom.h | 23 | ||||
-rw-r--r-- | arch/microblaze/kernel/head.S | 15 | ||||
-rw-r--r-- | arch/microblaze/kernel/setup.c | 3 |
3 files changed, 26 insertions, 15 deletions
diff --git a/arch/microblaze/include/asm/prom.h b/arch/microblaze/include/asm/prom.h index 20f7b3a926e8..37e6f305a68e 100644 --- a/arch/microblaze/include/asm/prom.h +++ b/arch/microblaze/include/asm/prom.h | |||
@@ -16,6 +16,18 @@ | |||
16 | #define _ASM_MICROBLAZE_PROM_H | 16 | #define _ASM_MICROBLAZE_PROM_H |
17 | #ifdef __KERNEL__ | 17 | #ifdef __KERNEL__ |
18 | 18 | ||
19 | /* Definitions used by the flattened device tree */ | ||
20 | #define OF_DT_HEADER 0xd00dfeed /* marker */ | ||
21 | #define OF_DT_BEGIN_NODE 0x1 /* Start of node, full name */ | ||
22 | #define OF_DT_END_NODE 0x2 /* End node */ | ||
23 | #define OF_DT_PROP 0x3 /* Property: name off, size, content */ | ||
24 | #define OF_DT_NOP 0x4 /* nop */ | ||
25 | #define OF_DT_END 0x9 | ||
26 | |||
27 | #define OF_DT_VERSION 0x10 | ||
28 | |||
29 | #ifndef __ASSEMBLY__ | ||
30 | |||
19 | #include <linux/types.h> | 31 | #include <linux/types.h> |
20 | #include <linux/proc_fs.h> | 32 | #include <linux/proc_fs.h> |
21 | #include <linux/platform_device.h> | 33 | #include <linux/platform_device.h> |
@@ -29,16 +41,6 @@ | |||
29 | #define of_prop_cmp(s1, s2) strcmp((s1), (s2)) | 41 | #define of_prop_cmp(s1, s2) strcmp((s1), (s2)) |
30 | #define of_node_cmp(s1, s2) strcasecmp((s1), (s2)) | 42 | #define of_node_cmp(s1, s2) strcasecmp((s1), (s2)) |
31 | 43 | ||
32 | /* Definitions used by the flattened device tree */ | ||
33 | #define OF_DT_HEADER 0xd00dfeed /* marker */ | ||
34 | #define OF_DT_BEGIN_NODE 0x1 /* Start of node, full name */ | ||
35 | #define OF_DT_END_NODE 0x2 /* End node */ | ||
36 | #define OF_DT_PROP 0x3 /* Property: name off, size, content */ | ||
37 | #define OF_DT_NOP 0x4 /* nop */ | ||
38 | #define OF_DT_END 0x9 | ||
39 | |||
40 | #define OF_DT_VERSION 0x10 | ||
41 | |||
42 | /* | 44 | /* |
43 | * This is what gets passed to the kernel by prom_init or kexec | 45 | * This is what gets passed to the kernel by prom_init or kexec |
44 | * | 46 | * |
@@ -309,5 +311,6 @@ extern void __iomem *of_iomap(struct device_node *device, int index); | |||
309 | */ | 311 | */ |
310 | #include <linux/of.h> | 312 | #include <linux/of.h> |
311 | 313 | ||
314 | #endif /* __ASSEMBLY__ */ | ||
312 | #endif /* __KERNEL__ */ | 315 | #endif /* __KERNEL__ */ |
313 | #endif /* _ASM_MICROBLAZE_PROM_H */ | 316 | #endif /* _ASM_MICROBLAZE_PROM_H */ |
diff --git a/arch/microblaze/kernel/head.S b/arch/microblaze/kernel/head.S index e568d6ec621b..815bcaae99c3 100644 --- a/arch/microblaze/kernel/head.S +++ b/arch/microblaze/kernel/head.S | |||
@@ -31,6 +31,7 @@ | |||
31 | #include <linux/linkage.h> | 31 | #include <linux/linkage.h> |
32 | #include <asm/thread_info.h> | 32 | #include <asm/thread_info.h> |
33 | #include <asm/page.h> | 33 | #include <asm/page.h> |
34 | #include <asm/prom.h> /* for OF_DT_HEADER */ | ||
34 | 35 | ||
35 | #ifdef CONFIG_MMU | 36 | #ifdef CONFIG_MMU |
36 | #include <asm/setup.h> /* COMMAND_LINE_SIZE */ | 37 | #include <asm/setup.h> /* COMMAND_LINE_SIZE */ |
@@ -54,11 +55,16 @@ ENTRY(_start) | |||
54 | andi r1, r1, ~2 | 55 | andi r1, r1, ~2 |
55 | mts rmsr, r1 | 56 | mts rmsr, r1 |
56 | 57 | ||
57 | /* save fdt to kernel location */ | 58 | /* r7 may point to an FDT, or there may be one linked in. |
58 | /* r7 stores pointer to fdt blob */ | 59 | if it's in r7, we've got to save it away ASAP. |
59 | beqi r7, no_fdt_arg | 60 | We ensure r7 points to a valid FDT, just in case the bootloader |
61 | is broken or non-existent */ | ||
62 | beqi r7, no_fdt_arg /* NULL pointer? don't copy */ | ||
63 | lw r11, r0, r7 /* Does r7 point to a */ | ||
64 | rsubi r11, r11, OF_DT_HEADER /* valid FDT? */ | ||
65 | bnei r11, no_fdt_arg /* No - get out of here */ | ||
60 | or r11, r0, r0 /* incremment */ | 66 | or r11, r0, r0 /* incremment */ |
61 | ori r4, r0, TOPHYS(_fdt_start) /* save bram context */ | 67 | ori r4, r0, TOPHYS(_fdt_start) |
62 | ori r3, r0, (0x4000 - 4) | 68 | ori r3, r0, (0x4000 - 4) |
63 | _copy_fdt: | 69 | _copy_fdt: |
64 | lw r12, r7, r11 /* r12 = r7 + r11 */ | 70 | lw r12, r7, r11 /* r12 = r7 + r11 */ |
@@ -67,6 +73,7 @@ _copy_fdt: | |||
67 | bgtid r3, _copy_fdt /* loop for all entries */ | 73 | bgtid r3, _copy_fdt /* loop for all entries */ |
68 | addik r3, r3, -4 /* descrement loop */ | 74 | addik r3, r3, -4 /* descrement loop */ |
69 | no_fdt_arg: | 75 | no_fdt_arg: |
76 | add r7, r0, r0 /* Clear r7, just to be sure */ | ||
70 | 77 | ||
71 | #ifdef CONFIG_MMU | 78 | #ifdef CONFIG_MMU |
72 | 79 | ||
diff --git a/arch/microblaze/kernel/setup.c b/arch/microblaze/kernel/setup.c index 8709bea09604..59a383621b22 100644 --- a/arch/microblaze/kernel/setup.c +++ b/arch/microblaze/kernel/setup.c | |||
@@ -139,7 +139,8 @@ void __init machine_early_init(const char *cmdline, unsigned int ram, | |||
139 | #endif | 139 | #endif |
140 | 140 | ||
141 | early_printk("Ramdisk addr 0x%08x, FDT 0x%08x\n", ram, fdt); | 141 | early_printk("Ramdisk addr 0x%08x, FDT 0x%08x\n", ram, fdt); |
142 | printk(KERN_NOTICE "Found FDT at 0x%08x\n", fdt); | 142 | if(fdt) |
143 | printk(KERN_NOTICE "Found FDT at 0x%08x\n", fdt); | ||
143 | 144 | ||
144 | #ifdef CONFIG_MTD_UCLINUX | 145 | #ifdef CONFIG_MTD_UCLINUX |
145 | early_printk("Found romfs @ 0x%08x (0x%08x)\n", | 146 | early_printk("Found romfs @ 0x%08x (0x%08x)\n", |