[PATCH] powerpc: Make early debugging configurable via Kconfig

Michael Ellerman michael at ellerman.id.au
Thu Nov 17 20:41:49 EST 2005


This patch adds Kconfig entries to control the early debugging options,
currently in setup_64.c. I was kind of keen to add these without them being
exposed in the menus, as they're for "advanced users only", but that
doesn't seem to work - anyone know if that's possible in Kconfig?

Doing this via Kconfig means you can have one source tree, which is
buildable for multiple platforms - and you can enable the correct early debug
option for each platform via .config.

I made udbg_early_init() a static inline 'cause otherwise GCC is to daft to
optimise it away when debugging is off.

Now that we have udbg_init_rtas() we can make call_rtas_display_status* static.

Signed-off-by: Michael Ellerman <michael at ellerman.id.au>
---

 arch/powerpc/Kconfig.debug     |   42 +++++++++++++++++++++++++++++++++++++++++
 arch/powerpc/kernel/rtas.c     |   10 +++++++--
 arch/powerpc/kernel/setup_64.c |   38 +------------------------------------
 arch/powerpc/kernel/udbg.c     |    7 +++---
 include/asm-powerpc/rtas.h     |    1 
 include/asm-powerpc/udbg.h     |   41 +++++++++++++++++++++++++++++++++++++++-
 6 files changed, 96 insertions(+), 43 deletions(-)

Index: kexec/arch/powerpc/Kconfig.debug
===================================================================
--- kexec.orig/arch/powerpc/Kconfig.debug
+++ kexec/arch/powerpc/Kconfig.debug
@@ -115,4 +115,46 @@ config PPC_OCP
 	depends on IBM_OCP || XILINX_OCP
 	default y
 
+choice
+	prompt "Early debugging (dangerous)"
+	bool
+	optional
+	help
+	  Enable early debugging. Careful, if you enable debugging for the
+	  wrong type of machine your kernel _will not boot_.
+
+config PPC_EARLY_DEBUG_LPAR
+	bool "LPAR HV Console"
+	depends on PPC_PSERIES
+	help
+	  Select this to enable early debugging for a machine with a HVC
+	  console on vterm 0.
+
+config PPC_EARLY_DEBUG_G5
+	bool "Apple G5"
+	depends on PPC_PMAC64
+	help
+	  Select this to enable early debugging for Apple G5 machines.
+
+config PPC_EARLY_DEBUG_RTAS
+	bool "RTAS Panel"
+	depends on PPC_RTAS
+	help
+	  Select this to enable early debugging via the RTAS panel.
+
+config PPC_EARLY_DEBUG_MAPLE
+	bool "Maple real mode"
+	depends on PPC_MAPLE
+	help
+	  Select this to enable early debugging for Maple.
+
+config PPC_EARLY_DEBUG_ISERIES
+	bool "iSeries HV Console"
+	depends on PPC_ISERIES
+	help
+	  Select this to enable early debugging for legacy iSeries. You need
+	  to hit "Ctrl-x Ctrl-x" to see the messages on the console.
+
+endchoice
+
 endmenu
Index: kexec/arch/powerpc/kernel/rtas.c
===================================================================
--- kexec.orig/arch/powerpc/kernel/rtas.c
+++ kexec/arch/powerpc/kernel/rtas.c
@@ -29,6 +29,7 @@
 #include <asm/delay.h>
 #include <asm/uaccess.h>
 #include <asm/lmb.h>
