[parisc-linux-cvs] auto-enable pdc console on kernel error

Helge Deller deller@gmx.de
Wed, 20 Jun 2001 16:17:40 +0200


- EXTRAVERSION = -pa33
- auto-enable the pdc console if a kernel error occurs and no other console
was already registered.

Index: Makefile
===================================================================
RCS file: /home/cvs/parisc/linux/Makefile,v
retrieving revision 1.64
diff -u -r1.64 Makefile
--- Makefile	2001/06/20 12:29:34	1.64
+++ Makefile	2001/06/20 14:04:03
@@ -1,7 +1,7 @@
 VERSION = 2
 PATCHLEVEL = 4
 SUBLEVEL = 0
-EXTRAVERSION = -pa32
+EXTRAVERSION = -pa33
 
 KERNELRELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
 
Index: arch/parisc/kernel/pdc_cons.c
===================================================================
RCS file: /home/cvs/parisc/linux/arch/parisc/kernel/pdc_cons.c,v
retrieving revision 1.27
diff -u -r1.27 pdc_cons.c
--- pdc_cons.c	2001/06/20 12:29:35	1.27
+++ pdc_cons.c	2001/06/20 14:04:06
@@ -1,3 +1,20 @@
+/*
+ *  linux/arch/parisc/kernel/pdc_console.c
+ *
+ *  The PDC console is a simple console, which can be used for debugging 
+ *  boot related problems on HP PA-RISC machines.
+ *
+ *  This code uses the ROM (=PDC) based functions to read and write 
characters
+ *  from and to PDC's boot path.
+ *  Since all character read from that path must be polled, this code never
+ *  can or will be a fully functional linux console.
+ */
+
+/* Define EARLY_BOOTUP_DEBUG to debug kernel related boot problems. 
+ * On production kernels EARLY_BOOTUP_DEBUG should be undefined. */
+#undef EARLY_BOOTUP_DEBUG
+
+
 #include <linux/config.h>
 #include <linux/kernel.h>
 #include <linux/console.h>
@@ -9,13 +26,8 @@
 #include <asm/page.h>
 #include <asm/types.h>
 #include <asm/system.h>
-#include <asm/pdc.h>	/* for iodc_call() proto and friends */
+#include <asm/pdc.h>		/* for iodc_call() proto and friends */
 
-/* define EARLY_BOOTUP_DEBUG to use this simple console driver
- * for debugging kernel related boot problems. 
- * On production kernels EARLY_BOOTUP_DEBUG should be undefined. */
-#undef EARLY_BOOTUP_DEBUG
-
 
 static void pdc_console_write(struct console *co, const char *s, unsigned 
count)
 {
@@ -41,7 +53,7 @@
 };
 
 static int pdc_console_initialized;
-extern unsigned long log_size; /* kernel/printk.c */
+extern unsigned long log_size;		/* kernel/printk.c */
 
 
 static void pdc_console_init_force(void)
@@ -56,14 +68,13 @@
 
 	/* register the pdc console */
 	register_console(&pdc_cons);
-
-	pdc_console_write(0, "PDC Console Initialized\n", 24);
 }
 
 void pdc_console_init(void)
 {
 #ifdef EARLY_BOOTUP_DEBUG
 	pdc_console_init_force();
+	printk(KERN_INFO "Initialized PDC Console for debugging.\n");
 #endif
 }
 
@@ -102,6 +113,10 @@
 	while ((console = console_drivers) != NULL)
 		unregister_console(console_drivers);
 
+	/* Don't repeat what we've already printed */
 	log_size = 0;
-	pdc_console_init_force();	/* force registering the pdc console */
+	
+	/* force registering the pdc console */
+	pdc_console_init_force();
 }
+
Index: arch/parisc/kernel/traps.c
===================================================================
RCS file: /home/cvs/parisc/linux/arch/parisc/kernel/traps.c,v
retrieving revision 1.48
diff -u -r1.48 traps.c
--- traps.c	2001/05/28 18:11:18	1.48
+++ traps.c	2001/06/20 14:04:09
@@ -23,6 +23,7 @@
 #include <linux/spinlock.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
+#include <linux/console.h>
 #include <asm/system.h>
 #include <asm/uaccess.h>
 #include <asm/io.h>
@@ -46,18 +47,6 @@
 			 /*  dumped to the console via printk)          */
 
 
-void page_exception(void);
-
-/*
- * These constants are for searching for possible module text
- * segments.  VMALLOC_OFFSET comes from mm/vmalloc.c; MODULE_RANGE is
- * a guess of how much space is likely to be vmalloced.
- */
-#define VMALLOC_OFFSET (8*1024*1024)
-#define MODULE_RANGE (8*1024*1024)
-
-int kstack_depth_to_print = 24;
-
 static int printbinary(char *buf, unsigned long x, int nbits)
 {
 	unsigned long mask = 1UL << (nbits - 1);
@@ -140,13 +129,20 @@
 		return;
 	}
 
-	printk("%s[%d]: %s %ld\n", current->comm, current->pid, str, err);
+	/* maybe the kernel hasn't booted very far yet and hasn't been able 
+	 * to initialize the serial or STI console. In that case we should 
+	 * re-enable the pdc console, so that the user will be able to 
+	 * identify the problem. */
+	if (!console_drivers)
+		pdc_console_restart();
+	
+	printk(KERN_CRIT "%s[%d]: %s %ld\n", current->comm, current->pid, str, err);
 
 	show_regs(regs);
 
 	/* Wot's wrong wif bein' racy? */
 	if (current->thread.flags & PARISC_KERNEL_DEATH) {
-		printk("die_if_kernel recursion detected.\n");
+		printk(KERN_CRIT "die_if_kernel recursion detected.\n");
 		sti();
 		while (1);
 	}
@@ -202,7 +198,6 @@
 		break;
 
 #ifdef CONFIG_KWDB
-
 	case KGDB_BREAK_INSN:
 		mtctl(0, 15);
 		pt_regs_to_ssp(regs, &ssp);
@@ -220,7 +215,6 @@
 		regs->iaoq[0] = regs->iaoq[1];
 		regs->iaoq[1] += 4;
 		break;
-
 #endif /* CONFIG_KWDB */
 
 	default:
@@ -246,8 +240,7 @@
 
 void default_trap(int code, struct pt_regs *regs)
 {
-	printk("Trap %d on CPU %d\n", code, smp_processor_id());
-
+	printk(KERN_ERR "Trap %d on CPU %d\n", code, smp_processor_id());
 	show_regs(regs);
 }
 
@@ -267,10 +260,9 @@
 }
 #endif /* CONFIG_KWDB */
 
-extern void do_page_fault(struct pt_regs *, int, unsigned long);
+extern void do_page_fault(struct pt_regs *, int, unsigned long); /* in 
mm/fault.c */
 extern void parisc_terminate(char *, struct pt_regs *, int, unsigned long);
 extern void transfer_pim_to_trap_frame(struct pt_regs *);
-extern void pdc_console_restart(void);
 
 void handle_interruption(int code, struct pt_regs *regs)
 {
@@ -287,7 +279,7 @@
 	    sti();
 
 #if 0
-	printk("interrupted with code %d, regs %p\n", code, regs);
+	printk(KERN_DEBUG "interrupted with code %d, regs %p\n", code, regs);
 	show_regs(regs);
 #endif
 
@@ -492,12 +484,14 @@
 	set_eiem(0);
 	cli();
 
+	/* restart pdc console if necessary */
+	if (!console_drivers)
+		pdc_console_restart();
+
 	if (code == 1)
 	    transfer_pim_to_trap_frame(regs);
 
-#if 1
 	show_stack(regs);
-#endif
 
 	printk("\n%s: Code=%d regs=%p (Addr=" RFMT ")\n",msg,code,regs,offset);
 	show_regs(regs);
Index: include/asm-parisc/pdc.h
===================================================================
RCS file: /home/cvs/parisc/linux/include/asm-parisc/pdc.h,v
retrieving revision 1.30
diff -u -r1.30 pdc.h
--- pdc.h	2001/05/11 15:39:04	1.30
+++ pdc.h	2001/06/20 14:04:24
@@ -790,8 +790,10 @@
 #define BOOT_CONSOLE_PATH_OFFSET 0x3a8
 
 #ifndef __ASSEMBLY__
-extern void pdc_console_init(void);
-extern void setup_pdc(void);            /* in inventory.c */
+void pdc_console_init(void);	/* in pdc_console.c */
+void pdc_console_restart(void);
+
+void setup_pdc(void);		/* in inventory.c */
 
 /* wrapper-functions from pdc.c */