in wdc_softc: access the per-channel data via a pointer array instead of

an array of fixed-sized channel_softc elements. This way IDE controllers
which more than 1 channel (pciide) can extend the channel data easily
for private needs.
To avoid the double dereference at runtime, change the argument of
wdcstart() to the channel data pointer instead of the array index.
This commit is contained in:
drochner 1998-11-21 15:41:41 +00:00
parent 13a8c73bb6
commit 3e38051bc5
7 changed files with 31 additions and 29 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: ata_wdc.c,v 1.8 1998/11/20 01:23:52 thorpej Exp $ */ /* $NetBSD: ata_wdc.c,v 1.9 1998/11/21 15:41:41 drochner Exp $ */
/* /*
* Copyright (c) 1998 Manuel Bouyer. * Copyright (c) 1998 Manuel Bouyer.
@ -551,7 +551,7 @@ wdc_ata_bio_done(chp, xfer)
} }
WDCDEBUG_PRINT(("wdcstart from wdc_ata_done, flags 0x%x\n", WDCDEBUG_PRINT(("wdcstart from wdc_ata_done, flags 0x%x\n",
chp->ch_flags), DEBUG_XFERS); chp->ch_flags), DEBUG_XFERS);
wdcstart(chp->wdc, chp->channel); wdcstart(chp);
} }
/* /*

View File

@ -1,4 +1,4 @@
/* $NetBSD: wdc.c,v 1.44 1998/11/20 01:22:37 thorpej Exp $ */ /* $NetBSD: wdc.c,v 1.45 1998/11/21 15:41:41 drochner Exp $ */
/* /*
@ -416,12 +416,10 @@ wdcattach(chp)
* are shared. * are shared.
*/ */
void void
wdcstart(wdc, channel) wdcstart(chp)
struct wdc_softc *wdc; struct channel_softc *chp;
int channel;
{ {
struct wdc_xfer *xfer; struct wdc_xfer *xfer;
struct channel_softc *chp;
#ifdef WDC_DIAGNOSTIC #ifdef WDC_DIAGNOSTIC
int spl1, spl2; int spl1, spl2;
@ -437,9 +435,8 @@ wdcstart(wdc, channel)
#endif /* WDC_DIAGNOSTIC */ #endif /* WDC_DIAGNOSTIC */
/* is there a xfer ? */ /* is there a xfer ? */
if ((xfer = wdc->channels[channel].ch_queue->sc_xfer.tqh_first) == NULL) if ((xfer = chp->ch_queue->sc_xfer.tqh_first) == NULL)
return; return;
chp = &wdc->channels[xfer->channel];
if ((chp->ch_flags & WDCF_ACTIVE) != 0 ) { if ((chp->ch_flags & WDCF_ACTIVE) != 0 ) {
return; /* channel aleady active */ return; /* channel aleady active */
} }
@ -447,8 +444,8 @@ wdcstart(wdc, channel)
if ((chp->ch_flags & WDCF_IRQ_WAIT) != 0) if ((chp->ch_flags & WDCF_IRQ_WAIT) != 0)
panic("wdcstart: channel waiting for irq\n"); panic("wdcstart: channel waiting for irq\n");
#endif #endif
if (wdc->cap & WDC_CAPABILITY_HWLOCK) if (chp->wdc->cap & WDC_CAPABILITY_HWLOCK)
if (!(*wdc->claim_hw)(chp, 0)) if (!(*chp->wdc->claim_hw)(chp, 0))
return; return;
WDCDEBUG_PRINT(("wdcstart: xfer %p channel %d drive %d\n", xfer, WDCDEBUG_PRINT(("wdcstart: xfer %p channel %d drive %d\n", xfer,
@ -470,7 +467,7 @@ wdcrestart(v)
int s; int s;
s = splbio(); s = splbio();
wdcstart(chp->wdc, chp->channel); wdcstart(chp);
splx(s); splx(s);
} }
@ -1006,7 +1003,7 @@ __wdccommand_done(chp, xfer)
else else
wdc_c->callback(wdc_c->callback_arg); wdc_c->callback(wdc_c->callback_arg);
} }
wdcstart(chp->wdc, chp->channel); wdcstart(chp);
return; return;
} }
@ -1091,7 +1088,7 @@ wdc_exec_xfer(chp, xfer)
TAILQ_INSERT_TAIL(&chp->ch_queue->sc_xfer,xfer , c_xferchain); TAILQ_INSERT_TAIL(&chp->ch_queue->sc_xfer,xfer , c_xferchain);
WDCDEBUG_PRINT(("wdcstart from wdc_exec_xfer, flags 0x%x\n", WDCDEBUG_PRINT(("wdcstart from wdc_exec_xfer, flags 0x%x\n",
chp->ch_flags), DEBUG_XFERS); chp->ch_flags), DEBUG_XFERS);
wdcstart(chp->wdc, chp->channel); wdcstart(chp);
xfer->c_flags |= C_NEEDDONE; /* we can now call upper level done() */ xfer->c_flags |= C_NEEDDONE; /* we can now call upper level done() */
} }

