Subject: Re: halt after "halt".
To: None <ragge@ludd.luth.se>
From: Greg A. Woods <woods@weird.com>
List: port-alpha
Date: 11/02/2004 17:19:05
[ On Sunday, October 17, 2004 at 21:05:45 (+0200), ragge@ludd.luth.se wrote: ]
> Subject: halt after "halt".
>
> I have been trying to find what the problem with the 8400 support is,
> but there is a very annoying problem that shows up: The machine do not
> go back to SRM after halt (or reboot) from ddb, it just hangs.
> It prints out the text "halt code 5", "pc = 0xfffff0000..." but then
> nothing happens, no P00>>> prompt.  Does anyone have any idea what
> the problem can be?

I added a "prom halt" command (and a few other things) to DDB and it
works on my as4000, though it may be the underlying call I use that's
not working for you on the 8400.  In any case see the attached diffs.

>  It is really annoying to have to go to the 
> computer room each time I testboot a kernel :-(

Does the 8400 have an RCM processor or equivalent?  Can you use it from
a serial console to reset (or properly halt) the system?

BTW, I've discovered that on the as4x00 and es45 the console code never
sees a BREAK signal on the serial console (presumably because of the
RCM's hooks onto the serial port) and that the only proper way to halt
the system (and thus drop into DDB in the first place) is to wake up the
RCM using its escape sequence so that it is in control of the serial
port and then to give it a "halt" command.

-- 
						Greg A. Woods

+1 416 218-0098                  VE3TCP            RoboHack <woods@robohack.ca>
Planix, Inc. <woods@planix.com>          Secrets of the Weird <woods@weird.com>

Index: sys/arch/alpha/alpha/db_interface.c
===================================================================
RCS file: /cvs/master/m-NetBSD/main/src/sys/arch/alpha/alpha/db_interface.c,v
retrieving revision 1.17
diff -u -r1.17 db_interface.c
--- sys/arch/alpha/alpha/db_interface.c	13 May 2002 20:30:08 -0000	1.17
+++ sys/arch/alpha/alpha/db_interface.c	23 Sep 2004 21:03:20 -0000
@@ -78,6 +78,10 @@
 #include <ddb/db_variables.h>
 #include <ddb/db_interface.h>
 
+#include <uvm/uvm.h>
+
+extern void uvmhist_dump __P((struct uvm_history *));
+extern struct uvm_history_head uvm_histories;
 
 #if 0
 extern char *trap_type[];
@@ -88,14 +92,22 @@
 
 db_regs_t *ddb_regp;
 
+void db_lock_cmd __P((db_expr_t, int, db_expr_t, char *));
+void db_simple_lock_cmd __P((db_expr_t, int, db_expr_t, char *));
+void db_prom_cmd __P((db_expr_t, int, db_expr_t, char *));
+void db_uvmhistdump __P((db_expr_t, int, db_expr_t, char *));
 #if defined(MULTIPROCESSOR)
 void	db_mach_cpu __P((db_expr_t, int, db_expr_t, char *));
 #endif
 
 const struct db_command db_machine_command_table[] = {
+	{ "lock",	db_lock_cmd,	0,	0 },
+	{ "slock",	db_simple_lock_cmd,	0,	0 },
 #if defined(MULTIPROCESSOR)
 	{ "cpu",	db_mach_cpu,	0,	0 },
 #endif
+	{ "prom",	db_prom_cmd,	0,	0 },
+	{ "uvmdump",	db_uvmhistdump,	0,	0 },
 	{ (char *)0, },
 };
 
@@ -268,8 +280,85 @@
  *
  *	cpu		tell DDB to use register state from the
  *			CPU specified (MULTIPROCESSOR)
+ *
+ *	lock		Dump a struct lock.
+ *
+ *	slock		Dump a struct simplelock.
+ *
+ *	uvmhistdump	Dump the UVM histories.
  */
 
+void
+db_lock_cmd(addr, have_addr, count, modif)
+	db_expr_t addr;
+	int have_addr;
+	db_expr_t count;
+	char *modif;
+{
+	struct lock *l;
+
+	if (!have_addr) {
+		db_printf("What lock address?\n");
+		return;
+	}
+
+	l = (struct lock *)addr;
+	db_printf("interlock=%x flags=%x\n waitcount=%x sharecount=%x "
+	    "exclusivecount=%x\n wmesg=%s recurselevel=%x\n",
+	    l->lk_interlock.lock_data, l->lk_flags, l->lk_waitcount,
+	    l->lk_sharecount, l->lk_exclusivecount, l->lk_wmesg,
+	    l->lk_recurselevel);
+}
+
+void
+db_simple_lock_cmd(addr, have_addr, count, modif)
+	db_expr_t addr;
+	int have_addr;
+	db_expr_t count;
+	char *modif;
+{
+	struct simplelock *l;
+
+	if (!have_addr) {
+		db_printf("What lock address?\n");
+		return;
+	}
+
+	l = (struct simplelock *)addr;
+	db_printf("lock_data=%d", l->lock_data);
+#ifdef LOCKDEBUG
+	db_printf(" holder=%ld\n"
+	    " last locked=%s:%d\n last unlocked=%s:%d\n",
+	    l->lock_holder, l->lock_file, l->lock_line, l->unlock_file,
+	    l->unlock_line);
+#endif
+	db_printf("\n");
+}
+
+void
+db_prom_cmd(addr, have_addr, count, modif)
+	db_expr_t addr;
+	int have_addr;
+	db_expr_t count;
+	char *modif;
+{
+
+	db_printf("Halting system (type 'cont' to return to DDB)\n");
+	prom_halt(TRUE);
+}
+
+void
+db_uvmhistdump(addr, have_addr, count, modif)
+	db_expr_t addr;
+	int have_addr;
+	db_expr_t count;
+	char *modif;
+{
+
+	uvmhist_dump(uvm_histories.lh_first);
+}
+
+
 #if defined(MULTIPROCESSOR)
 void
 db_mach_cpu(addr, have_addr, count, modif)