+#include <asm/udbg.h>
 
 struct rtas_t rtas = {
 	.lock = SPIN_LOCK_UNLOCKED
@@ -52,7 +53,7 @@ EXPORT_SYMBOL(rtas_flash_term_hook);
  * are designed only for very early low-level debugging, which
  * is why the token is hard-coded to 10.
  */
-void call_rtas_display_status(unsigned char c)
+static void call_rtas_display_status(unsigned char c)
 {
 	struct rtas_args *args = &rtas.args;
 	unsigned long s;
@@ -72,7 +73,7 @@ void call_rtas_display_status(unsigned c
 	spin_unlock_irqrestore(&rtas.lock, s);
 }
 
-void call_rtas_display_status_delay(unsigned char c)
+static void call_rtas_display_status_delay(unsigned char c)
 {
 	static int pending_newline = 0;  /* did last write end with unprinted newline? */
 	static int width = 16;
@@ -96,6 +97,11 @@ void call_rtas_display_status_delay(unsi
 	}
 }
 
+void udbg_init_rtas(void)
+{
+	udbg_putc = call_rtas_display_status_delay;
+}
+
 void rtas_progress(char *s, unsigned short hex)
 {
 	struct device_node *root;
Index: kexec/arch/powerpc/kernel/setup_64.c
===================================================================
--- kexec.orig/arch/powerpc/kernel/setup_64.c
+++ kexec/arch/powerpc/kernel/setup_64.c
@@ -69,37 +69,6 @@
 #define DBG(fmt...)
 #endif
 
-/*
- * Here are some early debugging facilities. You can enable one
- * but your kernel will not boot on anything else if you do so
- */
-
-/* For use on LPAR machines that support an HVC console on vterm 0 */
-extern void udbg_init_debug_lpar(void);
-
-/* This one is for use on Apple G5 machines */
-extern void udbg_init_pmac_realmode(void);
-
-/* That's RTAS panel debug */
-extern void call_rtas_display_status_delay(unsigned char c);
-
-/* Here's maple real mode debug */
-extern void udbg_init_maple_realmode(void);
-
-/* For iSeries - hit Ctrl-x Ctrl-x to see the output */
-extern void udbg_init_iseries(void);
-
-#define EARLY_DEBUG_INIT() do {} while(0)
-
-#if 0
-#define EARLY_DEBUG_INIT() udbg_init_debug_lpar()
-#define EARLY_DEBUG_INIT() udbg_init_iseries()
-#define EARLY_DEBUG_INIT() udbg_init_maple_realmode()
-#define EARLY_DEBUG_INIT() udbg_init_pmac_realmode()
-#define EARLY_DEBUG_INIT()						\
-	do { udbg_putc = call_rtas_display_status_delay; } while(0)
-#endif
-
 int have_of = 1;
 int boot_cpuid = 0;
 int boot_cpuid_phys = 0;
@@ -232,11 +201,8 @@ void __init early_setup(unsigned long dt
 	struct paca_struct *lpaca = get_paca();
 	static struct machdep_calls **mach;
 
-	/*
-	 * Enable early debugging if any specified (see top of
-	 * this file)
-	 */
-	EARLY_DEBUG_INIT();
+	/* Enable early debugging if any specified (see udbg.h) */
+	udbg_early_init();
 
 	DBG(" -> early_setup()\n");
 
Index: kexec/arch/powerpc/kernel/udbg.c
===================================================================
--- kexec.orig/arch/powerpc/kernel/udbg.c
+++ kexec/arch/powerpc/kernel/udbg.c
@@ -1,7 +1,8 @@
 /*
- * polling mode stateless debugging stuff, originally for NS16550 Serial Ports
+ * Polling mode stateless debugging stuff, originally for NS16550 Serial Ports.
+ * Used for early debugging and by xmon et al.
  *
- * c 2001 PPC 64 Team, IBM Corp
+ * (c) 2001,2005 IBM Corporation.
  *
  *      This program is free software; you can redistribute it and/or
  *      modify it under the terms of the GNU General Public License
@@ -15,12 +16,12 @@
 #include <linux/sched.h>
 #include <linux/console.h>
 #include <asm/processor.h>
+#include <asm/udbg.h>
 
 void (*udbg_putc)(unsigned char c);
 unsigned char (*udbg_getc)(void);
 int (*udbg_getc_poll)(void);
 
-/* udbg library, used by xmon et al */
 void udbg_puts(const char *s)
 {
 	if (udbg_putc) {
Index: kexec/include/asm-powerpc/udbg.h
===================================================================
--- kexec.orig/include/asm-powerpc/udbg.h
+++ kexec/include/asm-powerpc/udbg.h
@@ -1,5 +1,5 @@
 /*
- * c 2001 PPC 64 Team, IBM Corp
+ * (c) 2001,2005 IBM Corporation.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -28,4 +28,43 @@ extern void udbg_init_uart(void __iomem 
 
 struct device_node;
 extern void udbg_init_scc(struct device_node *np);
+extern void udbg_init_debug_lpar(void);
+extern void udbg_init_pmac_realmode(void);
+extern void udbg_init_maple_realmode(void);
+extern void udbg_init_iseries(void);
+extern void udbg_init_rtas(void);
+
+/*
+ * Early debugging facilities. You can enable _one_ of these, but if you do so
+ * your kernel _will not boot_ on anything else. Be careful.
+ */
+static inline void udbg_early_init(void)
+{
+#if defined(CONFIG_PPC_EARLY_DEBUG_LPAR)
+
+	/* For LPAR machines that have an HVC console on vterm 0 */
+	udbg_init_debug_lpar();
+
+#elif defined(CONFIG_PPC_EARLY_DEBUG_G5)
+
+	/* For use on Apple G5 machines */
+	udbg_init_pmac_realmode();
+
+#elif defined(CONFIG_PPC_EARLY_DEBUG_RTAS)
+
+	/* RTAS panel debug */
+	udbg_init_rtas();
+
+#elif defined(CONFIG_PPC_EARLY_DEBUG_MAPLE)
+
+	/* Maple real mode debug */
+	udbg_init_maple_realmode();
+
+#elif defined(CONFIG_PPC_EARLY_DEBUG_ISERIES)
+
+	/* For iSeries - hit Ctrl-x Ctrl-x to see the output */
+	udbg_init_iseries();
+#endif
+}
+
 #endif /* _ASM_POWERPC_UDBG_H */
Index: kexec/include/asm-powerpc/rtas.h
===================================================================
--- kexec.orig/include/asm-powerpc/rtas.h
+++ kexec/include/asm-powerpc/rtas.h
@@ -160,7 +160,6 @@ extern struct rtas_t rtas;
 extern void enter_rtas(unsigned long);
 extern int rtas_token(const char *service);
 extern int rtas_call(int token, int, int, int *, ...);
-extern void call_rtas_display_status(unsigned char);
 extern void rtas_restart(char *cmd);
 extern void rtas_power_off(void);
 extern void rtas_halt(void);



More information about the Linuxppc64-dev mailing list