Commit 1406bc2f authored by Jeremy Kerr's avatar Jeremy Kerr Committed by Grant Likely

of/flattree: use callback to setup initrd from /chosen

At present, the fdt code sets the kernel-wide initrd_start and
initrd_end variables when parsing /chosen. On ARM, we only set these
once the bootmem has been reserved.

This change adds an arch hook to setup the initrd from the device
tree:

 void early_init_dt_setup_initrd_arch(unsigned long start,
				      unsigned long end);

The arch-specific code can then setup the initrd however it likes.

Compiled on powerpc, with CONFIG_BLK_DEV_INITRD=y and =n.
Signed-off-by: default avatarJeremy Kerr <jeremy.kerr@canonical.com>
Signed-off-by: default avatarGrant Likely <grant.likely@secretlab.ca>
parent 50ab2fe1
...@@ -118,6 +118,16 @@ void __init early_init_devtree(void *params) ...@@ -118,6 +118,16 @@ void __init early_init_devtree(void *params)
pr_debug(" <- early_init_devtree()\n"); pr_debug(" <- early_init_devtree()\n");
} }
#ifdef CONFIG_BLK_DEV_INITRD
void __init early_init_dt_setup_initrd_arch(unsigned long start,
unsigned long end)
{
initrd_start = (unsigned long)__va(start);
initrd_end = (unsigned long)__va(end);
initrd_below_start_ok = 1;
}
#endif
/******* /*******
* *
* New implementation of the OF "find" APIs, return a refcounted * New implementation of the OF "find" APIs, return a refcounted
......
...@@ -510,6 +510,16 @@ void __init early_init_dt_add_memory_arch(u64 base, u64 size) ...@@ -510,6 +510,16 @@ void __init early_init_dt_add_memory_arch(u64 base, u64 size)
memstart_addr = min((u64)memstart_addr, base); memstart_addr = min((u64)memstart_addr, base);
} }
#ifdef CONFIG_BLK_DEV_INITRD
void __init early_init_dt_setup_initrd_arch(unsigned long start,
unsigned long end)
{
initrd_start = (unsigned long)__va(start);
initrd_end = (unsigned long)__va(end);
initrd_below_start_ok = 1;
}
#endif
static void __init early_reserve_mem(void) static void __init early_reserve_mem(void)
{ {
u64 base, size; u64 base, size;
......
...@@ -384,28 +384,23 @@ unsigned long __init unflatten_dt_node(unsigned long mem, ...@@ -384,28 +384,23 @@ unsigned long __init unflatten_dt_node(unsigned long mem,
*/ */
void __init early_init_dt_check_for_initrd(unsigned long node) void __init early_init_dt_check_for_initrd(unsigned long node)
{ {
unsigned long len; unsigned long start, end, len;
u32 *prop; u32 *prop;
pr_debug("Looking for initrd properties... "); pr_debug("Looking for initrd properties... ");
prop = of_get_flat_dt_prop(node, "linux,initrd-start", &len); prop = of_get_flat_dt_prop(node, "linux,initrd-start", &len);
if (prop) { if (!prop)
initrd_start = (unsigned long) return;
__va(of_read_ulong(prop, len/4)); start = of_read_ulong(prop, len/4);
prop = of_get_flat_dt_prop(node, "linux,initrd-end", &len); prop = of_get_flat_dt_prop(node, "linux,initrd-end", &len);
if (prop) { if (!prop)
initrd_end = (unsigned long) return;
__va(of_read_ulong(prop, len/4)); end = of_read_ulong(prop, len/4);
initrd_below_start_ok = 1;
} else {
initrd_start = 0;
}
}
pr_debug("initrd_start=0x%lx initrd_end=0x%lx\n", early_init_dt_setup_initrd_arch(start, end);
initrd_start, initrd_end); pr_debug("initrd_start=0x%lx initrd_end=0x%lx\n", start, end);
} }
#else #else
inline void early_init_dt_check_for_initrd(unsigned long node) inline void early_init_dt_check_for_initrd(unsigned long node)
......
...@@ -80,6 +80,16 @@ extern int early_init_dt_scan_memory(unsigned long node, const char *uname, ...@@ -80,6 +80,16 @@ extern int early_init_dt_scan_memory(unsigned long node, const char *uname,
extern void early_init_dt_add_memory_arch(u64 base, u64 size); extern void early_init_dt_add_memory_arch(u64 base, u64 size);
extern u64 dt_mem_next_cell(int s, u32 **cellp); extern u64 dt_mem_next_cell(int s, u32 **cellp);
/*
* If BLK_DEV_INITRD, the fdt early init code will call this function,
* to be provided by the arch code. start and end are specified as
* physical addresses.
*/
#ifdef CONFIG_BLK_DEV_INITRD
extern void early_init_dt_setup_initrd_arch(unsigned long start,
unsigned long end);
#endif
/* Early flat tree scan hooks */ /* Early flat tree scan hooks */
extern int early_init_dt_scan_root(unsigned long node, const char *uname, extern int early_init_dt_scan_root(unsigned long node, const char *uname,
int depth, void *data); int depth, void *data);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment