Subject: Re: configure() with valid context
To: Jason Thorpe <thorpej@nas.nasa.gov>
From: Eduardo E. Horvath <eeh@one-o.com>
List: tech-kern
Date: 09/16/1999 08:53:00
On Wed, 15 Sep 1999, Jason Thorpe wrote:

> Hi folks...
> 
> I'd like to make the following trivial change to main() to call configure()
> a bit later:
> 
> Index: init_main.c
> ===================================================================
> RCS file: /cvsroot/syssrc/sys/kern/init_main.c,v
> retrieving revision 1.155
> diff -c -r1.155 init_main.c
> *** init_main.c	1999/09/15 18:10:34	1.155
> --- init_main.c	1999/09/15 22:13:43
> ***************
> *** 320,325 ****
> --- 322,330 ----
>   
>   	/* Start real time and statistics clocks. */
>   	initclocks();
> + 
> + 	/* Configure the system hardware.  This will enable interrupts. */
> + 	configure();
>   
>   #ifdef SYSVSHM
>   	/* Initialize System V style shared memory. */
> 
> ...essentially, this allows autoconfiguration to run in a valid thread
> context.
> 
> Objections?

Yes, I object (I'm surprised pk hasen't also).  initclocks() is supposed
to fire up the clock interrupt, which means it needs access to the clock
hardware.  In order to call initclocks() you need to have the clocks
probed and attached, which is done in configure().  

This gets much nastier if you can have different types of clocks depending
on the particular hardware.  To retrieve this information in an OBP 
machine means complete traversal of the entire device tree hunting for an
appropriate node.  If the clock node happens to be attached to some other
bus node, then that bus node also needs to be probed and attached before
the clock node can be attached.  And if the system happens to have
multiple clocks, you need to do a full tree scan, see what you're got at
the end and and then decide which one to use.

I already have this problem with the keyboard/mouse.  Before configure() I
need to use OBP routines for keyboard/console I/O.  During configure(), if
I detect the devices that the keyboard/mouse/console are attached to I
need to switch the console vector from routines that call the OBP to
routines that call the device driver to use the hardware directly.  I
would really prefer not to have to make a similar kluge for the clock.

=========================================================================
Eduardo Horvath				eeh@one-o.com
	"I need to find a pithy new quote." -- me