Subject: Dumping autoconf info from DDB
To: None <tech-kern@netbsd.org>
From: David Brownlee <abs@netbsd.org>
List: tech-kern
Date: 02/03/2000 18:12:49
	Gregory McGarry suggested we add an 'autoconf_dump' function
	to allow people to boot -d and more easily edit their autoconf
	information (for example to match awkward ISA cards), but it
	should be generic enough to be useful across all ports for anyone
 	tweaking their autoconfiguration data.

	Matthias mentioned that config currently packs locators, which
	would mean modifying one locator could affect others (not good).

        Not packing the locators would waste a little space, but being
	able to change the values from within DDB (or some other boot time
	tool) is a very valuable feature for those with unfortunate hardware.

	What I would like to do would be disable locator packing if
	DDB is enabled - this would involve a runtime switch in config,
	but should give us the best of both worlds - no overhead in
	the non DDB case, and no overlapping locators in the DDB case
	(when the overhead is very small compared to DDB)

	What do people think - is there a clean way to add this to config?

> ---------- Forwarded message ----------
> Date: Wed, 19 Jan 2000 18:15:39 +1000
> From: Gregory McGarry <g.mcgarry@qut.edu.au>
> To: port-i386@netbsd.org
> Cc: David Brownlee <abs@netbsd.org>, Guy Santiglia <robin5153@yahoo.com>,
>      David Maxwell <david@fundy.ca>
> Subject: kernel config and DDB
> 
> Using DDB to edit the autoconfig tables isn't the easiest task
> for the first time user.  The attached patch might be useful.
> 
> Used something like this:
> 
> boot netbsd -d
> ...
> db> call autoconf_dump
> ...
> we at isa: port 0x340 [0xf026a4d0], size 0x0 [0xf026a4d4], iomem 0xd0000 [0dxf02
> 6a4d8], iosiz 0x0 [0xf026a4dc], irq 0xb [0xf026a4e0]
> ...
> db> w/l 0xf026a4d0 0x300
> _loc                 0x340 =    0x300
> db> w/l 0xf026a4e0 5
> _loc+0x10                 0xb =    0x5
> db> call autoconf_dump
> ...
> we at isa: port 0x300 [0xf026a4d0], size 0x0 [0xf026a4d4], iomem 0xd0000 [0dxf02
> 6a4d8], iosiz 0x0 [0xf026a4dc], irq 0x5 [0xf026a4e0]
> ...
> db> c
> 
> 
> 	-- Gregory McGarry <g.mcgarry@qut.edu.au>
> 
> 
> *** subr_autoconf.c.orig	Wed Jan 19 11:53:44 2000
> --- subr_autoconf.c	Wed Jan 19 17:00:00 2000
> ***************
> *** 1,4 ****
> ! /*	$NetBSD: subr_autoconf.c,v 1.44 1999/09/23 15:14:57 minoura Exp $	*/
>   
>   /*
>    * Copyright (c) 1992, 1993
> --- 1,4 ----
> ! /*	$NetBSD$	*/
>   
>   /*
>    * Copyright (c) 1992, 1993
> ***************
> *** 679,681 ****
> --- 679,724 ----
>   
>   	TAILQ_REMOVE(&allevents, ev, ev_list);
>   }
> + 
> + 
> + /*
> +  *  If DDB is enabled then dump the autoconfiguration details.
> +  */
> + #include "opt_ddb.h"
> + #ifdef DDB
> + #include <ddb/db_output.h>
> + void autoconf_dump __P((void));
> + void
> + autoconf_dump (void)
> + {
> + 	struct cfdata *cf;
> + 	short *p;
> + 	const char **l;
> + 	int i;
> + 	int needcomma;
> + 
> + 	for (cf = cfdata; cf->cf_driver; cf++) {
> + 		if (cf->cf_locnames[0] == NULL)
> + 			continue;
> + 		db_printf("%s at", cf->cf_driver->cd_name);
> + 		needcomma = 0;
> + 		for (p = cf->cf_parents; *p >= 0; p++) {
> + 			db_printf("%s%s", (needcomma ? ", " : " "),
> + 				cfdata[*p].cf_driver->cd_name);
> + 			needcomma = 1;
> + 		}
> + 		db_printf(":");
> + 		needcomma = 0;
> + 		for (l = cf->cf_locnames, i = 0; *l != NULL; i++, l++) {
> + 			if (cf->cf_loc[i] != -1) {
> + 				db_printf("%s%s 0x%x [%p]",
> + 					(needcomma ? ", " : " "), *l,
> + 					cf->cf_loc[i], &cf->cf_loc[i]);
> + 				needcomma = 1;
> + 			}
> + 		}
> + 		db_printf("\n");
> + 	}
> + 
> + }
> + #endif
> 
>