Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 3 May 2003 12:57:02 -0700 (PDT)
From:      Marcel Moolenaar <marcel@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 30474 for review
Message-ID:  <200305031957.h43Jv26B068738@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=30474

Change 30474 by marcel@marcel_nfs on 2003/05/03 12:56:04

	WARNING: deliberate incomplete commit.
	
	Implement a generic remote debug driver interface, also known
	as debug port. The interface mimics the console interface,
	and includes a linker set. Debugger initialization (moved to
	db_init()) will iterate over the dbgport driver set and select
	a device to use as the debug port, based on driver specific
	probing. Nothing too fancy, but extensible. On ia64 it will
	use the firmware provided HCDP table (yay!)
	The current approach allows any driver to become a debug
	port, not just sio(4). 
	
	While here, start a whole new nextgen project (I need to be
	stopped). This includes:
	o  The GDB interface is duplicated in each MD directory,
	   even though only a small part is really MD (the registers).
	   So, copy the core GDB support to ddb/db_gdb.c and have it
	   use the new debug port "stuff". Functions and macros will
	   be used to deal with platform specifics. This is not yet
	   completed and is currently broken on all platforms.
	o  Remove the linkmap handling from the linker. It's debugger
	   dependent. Instead, have the linker call the debugger to
	   notify it of the arrival and departure of kernel modules.
	   The linker also calls the debugger to provide a pointer to
	   put in DT_DEBUG for GDB to query.
	o  With the linker calling the debugger, we can arrange for
	   the debugger to call the linker to do symbol lookups. We
	   now have the linker_file_t pointers we need to pass to the
	   linker. This has to be implemented still. Of course, using
	   the linker for symbol table lookups has it's downside:
	   1. You cannot do symbol lookups prior to linker initialization.
	      This will be handled by having MD code pass relevant info
	      to db_init(). (todo)
	   2. Debugging the linker may become too impractical. The best
	      way to deal with this is to use GDB, so I'm not too worried
	      about it.
	   The upshot of course is that we can make DDB module aware. In
	   fact, the existing syntax to specify which symbol table to
	   look in for a symbol (using symtab:symbol) now automaticly
	   applicable to modules. Of course this needs to be done still.
	
	Things that need to be done:
	o  Add MD hooks to the GDB code.
	o  Implement symbol table lookups using the linker.
	o  Copy over the linkmap handling from the linker to DDB.
	o  Add support for pre-linker symbol lookups.
	o  Add debug port handling to zs(4) for sparc64.
	o  Port this all to alpha, i386, ia64 and sparc64.
	o  I need to get my brain examined. I must be loosing it.

Affected files ...

.. //depot/projects/sio/sys/alpha/alpha/alpha-gdbstub.c#2 delete
.. //depot/projects/sio/sys/conf/files#4 edit
.. //depot/projects/sio/sys/conf/files.alpha#3 edit
.. //depot/projects/sio/sys/conf/files.i386#3 edit
.. //depot/projects/sio/sys/conf/files.ia64#3 edit
.. //depot/projects/sio/sys/conf/files.pc98#3 edit
.. //depot/projects/sio/sys/ddb/db_command.c#2 edit
.. //depot/projects/sio/sys/ddb/db_gdb.c#1 add
.. //depot/projects/sio/sys/ddb/db_main.c#1 add
.. //depot/projects/sio/sys/ddb/db_sym.c#2 edit
.. //depot/projects/sio/sys/ddb/ddb.h#2 edit
.. //depot/projects/sio/sys/dev/sio/sio.c#4 edit
.. //depot/projects/sio/sys/dev/sio/sio_cons.c#3 edit
.. //depot/projects/sio/sys/dev/sio/sio_dbg.c#1 add
.. //depot/projects/sio/sys/dev/sio/sioreg.h#3 edit
.. //depot/projects/sio/sys/dev/sio/siovar.h#4 edit
.. //depot/projects/sio/sys/i386/i386/db_interface.c#2 edit
.. //depot/projects/sio/sys/i386/i386/i386-gdbstub.c#2 delete
.. //depot/projects/sio/sys/i386/i386/machdep.c#2 edit
.. //depot/projects/sio/sys/i386/i386/sio_machdep.c#2 edit
.. //depot/projects/sio/sys/i386/include/db_machdep.h#2 edit
.. //depot/projects/sio/sys/ia64/ia64/db_interface.c#2 edit
.. //depot/projects/sio/sys/ia64/ia64/ia64-gdbstub.c#2 delete
.. //depot/projects/sio/sys/ia64/ia64/machdep.c#3 edit
.. //depot/projects/sio/sys/ia64/ia64/sio_machdep.c#2 edit
.. //depot/projects/sio/sys/kern/link_elf.c#2 edit

Differences ...

==== //depot/projects/sio/sys/conf/files#4 (text+ko) ====

@@ -210,12 +210,12 @@
 ddb/db_access.c		optional ddb
 ddb/db_break.c		optional ddb
 ddb/db_command.c	optional ddb
-ddb/db_elf.c		optional ddb
 ddb/db_examine.c	optional ddb
 ddb/db_expr.c		optional ddb
+ddb/db_gdb.c		optional ddb
 ddb/db_input.c		optional ddb
-ddb/db_kld.c		optional ddb
 ddb/db_lex.c		optional ddb
+ddb/db_main.c		optional ddb
 ddb/db_output.c		optional ddb
 ddb/db_print.c		optional ddb
 ddb/db_ps.c		optional ddb
@@ -651,6 +651,7 @@
 dev/si/si_pci.c		optional si pci
 dev/sio/sio.c		optional sio
 dev/sio/sio_cons.c	optional sio
+dev/sio/sio_dbg.c	optional sio ddb
 dev/sio/sio_ebus.c	optional sio ebus
 dev/sio/sio_pccard.c	optional sio card
 dev/sio/sio_pccard.c	optional sio pccard

==== //depot/projects/sio/sys/conf/files.alpha#3 (text+ko) ====

@@ -35,7 +35,6 @@
 	no-obj no-implicit-rule before-depend				\
 	clean		"ukbdmap.h"
 #
-alpha/alpha/alpha-gdbstub.c	optional	ddb
 alpha/alpha/api_up1000.c	optional	api_up1000
 alpha/alpha/atomic.s		standard
 alpha/alpha/autoconf.c		standard

==== //depot/projects/sio/sys/conf/files.i386#3 (text+ko) ====

@@ -211,7 +211,6 @@
 i386/i386/elan-mmcr.c		optional	cpu_elan
 i386/i386/elf_machdep.c		standard
 i386/i386/exception.s		standard
-i386/i386/i386-gdbstub.c	optional	ddb
 i386/i386/i686_mem.c		standard
 i386/i386/identcpu.c		standard
 i386/i386/in_cksum.c		optional	inet

==== //depot/projects/sio/sys/conf/files.ia64#3 (text+ko) ====

@@ -71,7 +71,6 @@
 ia64/ia64/eficlock.c		standard
 ia64/ia64/elf_machdep.c		standard
 ia64/ia64/exception.s		standard
-ia64/ia64/ia64-gdbstub.c	optional	ddb
 ia64/ia64/in_cksum.c		optional	inet
 ia64/ia64/interrupt.c		standard
 ia64/ia64/locore.s		standard	no-obj

==== //depot/projects/sio/sys/conf/files.pc98#3 (text+ko) ====

@@ -173,7 +173,6 @@
 i386/i386/dump_machdep.c	standard
 i386/i386/elf_machdep.c		standard
 i386/i386/exception.s		standard
-i386/i386/i386-gdbstub.c	optional	ddb
 i386/i386/i686_mem.c		standard
 i386/i386/identcpu.c		standard
 i386/i386/in_cksum.c		optional	inet

==== //depot/projects/sio/sys/ddb/db_command.c#2 (text+ko) ====

@@ -66,10 +66,13 @@
 SET_DECLARE(db_show_cmd_set, struct command);
 
 static db_cmdfcn_t	db_fncall;
-static db_cmdfcn_t	db_gdb;
 static db_cmdfcn_t	db_kill;
 static db_cmdfcn_t	db_reset;
 
+#ifdef GDB
+static db_cmdfcn_t	db_gdb;
+#endif
+
 /* XXX this is actually forward-static. */
 extern struct command	db_show_cmds[];
 
@@ -417,7 +420,9 @@
 	{ "call",	db_fncall,		CS_OWN,	0 },
 	{ "show",	0,			0,	db_show_cmds },
 	{ "ps",		db_ps,			0,	0 },
+#ifdef GDB
 	{ "gdb",	db_gdb,			0,	0 },
+#endif
 	{ "reset",	db_reset,		0,	0 },
 	{ "kill",	db_kill,		CS_OWN,	0 },
 	{ (char *)0, }
@@ -548,32 +553,6 @@
 	db_printf("%#lr\n", (long)retval);
 }
 
-/* Enter GDB remote protocol debugger on the next trap. */
-
-void	  *gdb_arg = NULL;
-cn_getc_t *gdb_getc;
-cn_putc_t *gdb_putc;
-
-static void
-db_gdb (dummy1, dummy2, dummy3, dummy4)
-	db_expr_t	dummy1;
-	boolean_t	dummy2;
-	db_expr_t	dummy3;
-	char *		dummy4;
-{
-
-	if (gdb_arg == NULL) {
-		db_printf("No gdb port enabled. Set flag 0x80 on desired port\n");
-		db_printf("in your configuration file (currently sio only).\n");
-		return;
-	}
-	boothowto ^= RB_GDB;
-
-	db_printf("Next trap will enter %s\n",
-		   boothowto & RB_GDB ? "GDB remote protocol mode"
-				      : "DDB debugger");
-}
-
 static void
 db_kill(dummy1, dummy2, dummy3, dummy4)
 	db_expr_t	dummy1;