View File

@ -1,4 +1,4 @@
/* $NetBSD: wdcvar.h,v 1.9 1998/11/20 01:22:37 thorpej Exp $ */ /* $NetBSD: wdcvar.h,v 1.10 1998/11/21 15:41:42 drochner Exp $ */
/*- /*-
* Copyright (c) 1998 The NetBSD Foundation, Inc. * Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -93,7 +93,7 @@ struct wdc_softc { /* Per controller state */
u_int8_t pio_mode; /* highest PIO mode supported */ u_int8_t pio_mode; /* highest PIO mode supported */
u_int8_t dma_mode; /* highest DMA mode supported */ u_int8_t dma_mode; /* highest DMA mode supported */
int nchannels; /* Number of channels on this controller */ int nchannels; /* Number of channels on this controller */
struct channel_softc *channels; /* channels-specific datas (array) */ struct channel_softc **channels; /* channels-specific datas (array) */
/* /*
* The reference count here is used for both IDE and ATAPI devices. * The reference count here is used for both IDE and ATAPI devices.
@ -157,7 +157,7 @@ struct wdc_xfer *wdc_get_xfer __P((int)); /* int = WDC_NOSLEEP/CANSLEEP */
#define WDC_CANSLEEP 0x00 #define WDC_CANSLEEP 0x00
#define WDC_NOSLEEP 0x01 #define WDC_NOSLEEP 0x01
void wdc_free_xfer __P((struct channel_softc *, struct wdc_xfer *)); void wdc_free_xfer __P((struct channel_softc *, struct wdc_xfer *));
void wdcstart __P((struct wdc_softc *, int)); void wdcstart __P((struct channel_softc *));
void wdcrestart __P((void*)); void wdcrestart __P((void*));
int wdcreset __P((struct channel_softc *, int)); int wdcreset __P((struct channel_softc *, int));
#define VERBOSE 1 #define VERBOSE 1

View File

