[net.unix-wizards] UDA driver query

eichelbe@nadc.arpa (03/21/86)

---
Here's a problem that asks wizards to test out their long-term memory.
I have a VAX 11/780 under 4.1 BSD UNIX and I have a version of a supposedly
4.1 BSD UNIX uda.c (UDA50/RA81) driver that compiles but for one error.
In the routine udprobe (which is shown below) there is a reference to
a variable uh_lastiv in the uba_hd structure.  This structure is in the header
file /sys/h/ubavar.h, but I don't find a uh_lastiv in the structure.  Here come
the questions:
(1) What is uh_lastiv supposed to do?
(2) Can I (and how if I can) change udprobe to get rid of the uh_lastiv
    reference safely?
(3) If I can't get rid of the reference, how should I change the uba_hd
    structure in /sys/h/ubavar.h so I too can use uh_lastiv, and if I do this
    will I have to change any code anywhere else in the kernel, etc. ?
    (This last part, about changes to other code, is important since I am
     really at a loss here.  If someone could just do a grep for uh_lastiv
     through the system code if you have uh_lastiv in your /sys/h/ubavar.h.)
---
udprobe(reg, ctlr)
	caddr_t reg;
	int ctlr;
{
	register int br, cvec;
	register struct uda_softc *sc = &uda_softc[ctlr];

#ifdef lint
	br = 0; cvec = br; br = cvec;
#endif
	/* SHOULD CHECK THAT IT REALLY IS A UDA */
	br = 0x15;
	cvec = sc->sc_ivec = (uba_hd[numuba].uh_lastiv -= 4);
	return(1);
}
---
	Oh, and here's uba_hd, extracted from /sys/h/ubavar.h.
---
struct	uba_hd {
	struct	uba_regs *uh_uba;	/* virt addr of uba */
	struct	uba_regs *uh_physuba;	/* phys addr of uba */
	int	(**uh_vec)();		/* interrupt vector */
	struct	uba_device *uh_actf;	/* head of queue to transfer */
	struct	uba_device *uh_actl;	/* tail of queue to transfer */
	short	uh_mrwant;		/* someone is waiting for map reg */
	short	uh_bdpwant;		/* someone awaits bdp's */
	int	uh_bdpfree;		/* free bdp's */
	int	uh_hangcnt;		/* number of ticks hung */
	int	uh_zvcnt;		/* number of 0 vectors */
	short	uh_users;		/* transient bdp use count */
	short	uh_xclu;		/* an rk07 is using this uba! */
#define	UAMSIZ	25
	struct	map *uh_map;		/* buffered data path regs free */
};
---
	Thanks.
		Jon Eichelberger
		eichelbe@NADC.ARPA

chris@umcp-cs.UUCP (Chris Torek) (03/24/86)

In article <1986@brl-smoke.ARPA> eichelbe@nadc.arpa writes:
>I have a VAX 11/780 under 4.1 BSD UNIX and [a] (UDA50/RA81) driver
>that compiles but for one error.  In the routine udprobe ... there
>is a reference to a variable uh_lastiv in the uba_hd structure. ...
>I don't find a uh_lastiv in the structure.

Ah, at last, I can show off my wizardly skills again! :-)  Actually,
I had the exact same thing happen when I installed a uda.c on a 4.1
system, long ago.

>(1) What is uh_lastiv supposed to do?

It is the `last interrupt vector' address, for devices with
programmable interrupt vectors.  These did not appear until well
after the 4.1 release, so only `late 4.1s' have the code.  The
variable is set to 0x200 (01000) in autoconf.c, and predecremented
by the appropriate amount by any driver needing a programmable
interrupt vector.

>(2) Can I (and how if I can) change udprobe to get rid of the uh_lastiv
>    reference safely?

If you have exactly one UDA50, no DMF32s, no DMZ32s, and so forth,
you can use

	br = 0x15;
	cvec = sc->sc_ivec = 0774;

but this creates a bug just waiting until the time is ripe to leap out
and strangle you.

>(3) If I can't get rid of the reference, how should I change the uba_hd
>    structure in /sys/h/ubavar.h so I too can use uh_lastiv ....

1) Add `uh_lastiv' to `struct uba_hd' in ubavar.h (at the end; that
   may be unnecessary, but is definitely safe).

2) In autoconf.c, find the routine named `unifind' or `UNIfind' or
   some variation thereof.  In there will be code resembling the
   following:

	if (numuba == 0)
		uhp->uh_vec = UNIvec;
	else
		uhp->uh_vec = (int(**)())calloc(512);
	for (i = 0; i < 128; i++)
		uhp->uh_vec[i] = scbentry(&catcher[i*2], SCB_ISTACK);

   After this, add:

	/*
	 * Set last free interrupt vector for devices with
	 * programmable interrupt vectors.  Use is to decrement
	 * this number and use result as interrupt vector.
	 */
	uhp->uh_lastiv = 0x200;


Unfortunately, that uda.c is fairly buggy.  If I had to run RA81s
on a 4.1 system, I would reconvert my new driver to 4.1 code.  But
if you must run that driver on a 780, use it on a Unibus all by
itself, or at least with nothing else that uses BDPs.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1415)
UUCP:	seismo!umcp-cs!chris
CSNet:	chris@umcp-cs		ARPA:	chris@mimsy.umd.edu

ed@mtxinu.UUCP (Ed Gould) (03/25/86)

In article <1986@brl-smoke.ARPA> eichelbe@nadc.arpa writes:
>---
>Here's a problem that asks wizards to test out their long-term memory.
>I have a VAX 11/780 under 4.1 BSD UNIX and I have a version of a supposedly
>4.1 BSD UNIX uda.c (UDA50/RA81) driver that compiles but for one error.
>In the routine udprobe (which is shown below) there is a reference to
>a variable uh_lastiv in the uba_hd structure.  This structure is in the header
>file /sys/h/ubavar.h, but I don't find a uh_lastiv in the structure.  Here come
>the questions:
>(1) What is uh_lastiv supposed to do?
>(2) Can I (and how if I can) change udprobe to get rid of the uh_lastiv
>    reference safely?
>(3) If I can't get rid of the reference, how should I change the uba_hd
>    structure in /sys/h/ubavar.h so I too can use uh_lastiv, and if I do this
>    will I have to change any code anywhere else in the kernel, etc. ?
>    (This last part, about changes to other code, is important since I am
>     really at a loss here.  If someone could just do a grep for uh_lastiv
>     through the system code if you have uh_lastiv in your /sys/h/ubavar.h.)

It sounds like you really have a 4.2 driver.  4.1 didn't have uh_lastiv,
nor did it support UDA50's or DMF32's or any other devices with software-
programmable interrupt vectors.  Uh_lastiv (last interrupt vector) was
added to support these kind of devices.  It is initialized to 01000 before
autoconfiguration starts.  When it's needed, as in the UDA probe routine,
it is decremented by the size of the vector space (4 for the UDA), and
the result is handed to the device to use as its interrupt vector:

	cvec = sc->sc_ivec = (uba_hd[numuba].uh_lastiv -= 4);

(sc_ivec is later handed to the device; cvec is the return-in-register
from probe).

-- 
Ed Gould                    mt Xinu, 2910 Seventh St., Berkeley, CA  94710  USA
{ucbvax,decvax}!mtxinu!ed   +1 415 644 0146

"A man of quality is not threatened by a woman of equality."