==== //depot/projects/sio/sys/ddb/db_sym.c#2 (text+ko) ====


==== //depot/projects/sio/sys/ddb/ddb.h#2 (text+ko) ====

@@ -65,6 +65,30 @@
 	db_expr_t count;					\
 	char *modif;
 
+/*
+ * Remote debug device support.
+ */
+typedef int dbg_probe_t(void);
+typedef void dbg_init_t(void);
+typedef void dbg_term_t(void);
+typedef int dbg_getc_t(void);
+typedef void dbg_putc_t(int);
+
+struct dbgdev {
+	const char	*dbg_devname;
+	dbg_probe_t	*dbg_probe;
+	dbg_init_t	*dbg_init;
+	dbg_term_t	*dbg_term;
+	dbg_getc_t	*dbg_getc;
+	dbg_putc_t	*dbg_putc;
+};
+
+#define	DBG_DRIVER(name, probe, init, term, getc, putc)		\
+	static struct dbgdev name##_dbgdev = {			\
+		#name, probe, init, term, getc, putc		\
+	};							\
+	DATA_SET(dbgdev_set, name##_dbgdev)
+
 extern char *esym;
 extern db_expr_t db_maxoff;
 extern int db_active;
@@ -109,7 +133,7 @@
 				/* machine-dependent */
 void		db_stack_thread(db_expr_t addr, boolean_t have_addr,
 				db_expr_t count, char *modif);
-void		kdb_init(void);
+void		db_init(void);
 
 db_cmdfcn_t	db_breakpoint_cmd;
 db_cmdfcn_t	db_continue_cmd;
@@ -132,16 +156,19 @@
 db_cmdfcn_t	db_write_cmd;
 db_cmdfcn_t	db_show_one_thread;
 
-#if 0
-db_cmdfcn_t	db_help_cmd;
-db_cmdfcn_t	db_show_all_threads;
-db_cmdfcn_t	ipc_port_print;
-db_cmdfcn_t	vm_page_print;
-#endif
+/* Remote GDB support. */
+int		gdb_handle_exception(db_regs_t *, int);
+void		gdb_init(void);
+db_cmdfcn_t	db_gdb_cmd;
 
 /* Scare the user with backtrace of curthread to console. */
 void		db_print_backtrace(void);
 
+/* Linker hooks. */
+struct linker_file;
+vm_offset_t	db_debug_base(void);
+void		db_load_file(struct linker_file *);
+void		db_unload_file(struct linker_file *);
 /*
  * Command table.
  */
@@ -156,14 +183,4 @@
 	struct command *more;	/* another level of command */
 };
 
-/* XXX: UGLY hack */
-#ifdef CN_DEAD
-/*
- * Routines to support GDB on an sio port.
- */
-extern void	 *gdb_arg;
-extern cn_getc_t *gdb_getc;
-extern cn_putc_t *gdb_putc;
-#endif
-
 #endif /* !_DDB_DDB_H_ */

==== //depot/projects/sio/sys/dev/sio/sio.c#4 (text+ko) ====

@@ -89,8 +89,6 @@
 #define	UNIT_TO_MINOR(unit)	((((unit) & ~0x1fU) << (8 + 3)) \
 				 | ((unit) & 0x1f))
 
-#define	COM_LLCONSOLE(flags)	((flags) & 0x40)
-#define	COM_DEBUGGER(flags)	((flags) & 0x80)
 #define	COM_LOSESOUTINTS(flags)	((flags) & 0x08)
 #define	COM_NOFIFO(flags)		((flags) & 0x02)
 #define	COM_PPSCTS(flags)	((flags) & 0x10000)
@@ -191,7 +189,7 @@
 u_long comdefaultrclk = DEFAULT_RCLK;
 SYSCTL_ULONG(_machdep, OID_AUTO, conrclk, CTLFLAG_RW, &comdefaultrclk, 0, "");
 
-static speed_t gdbdefaultrate = GDBSPEED;
+speed_t gdbdefaultrate = GDBSPEED;
 SYSCTL_ULONG(_machdep, OID_AUTO, gdbspeed, CTLFLAG_RW, &gdbdefaultrate,
     GDBSPEED, "");
 
@@ -544,6 +542,31 @@
 	return (divisor);
 }
 
