Subject: Re: MI soft interupts
To: None <ignatios@cs.uni-bonn.de>
From: Gordon W. Ross <gwr@mc.com>
List: tech-kern
Date: 04/06/1996 15:21:48
> Date: Sat, 6 Apr 1996 20:22:45 +0200 (MET DST)
> From: Ignatios Souvatzis <ignatios@cs.uni-bonn.de>

> Hello,
> 
> I started making the core of if_bah.c (the SMC chipset ARCnet driver
> for NetBSD/Amiga) MI, and to write an ISA frontend for it. I noticed
> that it would be VERY NICE to have a MI version of softint callbacks. 
> 
> I'd propose just to adopt the Amiga interface, but cgd convinced me
> that it should be modified... I summarize a proposal for an interface:

I have some concerns about this:

(1) There may be more than one "soft interrupt" level, so this MI
    interface could not replace the currently MD facilities in the
    sun3 or sparc ports unless you allow some way to specify which
    soft interrupt the function should be attached to.

(2) There should be three interface functions and one data structure
    visible to the caller of this interface.  Here is an example
    based on the Solaris ddi_add_softintr() family:
    (Maybe you intended this and I misunderstood.)


/*
 * These items would be defined in some MD header,
 * say <machine/softint.h>
 */
typedef void (*sicb_func_t)(void *arg);
struct sicb {
	sicb_func_t si_func;
	void *si_arg;
	/* These elements are used only by the (MD) implementation. */
	int si_pending;
	int si_priority;
	TAILQ_ENTRY(sicb) si_tq;
};

/*
 * Values that may be passed as the "priority" to softint_attach()
 * Note: the integer values are machine-specific!
 */
#define	SOFTINT_LOW	1
#define SOFTINT_MED	2
#define SOFTINT_HIGH	3
/* Maybe some "logical" ones like this would be handy: */
#define SOFTINT_NET	1	/* old setsoftnet() */
#define SOFTINT_CLOCK	1	/* old setsoftclock() */
#define SOFTINT_TTY	3	/* as close as possible to tty pri. */

/*
 * Prototypes:
 * Note: the caller provides space for the struct sicb,
 * typically as one member of a driver softc struct.
 */

/*
 * Caller fills-in si_func, si_arg, then calls this.
 * It returns an error if the attach fails.
 */
int softint_attach __P((struct sicb *si, int priority));

/*
 * Use this to ask for a soft interrupt call to a
 * previously attached sicb.
 */
void softint_request __P((struct sicb *si));

/*
 * Use this to detach a previously attached sicb.
 */
void softint_detach __P((struct sicb *si));