diff options
author | David Gibson <david@gibson.dropbear.id.au> | 2007-12-09 22:28:39 -0500 |
---|---|---|
committer | Paul Mackerras <paulus@samba.org> | 2007-12-10 21:46:14 -0500 |
commit | 2f0dfeaa84a8eea56218b77ffc61ed3dd7181847 (patch) | |
tree | fe17563bf38c2cc92df7ae997f70ff788eb9fa6b /arch | |
parent | 1cade99497c881a8c719df561d1bdc96831ff040 (diff) |
[POWERPC] Use embedded libfdt in the bootwrapper
This incorporates libfdt (from the source embedded in an earlier
commit) into the wrapper.a library used by the bootwrapper. This
includes adding a libfdt_env.h file, which the libfdt sources need in
order to integrate into the bootwrapper environment, and a
libfdt-wrapper.c which provides glue to connect the bootwrapper's
abstract device tree callbacks to the libfdt functions.
In addition, this changes the various wrapper and platform files to
use libfdt functions instead of the older flatdevtree.c library.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/powerpc/boot/Makefile | 6 | ||||
-rw-r--r-- | arch/powerpc/boot/bamboo.c | 2 | ||||
-rw-r--r-- | arch/powerpc/boot/cuboot-52xx.c | 2 | ||||
-rw-r--r-- | arch/powerpc/boot/cuboot-83xx.c | 2 | ||||
-rw-r--r-- | arch/powerpc/boot/cuboot-85xx.c | 2 | ||||
-rw-r--r-- | arch/powerpc/boot/cuboot-8xx.c | 2 | ||||
-rw-r--r-- | arch/powerpc/boot/cuboot-hpc2.c | 2 | ||||
-rw-r--r-- | arch/powerpc/boot/cuboot-pq2.c | 2 | ||||
-rw-r--r-- | arch/powerpc/boot/cuboot-sequoia.c | 2 | ||||
-rw-r--r-- | arch/powerpc/boot/ebony.c | 2 | ||||
-rw-r--r-- | arch/powerpc/boot/ep88xc.c | 2 | ||||
-rw-r--r-- | arch/powerpc/boot/holly.c | 2 | ||||
-rw-r--r-- | arch/powerpc/boot/libfdt-wrapper.c | 182 | ||||
-rw-r--r-- | arch/powerpc/boot/libfdt_env.h | 17 | ||||
-rw-r--r-- | arch/powerpc/boot/ops.h | 1 | ||||
-rw-r--r-- | arch/powerpc/boot/prpmc2800.c | 3 | ||||
-rw-r--r-- | arch/powerpc/boot/ps3.c | 2 | ||||
-rw-r--r-- | arch/powerpc/boot/treeboot-walnut.c | 2 |
18 files changed, 219 insertions, 16 deletions
diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile index e1c73e9afa59..2d2c9843ce93 100644 --- a/arch/powerpc/boot/Makefile +++ b/arch/powerpc/boot/Makefile | |||
@@ -33,7 +33,7 @@ ifeq ($(call cc-option-yn, -fstack-protector),y) | |||
33 | BOOTCFLAGS += -fno-stack-protector | 33 | BOOTCFLAGS += -fno-stack-protector |
34 | endif | 34 | endif |
35 | 35 | ||
36 | BOOTCFLAGS += -I$(obj) -I$(srctree)/$(obj) | 36 | BOOTCFLAGS += -I$(obj) -I$(srctree)/$(obj) -I$(srctree)/$(src)/libfdt |
37 | 37 | ||
38 | $(obj)/4xx.o: BOOTCFLAGS += -mcpu=440 | 38 | $(obj)/4xx.o: BOOTCFLAGS += -mcpu=440 |
39 | $(obj)/ebony.o: BOOTCFLAGS += -mcpu=440 | 39 | $(obj)/ebony.o: BOOTCFLAGS += -mcpu=440 |
@@ -46,7 +46,9 @@ zliblinuxheader := zlib.h zconf.h zutil.h | |||
46 | $(addprefix $(obj)/,$(zlib) gunzip_util.o main.o): \ | 46 | $(addprefix $(obj)/,$(zlib) gunzip_util.o main.o): \ |
47 | $(addprefix $(obj)/,$(zliblinuxheader)) $(addprefix $(obj)/,$(zlibheader)) | 47 | $(addprefix $(obj)/,$(zliblinuxheader)) $(addprefix $(obj)/,$(zlibheader)) |
48 | 48 | ||
49 | src-libfdt := fdt.c fdt_ro.c fdt_wip.c fdt_sw.c fdt_rw.c fdt_strerror.c | ||
49 | src-wlib := string.S crt0.S stdio.c main.c flatdevtree.c flatdevtree_misc.c \ | 50 | src-wlib := string.S crt0.S stdio.c main.c flatdevtree.c flatdevtree_misc.c \ |
51 | $(addprefix libfdt/,$(src-libfdt)) libfdt-wrapper.c \ | ||
50 | ns16550.c serial.c simple_alloc.c div64.S util.S \ | 52 | ns16550.c serial.c simple_alloc.c div64.S util.S \ |
51 | gunzip_util.c elf_util.c $(zlib) devtree.c oflib.c ofconsole.c \ | 53 | gunzip_util.c elf_util.c $(zlib) devtree.c oflib.c ofconsole.c \ |
52 | 4xx.c ebony.c mv64x60.c mpsc.c mv64x60_i2c.c cuboot.c bamboo.c \ | 54 | 4xx.c ebony.c mv64x60.c mpsc.c mv64x60_i2c.c cuboot.c bamboo.c \ |
@@ -101,8 +103,10 @@ quiet_cmd_bootar = BOOTAR $@ | |||
101 | cmd_bootar = $(CROSS32AR) -cr $@.$$$$ $(filter-out FORCE,$^); mv $@.$$$$ $@ | 103 | cmd_bootar = $(CROSS32AR) -cr $@.$$$$ $(filter-out FORCE,$^); mv $@.$$$$ $@ |
102 | 104 | ||
103 | $(patsubst %.c,%.o, $(filter %.c, $(src-boot))): %.o: %.c FORCE | 105 | $(patsubst %.c,%.o, $(filter %.c, $(src-boot))): %.o: %.c FORCE |
106 | $(Q)mkdir -p $(dir $@) | ||
104 | $(call if_changed_dep,bootcc) | 107 | $(call if_changed_dep,bootcc) |
105 | $(patsubst %.S,%.o, $(filter %.S, $(src-boot))): %.o: %.S FORCE | 108 | $(patsubst %.S,%.o, $(filter %.S, $(src-boot))): %.o: %.S FORCE |
109 | $(Q)mkdir -p $(dir $@) | ||
106 | $(call if_changed_dep,bootas) | 110 | $(call if_changed_dep,bootas) |
107 | 111 | ||
108 | $(obj)/wrapper.a: $(obj-wlib) FORCE | 112 | $(obj)/wrapper.a: $(obj-wlib) FORCE |
diff --git a/arch/powerpc/boot/bamboo.c b/arch/powerpc/boot/bamboo.c index f61fcdab1c7c..e634359d98e9 100644 --- a/arch/powerpc/boot/bamboo.c +++ b/arch/powerpc/boot/bamboo.c | |||
@@ -42,6 +42,6 @@ void bamboo_init(void *mac0, void *mac1) | |||
42 | platform_ops.exit = ibm44x_dbcr_reset; | 42 | platform_ops.exit = ibm44x_dbcr_reset; |
43 | bamboo_mac0 = mac0; | 43 | bamboo_mac0 = mac0; |
44 | bamboo_mac1 = mac1; | 44 | bamboo_mac1 = mac1; |
45 | ft_init(_dtb_start, 0, 32); | 45 | fdt_init(_dtb_start); |
46 | serial_console_init(); | 46 | serial_console_init(); |
47 | } | 47 | } |
diff --git a/arch/powerpc/boot/cuboot-52xx.c b/arch/powerpc/boot/cuboot-52xx.c index 9256a26d40e4..a8611546a656 100644 --- a/arch/powerpc/boot/cuboot-52xx.c +++ b/arch/powerpc/boot/cuboot-52xx.c | |||
@@ -53,7 +53,7 @@ void platform_init(unsigned long r3, unsigned long r4, unsigned long r5, | |||
53 | unsigned long r6, unsigned long r7) | 53 | unsigned long r6, unsigned long r7) |
54 | { | 54 | { |
55 | CUBOOT_INIT(); | 55 | CUBOOT_INIT(); |
56 | ft_init(_dtb_start, _dtb_end - _dtb_start, 32); | 56 | fdt_init(_dtb_start); |
57 | serial_console_init(); | 57 | serial_console_init(); |
58 | platform_ops.fixups = platform_fixups; | 58 | platform_ops.fixups = platform_fixups; |
59 | } | 59 | } |
diff --git a/arch/powerpc/boot/cuboot-83xx.c b/arch/powerpc/boot/cuboot-83xx.c index a0505509abcc..acd860ed7393 100644 --- a/arch/powerpc/boot/cuboot-83xx.c +++ b/arch/powerpc/boot/cuboot-83xx.c | |||
@@ -52,7 +52,7 @@ void platform_init(unsigned long r3, unsigned long r4, unsigned long r5, | |||
52 | unsigned long r6, unsigned long r7) | 52 | unsigned long r6, unsigned long r7) |
53 | { | 53 | { |
54 | CUBOOT_INIT(); | 54 | CUBOOT_INIT(); |
55 | ft_init(_dtb_start, _dtb_end - _dtb_start, 32); | 55 | fdt_init(_dtb_start); |
56 | serial_console_init(); | 56 | serial_console_init(); |
57 | platform_ops.fixups = platform_fixups; | 57 | platform_ops.fixups = platform_fixups; |
58 | } | 58 | } |
diff --git a/arch/powerpc/boot/cuboot-85xx.c b/arch/powerpc/boot/cuboot-85xx.c index 345dcbecef0f..943779ed19be 100644 --- a/arch/powerpc/boot/cuboot-85xx.c +++ b/arch/powerpc/boot/cuboot-85xx.c | |||
@@ -53,7 +53,7 @@ void platform_init(unsigned long r3, unsigned long r4, unsigned long r5, | |||
53 | unsigned long r6, unsigned long r7) | 53 | unsigned long r6, unsigned long r7) |
54 | { | 54 | { |
55 | CUBOOT_INIT(); | 55 | CUBOOT_INIT(); |
56 | ft_init(_dtb_start, _dtb_end - _dtb_start, 32); | 56 | fdt_init(_dtb_start); |
57 | serial_console_init(); | 57 | serial_console_init(); |
58 | platform_ops.fixups = platform_fixups; | 58 | platform_ops.fixups = platform_fixups; |
59 | } | 59 | } |
diff --git a/arch/powerpc/boot/cuboot-8xx.c b/arch/powerpc/boot/cuboot-8xx.c index 0e82015a5f95..c202c8868bd6 100644 --- a/arch/powerpc/boot/cuboot-8xx.c +++ b/arch/powerpc/boot/cuboot-8xx.c | |||
@@ -41,7 +41,7 @@ void platform_init(unsigned long r3, unsigned long r4, unsigned long r5, | |||
41 | unsigned long r6, unsigned long r7) | 41 | unsigned long r6, unsigned long r7) |
42 | { | 42 | { |
43 | CUBOOT_INIT(); | 43 | CUBOOT_INIT(); |
44 | ft_init(_dtb_start, _dtb_end - _dtb_start, 32); | 44 | fdt_init(_dtb_start); |
45 | serial_console_init(); | 45 | serial_console_init(); |
46 | platform_ops.fixups = platform_fixups; | 46 | platform_ops.fixups = platform_fixups; |
47 | } | 47 | } |
diff --git a/arch/powerpc/boot/cuboot-hpc2.c b/arch/powerpc/boot/cuboot-hpc2.c index d333898bca30..1b8953259d75 100644 --- a/arch/powerpc/boot/cuboot-hpc2.c +++ b/arch/powerpc/boot/cuboot-hpc2.c | |||
@@ -42,7 +42,7 @@ void platform_init(unsigned long r3, unsigned long r4, unsigned long r5, | |||
42 | unsigned long r6, unsigned long r7) | 42 | unsigned long r6, unsigned long r7) |
43 | { | 43 | { |
44 | CUBOOT_INIT(); | 44 | CUBOOT_INIT(); |
45 | ft_init(_dtb_start, _dtb_end - _dtb_start, 32); | 45 | fdt_init(_dtb_start); |
46 | serial_console_init(); | 46 | serial_console_init(); |
47 | platform_ops.fixups = platform_fixups; | 47 | platform_ops.fixups = platform_fixups; |
48 | } | 48 | } |
diff --git a/arch/powerpc/boot/cuboot-pq2.c b/arch/powerpc/boot/cuboot-pq2.c index 61574f3272dd..f56ac6cae9f3 100644 --- a/arch/powerpc/boot/cuboot-pq2.c +++ b/arch/powerpc/boot/cuboot-pq2.c | |||
@@ -255,7 +255,7 @@ void platform_init(unsigned long r3, unsigned long r4, unsigned long r5, | |||
255 | unsigned long r6, unsigned long r7) | 255 | unsigned long r6, unsigned long r7) |
256 | { | 256 | { |
257 | CUBOOT_INIT(); | 257 | CUBOOT_INIT(); |
258 | ft_init(_dtb_start, _dtb_end - _dtb_start, 32); | 258 | fdt_init(_dtb_start); |
259 | serial_console_init(); | 259 | serial_console_init(); |
260 | platform_ops.fixups = pq2_platform_fixups; | 260 | platform_ops.fixups = pq2_platform_fixups; |
261 | } | 261 | } |
diff --git a/arch/powerpc/boot/cuboot-sequoia.c b/arch/powerpc/boot/cuboot-sequoia.c index ec635e0bd4ec..cf78260fcf3f 100644 --- a/arch/powerpc/boot/cuboot-sequoia.c +++ b/arch/powerpc/boot/cuboot-sequoia.c | |||
@@ -51,6 +51,6 @@ void platform_init(unsigned long r3, unsigned long r4, unsigned long r5, | |||
51 | CUBOOT_INIT(); | 51 | CUBOOT_INIT(); |
52 | platform_ops.fixups = sequoia_fixups; | 52 | platform_ops.fixups = sequoia_fixups; |
53 | platform_ops.exit = ibm44x_dbcr_reset; | 53 | platform_ops.exit = ibm44x_dbcr_reset; |
54 | ft_init(_dtb_start, 0, 32); | 54 | fdt_init(_dtb_start); |
55 | serial_console_init(); | 55 | serial_console_init(); |
56 | } | 56 | } |
diff --git a/arch/powerpc/boot/ebony.c b/arch/powerpc/boot/ebony.c index 86c0f5df0a86..ee31be5e633e 100644 --- a/arch/powerpc/boot/ebony.c +++ b/arch/powerpc/boot/ebony.c | |||
@@ -146,6 +146,6 @@ void ebony_init(void *mac0, void *mac1) | |||
146 | platform_ops.exit = ibm44x_dbcr_reset; | 146 | platform_ops.exit = ibm44x_dbcr_reset; |
147 | ebony_mac0 = mac0; | 147 | ebony_mac0 = mac0; |
148 | ebony_mac1 = mac1; | 148 | ebony_mac1 = mac1; |
149 | ft_init(_dtb_start, _dtb_end - _dtb_start, 32); | 149 | fdt_init(_dtb_start); |
150 | serial_console_init(); | 150 | serial_console_init(); |
151 | } | 151 | } |
diff --git a/arch/powerpc/boot/ep88xc.c b/arch/powerpc/boot/ep88xc.c index 6b87cdce3fe7..a400f5407155 100644 --- a/arch/powerpc/boot/ep88xc.c +++ b/arch/powerpc/boot/ep88xc.c | |||
@@ -45,7 +45,7 @@ void platform_init(unsigned long r3, unsigned long r4, unsigned long r5, | |||
45 | mem_size *= 1024 * 1024; | 45 | mem_size *= 1024 * 1024; |
46 | simple_alloc_init(_end, mem_size - (unsigned long)_end, 32, 64); | 46 | simple_alloc_init(_end, mem_size - (unsigned long)_end, 32, 64); |
47 | 47 | ||
48 | ft_init(_dtb_start, _dtb_end - _dtb_start, 32); | 48 | fdt_init(_dtb_start); |
49 | 49 | ||
50 | planetcore_set_stdout_path(table); | 50 | planetcore_set_stdout_path(table); |
51 | 51 | ||
diff --git a/arch/powerpc/boot/holly.c b/arch/powerpc/boot/holly.c index 199e783aea4d..58013b923178 100644 --- a/arch/powerpc/boot/holly.c +++ b/arch/powerpc/boot/holly.c | |||
@@ -28,6 +28,6 @@ void platform_init(unsigned long r3, unsigned long r4, unsigned long r5) | |||
28 | u32 heapsize = 0x8000000 - (u32)_end; /* 128M */ | 28 | u32 heapsize = 0x8000000 - (u32)_end; /* 128M */ |
29 | 29 | ||
30 | simple_alloc_init(_end, heapsize, 32, 64); | 30 | simple_alloc_init(_end, heapsize, 32, 64); |
31 | ft_init(_dtb_start, 0, 4); | 31 | fdt_init(_dtb_start); |
32 | serial_console_init(); | 32 | serial_console_init(); |
33 | } | 33 | } |
diff --git a/arch/powerpc/boot/libfdt-wrapper.c b/arch/powerpc/boot/libfdt-wrapper.c new file mode 100644 index 000000000000..002da16c97c1 --- /dev/null +++ b/arch/powerpc/boot/libfdt-wrapper.c | |||
@@ -0,0 +1,182 @@ | |||
1 | /* | ||
2 | * This file does the necessary interface mapping between the bootwrapper | ||
3 | * device tree operations and the interface provided by shared source | ||
4 | * files flatdevicetree.[ch]. | ||
5 | * | ||
6 | * Copyright 2007 David Gibson, IBM Corporation. | ||
7 | * | ||
8 | * This library is free software; you can redistribute it and/or | ||
9 | * modify it under the terms of the GNU General Public License as | ||
10 | * published by the Free Software Foundation; either version 2 of the | ||
11 | * License, or (at your option) any later version. | ||
12 | * | ||
13 | * This library is distributed in the hope that it will be useful, but | ||
14 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
16 | * General Public License for more details. | ||
17 | * | ||
18 | * You should have received a copy of the GNU General Public License | ||
19 | * along with this library; if not, write to the Free Software | ||
20 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
21 | * 02110-1301 USA | ||
22 | */ | ||
23 | |||
24 | #include <stddef.h> | ||
25 | #include <stdio.h> | ||
26 | #include <page.h> | ||
27 | #include <libfdt.h> | ||
28 | #include "ops.h" | ||
29 | |||
30 | #define DEBUG 0 | ||
31 | #define BAD_ERROR(err) (((err) < 0) \ | ||
32 | && ((err) != -FDT_ERR_NOTFOUND) \ | ||
33 | && ((err) != -FDT_ERR_EXISTS)) | ||
34 | |||
35 | #define check_err(err) \ | ||
36 | ({ \ | ||
37 | if (BAD_ERROR(err) || ((err < 0) && DEBUG)) \ | ||
38 | printf("%s():%d %s\n\r", __FUNCTION__, __LINE__, \ | ||
39 | fdt_strerror(err)); \ | ||
40 | if (BAD_ERROR(err)) \ | ||
41 | exit(); \ | ||
42 | (err < 0) ? -1 : 0; \ | ||
43 | }) | ||
44 | |||
45 | #define offset_devp(off) \ | ||
46 | ({ \ | ||
47 | int offset = (off); \ | ||
48 | check_err(offset) ? NULL : (void *)(offset+1); \ | ||
49 | }) | ||
50 | |||
51 | #define devp_offset(devp) (((int)(devp))-1) | ||
52 | |||
53 | static void *fdt; | ||
54 | static void *buf; /* = NULL */ | ||
55 | |||
56 | #define EXPAND_GRANULARITY 1024 | ||
57 | |||
58 | static void expand_buf(int minexpand) | ||
59 | { | ||
60 | int size = fdt_totalsize(fdt); | ||
61 | int rc; | ||
62 | |||
63 | size = _ALIGN(size + minexpand, EXPAND_GRANULARITY); | ||
64 | buf = platform_ops.realloc(buf, size); | ||
65 | if (!buf) | ||
66 | fatal("Couldn't find %d bytes to expand device tree\n\r", size); | ||
67 | rc = fdt_open_into(fdt, buf, size); | ||
68 | if (rc != 0) | ||
69 | fatal("Couldn't expand fdt into new buffer: %s\n\r", | ||
70 | fdt_strerror(rc)); | ||
71 | |||
72 | fdt = buf; | ||
73 | } | ||
74 | |||
75 | static void *fdt_wrapper_finddevice(const char *path) | ||
76 | { | ||
77 | return offset_devp(fdt_path_offset(fdt, path)); | ||
78 | } | ||
79 | |||
80 | static int fdt_wrapper_getprop(const void *devp, const char *name, | ||
81 | void *buf, const int buflen) | ||
82 | { | ||
83 | const void *p; | ||
84 | int len; | ||
85 | |||
86 | p = fdt_getprop(fdt, devp_offset(devp), name, &len); | ||
87 | if (!p) | ||
88 | return check_err(len); | ||
89 | memcpy(buf, p, min(len, buflen)); | ||
90 | return len; | ||
91 | } | ||
92 | |||
93 | static int fdt_wrapper_setprop(const void *devp, const char *name, | ||
94 | const void *buf, const int len) | ||
95 | { | ||
96 | int rc; | ||
97 | |||
98 | rc = fdt_setprop(fdt, devp_offset(devp), name, buf, len); | ||
99 | if (rc == -FDT_ERR_NOSPACE) { | ||
100 | expand_buf(len + 16); | ||
101 | rc = fdt_setprop(fdt, devp_offset(devp), name, buf, len); | ||
102 | } | ||
103 | |||
104 | return check_err(rc); | ||
105 | } | ||
106 | |||
107 | static void *fdt_wrapper_get_parent(const void *devp) | ||
108 | { | ||
109 | return offset_devp(fdt_parent_offset(fdt, devp_offset(devp))); | ||
110 | } | ||
111 | |||
112 | static void *fdt_wrapper_create_node(const void *devp, const char *name) | ||
113 | { | ||
114 | int offset; | ||
115 | |||
116 | offset = fdt_add_subnode(fdt, devp_offset(devp), name); | ||
117 | if (offset == -FDT_ERR_NOSPACE) { | ||
118 | expand_buf(strlen(name) + 16); | ||
119 | offset = fdt_add_subnode(fdt, devp_offset(devp), name); | ||
120 | } | ||
121 | |||
122 | return offset_devp(offset); | ||
123 | } | ||
124 | |||
125 | static void *fdt_wrapper_find_node_by_prop_value(const void *prev, | ||
126 | const char *name, | ||
127 | const char *val, | ||
128 | int len) | ||
129 | { | ||
130 | return offset_devp(fdt_node_offset_by_prop_value(fdt, devp_offset(prev), | ||
131 | name, val, len)); | ||
132 | } | ||
133 | |||
134 | static char *fdt_wrapper_get_path(const void *devp, char *buf, int len) | ||
135 | { | ||
136 | int rc; | ||
137 | |||
138 | rc = fdt_get_path(fdt, devp_offset(devp), buf, len); | ||
139 | if (check_err(rc)) | ||
140 | return NULL; | ||
141 | return buf; | ||
142 | } | ||
143 | |||
144 | static unsigned long fdt_wrapper_finalize(void) | ||
145 | { | ||
146 | int rc; | ||
147 | |||
148 | rc = fdt_pack(fdt); | ||
149 | if (rc != 0) | ||
150 | fatal("Couldn't pack flat tree: %s\n\r", | ||
151 | fdt_strerror(rc)); | ||
152 | return (unsigned long)fdt; | ||
153 | } | ||
154 | |||
155 | void fdt_init(void *blob) | ||
156 | { | ||
157 | int err; | ||
158 | |||
159 | dt_ops.finddevice = fdt_wrapper_finddevice; | ||
160 | dt_ops.getprop = fdt_wrapper_getprop; | ||
161 | dt_ops.setprop = fdt_wrapper_setprop; | ||
162 | dt_ops.get_parent = fdt_wrapper_get_parent; | ||
163 | dt_ops.create_node = fdt_wrapper_create_node; | ||
164 | dt_ops.find_node_by_prop_value = fdt_wrapper_find_node_by_prop_value; | ||
165 | dt_ops.get_path = fdt_wrapper_get_path; | ||
166 | dt_ops.finalize = fdt_wrapper_finalize; | ||
167 | |||
168 | /* Make sure the dt blob is the right version and so forth */ | ||
169 | fdt = blob; | ||
170 | err = fdt_open_into(fdt, fdt, fdt_totalsize(blob)); | ||
171 | if (err == -FDT_ERR_NOSPACE) { | ||
172 | int bufsize = fdt_totalsize(fdt) + 4; | ||
173 | buf = malloc(bufsize); | ||
174 | err = fdt_open_into(fdt, buf, bufsize); | ||
175 | } | ||
176 | |||
177 | if (err != 0) | ||
178 | fatal("fdt_init(): %s\n\r", fdt_strerror(err)); | ||
179 | |||
180 | if (buf) | ||
181 | fdt = buf; | ||
182 | } | ||
diff --git a/arch/powerpc/boot/libfdt_env.h b/arch/powerpc/boot/libfdt_env.h new file mode 100644 index 000000000000..a4b0fc959ece --- /dev/null +++ b/arch/powerpc/boot/libfdt_env.h | |||
@@ -0,0 +1,17 @@ | |||
1 | #ifndef _ARCH_POWERPC_BOOT_LIBFDT_ENV_H | ||
2 | #define _ARCH_POWERPC_BOOT_LIBFDT_ENV_H | ||
3 | |||
4 | #include <types.h> | ||
5 | #include <string.h> | ||
6 | |||
7 | typedef u32 uint32_t; | ||
8 | typedef u64 uint64_t; | ||
9 | |||
10 | #define fdt16_to_cpu(x) (x) | ||
11 | #define cpu_to_fdt16(x) (x) | ||
12 | #define fdt32_to_cpu(x) (x) | ||
13 | #define cpu_to_fdt32(x) (x) | ||
14 | #define fdt64_to_cpu(x) (x) | ||
15 | #define cpu_to_fdt64(x) (x) | ||
16 | |||
17 | #endif /* _ARCH_POWERPC_BOOT_LIBFDT_ENV_H */ | ||
diff --git a/arch/powerpc/boot/ops.h b/arch/powerpc/boot/ops.h index a180b6505f47..28df2c5a9761 100644 --- a/arch/powerpc/boot/ops.h +++ b/arch/powerpc/boot/ops.h | |||
@@ -80,6 +80,7 @@ extern struct loader_info loader_info; | |||
80 | 80 | ||
81 | void start(void); | 81 | void start(void); |
82 | int ft_init(void *dt_blob, unsigned int max_size, unsigned int max_find_device); | 82 | int ft_init(void *dt_blob, unsigned int max_size, unsigned int max_find_device); |
83 | void fdt_init(void *blob); | ||
83 | int serial_console_init(void); | 84 | int serial_console_init(void); |
84 | int ns16550_console_init(void *devp, struct serial_console_data *scdp); | 85 | int ns16550_console_init(void *devp, struct serial_console_data *scdp); |
85 | int mpsc_console_init(void *devp, struct serial_console_data *scdp); | 86 | int mpsc_console_init(void *devp, struct serial_console_data *scdp); |
diff --git a/arch/powerpc/boot/prpmc2800.c b/arch/powerpc/boot/prpmc2800.c index 9614e1db9dae..05c3245b30d7 100644 --- a/arch/powerpc/boot/prpmc2800.c +++ b/arch/powerpc/boot/prpmc2800.c | |||
@@ -547,8 +547,7 @@ void platform_init(unsigned long r3, unsigned long r4, unsigned long r5, | |||
547 | if (!dtb) | 547 | if (!dtb) |
548 | exit(); | 548 | exit(); |
549 | memmove(dtb, _dtb_start, dt_size); | 549 | memmove(dtb, _dtb_start, dt_size); |
550 | if (ft_init(dtb, dt_size, 16)) | 550 | fdt_init(dtb); |
551 | exit(); | ||
552 | 551 | ||
553 | bridge_base = mv64x60_get_bridge_base(); | 552 | bridge_base = mv64x60_get_bridge_base(); |
554 | 553 | ||
diff --git a/arch/powerpc/boot/ps3.c b/arch/powerpc/boot/ps3.c index d6661151b494..3b0ac4d006ec 100644 --- a/arch/powerpc/boot/ps3.c +++ b/arch/powerpc/boot/ps3.c | |||
@@ -131,7 +131,7 @@ void platform_init(void) | |||
131 | printf("\n-- PS3 bootwrapper --\n"); | 131 | printf("\n-- PS3 bootwrapper --\n"); |
132 | 132 | ||
133 | simple_alloc_init(_end, heapsize, 32, 64); | 133 | simple_alloc_init(_end, heapsize, 32, 64); |
134 | ft_init(_dtb_start, 0, 4); | 134 | fdt_init(_dtb_start); |
135 | 135 | ||
136 | chosen = finddevice("/chosen"); | 136 | chosen = finddevice("/chosen"); |
137 | 137 | ||
diff --git a/arch/powerpc/boot/treeboot-walnut.c b/arch/powerpc/boot/treeboot-walnut.c index bb2c309d70fc..70ffce343c0a 100644 --- a/arch/powerpc/boot/treeboot-walnut.c +++ b/arch/powerpc/boot/treeboot-walnut.c | |||
@@ -128,6 +128,6 @@ void platform_init(void) | |||
128 | simple_alloc_init(_end, avail_ram, 32, 32); | 128 | simple_alloc_init(_end, avail_ram, 32, 32); |
129 | platform_ops.fixups = walnut_fixups; | 129 | platform_ops.fixups = walnut_fixups; |
130 | platform_ops.exit = ibm40x_dbcr_reset; | 130 | platform_ops.exit = ibm40x_dbcr_reset; |
131 | ft_init(_dtb_start, _dtb_end - _dtb_start, 32); | 131 | fdt_init(_dtb_start); |
132 | serial_console_init(); | 132 | serial_console_init(); |
133 | } | 133 | } |