+/* Sloppily translate databits, stopbits and parity to LCR register bits. */
+u_char
+sioddtolcr(struct sio_devdata *dd)
+{
+	u_char lcr;
+
+	lcr = 0;
+
+	if (dd->databits >= 8)
+		lcr |= LCR_8BITS;
+	else if (dd->databits == 7)
+		lcr |= LCR_7BITS;
+	else if (dd->databits == 6)
+		lcr |= LCR_6BITS;
+	else
+		lcr |= LCR_5BITS;
+
+	if (dd->stopbits > 1)
+		lcr |= LCR_STOPB;
+
+	/* XXX set parity */
+
+	return (lcr);
+}
+
 /*
  * Do some non-destructive (for this device that is) tests
  * to make sure we have something that looks like an UART.
@@ -645,7 +668,10 @@
 	 * switch to the static sio_console struct so that if we have a
 	 * serial console we have all the state information. We assume that
 	 * at this time the bus specific front-ends only defined addr_type,
-	 * addr_rid and addr_res.
+	 * addr_rid and addr_res. If it's not the console, check if it's
+	 * the remote GDB debug port. Note that the debug port can also be
+	 * the console. In that case sio_dbgport points to sio_console and
+	 * we don't have to do anything special.
 	 */
 	if (com->bst == sio_console.bst && com->bsh == sio_console.bsh) {
 		sio_console.addr_res = com->addr_res;
@@ -653,6 +679,13 @@
 		sio_console.addr_type = com->addr_type;
 		device_set_softc(dev, &sio_console);
 		com = &sio_console;
+	} else if (com->bst == sio_dbgport->bst &&
+	    com->bsh == sio_dbgport->bsh) {
+		sio_dbgport->addr_res = com->addr_res;
+		sio_dbgport->addr_rid = com->addr_rid;
+		sio_dbgport->addr_type = com->addr_type;
+		device_set_softc(dev, sio_dbgport);
+		com = sio_dbgport;
 	}
 
 	com->dev = dev;
@@ -707,15 +740,6 @@
 
 	flags = device_get_flags(dev);
 
-	if (COM_LLCONSOLE(flags)) {
-		device_printf(dev, "reserved for low-level i/o\n");
-		/*
-		 * Don't release the address resource! We don't want it to be
-		 * taken by other drivers.
-		 */
-		return (ENXIO);
-	}
-
 	bus_release_resource(dev, com->addr_type, com->addr_rid,
 	    com->addr_res);
 	return (0);
@@ -732,7 +756,7 @@
 
 	/* Assume addr_rid and addr_type are still valid (set by probe). */
 	com->addr_res = bus_alloc_resource(dev, com->addr_type, &com->addr_rid,
-	    0, ~0, 8, RF_ACTIVE);
+	    0, ~0, SIO_NREGS, RF_ACTIVE);
 	if (com->addr_res == NULL)
 		return (ENXIO);
 

==== //depot/projects/sio/sys/dev/sio/sio_cons.c#3 (text+ko) ====

@@ -83,35 +83,10 @@
 CONS_DRIVER(sio, siocnprobe, siocninit, siocnterm, siocngetc, siocncheckc,
 	siocnputc, NULL);
 
