1997-06-08 10:34:52 +04:00
|
|
|
/* $NetBSD: isp_pci.c,v 1.13 1997/06/08 06:34:52 thorpej Exp $ */
|
1997-03-12 23:44:50 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* PCI specific probe and attach routines for Qlogic ISP SCSI adapters.
|
|
|
|
*
|
|
|
|
* Copyright (c) 1997 by Matthew Jacob
|
|
|
|
* NASA AMES Research Center
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice immediately at the beginning of the file, without modification,
|
|
|
|
* this list of conditions, and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. The name of the author may not be used to endorse or promote products
|
|
|
|
* derived from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
|
|
|
|
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/malloc.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/queue.h>
|
|
|
|
#include <sys/device.h>
|
|
|
|
#include <machine/bus.h>
|
|
|
|
#include <machine/intr.h>
|
|
|
|
#include <scsi/scsi_all.h>
|
|
|
|
#include <scsi/scsiconf.h>
|
|
|
|
#include <dev/pci/pcireg.h>
|
|
|
|
#include <dev/pci/pcivar.h>
|
|
|
|
#include <dev/pci/pcidevs.h>
|
1997-03-13 04:56:06 +03:00
|
|
|
#include <vm/vm.h>
|
1997-03-12 23:44:50 +03:00
|
|
|
|
|
|
|
#include <dev/ic/ispreg.h>
|
|
|
|
#include <dev/ic/ispvar.h>
|
|
|
|
#include <dev/ic/ispmbox.h>
|
|
|
|
#include <dev/microcode/isp/asm_pci.h>
|
1997-03-13 04:56:06 +03:00
|
|
|
|
1997-03-12 23:44:50 +03:00
|
|
|
static u_int16_t isp_pci_rd_reg __P((struct ispsoftc *, int));
|
|
|
|
static void isp_pci_wr_reg __P((struct ispsoftc *, int, u_int16_t));
|
1997-06-08 10:34:52 +04:00
|
|
|
static int isp_pci_mbxdma __P((struct ispsoftc *));
|
|
|
|
static int isp_pci_dmasetup __P((struct ispsoftc *, struct scsi_xfer *,
|
|
|
|
ispreq_t *, u_int8_t *, u_int8_t));
|
|
|
|
static void isp_pci_dmateardown __P((struct ispsoftc *, struct scsi_xfer *,
|
|
|
|
u_int32_t));
|
1997-03-12 23:44:50 +03:00
|
|
|
|
|
|
|
static void isp_pci_reset1 __P((struct ispsoftc *));
|
|
|
|
|
|
|
|
static struct ispmdvec mdvec = {
|
|
|
|
isp_pci_rd_reg,
|
|
|
|
isp_pci_wr_reg,
|
|
|
|
isp_pci_mbxdma,
|
|
|
|
isp_pci_dmasetup,
|
1997-06-08 10:34:52 +04:00
|
|
|
isp_pci_dmateardown,
|
1997-03-12 23:44:50 +03:00
|
|
|
NULL,
|
|
|
|
isp_pci_reset1,
|
1997-03-13 07:07:44 +03:00
|
|
|
ISP_RISC_CODE,
|
1997-03-12 23:44:50 +03:00
|
|
|
ISP_CODE_LENGTH,
|
|
|
|
ISP_CODE_ORG,
|
1997-04-05 06:55:28 +04:00
|
|
|
BIU_PCI_CONF1_FIFO_16 | BIU_BURST_ENABLE,
|
|
|
|
60 /* MAGIC- all known PCI card implementations are 60MHz */
|
1997-03-12 23:44:50 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#define PCI_QLOGIC_ISP \
|
|
|
|
((PCI_PRODUCT_QLOGIC_ISP1020 << 16) | PCI_VENDOR_QLOGIC)
|
|
|
|
|
1997-03-16 03:37:00 +03:00
|
|
|
#define IO_MAP_REG 0x10
|
|
|
|
#define MEM_MAP_REG 0x14
|
|
|
|
|
1997-03-12 23:44:50 +03:00
|
|
|
|
|
|
|
#ifdef __BROKEN_INDIRECT_CONFIG
|
|
|
|
static int isp_pci_probe __P((struct device *, void *, void *));
|
|
|
|
#else
|
|
|
|
static int isp_pci_probe __P((struct device *, struct cfdata *, void *));
|
|
|
|
#endif
|
|
|
|
static void isp_pci_attach __P((struct device *, struct device *, void *));
|
|
|
|
|
|
|
|
struct isp_pcisoftc {
|
|
|
|
struct ispsoftc pci_isp;
|
1997-03-16 03:37:00 +03:00
|
|
|
bus_space_tag_t pci_st;
|
|
|
|
bus_space_handle_t pci_sh;
|
1997-06-08 10:34:52 +04:00
|
|
|
bus_dma_tag_t pci_dmat;
|
|
|
|
bus_dmamap_t pci_rquest_dmap;
|
|
|
|
bus_dmamap_t pci_result_dmap;
|
|
|
|
bus_dmamap_t pci_xfer_dmap[RQUEST_QUEUE_LEN];
|
1997-03-12 23:44:50 +03:00
|
|
|
void * pci_ih;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct cfattach isp_pci_ca = {
|
|
|
|
sizeof (struct isp_pcisoftc), isp_pci_probe, isp_pci_attach
|
|
|
|
};
|
|
|
|
|
|
|
|
static int
|
|
|
|
isp_pci_probe(parent, match, aux)
|
|
|
|
struct device *parent;
|
|
|
|
#ifdef __BROKEN_INDIRECT_CONFIG
|
|
|
|
void *match, *aux;
|
|
|
|
#else
|
|
|
|
struct cfdata *match;
|
|
|
|
void *aux;
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
struct pci_attach_args *pa = aux;
|
|
|
|
|
|
|
|
if (pa->pa_id == PCI_QLOGIC_ISP) {
|
|
|
|
return (1);
|
|
|
|
} else {
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
isp_pci_attach(parent, self, aux)
|
|
|
|
struct device *parent, *self;
|
|
|
|
void *aux;
|
|
|
|
{
|
|
|
|
struct pci_attach_args *pa = aux;
|
|
|
|
struct isp_pcisoftc *pcs = (struct isp_pcisoftc *) self;
|
1997-04-13 23:48:16 +04:00
|
|
|
bus_space_tag_t st, iot, memt;
|
|
|
|
bus_space_handle_t sh, ioh, memh;
|
1997-03-12 23:44:50 +03:00
|
|
|
pci_intr_handle_t ih;
|
|
|
|
const char *intrstr;
|
1997-04-13 23:48:16 +04:00
|
|
|
int ioh_valid, memh_valid;
|
1997-06-08 10:34:52 +04:00
|
|
|
int i;
|
1997-04-13 23:48:16 +04:00
|
|
|
|
1997-04-14 00:14:20 +04:00
|
|
|
ioh_valid = (pci_mapreg_map(pa, IO_MAP_REG,
|
1997-04-13 23:48:16 +04:00
|
|
|
PCI_MAPREG_TYPE_IO, 0,
|
|
|
|
&iot, &ioh, NULL, NULL) == 0);
|
1997-04-14 00:14:20 +04:00
|
|
|
memh_valid = (pci_mapreg_map(pa, MEM_MAP_REG,
|
1997-04-13 23:48:16 +04:00
|
|
|
PCI_MAPREG_TYPE_MEM | PCI_MAPREG_MEM_TYPE_32BIT, 0,
|
|
|
|
&memt, &memh, NULL, NULL) == 0);
|
|
|
|
|
|
|
|
if (memh_valid) {
|
|
|
|
st = memt;
|
|
|
|
sh = memh;
|
|
|
|
} else if (ioh_valid) {
|
|
|
|
st = iot;
|
|
|
|
sh = ioh;
|
1997-03-16 03:37:00 +03:00
|
|
|
} else {
|
1997-04-13 23:48:16 +04:00
|
|
|
printf(": unable to map device registers\n");
|
1997-03-29 01:25:01 +03:00
|
|
|
return;
|
1997-03-12 23:44:50 +03:00
|
|
|
}
|
|
|
|
printf("\n");
|
|
|
|
|
1997-03-16 03:37:00 +03:00
|
|
|
pcs->pci_st = st;
|
|
|
|
pcs->pci_sh = sh;
|
1997-06-08 10:34:52 +04:00
|
|
|
pcs->pci_dmat = pa->pa_dmat;
|
1997-03-12 23:44:50 +03:00
|
|
|
pcs->pci_isp.isp_mdvec = &mdvec;
|
|
|
|
isp_reset(&pcs->pci_isp);
|
|
|
|
if (pcs->pci_isp.isp_state != ISP_RESETSTATE) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
isp_init(&pcs->pci_isp);
|
|
|
|
if (pcs->pci_isp.isp_state != ISP_INITSTATE) {
|
|
|
|
isp_uninit(&pcs->pci_isp);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pci_intr_map(pa->pa_pc, pa->pa_intrtag, pa->pa_intrpin,
|
|
|
|
pa->pa_intrline, &ih)) {
|
|
|
|
printf("%s: couldn't map interrupt\n", pcs->pci_isp.isp_name);
|
|
|
|
isp_uninit(&pcs->pci_isp);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
intrstr = pci_intr_string(pa->pa_pc, ih);
|
|
|
|
if (intrstr == NULL)
|
|
|
|
intrstr = "<I dunno>";
|
|
|
|
pcs->pci_ih =
|
|
|
|
pci_intr_establish(pa->pa_pc, ih, IPL_BIO, isp_intr, &pcs->pci_isp);
|
|
|
|
if (pcs->pci_ih == NULL) {
|
|
|
|
printf("%s: couldn't establish interrupt at %s\n",
|
|
|
|
pcs->pci_isp.isp_name, intrstr);
|
|
|
|
isp_uninit(&pcs->pci_isp);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
printf("%s: interrupting at %s\n", pcs->pci_isp.isp_name, intrstr);
|
|
|
|
|
1997-06-08 10:34:52 +04:00
|
|
|
/*
|
|
|
|
* Create the DMA maps for the data transfers.
|
|
|
|
*/
|
|
|
|
for (i = 0; i < RQUEST_QUEUE_LEN; i++) {
|
|
|
|
if (bus_dmamap_create(pcs->pci_dmat, MAXPHYS,
|
|
|
|
(MAXPHYS / NBPG) + 1, MAXPHYS, 0, BUS_DMA_NOWAIT,
|
|
|
|
&pcs->pci_xfer_dmap[i])) {
|
|
|
|
printf("%s: can't create dma maps\n",
|
|
|
|
pcs->pci_isp.isp_name);
|
|
|
|
isp_uninit(&pcs->pci_isp);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1997-03-12 23:44:50 +03:00
|
|
|
/*
|
|
|
|
* Do Generic attach now.
|
|
|
|
*/
|
|
|
|
isp_attach(&pcs->pci_isp);
|
|
|
|
if (pcs->pci_isp.isp_state != ISP_RUNSTATE) {
|
|
|
|
isp_uninit(&pcs->pci_isp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#define PCI_BIU_REGS_OFF 0x00
|
|
|
|
#define PCI_MBOX_REGS_OFF 0x70
|
|
|
|
#define PCI_SXP_REGS_OFF 0x80
|
|
|
|
#define PCI_RISC_REGS_OFF 0x80
|
|
|
|
|
|
|
|
static u_int16_t
|
|
|
|
isp_pci_rd_reg(isp, regoff)
|
|
|
|
struct ispsoftc *isp;
|
|
|
|
int regoff;
|
|
|
|
{
|
|
|
|
struct isp_pcisoftc *pcs = (struct isp_pcisoftc *) isp;
|
|
|
|
int offset;
|
|
|
|
if ((regoff & BIU_BLOCK) != 0) {
|
|
|
|
offset = PCI_BIU_REGS_OFF;
|
|
|
|
} else if ((regoff & MBOX_BLOCK) != 0) {
|
|
|
|
offset = PCI_MBOX_REGS_OFF;
|
|
|
|
} else if ((regoff & SXP_BLOCK) != 0) {
|
|
|
|
offset = PCI_SXP_REGS_OFF;
|
|
|
|
/*
|
|
|
|
* XXX
|
|
|
|
*/
|
|
|
|
panic("SXP Registers not accessible yet!");
|
|
|
|
} else {
|
|
|
|
offset = PCI_RISC_REGS_OFF;
|
|
|
|
}
|
|
|
|
regoff &= 0xff;
|
|
|
|
offset += regoff;
|
1997-03-16 03:37:00 +03:00
|
|
|
return bus_space_read_2(pcs->pci_st, pcs->pci_sh, offset);
|
1997-03-12 23:44:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
isp_pci_wr_reg(isp, regoff, val)
|
|
|
|
struct ispsoftc *isp;
|
|
|
|
int regoff;
|
|
|
|
u_int16_t val;
|
|
|
|
{
|
|
|
|
struct isp_pcisoftc *pcs = (struct isp_pcisoftc *) isp;
|
|
|
|
int offset;
|
|
|
|
if ((regoff & BIU_BLOCK) != 0) {
|
|
|
|
offset = PCI_BIU_REGS_OFF;
|
|
|
|
} else if ((regoff & MBOX_BLOCK) != 0) {
|
|
|
|
offset = PCI_MBOX_REGS_OFF;
|
|
|
|
} else if ((regoff & SXP_BLOCK) != 0) {
|
|
|
|
offset = PCI_SXP_REGS_OFF;
|
|
|
|
/*
|
|
|
|
* XXX
|
|
|
|
*/
|
|
|
|
panic("SXP Registers not accessible yet!");
|
|
|
|
} else {
|
|
|
|
offset = PCI_RISC_REGS_OFF;
|
|
|
|
}
|
|
|
|
regoff &= 0xff;
|
|
|
|
offset += regoff;
|
1997-03-16 03:37:00 +03:00
|
|
|
bus_space_write_2(pcs->pci_st, pcs->pci_sh, offset, val);
|
1997-03-12 23:44:50 +03:00
|
|
|
}
|
|
|
|
|
1997-06-08 10:34:52 +04:00
|
|
|
static int
|
|
|
|
isp_pci_mbxdma(isp)
|
1997-03-12 23:44:50 +03:00
|
|
|
struct ispsoftc *isp;
|
|
|
|
{
|
1997-06-08 10:34:52 +04:00
|
|
|
struct isp_pcisoftc *pci = (struct isp_pcisoftc *)isp;
|
|
|
|
bus_dma_segment_t seg;
|
|
|
|
bus_size_t len;
|
|
|
|
int rseg;
|
1997-03-12 23:44:50 +03:00
|
|
|
|
1997-06-08 10:34:52 +04:00
|
|
|
/*
|
|
|
|
* Allocate and map the request queue.
|
|
|
|
*/
|
|
|
|
len = ISP_QUEUE_SIZE(RQUEST_QUEUE_LEN);
|
|
|
|
if (bus_dmamem_alloc(pci->pci_dmat, len, NBPG, 0, &seg, 1, &rseg,
|
|
|
|
BUS_DMA_NOWAIT) ||
|
|
|
|
bus_dmamem_map(pci->pci_dmat, &seg, rseg, len,
|
|
|
|
(caddr_t *)&isp->isp_rquest, BUS_DMA_NOWAIT|BUS_DMAMEM_NOSYNC))
|
|
|
|
return (1);
|
|
|
|
if (bus_dmamap_create(pci->pci_dmat, len, 1, len, 0, BUS_DMA_NOWAIT,
|
|
|
|
&pci->pci_rquest_dmap) ||
|
|
|
|
bus_dmamap_load(pci->pci_dmat, pci->pci_rquest_dmap,
|
|
|
|
(caddr_t)isp->isp_rquest, len, NULL, BUS_DMA_NOWAIT))
|
|
|
|
return (1);
|
1997-03-12 23:44:50 +03:00
|
|
|
|
1997-06-08 10:34:52 +04:00
|
|
|
isp->isp_rquest_dma = pci->pci_rquest_dmap->dm_segs[0].ds_addr;
|
1997-03-12 23:44:50 +03:00
|
|
|
|
1997-06-08 10:34:52 +04:00
|
|
|
/*
|
|
|
|
* Allocate and map the result queue.
|
|
|
|
*/
|
|
|
|
len = ISP_QUEUE_SIZE(RESULT_QUEUE_LEN);
|
|
|
|
if (bus_dmamem_alloc(pci->pci_dmat, len, NBPG, 0, &seg, 1, &rseg,
|
|
|
|
BUS_DMA_NOWAIT) ||
|
|
|
|
bus_dmamem_map(pci->pci_dmat, &seg, rseg, len,
|
|
|
|
(caddr_t *)&isp->isp_result, BUS_DMA_NOWAIT|BUS_DMAMEM_NOSYNC))
|
|
|
|
return (1);
|
|
|
|
if (bus_dmamap_create(pci->pci_dmat, len, 1, len, 0, BUS_DMA_NOWAIT,
|
|
|
|
&pci->pci_result_dmap) ||
|
|
|
|
bus_dmamap_load(pci->pci_dmat, pci->pci_result_dmap,
|
|
|
|
(caddr_t)isp->isp_result, len, NULL, BUS_DMA_NOWAIT))
|
|
|
|
return (1);
|
1997-03-12 23:44:50 +03:00
|
|
|
|
1997-06-08 10:34:52 +04:00
|
|
|
isp->isp_result_dma = pci->pci_result_dmap->dm_segs[0].ds_addr;
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
1997-03-12 23:44:50 +03:00
|
|
|
|
|
|
|
static int
|
|
|
|
isp_pci_dmasetup(isp, xs, rq, iptrp, optr)
|
|
|
|
struct ispsoftc *isp;
|
|
|
|
struct scsi_xfer *xs;
|
|
|
|
ispreq_t *rq;
|
|
|
|
u_int8_t *iptrp;
|
|
|
|
u_int8_t optr;
|
|
|
|
{
|
1997-06-08 10:34:52 +04:00
|
|
|
struct isp_pcisoftc *pci = (struct isp_pcisoftc *)isp;
|
|
|
|
bus_dmamap_t dmap = pci->pci_xfer_dmap[rq->req_handle];
|
1997-03-12 23:44:50 +03:00
|
|
|
ispcontreq_t *crq;
|
1997-06-08 10:34:52 +04:00
|
|
|
int segcnt, seg, error, ovseg;
|
1997-03-12 23:44:50 +03:00
|
|
|
|
|
|
|
if (xs->datalen == 0) {
|
|
|
|
rq->req_seg_count = 1;
|
|
|
|
rq->req_flags |= REQFLAG_DATA_IN;
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
1997-06-08 10:34:52 +04:00
|
|
|
if (rq->req_handle >= RQUEST_QUEUE_LEN) {
|
|
|
|
panic("%s: bad handle (%d) in isp_sbus_dmasetup\n",
|
|
|
|
isp->isp_name, rq->req_handle);
|
|
|
|
/* NOTREACHED */
|
|
|
|
}
|
|
|
|
|
1997-03-12 23:44:50 +03:00
|
|
|
if (xs->flags & SCSI_DATA_IN) {
|
|
|
|
rq->req_flags |= REQFLAG_DATA_IN;
|
|
|
|
} else {
|
|
|
|
rq->req_flags |= REQFLAG_DATA_OUT;
|
|
|
|
}
|
|
|
|
|
1997-06-08 10:34:52 +04:00
|
|
|
error = bus_dmamap_load(pci->pci_dmat, dmap, xs->data, xs->datalen,
|
|
|
|
NULL, xs->flags & SCSI_NOSLEEP ? BUS_DMA_NOWAIT : BUS_DMA_WAITOK);
|
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
|
|
|
|
segcnt = dmap->dm_nsegs;
|
|
|
|
|
|
|
|
for (seg = 0, rq->req_seg_count = 0;
|
|
|
|
seg < segcnt && rq->req_seg_count < ISP_RQDSEG;
|
|
|
|
seg++, rq->req_seg_count++) {
|
|
|
|
rq->req_dataseg[rq->req_seg_count].ds_count =
|
|
|
|
dmap->dm_segs[seg].ds_len;
|
|
|
|
rq->req_dataseg[rq->req_seg_count].ds_base =
|
|
|
|
dmap->dm_segs[seg].ds_addr;
|
1997-03-12 23:44:50 +03:00
|
|
|
}
|
|
|
|
|
1997-06-08 10:34:52 +04:00
|
|
|
if (seg == segcnt)
|
|
|
|
goto mapsync;
|
|
|
|
|
1997-03-12 23:44:50 +03:00
|
|
|
do {
|
1997-06-08 10:34:52 +04:00
|
|
|
crq = (ispcontreq_t *) ISP_QUEUE_ENTRY(isp->isp_rquest,
|
|
|
|
*iptrp);
|
1997-03-12 23:44:50 +03:00
|
|
|
*iptrp = (*iptrp + 1) & (RQUEST_QUEUE_LEN - 1);
|
|
|
|
if (*iptrp == optr) {
|
|
|
|
printf("%s: Request Queue Overflow++\n",
|
|
|
|
isp->isp_name);
|
1997-06-08 10:34:52 +04:00
|
|
|
bus_dmamap_unload(pci->pci_dmat, dmap);
|
|
|
|
return (EFBIG);
|
1997-03-12 23:44:50 +03:00
|
|
|
}
|
|
|
|
rq->req_header.rqs_entry_count++;
|
|
|
|
bzero((void *)crq, sizeof (*crq));
|
|
|
|
crq->req_header.rqs_entry_count = 1;
|
|
|
|
crq->req_header.rqs_entry_type = RQSTYPE_DATASEG;
|
1997-06-08 10:34:52 +04:00
|
|
|
|
|
|
|
for (ovseg = 0; seg < segcnt && ovseg < ISP_CDSEG;
|
|
|
|
rq->req_seg_count++, seg++, ovseg++) {
|
|
|
|
crq->req_dataseg[ovseg].ds_count =
|
|
|
|
dmap->dm_segs[seg].ds_len;
|
|
|
|
crq->req_dataseg[ovseg].ds_base =
|
|
|
|
dmap->dm_segs[seg].ds_addr;
|
1997-03-12 23:44:50 +03:00
|
|
|
}
|
1997-06-08 10:34:52 +04:00
|
|
|
} while (seg < segcnt);
|
|
|
|
|
|
|
|
mapsync:
|
|
|
|
bus_dmamap_sync(pci->pci_dmat, dmap, xs->flags & SCSI_DATA_IN ?
|
|
|
|
BUS_DMASYNC_PREREAD : BUS_DMASYNC_PREWRITE);
|
1997-03-12 23:44:50 +03:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
1997-06-08 10:34:52 +04:00
|
|
|
static void
|
|
|
|
isp_pci_dmateardown(isp, xs, handle)
|
|
|
|
struct ispsoftc *isp;
|
|
|
|
struct scsi_xfer *xs;
|
|
|
|
u_int32_t handle;
|
|
|
|
{
|
|
|
|
struct isp_pcisoftc *pci = (struct isp_pcisoftc *)isp;
|
|
|
|
bus_dmamap_t dmap = pci->pci_xfer_dmap[handle];
|
|
|
|
|
|
|
|
bus_dmamap_sync(pci->pci_dmat, dmap, xs->flags & SCSI_DATA_IN ?
|
|
|
|
BUS_DMASYNC_POSTREAD : BUS_DMASYNC_POSTWRITE);
|
|
|
|
|
|
|
|
bus_dmamap_unload(pci->pci_dmat, dmap);
|
|
|
|
}
|
|
|
|
|
1997-03-12 23:44:50 +03:00
|
|
|
static void
|
|
|
|
isp_pci_reset1(isp)
|
|
|
|
struct ispsoftc *isp;
|
|
|
|
{
|
|
|
|
/* Make sure the BIOS is disabled */
|
|
|
|
isp_pci_wr_reg(isp, HCCR, PCI_HCCR_CMD_BIOS);
|
|
|
|
}
|