aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/boot/main.c
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2007-03-22 02:02:21 -0400
committerPaul Mackerras <paulus@samba.org>2007-04-12 13:55:14 -0400
commit27fbaa9702e548e74dffd21855769f6cedad42bd (patch)
tree2af4decec01306e34031e2a62a3932991b899fbc /arch/powerpc/boot/main.c
parent3467bfd340f9ad48f3732415533a2e9c18240b62 (diff)
[POWERPC] Add device tree utility functions to zImage
This patch adds a library of useful device tree manipulation functions to the zImage library, for use by platform code. These functions are based on the hooks already in dt_ops, so they're not dependent on a particular device tree implementation. This patch also slightly streamlines the code in main.c using these new functions. This is a consolidation of my work in this area with Scott Wood's patches to a very similar end. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch/powerpc/boot/main.c')
-rw-r--r--arch/powerpc/boot/main.c27
1 files changed, 11 insertions, 16 deletions
diff --git a/arch/powerpc/boot/main.c b/arch/powerpc/boot/main.c
index e1df8feaf16d..ab9dfe2b38f1 100644
--- a/arch/powerpc/boot/main.c
+++ b/arch/powerpc/boot/main.c
@@ -153,13 +153,10 @@ static struct addr_range prep_kernel(void)
153 return (struct addr_range){addr, ei.memsize}; 153 return (struct addr_range){addr, ei.memsize};
154} 154}
155 155
156static struct addr_range prep_initrd(struct addr_range vmlinux, 156static struct addr_range prep_initrd(struct addr_range vmlinux, void *chosen,
157 unsigned long initrd_addr, 157 unsigned long initrd_addr,
158 unsigned long initrd_size) 158 unsigned long initrd_size)
159{ 159{
160 void *devp;
161 u32 initrd_start, initrd_end;
162
163 /* If we have an image attached to us, it overrides anything 160 /* If we have an image attached to us, it overrides anything
164 * supplied by the loader. */ 161 * supplied by the loader. */
165 if (_initrd_end > _initrd_start) { 162 if (_initrd_end > _initrd_start) {
@@ -198,16 +195,8 @@ static struct addr_range prep_initrd(struct addr_range vmlinux,
198 printf("initrd head: 0x%lx\n\r", *((unsigned long *)initrd_addr)); 195 printf("initrd head: 0x%lx\n\r", *((unsigned long *)initrd_addr));
199 196
200 /* Tell the kernel initrd address via device tree */ 197 /* Tell the kernel initrd address via device tree */
201 devp = finddevice("/chosen"); 198 setprop_val(chosen, "linux,initrd-start", (u32)(initrd_addr));
202 if (! devp) 199 setprop_val(chosen, "linux,initrd-end", (u32)(initrd_addr+initrd_size));
203 fatal("Device tree has no chosen node!\n\r");
204
205 initrd_start = (u32)initrd_addr;
206 initrd_end = (u32)initrd_addr + initrd_size;
207
208 setprop(devp, "linux,initrd-start", &initrd_start,
209 sizeof(initrd_start));
210 setprop(devp, "linux,initrd-end", &initrd_end, sizeof(initrd_end));
211 200
212 return (struct addr_range){(void *)initrd_addr, initrd_size}; 201 return (struct addr_range){(void *)initrd_addr, initrd_size};
213} 202}
@@ -254,6 +243,7 @@ void start(void)
254 kernel_entry_t kentry; 243 kernel_entry_t kentry;
255 char cmdline[COMMAND_LINE_SIZE]; 244 char cmdline[COMMAND_LINE_SIZE];
256 unsigned long ft_addr = 0; 245 unsigned long ft_addr = 0;
246 void *chosen;
257 247
258 if (console_ops.open && (console_ops.open() < 0)) 248 if (console_ops.open && (console_ops.open() < 0))
259 exit(); 249 exit();
@@ -263,9 +253,14 @@ void start(void)
263 printf("\n\rzImage starting: loaded at 0x%p (sp: 0x%p)\n\r", 253 printf("\n\rzImage starting: loaded at 0x%p (sp: 0x%p)\n\r",
264 _start, get_sp()); 254 _start, get_sp());
265 255
256 /* Ensure that the device tree has a /chosen node */
257 chosen = finddevice("/chosen");
258 if (!chosen)
259 chosen = create_node(NULL, "chosen");
260
266 vmlinux = prep_kernel(); 261 vmlinux = prep_kernel();
267 initrd = prep_initrd(vmlinux, loader_info.initrd_addr, 262 initrd = prep_initrd(vmlinux, chosen,
268 loader_info.initrd_size); 263 loader_info.initrd_addr, loader_info.initrd_size);
269 264
270 /* If cmdline came from zimage wrapper or if we can edit the one 265 /* If cmdline came from zimage wrapper or if we can edit the one
271 * in the dt, print it out and edit it, if possible. 266 * in the dt, print it out and edit it, if possible.