clean these up (mostly rename bus_space_{tag,handle}_t variables) so that

this code makes equal sense for memory and I/O space, prefer to map
the PCI front end via memory space (conditionalized on a patchable kernel
variable), and do a bit of other random NetBSD-specific cleanup.  (These
changes were sent to Justin Gibbs on March 28.)
This commit is contained in:
cgd 1997-04-10 02:48:38 +00:00
parent 319b64a8f7
commit db0f072019
4 changed files with 65 additions and 46 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: aic7xxx.c,v 1.22 1997/03/13 00:38:48 cgd Exp $ */
/* $NetBSD: aic7xxx.c,v 1.23 1997/04/10 02:48:38 cgd Exp $ */
/*
* Generic driver for the aic7xxx based adaptec SCSI controllers
@ -428,10 +428,10 @@ ahc_alloc(unit, iobase, type, flags)
u_long iobase;
#elif defined(__NetBSD__)
void
ahc_construct(ahc, iot, ioh, type, flags)
ahc_construct(ahc, st, sh, type, flags)
struct ahc_data *ahc;
bus_space_tag_t iot;
bus_space_handle_t ioh;
bus_space_tag_t st;
bus_space_handle_t sh;
#endif
ahc_type type;
ahc_flag flags;
@ -465,8 +465,8 @@ ahc_construct(ahc, iot, ioh, type, flags)
#if defined(__FreeBSD__)
ahc->baseport = iobase;
#elif defined(__NetBSD__)
ahc->sc_iot = iot;
ahc->sc_ioh = ioh;
ahc->sc_st = st;
ahc->sc_sh = sh;
#endif
ahc->type = type;
ahc->flags = flags;
@ -493,10 +493,10 @@ void
ahc_reset(iobase)
u_long iobase;
#elif defined(__NetBSD__)
ahc_reset(devname, iot, ioh)
ahc_reset(devname, st, sh)
char *devname;
bus_space_tag_t iot;
bus_space_handle_t ioh;
bus_space_tag_t st;
bus_space_handle_t sh;
#endif
{
u_char hcntrl;
@ -508,9 +508,9 @@ ahc_reset(devname, iot, ioh)
outb(HCNTRL + iobase, CHIPRST | PAUSE);
#elif defined(__NetBSD__)
hcntrl = (bus_space_read_1(iot, ioh, HCNTRL) & IRQMS) | INTEN;
hcntrl = (bus_space_read_1(st, sh, HCNTRL) & IRQMS) | INTEN;
bus_space_write_1(iot, ioh, HCNTRL, CHIPRST | PAUSE);
bus_space_write_1(st, sh, HCNTRL, CHIPRST | PAUSE);
#endif
/*
* Ensure that the reset has finished
@ -519,7 +519,7 @@ ahc_reset(devname, iot, ioh)
#if defined(__FreeBSD__)
while (--wait && !(inb(HCNTRL + iobase) & CHIPRSTACK))
#elif defined(__NetBSD__)
while (--wait && !(bus_space_read_1(iot, ioh, HCNTRL) & CHIPRSTACK))
while (--wait && !(bus_space_read_1(st, sh, HCNTRL) & CHIPRSTACK))
#endif
DELAY(1000);
if(wait == 0) {
@ -534,7 +534,7 @@ ahc_reset(devname, iot, ioh)
#if defined(__FreeBSD__)
outb(HCNTRL + iobase, hcntrl | PAUSE);
#elif defined(__NetBSD__)
bus_space_write_1(iot, ioh, HCNTRL, hcntrl | PAUSE);
bus_space_write_1(st, sh, HCNTRL, hcntrl | PAUSE);
#endif
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: aic7xxxvar.h,v 1.12 1997/03/13 00:38:50 cgd Exp $ */
/* $NetBSD: aic7xxxvar.h,v 1.13 1997/04/10 02:48:41 cgd Exp $ */
/*
* Interface to the generic driver for the aic7xxx based adaptec
@ -70,15 +70,15 @@
outsl((ahc)->baseport+(port), valp, size)
#elif defined(__NetBSD__)
#define AHC_INB(ahc, port) \
bus_space_read_1((ahc)->sc_iot, (ahc)->sc_ioh, port)
bus_space_read_1((ahc)->sc_st, (ahc)->sc_sh, port)
#define AHC_INSB(ahc, port, valp, size) \
bus_space_read_multi_1((ahc)->sc_iot, (ahc)->sc_ioh, port, (u_int8_t *) valp, size)
bus_space_read_multi_1((ahc)->sc_st, (ahc)->sc_sh, port, (u_int8_t *) valp, size)
#define AHC_OUTB(ahc, port, val) \
bus_space_write_1((ahc)->sc_iot, (ahc)->sc_ioh, port, val)
bus_space_write_1((ahc)->sc_st, (ahc)->sc_sh, port, val)
#define AHC_OUTSB(ahc, port, valp, size) \
bus_space_write_multi_1((ahc)->sc_iot, (ahc)->sc_ioh, port, (u_int8_t *) valp, size)
bus_space_write_multi_1((ahc)->sc_st, (ahc)->sc_sh, port, (u_int8_t *) valp, size)
#define AHC_OUTSL(ahc, port, valp, size) \
bus_space_write_multi_4((ahc)->sc_iot, (ahc)->sc_ioh, port, (u_int32_t *) valp, size)
bus_space_write_multi_4((ahc)->sc_st, (ahc)->sc_sh, port, (u_int32_t *) valp, size)
#endif
#define AHC_NSEG 256 /* number of dma segments supported */
@ -211,8 +211,8 @@ struct ahc_data {
#elif defined(__NetBSD__)
struct device sc_dev;
void *sc_ih;
bus_space_tag_t sc_iot;
bus_space_handle_t sc_ioh;
bus_space_tag_t sc_st;
bus_space_handle_t sc_sh;
LIST_HEAD(, scsi_xfer) sc_xxxq; /* XXX software request queue */
struct scsi_xfer *sc_xxxqlast; /* last entry in queue */
#endif
@ -292,10 +292,10 @@ struct ahc_data *ahc_alloc __P((int unit, u_long io_base, ahc_type type, ahc_fla
#define ahc_name(ahc) (ahc)->sc_dev.dv_xname
void ahc_reset __P((char *devname, bus_space_tag_t iot,
bus_space_handle_t ioh));
void ahc_construct __P((struct ahc_data *ahc, bus_space_tag_t iot,
bus_space_handle_t ioh, ahc_type type, ahc_flag flags));
void ahc_reset __P((char *devname, bus_space_tag_t st,
bus_space_handle_t sh));
void ahc_construct __P((struct ahc_data *ahc, bus_space_tag_t st,
bus_space_handle_t sh, ahc_type type, ahc_flag flags));
#endif
void ahc_free __P((struct ahc_data *));
int ahc_init __P((struct ahc_data *));

View File

@ -1,4 +1,4 @@
/* $NetBSD: smc93cx6var.h,v 1.3 1996/10/21 22:34:41 thorpej Exp $ */
/* $NetBSD: smc93cx6var.h,v 1.4 1997/04/10 02:48:42 cgd Exp $ */
/*
* Interface to the 93C46 serial EEPROM that is used to store BIOS
@ -34,8 +34,8 @@ struct seeprom_descriptor {
#if defined(__FreeBSD__)
u_long sd_iobase;
#elif defined(__NetBSD__)
bus_space_tag_t sd_iot;
bus_space_handle_t sd_ioh;
bus_space_tag_t sd_st;
bus_space_handle_t sd_sh;
bus_size_t sd_offset;
#endif
u_int16_t sd_MS;
@ -67,9 +67,9 @@ struct seeprom_descriptor {
#define SEEPROM_OUTB(sd, value) outb(sd->sd_iobase, value)
#elif defined(__NetBSD__)
#define SEEPROM_INB(sd) \
bus_space_read_1(sd->sd_iot, sd->sd_ioh, sd->sd_offset)
bus_space_read_1(sd->sd_st, sd->sd_sh, sd->sd_offset)
#define SEEPROM_OUTB(sd, value) \
bus_space_write_1(sd->sd_iot, sd->sd_ioh, sd->sd_offset, value)
bus_space_write_1(sd->sd_st, sd->sd_sh, sd->sd_offset, value)
#endif
#if defined(__FreeBSD__)

View File

@ -1,4 +1,4 @@
/* $NetBSD: ahc_pci.c,v 1.11 1997/03/13 01:04:02 cgd Exp $ */
/* $NetBSD: ahc_pci.c,v 1.12 1997/04/10 02:48:45 cgd Exp $ */
/*
* Product specific probe and attach routines for:
@ -85,7 +85,10 @@
#define bootverbose 0
#endif
#define PCI_BASEADR0 PCI_MAPREG_START
#define PCI_BASEADR_IO 0x10
#define PCI_BASEADR_MEM 0x14
int ahc_pci_prefer_io = 0; /* 1 -> map via I/O (patchable data) */
#endif /* defined(__NetBSD__) */
@ -315,9 +318,10 @@ ahc_pci_attach(parent, self, aux)
#elif defined(__NetBSD__)
struct pci_attach_args *pa = aux;
struct ahc_data *ahc = (void *)self;
bus_addr_t iobase;
bus_size_t iosize;
bus_space_handle_t ioh;
bus_addr_t busbase;
bus_size_t bussize;
bus_space_tag_t st;
bus_space_handle_t sh;
pci_intr_handle_t ih;
const char *intrstr;
#endif
@ -340,10 +344,27 @@ ahc_pci_attach(parent, self, aux)
*/
io_port &= 0xfffffffe;
#elif defined(__NetBSD__)
if (pci_io_find(pa->pa_pc, pa->pa_tag, PCI_BASEADR0, &iobase, &iosize))
if (ahc_pci_prefer_io) {
if (pci_io_find(pa->pa_pc, pa->pa_tag, PCI_BASEADR_IO,
&busbase, &bussize)) {
printf(": unable to find PCI I/O base\n");
return;
if (bus_space_map(pa->pa_iot, iobase, iosize, 0, &ioh))
}
st = pa->pa_iot;
} else {
if (pci_mem_find(pa->pa_pc, pa->pa_tag, PCI_BASEADR_MEM,
&busbase, &bussize, NULL)) {
printf(": unable to find PCI memory base\n");
return;
}
st = pa->pa_memt;
}
if (bus_space_map(st, busbase, bussize, 0, &sh)) {
printf(": unable to map %s registers\n",
ahc_pci_prefer_io ? "I/O" : "memory");
return;
}
printf("\n");
#endif
#if defined(__FreeBSD__)
@ -399,17 +420,15 @@ ahc_pci_attach(parent, self, aux)
if(ahc_t & AHC_ULTRA)
ultra_enb = inb(SXFRCTL0 + io_port) & ULTRAEN;
#else
our_id = bus_space_read_1(pa->pa_iot, ioh, SCSIID) & OID;
our_id = bus_space_read_1(st, sh, SCSIID) & OID;
if(ahc_t & AHC_ULTRA)
ultra_enb = bus_space_read_1(pa->pa_iot, ioh,
SXFRCTL0) & ULTRAEN;
ultra_enb = bus_space_read_1(st, sh, SXFRCTL0) & ULTRAEN;
#endif
#if defined(__FreeBSD__)
ahc_reset(io_port);
#elif defined(__NetBSD__)
printf("\n");
ahc_reset(ahc->sc_dev.dv_xname, pa->pa_iot, ioh);
ahc_reset(ahc->sc_dev.dv_xname, st, sh);
#endif
if(ahc_t & AHC_AIC7870){
@ -459,7 +478,7 @@ ahc_pci_attach(parent, self, aux)
return;
}
#elif defined(__NetBSD__)
ahc_construct(ahc, pa->pa_iot, ioh, ahc_t, ahc_f);
ahc_construct(ahc, st, sh, ahc_t, ahc_f);
if (pci_intr_map(pa->pa_pc, pa->pa_intrtag, pa->pa_intrpin,
pa->pa_intrline, &ih)) {
@ -630,8 +649,8 @@ load_seeprom(ahc)
#if defined(__FreeBSD__)
sd.sd_iobase = ahc->baseport + SEECTL;
#elif defined(__NetBSD__)
sd.sd_iot = ahc->sc_iot;
sd.sd_ioh = ahc->sc_ioh;
sd.sd_st = ahc->sc_st;
sd.sd_sh = ahc->sc_sh;
sd.sd_offset = SEECTL;
#endif
sd.sd_MS = SEEMS;