1 /* $OpenBSD: dptvar.h,v 1.2 2002/03/14 01:26:54 millert Exp $ */ 2 /* $NetBSD: dptvar.h,v 1.5 1999/10/23 16:26:32 ad Exp $ */ 3 4 /* 5 * Copyright (c) 1999 Andy Doran <ad@NetBSD.org> 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * 2. Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in the 15 * documentation and/or other materials provided with the distribution. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * 29 */ 30 31 #ifndef _IC_DPTVAR_H_ 32 #define _IC_DPTVAR_H_ 1 33 #ifdef _KERNEL 34 35 #define CCB_OFF(sc,m) ((u_long)(m) - (u_long)((sc)->sc_ccbs)) 36 37 #define CCB_ALLOC 0x01 /* CCB allocated */ 38 #define CCB_ABORT 0x02 /* abort has been issued on this CCB */ 39 #define CCB_INTR 0x04 /* HBA interrupted for this CCB */ 40 #define CCB_PRIVATE 0x08 /* ours; don't talk to scsipi when done */ 41 42 struct dpt_ccb { 43 struct eata_cp ccb_eata_cp; /* EATA command packet */ 44 struct eata_sg ccb_sg[DPT_SG_SIZE]; /* SG element list */ 45 volatile int ccb_flg; /* CCB flags */ 46 int ccb_timeout; /* timeout in ms */ 47 u_int32_t ccb_ccbpa; /* physical addr of this CCB */ 48 bus_dmamap_t ccb_dmamap_xfer; /* dmamap for data xfers */ 49 int ccb_hba_status; /* from status packet */ 50 int ccb_scsi_status; /* from status packet */ 51 int ccb_id; /* unique ID of this CCB */ 52 TAILQ_ENTRY(dpt_ccb) ccb_chain; /* link to next CCB */ 53 #ifdef __NetBSD__ 54 struct scsipi_sense_data ccb_sense; /* SCSI sense data on error */ 55 struct scsipi_xfer *ccb_xs; /* initiating SCSI command */ 56 #endif /* __NetBSD__ */ 57 #ifdef __OpenBSD__ 58 struct scsi_sense_data ccb_sense; 59 struct scsi_xfer *ccb_xs; 60 #endif /* __OpenBSD__ */ 61 }; 62 63 struct dpt_softc { 64 struct device sc_dv; /* generic device data */ 65 bus_space_handle_t sc_ioh; /* bus space handle */ 66 #ifdef __NetBSD__ 67 struct scsipi_adapter sc_adapter;/* scsipi adapter */ 68 struct scsipi_link sc_link[3]; /* prototype link for each channel */ 69 #endif /* __NetBSD__ */ 70 #ifdef __OpenBSD__ 71 struct scsi_adapter sc_adapter;/* scsipi adapter */ 72 struct scsi_link sc_link[3]; /* prototype link for each channel */ 73 #endif /* __OpenBSD__ */ 74 struct eata_cfg sc_ec; /* EATA configuration data */ 75 bus_space_tag_t sc_iot; /* bus space tag */ 76 bus_dma_tag_t sc_dmat; /* bus DMA tag */ 77 bus_dmamap_t sc_dmamap_ccb; /* maps the CCBs */ 78 void *sc_ih; /* interrupt handler cookie */ 79 void *sc_sdh; /* shutdown hook */ 80 struct dpt_ccb *sc_ccbs; /* all our CCBs */ 81 struct eata_sp *sc_statpack; /* EATA status packet */ 82 int sc_spoff; /* status packet offset in dmamap */ 83 u_int32_t sc_sppa; /* status packet physical address */ 84 caddr_t sc_scr; /* scratch area */ 85 int sc_scrlen; /* scratch area length */ 86 int sc_scroff; /* scratch area offset in dmamap */ 87 u_int32_t sc_scrpa; /* scratch area physical address */ 88 int sc_hbaid[3]; /* ID of HBA on each channel */ 89 int sc_nccbs; /* number of CCBs available */ 90 int sc_open; /* device is open */ 91 TAILQ_HEAD(, dpt_ccb) sc_free_ccb;/* free ccb list */ 92 #ifdef __NetBSD__ 93 TAILQ_HEAD(, scsipi_xfer) sc_queue;/* pending commands */ 94 #endif /* __NetBSD__ */ 95 #ifdef __OpenBSD__ 96 LIST_HEAD(, scsi_xfer) sc_queue;/* pending commands */ 97 struct scsi_xfer *sc_queuelast; 98 #endif /* __NetBSD__ */ 99 }; 100 101 int dpt_intr(void *); 102 int dpt_readcfg(struct dpt_softc *); 103 void dpt_init(struct dpt_softc *, const char *); 104 void dpt_shutdown(void *); 105 void dpt_timeout(void *); 106 void dpt_minphys(struct buf *); 107 #ifdef __NetBSD__ 108 int dpt_scsi_cmd(struct scsipi_xfer *); 109 #endif /* __NetBSD__ */ 110 #ifdef __OpenBSD__ 111 int dpt_scsi_cmd(struct scsi_xfer *); 112 #endif /* __OpenBSD__ */ 113 int dpt_wait(struct dpt_softc *, u_int8_t, u_int8_t, int); 114 int dpt_poll(struct dpt_softc *, struct dpt_ccb *); 115 int dpt_cmd(struct dpt_softc *, struct eata_cp *, u_int32_t, int, int); 116 void dpt_hba_inquire(struct dpt_softc *, struct eata_inquiry_data **); 117 void dpt_reset_ccb(struct dpt_softc *, struct dpt_ccb *); 118 void dpt_free_ccb(struct dpt_softc *, struct dpt_ccb *); 119 void dpt_done_ccb(struct dpt_softc *, struct dpt_ccb *); 120 int dpt_init_ccb(struct dpt_softc *, struct dpt_ccb *); 121 int dpt_create_ccbs(struct dpt_softc *, struct dpt_ccb *, int); 122 struct dpt_ccb *dpt_alloc_ccb(struct dpt_softc *, int); 123 #ifdef DEBUG 124 void dpt_dump_sp(struct eata_sp *); 125 #endif 126 127 #endif /* _KERNEL */ 128 #endif /* !defined _IC_DPTVAR_H_ */ 129