h00835
s 00000/00000/00084
d D 1.3 82/09/13 13:52:29 ross 3 2
c 
e
s 00000/00000/00084
d D 1.2 82/09/13 12:09:22 ross 2 1
c 
e
s 00084/00000/00000
d D 1.1 82/09/13 10:31:33 ross 1 0
e
u
U
t
T
I 1
/*
 * Selector channel scheduling routines
 */

#include "../h/param.h"
#include "../h/buf.h"
#include "../h/selch.h"


extern char	devmap[];	/* map device address => minor device no */

/*
 * Queue of devices using each selch
 *	- top of queue is currently active device; others are waiting
 */
struct selchtab {
	struct selchq	*sc_actf;
	struct selchq	*sc_actl;
} selchtab[4];


/*
 * Request use of selch with address n
 */
selchreq(n, selchq)
struct selchq *selchq;
{
	register struct selchq *s;
	register struct selchtab *st;
	register free;
trace(2<<16, "schrequest", selchq);

	st = &selchtab[devmap[n]];
	/* Make sure request not already on queue */
	for (s = st->sc_actf; s; s = s->sq_forw)
		if (s == selchq)
			return;

	(s = selchq)->sq_forw = 0;
	if (st->sc_actf) {
		st->sc_actl->sq_forw = s;
		free  = 0;
	} else {
		st->sc_actf = s;
		free = 1;
	}
	st->sc_actl = s;

	if (free)
		(*s->sq_sstart)();
}

/*
 * Free selch with address n for next device
 */
selchfree(n)
{
	register struct selchq *s;
	register struct selchtab *st;

	st = &selchtab[devmap[n]];
trace(2<<16, "schfree", st->sc_actf);
	if ((s = st->sc_actf) == 0)
		return;
	st->sc_actf = s = s->sq_forw;

	if (s)
		(*s->sq_sstart)();
}

/*
 * Selector channel interrupt -- handled by currently active device
 */
selchintr(dev, stat)
{
	register struct selchq *s;
	register struct selchtab *st;
trace(4<<16, "schint", dev);
trace(4<<16, "status", stat);

	st = &selchtab[dev];
	if (s = st->sc_actf)
		(*s->sq_sintr)(dev, stat);
}
E 1
