[PATCH 9/12] powerpc: Export htab start/end via device tree

Michael Ellerman michael at ellerman.id.au
Tue Nov 8 00:07:07 EST 2005


The userspace kexec-tools need to know the location of the htab on non-lpar
machines, as well as the end of the kernel. Export via the device tree.

NB. This patch has been updated to use "linux,x" property names. You may
need to update your kexec-tools to match.

 arch/powerpc/kernel/setup_64.c    |    5 +++
 arch/ppc64/kernel/machine_kexec.c |   51 ++++++++++++++++++++++++++++++++++++++
 include/asm-powerpc/kexec.h       |    1 
 3 files changed, 57 insertions(+)

Index: kexec/arch/powerpc/kernel/setup_64.c
===================================================================
--- kexec.orig/arch/powerpc/kernel/setup_64.c
+++ kexec/arch/powerpc/kernel/setup_64.c
@@ -61,6 +61,7 @@
 #include <asm/firmware.h>
 #include <asm/systemcfg.h>
 #include <asm/xmon.h>
+#include <asm/kexec.h>
 
 #ifdef DEBUG
 #define DBG(fmt...) udbg_printf(fmt)
@@ -455,6 +456,10 @@ void __init setup_system(void)
 	 */
 	unflatten_device_tree();
 
+#ifdef CONFIG_KEXEC
+	kexec_setup();	/* requires unflattened device tree. */
+#endif
+
 	/*
 	 * Fill the ppc64_caches & systemcfg structures with informations
 	 * retreived from the device-tree. Need to be called before
Index: kexec/arch/ppc64/kernel/machine_kexec.c
===================================================================
--- kexec.orig/arch/ppc64/kernel/machine_kexec.c
+++ kexec/arch/ppc64/kernel/machine_kexec.c
@@ -296,3 +296,54 @@ void machine_kexec(struct kimage *image)
 			ppc_md.hpte_clear_all);
 	/* NOTREACHED */
 }
+
+/* Values we need to export to the second kernel via the device tree. */
+static unsigned long htab_base, htab_size, kernel_end;
+
+static struct property htab_base_prop = {
+	.name = "linux,htab-base",
+	.length = sizeof(unsigned long),
+	.value = (unsigned char *)&htab_base,
+};
+
+static struct property htab_size_prop = {
+	.name = "linux,htab-size",
+	.length = sizeof(unsigned long),
+	.value = (unsigned char *)&htab_size,
+};
+
+static struct property kernel_end_prop = {
+	.name = "linux,kernel-end",
+	.length = sizeof(unsigned long),
+	.value = (unsigned char *)&kernel_end,
+};
+
+static void __init export_htab_values(void)
+{
+	struct device_node *node;
+
+	node = of_find_node_by_path("/chosen");
+	if (!node)
+		return;
+
+	kernel_end = __pa(_end);
+	prom_add_property(node, &kernel_end_prop);
+
+	/* On machines with no htab htab_address is NULL */
+	if (NULL == htab_address)
+		goto out;
+
+	htab_base = __pa(htab_address);
+	prom_add_property(node, &htab_base_prop);
+
+	htab_size = 1UL << ppc64_pft_size;
+	prom_add_property(node, &htab_size_prop);
+
+ out:
+	of_node_put(node);
+}
+
+void __init kexec_setup(void)
+{
+	export_htab_values();
+}
Index: kexec/include/asm-powerpc/kexec.h
===================================================================
--- kexec.orig/include/asm-powerpc/kexec.h
+++ kexec/include/asm-powerpc/kexec.h
@@ -41,6 +41,7 @@ extern note_buf_t crash_notes[];
 extern void kexec_smp_wait(void);	/* get and clear naca physid, wait for
 					  master to copy new code to 0 */
 extern int kexec_crashing_cpu;
+extern void __init kexec_setup(void);
 #else
 struct kimage;
 extern void machine_kexec_simple(struct kimage *image);



More information about the Linuxppc64-dev mailing list