@ -1,4 +1,4 @@
/* $NetBSD: wdc_isa.c,v 1.10 1998/10/12 16:09:19 bouyer Exp $ */ /* $NetBSD: wdc_isa.c,v 1.11 1998/11/21 15:41:42 drochner Exp $ */
/*- /*-
* Copyright (c) 1998 The NetBSD Foundation, Inc. * Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -61,6 +61,7 @@
struct wdc_isa_softc { struct wdc_isa_softc {
struct wdc_softc sc_wdcdev; struct wdc_softc sc_wdcdev;
struct channel_softc *wdc_chanptr;
struct channel_softc wdc_channel; struct channel_softc wdc_channel;
isa_chipset_tag_t sc_ic; isa_chipset_tag_t sc_ic;
void *sc_ih; void *sc_ih;
@ -151,7 +152,8 @@ wdc_isa_attach(parent, self, aux)
} }
sc->sc_wdcdev.cap |= WDC_CAPABILITY_DATA16 | WDC_CAPABILITY_DATA32; sc->sc_wdcdev.cap |= WDC_CAPABILITY_DATA16 | WDC_CAPABILITY_DATA32;
sc->sc_wdcdev.pio_mode = 0; sc->sc_wdcdev.pio_mode = 0;
sc->sc_wdcdev.channels = &sc->wdc_channel; sc->wdc_chanptr = &sc->wdc_channel;
sc->sc_wdcdev.channels = &sc->wdc_chanptr;
sc->sc_wdcdev.nchannels = 1; sc->sc_wdcdev.nchannels = 1;
sc->wdc_channel.channel = 0; sc->wdc_channel.channel = 0;
sc->wdc_channel.wdc = &sc->sc_wdcdev; sc->wdc_channel.wdc = &sc->sc_wdcdev;

View File

@ -1,4 +1,4 @@
/* $NetBSD: wdc_isapnp.c,v 1.8 1998/10/12 16:09:19 bouyer Exp $ */ /* $NetBSD: wdc_isapnp.c,v 1.9 1998/11/21 15:41:42 drochner Exp $ */
/*- /*-
* Copyright (c) 1998 The NetBSD Foundation, Inc. * Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -58,6 +58,7 @@
struct wdc_isapnp_softc { struct wdc_isapnp_softc {
struct wdc_softc sc_wdcdev; struct wdc_softc sc_wdcdev;
struct channel_softc *wdc_chanptr;
struct channel_softc wdc_channel; struct channel_softc wdc_channel;
isa_chipset_tag_t sc_ic; isa_chipset_tag_t sc_ic;
void *sc_ih; void *sc_ih;
@ -148,7 +149,8 @@ wdc_isapnp_attach(parent, self, aux)
#endif #endif
sc->sc_wdcdev.cap |= WDC_CAPABILITY_DATA16 | WDC_CAPABILITY_DATA32; sc->sc_wdcdev.cap |= WDC_CAPABILITY_DATA16 | WDC_CAPABILITY_DATA32;
sc->sc_wdcdev.pio_mode = 0; sc->sc_wdcdev.pio_mode = 0;
sc->sc_wdcdev.channels = &sc->wdc_channel; sc->wdc_chanptr = &sc->wdc_channel;
sc->sc_wdcdev.channels = &sc->wdc_chanptr;
sc->sc_wdcdev.nchannels = 1; sc->sc_wdcdev.nchannels = 1;
sc->wdc_channel.channel = 0; sc->wdc_channel.channel = 0;
sc->wdc_channel.wdc = &sc->sc_wdcdev; sc->wdc_channel.wdc = &sc->sc_wdcdev;

View File

@ -1,4 +1,4 @@
/* $NetBSD: wdc_pcmcia.c,v 1.15 1998/11/20 01:52:22 thorpej Exp $ */ /* $NetBSD: wdc_pcmcia.c,v 1.16 1998/11/21 15:41:42 drochner Exp $ */
/*- /*-
* Copyright (c) 1998 The NetBSD Foundation, Inc. * Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -72,6 +72,7 @@
struct wdc_pcmcia_softc { struct wdc_pcmcia_softc {
struct wdc_softc sc_wdcdev; struct wdc_softc sc_wdcdev;
struct channel_softc *wdc_chanptr;
struct channel_softc wdc_channel; struct channel_softc wdc_channel;
struct pcmcia_io_handle sc_pioh; struct pcmcia_io_handle sc_pioh;
struct pcmcia_io_handle sc_auxpioh; struct pcmcia_io_handle sc_auxpioh;
@ -326,7 +327,8 @@ wdc_pcmcia_attach(parent, self, aux)
sc->wdc_channel.data32ioh = sc->wdc_channel.cmd_ioh; sc->wdc_channel.data32ioh = sc->wdc_channel.cmd_ioh;
sc->sc_wdcdev.cap |= WDC_CAPABILITY_DATA16 | WDC_CAPABILITY_DATA32; sc->sc_wdcdev.cap |= WDC_CAPABILITY_DATA16 | WDC_CAPABILITY_DATA32;
sc->sc_wdcdev.pio_mode = 0; sc->sc_wdcdev.pio_mode = 0;
sc->sc_wdcdev.channels = &sc->wdc_channel; sc->wdc_chanptr = &sc->wdc_channel;
sc->sc_wdcdev.channels = &sc->wdc_chanptr;
sc->sc_wdcdev.nchannels = 1; sc->sc_wdcdev.nchannels = 1;
sc->wdc_channel.channel = 0; sc->wdc_channel.channel = 0;
sc->wdc_channel.wdc = &sc->sc_wdcdev; sc->wdc_channel.wdc = &sc->sc_wdcdev;

View File

@ -1,4 +1,4 @@
/* $NetBSD: atapi_wdc.c,v 1.9 1998/11/19 21:54:18 thorpej Exp $ */ /* $NetBSD: atapi_wdc.c,v 1.10 1998/11/21 15:41:42 drochner Exp $ */
/* /*
* Copyright (c) 1998 Manuel Bouyer. * Copyright (c) 1998 Manuel Bouyer.
@ -132,7 +132,7 @@ wdc_atapi_get_params(ab_link, drive, flags, id)
{ {
struct wdc_softc *wdc = (void*)ab_link->adapter_softc; struct wdc_softc *wdc = (void*)ab_link->adapter_softc;
struct channel_softc *chp = struct channel_softc *chp =
&wdc->channels[ab_link->scsipi_atapi.channel]; wdc->channels[ab_link->scsipi_atapi.channel];
struct wdc_command wdc_c; struct wdc_command wdc_c;
/* if no ATAPI device detected at wdc attach time, skip */ /* if no ATAPI device detected at wdc attach time, skip */
@ -202,7 +202,7 @@ wdc_atapi_send_cmd(sc_xfer)
} }
if (sc_xfer->flags & SCSI_POLL) if (sc_xfer->flags & SCSI_POLL)
xfer->c_flags |= C_POLL; xfer->c_flags |= C_POLL;
drvp = &wdc->channels[channel].ch_drive[drive]; drvp = &wdc->channels[channel]->ch_drive[drive];
if ((drvp->drive_flags & (DRIVE_DMA | DRIVE_UDMA)) && if ((drvp->drive_flags & (DRIVE_DMA | DRIVE_UDMA)) &&
sc_xfer->datalen > 0) sc_xfer->datalen > 0)
xfer->c_flags |= C_DMA; xfer->c_flags |= C_DMA;
@ -214,7 +214,7 @@ wdc_atapi_send_cmd(sc_xfer)
xfer->c_start = wdc_atapi_start; xfer->c_start = wdc_atapi_start;
xfer->c_intr = wdc_atapi_intr; xfer->c_intr = wdc_atapi_intr;
s = splbio(); s = splbio();
wdc_exec_xfer(&wdc->channels[channel], xfer); wdc_exec_xfer(wdc->channels[channel], xfer);
#ifdef DIAGNOSTIC #ifdef DIAGNOSTIC
if ((sc_xfer->flags & SCSI_POLL) != 0 && if ((sc_xfer->flags & SCSI_POLL) != 0 &&
(sc_xfer->flags & ITSDONE) == 0) (sc_xfer->flags & ITSDONE) == 0)
@ -725,7 +725,6 @@ wdc_atapi_done(chp, xfer)
struct wdc_xfer *xfer; struct wdc_xfer *xfer;
{ {
struct scsipi_xfer *sc_xfer = xfer->cmd; struct scsipi_xfer *sc_xfer = xfer->cmd;
struct wdc_softc *wdc = chp->wdc;
int need_done = xfer->c_flags & C_NEEDDONE; int need_done = xfer->c_flags & C_NEEDDONE;
WDCDEBUG_PRINT(("wdc_atapi_done %s:%d:%d: flags 0x%x\n", WDCDEBUG_PRINT(("wdc_atapi_done %s:%d:%d: flags 0x%x\n",
@ -742,7 +741,7 @@ wdc_atapi_done(chp, xfer)
} }
WDCDEBUG_PRINT(("wdcstart from wdc_atapi_done, flags 0x%x\n", WDCDEBUG_PRINT(("wdcstart from wdc_atapi_done, flags 0x%x\n",
chp->ch_flags), DEBUG_XFERS); chp->ch_flags), DEBUG_XFERS);
wdcstart(wdc, chp->channel); wdcstart(chp);
} }
void void