Subject: Re: "esp" driver reorg proposal
To: None <cgd@cs.cmu.edu>
From: Gordon W. Ross <gwr@mc.com>
List: tech-kern
Date: 01/26/1997 00:15:24
[ Sorry, I forgot to append that file.  It's below. -gwr ]

> > I do _not_ like the notion of <machine/espvar.h>, or whatever. [...]
[ I've already responded to this. -gwr ]

> It's not just a matter of this...
> 
> If every driver using MI code starts requiring a header in <machine>,
> things quickly get out of hand...

True, you need one for each port, but almost all of the traditional
xxxvar.h stuff would be in the common <dev/ic/xxxvar.h> file.
To make this more clear, I've attached a copy of the file I would
propose as <arch/sparc/include/espvar.h> below.  (Only 58 lines!)


/*
 * This file should exist as <arch/sparc/include/espvar.h>
 * so <dev/ic/esp.c> can include it as <machine/espvar.h>
 */

#include <machine/autoconf.h>
#include <sparc/dev/sbusvar.h>
#include <sparc/dev/dmareg.h>
#include <sparc/dev/dmavar.h>

#define ESP_DEBUG		0

/*
 * Machine-dependent things in esp_softc
 */
typedef u_char esp_reg_t;
typedef struct dma_softc esp_dma_t;
struct esp_sc_md {
	struct sbusdev scmd_sd;			/* sbus device */
	struct intrhand scmd_ih;		/* intr handler */
	int scmd_pri;				/* SBUS priority */
};
#define sc_sd	sc_md.scmd_sd
#define sc_ih	sc_md.scmd_ih
#define sc_pri	sc_md.scmd_pri

/*
 * Macros to read and write the chip's registers.
 */

#define	ESP_READ_REG(sc, reg)			\
	((sc)->sc_reg[(reg) * 4])

#define	ESP_WRITE_REG(sc, reg, val)		\
	do {					\
		u_char v = (val);		\
		(sc)->sc_reg[(reg) * 4] = v;	\
	} while (0)

/*
 * DMA macros...
 * Most are in <sparc/dev/dmavar.h>
 */

/*
 * This is used in esp_scsi_reset(sc).
 * XXX - Use DMA_RESET(sc) instead?
 */
#define	DMA_STOP(sc) \
	DMACSR((sc)->sc_dma) &= ~D_EN_DMA

/*
 * This is used in espreadregs(sc)
 * We have nothing to do there.
 */
#define	DMA_IACK(sc) ((void)(sc))