-/* Sloppily translate databits, stopbits and parity to LCR register bits. */
-static u_char
-siocnlcr(struct sio_consdata *cd)
-{
-	u_char lcr;
-
-	lcr = 0;
-
-	if (cd->databits >= 8)
-		lcr |= LCR_8BITS;
-	else if (cd->databits == 7)
-		lcr |= LCR_7BITS;
-	else if (cd->databits == 6)
-		lcr |= LCR_6BITS;
-	else
-		lcr |= LCR_5BITS;
-
-	if (cd->stopbits > 1)
-		lcr |= LCR_STOPB;
-
-	/* XXX set parity */
-
-	return (lcr);
-}
-
 static void
 siocnprobe(struct consdev *cp)
 {
-	struct sio_consdata cd;
+	struct sio_devdata dd;
 	u_int divisor;
 	u_char lcr;
 
@@ -120,28 +95,28 @@
 	cp->cn_dev = NULL;		/* How do we know. */
 	cp->cn_pri = CN_DEAD;
 
-	if (sio_get_console(&cd) != 0)
+	if (sio_get_console(&dd) != 0)
 		return;
 
 	/* Minimum fields needed for rudimentary checks. */
-	sio_console.bst = cd.bst;
-	sio_console.bsh = cd.bsh;
-	sio_console.regshft = cd.regshft;
+	sio_console.bst = dd.bst;
+	sio_console.bsh = dd.bsh;
+	sio_console.regshft = dd.regshft;
 
 	if (sioprobe1(&sio_console))
 		return;
 
-	sio_console.rclk = (cd.rclk != 0) ? cd.rclk : DEFAULT_RCLK;
+	sio_console.rclk = (dd.rclk != 0) ? dd.rclk : DEFAULT_RCLK;
 
-	if (cd.baud == 0)
-		cd.baud = CONSPEED;
+	if (dd.baud == 0)
+		dd.baud = CONSPEED;
 
 	/* Set DL and LCR. */
-	lcr = siocnlcr(&cd);
+	lcr = sioddtolcr(&dd);
 	sio_setreg(&sio_console, com_lcr, lcr | LCR_DLAB);
 	sio_barrier(&sio_console);
-	if (cd.baud != 0) {
-		divisor = siodivisor(sio_console.rclk, cd.baud);
+	if (dd.baud != 0) {
+		divisor = siodivisor(sio_console.rclk, dd.baud);
 		sio_setdreg(&sio_console, com_dl, divisor);
 	} else
 		divisor = sio_getdreg(&sio_console, com_dl);

==== //depot/projects/sio/sys/dev/sio/sioreg.h#3 (text+ko) ====

@@ -53,6 +53,8 @@
 #define	com_msr		6		/* MODEM Status Reg. */
 #define	com_scr		7		/* Scratch Reg. (16450 and up). */
 
+#define	SIO_NREGS	8
+
 /* interrupt enable register */
 #define	IER_ERXRDY	0x1
 #define	IER_ETXRDY	0x2
@@ -137,9 +139,6 @@
 #define	EMR_EFMODE	0x80
 #endif
 
-/* speed to initialize to during chip tests */
-#define	SIO_TEST_SPEED	9600
-
 /* default serial console speed if not set with sysctl or probed from boot */
 #ifndef CONSPEED
 #define	CONSPEED	9600
@@ -149,5 +148,3 @@
 #ifndef GDBSPEED
 #define	GDBSPEED	CONSPEED
 #endif
-
-#define	IO_COMSIZE	8		/* 8250, 16x50 com controllers */

==== //depot/projects/sio/sys/dev/sio/siovar.h#4 (text+ko) ====

@@ -61,7 +61,7 @@
 #endif /* PC98 */
 
 #define	COM_CONSOLE(flags)	((flags) & 0x10)
-#define	COM_PPSCTS(flags)	((flags) & 0x10000)
+#define	COM_DEBUGGER(flags)	((flags) & 0x80)
 
 #define	CE_NTYPES		3
 
@@ -90,7 +90,8 @@
 	int		addr_rid;
 	int		addr_type;		/* SYS_RES_{IOPORT|MEMORY}. */
 	u_int		regshft;		/* Interleaved multi-port. */
-	u_int		hasfifo:1;
+	int		dbgport:1;		/* Used as debug port. */
+	int		hasfifo:1;
 	u_int		fifosize;
 	u_short		reg_dl;			/* Copy of DL. */
 	u_char		reg_fcr;		/* Copy of FCR. */
@@ -177,7 +178,8 @@
 	bus_space_write_2((com)->bst, (com)->bsh, sio_offset(com, reg), value)
 
 #define	sio_barrier(com)		\
-	bus_space_barrier((com)->bst, (com)->bsh, 0, sio_offset(com, 8), \
+	bus_space_barrier((com)->bst, (com)->bsh, 0,		\
+	    sio_offset(com, SIO_NREGS),				\
 	    BUS_SPACE_BARRIER_READ|BUS_SPACE_BARRIER_WRITE)
 
 #define	SET_FLAG(dev, bit)	\
@@ -185,7 +187,7 @@
 #define	CLR_FLAG(dev, bit)	\
 	device_set_flags(dev, device_get_flags(dev) & ~(bit))
 
-struct sio_consdata {
+struct sio_devdata {
 	bus_space_handle_t bsh;
 	bus_space_tag_t	   bst;
 	u_int		regshft;
@@ -196,9 +198,12 @@
 	u_int		parity;
 };
 
-int	sio_get_console(struct sio_consdata*);
+int	sio_get_console(struct sio_devdata*);
+int	sio_get_dbgport(struct sio_devdata*);
 
 extern	struct com_s	sio_console;
+extern	struct com_s	*sio_dbgport;
+extern	struct com_s	sio_debugport;
 extern	devclass_t	sio_devclass;
 extern	char		sio_driver_name[];
 
@@ -209,5 +214,6 @@
 int	siodetach(device_t dev);
 int	sioprobe(device_t dev);
 
+u_char	sioddtolcr(struct sio_devdata *);
 u_int	siodivisor(u_long rclk, u_long speed);
 int	sioprobe1(struct com_s *sc);

==== //depot/projects/sio/sys/i386/i386/db_interface.c#2 (text+ko) ====

@@ -52,8 +52,6 @@
 static jmp_buf *db_nofault = 0;
 extern jmp_buf	db_jmpbuf;
 
-extern void	gdb_handle_exception(db_regs_t *, int, int);
-
 int	db_active;
 db_regs_t ddb_regs;
 
@@ -78,7 +76,9 @@
 kdb_trap(int type, int code, struct i386_saved_state *regs)
 {
 	u_int ef;
-	volatile int ddb_mode = !(boothowto & RB_GDB);
+	volatile int ddb_mode;
+
+	ddb_mode = !(boothowto & RB_GDB);
 
 	/*
 	 * XXX try to do nothing if the console is in graphics mode.
@@ -171,7 +171,7 @@
 	    cndbctl(FALSE);
 	} else {
 	    db_active = 1;
-	    gdb_handle_exception(&ddb_regs, type, code);
+	    gdb_handle_exception(&ddb_regs, type);
 	}
 	db_active = 0;
 

==== //depot/projects/sio/sys/i386/i386/machdep.c#2 (text+ko) ====

@@ -2075,7 +2075,7 @@
 #endif
 
 #ifdef DDB
-	kdb_init();
+	db_init();
 	if (boothowto & RB_KDB)
 		Debugger("Boot flags requested debugger");
 #endif

==== //depot/projects/sio/sys/i386/i386/sio_machdep.c#2 (text+ko) ====

@@ -39,11 +39,12 @@
 
 #include <dev/sio/siovar.h>
 
-int sio_get_console(struct sio_consdata *cd)
+int
+sio_get_console(struct sio_devdata *dd)
 {
 	unsigned int i, ivar;
 
-	bzero(cd, sizeof(*cd));
+	bzero(dd, sizeof(*dd));
 
 	/* XXX - Try ACPI SPCR descriptor */
 
@@ -65,14 +66,53 @@
 		if (resource_int_value("sio", i, "port", &ivar) != 0 ||
 		    ivar == 0)
 			continue;
-		cd->bsh = ivar;
-		cd->bst = I386_BUS_SPACE_IO;
+		dd->bsh = ivar;
+		dd->bst = I386_BUS_SPACE_IO;
+		if (resource_int_value("sio", i, "baud", &ivar) != 0)
+			ivar = 0;
+		dd->baud = ivar;
+		dd->databits = 8;
+		dd->stopbits = 1;
+		dd->parity = 0;
+		return (0);
+	}
+
+	return (ENXIO);
+}
+
+int
+sio_get_dbgport(struct sio_devdata *dd)
+{
+	unsigned int i, ivar;
+
+	bzero(dd, sizeof(*dd));
+
+	/*
+	 * Scan the hints. We only try units 0 to 3 (inclusive). This
+	 * covers the ISA legacy where 4 UARTs had their resources
+	 * predefined.
+	 */
+	for (i = 0; i < 4; i++) {
+		if (resource_int_value("sio", i, "flags", &ivar))
+			continue;
+		if (!COM_DEBUGGER(ivar))
+			continue;
+		/* We have a possible debug port. Make sure it's enabled. */
+		if (resource_int_value("sio", i, "disabled", &ivar) == 0 &&
+		    ivar != 0)
+			continue;
+		/* It's alive. Get the port. */
+		if (resource_int_value("sio", i, "port", &ivar) != 0 ||
+		    ivar == 0)
+			continue;
+		dd->bsh = ivar;
+		dd->bst = I386_BUS_SPACE_IO;
 		if (resource_int_value("sio", i, "baud", &ivar) != 0)
 			ivar = 0;
-		cd->baud = ivar;
-		cd->databits = 8;
-		cd->stopbits = 1;
-		cd->parity = 0;
+		dd->baud = ivar;
+		dd->databits = 8;
+		dd->stopbits = 1;
+		dd->parity = 0;
 		return (0);
 	}
 

==== //depot/projects/sio/sys/i386/include/db_machdep.h#2 (text+ko) ====

@@ -90,4 +90,16 @@
 #define	DB_SMALL_VALUE_MAX	0x7fffffff
 #define	DB_SMALL_VALUE_MIN	(-0x400001)
 
+/*
+ * Remote GDB support.
+ */
+#define	GDB_REGNUM_SP		4
+#define	GDB_REGNUM_FP		5
+#define	GDB_REGNUM_PC		8
+
+/* What size are registers? */
+#define	gdb_enc_register	gdb_enc_int32
+
+int gdb_signal(int);
+
 #endif /* !_MACHINE_DB_MACHDEP_H_ */

==== //depot/projects/sio/sys/ia64/ia64/db_interface.c#2 (text+ko) ====

@@ -65,8 +65,6 @@
 static jmp_buf *db_nofault = 0;
 extern jmp_buf	db_jmpbuf;
 
-extern void	gdb_handle_exception(db_regs_t *, int);
-
 int	db_active;
 db_regs_t ddb_regs;
 

==== //depot/projects/sio/sys/ia64/ia64/machdep.c#3 (text+ko) ====

@@ -677,7 +677,7 @@
 	 * Initialize debuggers, and break into them if appropriate.
 	 */
 #ifdef DDB
-	kdb_init();
+	db_init();
 	if (boothowto & RB_KDB) {
 		printf("Boot flags requested debugger\n");
 		breakpoint();

==== //depot/projects/sio/sys/ia64/ia64/sio_machdep.c#2 (text+ko) ====

@@ -43,81 +43,44 @@
 
 #include <dev/sio/siovar.h>
 
-static u_int64_t
-sio_map(u_int64_t pa, int region)
-{
-	struct ia64_pte pte;
-	u_int64_t psr, va;
-
-	bzero(&pte, sizeof(pte));
-	if (region == 6) {
-		va = IA64_PHYS_TO_RR6(pa);
-		pte.pte_ma = PTE_MA_UC;
-	} else {
-		va = IA64_PHYS_TO_RR7(pa);
-		pte.pte_ma = PTE_MA_WB;
-	}
-	pte.pte_p = 1;
-	pte.pte_a = 1;
-	pte.pte_d = 1;
-	pte.pte_pl = PTE_PL_KERN;
-	pte.pte_ar = PTE_AR_RW;
-	pte.pte_ppn = pa >> 12;
-
-	__asm __volatile("mov	%0=psr;;"	: "=r"(psr));
-	__asm __volatile("rsm	psr.ic|psr.i;;");
-	__asm __volatile("srlz.d");
-	__asm __volatile("mov	cr.ifa=%0"	:: "r"(va));
-	__asm __volatile("mov	cr.itir=%0;;"	:: "r"(28 << 2));
-	__asm __volatile("itc.d	%0;;"		:: "r"(*(u_int64_t*)&pte));
-	__asm __volatile("mov	psr.l=%0"	:: "r" (psr));
-	__asm __volatile("srlz.d");
-	return (va);
-}
-
-int sio_get_console(struct sio_consdata *cd)
+static int
+sio_get_device(struct sio_devdata *dd, int type)
 {
 	struct dig64_hcdp_table *tbl;
 	struct dig64_hcdp_entry *ent;
 	unsigned int i, ivar;
 
-	bzero(cd, sizeof(*cd));
+	bzero(dd, sizeof(*dd));
 
 	/*
 	 * Use the DIG64 HCDP table if present.
 	 */
 	if (bootinfo.bi_hcdp != 0) {
-		tbl = (struct dig64_hcdp_table*)sio_map(bootinfo.bi_hcdp, 7);
+		tbl = (void*)IA64_PHYS_TO_RR7(bootinfo.bi_hcdp);
 		for (i = 0; i < tbl->entries; i++) {
 			ent = tbl->entry + i;
 
-			/* Skip non-console entries. */
-			if (ent->type != DIG64_HCDP_CONSOLE)
+			if (ent->type != type)
 				continue;
 
-			cd->bsh = ent->address.addr_high;
-			cd->bsh = (cd->bsh << 32) + ent->address.addr_low;
-			cd->bst = (ent->address.addr_space == 0)
+			dd->bsh = ent->address.addr_high;
+			dd->bsh = (dd->bsh << 32) + ent->address.addr_low;
+			dd->bst = (ent->address.addr_space == 0)
 			    ? IA64_BUS_SPACE_MEM : IA64_BUS_SPACE_IO;
-			/* XXX - We should have pre-mapped all UC memory. */
-			if (cd->bst == IA64_BUS_SPACE_MEM)
-				(void)sio_map(cd->bsh, 6);
-			cd->rclk = (ent->pclock) ? ent->pclock : 115200L;
-			cd->rclk <<= 4;		/* rclk = 16 * pclock */
-			cd->baud = ent->baud_high;
-			cd->baud = (cd->baud << 32) + ent->baud_low;
-			cd->databits = ent->databits;
-			cd->stopbits = ent->stopbits;
+			dd->rclk = (ent->pclock) ? ent->pclock : 115200L;
+			dd->rclk <<= 4;		/* rclk = 16 * pclock */
+			dd->baud = ent->baud_high;
+			dd->baud = (dd->baud << 32) + ent->baud_low;
+			dd->databits = ent->databits;
+			dd->stopbits = ent->stopbits;
 			/* XXX map from dig64 to out own? */
-			cd->parity = ent->parity;
+			dd->parity = ent->parity;
 			return (0);
 		}
 
 		/* FALLTHROUGH */
 	}
 
-	/* XXX - Try ACPI SPCR descriptor */
-
 	/*
 	 * Scan the hints for backward compatibility. We only try units
 	 * 0 to 3 (inclusive). This covers the ISA legacy where 4 UARTs
@@ -126,9 +89,10 @@
 	for (i = 0; i < 4; i++) {
 		if (resource_int_value("sio", i, "flags", &ivar))
 			continue;
-		if (!COM_CONSOLE(ivar))
+		if ((type == DIG64_HCDP_CONSOLE && !COM_CONSOLE(ivar)) ||
+		    (type == DIG64_HCDP_DBGPORT && !COM_DEBUGGER(ivar)))
 			continue;
-		/* We have a possible console. Make sure it's enabled. */
+		/* We have a possible device. Make sure it's enabled. */
 		if (resource_int_value("sio", i, "disabled", &ivar) == 0 &&
 		    ivar != 0)
 			continue;
@@ -136,16 +100,28 @@
 		if (resource_int_value("sio", i, "port", &ivar) != 0 ||
 		    ivar == 0)
 			continue;
-		cd->bsh = ivar;
-		cd->bst = IA64_BUS_SPACE_IO;
+		dd->bsh = ivar;
+		dd->bst = IA64_BUS_SPACE_IO;
 		if (resource_int_value("sio", i, "baud", &ivar) != 0)
 			ivar = 0;
-		cd->baud = ivar;
-		cd->databits = 8;
-		cd->stopbits = 1;
-		cd->parity = 0;
+		dd->baud = ivar;
+		dd->databits = 8;
+		dd->stopbits = 1;
+		dd->parity = 0;
 		return (0);
 	}
 
 	return (ENXIO);
 }
+
+int
+sio_get_console(struct sio_devdata *dd)
+{
+	return (sio_get_device(dd, DIG64_HCDP_CONSOLE));
+}
+
+int
+sio_get_dbgport(struct sio_devdata *dd)
+{
+	return (sio_get_device(dd, DIG64_HCDP_DBGPORT));
+}

==== //depot/projects/sio/sys/kern/link_elf.c#2 (text+ko) ====

@@ -57,6 +57,10 @@
 #include <vm/pmap.h>
 #include <vm/vm_map.h>
 
+#ifdef DDB
+#include <ddb/ddb.h>
+#endif
+
 #include <sys/link_elf.h>
 
 #include "linker_if.h"
@@ -91,11 +95,8 @@
     long		ddbsymcnt;	/* Number of symbols */
     caddr_t		ddbstrtab;	/* String table */
     long		ddbstrcnt;	/* number of bytes in string table */
-    caddr_t		symbase;	/* malloc'ed symbold base */
+    caddr_t		symbase;	/* malloc'ed symbol base */
     caddr_t		strbase;	/* malloc'ed string base */
-#ifdef DDB
-    struct link_map	gdb;		/* hooks for gdb */
-#endif
 } *elf_file_t;
 
 static int	link_elf_link_common_finish(linker_file_t);
@@ -144,61 +145,6 @@
 static int		relocate_file(elf_file_t ef);
 static int		link_elf_preload_parse_symbols(elf_file_t ef);
 
-#ifdef DDB
-static void		r_debug_state(struct r_debug *dummy_one,
-				      struct link_map *dummy_two);
-
-/*
- * A list of loaded modules for GDB to use for loading symbols.
- */
-struct r_debug r_debug;
-
-#define GDB_STATE(s)	r_debug.r_state = s; r_debug_state(NULL, NULL);
-
-/*
- * Function for the debugger to set a breakpoint on to gain control.
- */
-static void
-r_debug_state(struct r_debug *dummy_one __unused,
-	      struct link_map *dummy_two __unused)
-{
-}
-
-static void
-link_elf_add_gdb(struct link_map *l)
-{
-    struct link_map *prev;
-
-    l->l_next = NULL;
-
-    if (r_debug.r_map == NULL) {
-	/* Add first. */
-	l->l_prev = NULL;
-	r_debug.r_map = l;
-    } else {
-	/* Append to list. */
-	for (prev = r_debug.r_map; prev->l_next != NULL; prev = prev->l_next)
-	    ;
-	l->l_prev = prev;
-	prev->l_next = l;
-    }
-}
-
-static void
-link_elf_delete_gdb(struct link_map *l)
-{
-    if (l->l_prev == NULL) {
-	/* Remove first. */
-	if ((r_debug.r_map = l->l_next) != NULL)
-	    l->l_next->l_prev = NULL;
-    } else {
-	/* Remove any but first. */
-	if ((l->l_prev->l_next = l->l_next) != NULL)
-	    l->l_next->l_prev = l->l_prev;
-    }
-}
-#endif /* DDB */
-
 #ifdef __ia64__
 Elf_Addr link_elf_get_gp(linker_file_t);
 #endif
@@ -221,10 +167,6 @@
 static int
 link_elf_link_common_finish(linker_file_t lf)
 {
-#ifdef DDB
-    elf_file_t ef = (elf_file_t)lf;
-    char *newfilename;
-#endif
     int error;
 
     /* Notify MD code that a module is being loaded. */
@@ -233,14 +175,8 @@
 	return (error);
 
 #ifdef DDB
-    GDB_STATE(RT_ADD);
-    ef->gdb.l_addr = lf->address;
-    newfilename = malloc(strlen(lf->filename) + 1, M_LINKER, M_WAITOK);
-    strcpy(newfilename, lf->filename);
-    ef->gdb.l_name = newfilename;
-    ef->gdb.l_ld = ef->dynamic;
-    link_elf_add_gdb(&ef->gdb);
-    GDB_STATE(RT_CONSISTENT);
+    /* Notify DDB that a module has been loaded. */

>>> TRUNCATED FOR MAIL (1000 lines) <<<



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200305031957.h43Jv26B068738>