Home | History | Annotate | Line # | Download | only in ic
aic79xx_osm.h revision 1.10.16.1
      1  1.10.16.1     yamt /*	$NetBSD: aic79xx_osm.h,v 1.10.16.1 2006/10/22 06:05:43 yamt Exp $	*/
      2        1.1     fvdl 
      3        1.1     fvdl /*
      4        1.1     fvdl  * NetBSD platform specific driver option settings, data structures,
      5        1.1     fvdl  * function declarations and includes.
      6        1.1     fvdl  *
      7        1.1     fvdl  * Copyright (c) 1994-2001 Justin T. Gibbs.
      8        1.1     fvdl  * Copyright (c) 2001-2002 Adaptec Inc.
      9        1.1     fvdl  * All rights reserved.
     10        1.1     fvdl  *
     11        1.1     fvdl  * Redistribution and use in source and binary forms, with or without
     12        1.1     fvdl  * modification, are permitted provided that the following conditions
     13        1.1     fvdl  * are met:
     14        1.1     fvdl  * 1. Redistributions of source code must retain the above copyright
     15        1.1     fvdl  *    notice, this list of conditions, and the following disclaimer,
     16        1.1     fvdl  *    without modification.
     17        1.1     fvdl  * 2. The name of the author may not be used to endorse or promote products
     18        1.1     fvdl  *    derived from this software without specific prior written permission.
     19        1.1     fvdl  *
     20        1.1     fvdl  * Alternatively, this software may be distributed under the terms of the
     21        1.1     fvdl  * GNU Public License ("GPL").
     22        1.1     fvdl  *
     23        1.1     fvdl  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
     24        1.1     fvdl  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     25        1.1     fvdl  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     26        1.1     fvdl  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
     27        1.1     fvdl  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     28        1.1     fvdl  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     29        1.1     fvdl  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     30        1.1     fvdl  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     31        1.1     fvdl  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     32        1.1     fvdl  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     33        1.1     fvdl  * SUCH DAMAGE.
     34        1.1     fvdl  *
     35  1.10.16.1     yamt  * $NetBSD: aic79xx_osm.h,v 1.10.16.1 2006/10/22 06:05:43 yamt Exp $
     36        1.1     fvdl  *
     37  1.10.16.1     yamt  * //depot/aic7xxx/freebsd/dev/aic7xxx/aic79xx_osm.h#19 $$NetBSD: aic79xx_osm.h,v 1.10.16.1 2006/10/22 06:05:43 yamt Exp $
     38        1.1     fvdl  *
     39        1.4  thorpej  * $FreeBSD: src/sys/dev/aic7xxx/aic79xx_osm.h,v 1.9 2003/05/26 21:43:29 gibbs Exp $
     40        1.1     fvdl  */
     41        1.1     fvdl /*
     42        1.1     fvdl  * Ported from FreeBSD by Pascal Renauld, Network Storage Solutions, Inc.
     43        1.1     fvdl  * - April 2003
     44        1.1     fvdl  */
     45        1.1     fvdl 
     46        1.1     fvdl #ifndef _AIC79XX_NETBSD_H_
     47        1.1     fvdl #define _AIC79XX_NETBSD_H_
     48        1.1     fvdl 
     49        1.1     fvdl #include "opt_ahd.h"	/* for config options */
     50        1.1     fvdl 
     51        1.1     fvdl #include <sys/param.h>
     52        1.1     fvdl #include <sys/kernel.h>
     53        1.1     fvdl #include <sys/systm.h>
     54        1.1     fvdl #include <sys/device.h>
     55        1.1     fvdl #include <sys/malloc.h>
     56        1.1     fvdl #include <sys/buf.h>
     57        1.1     fvdl #include <sys/proc.h>
     58        1.1     fvdl #include <sys/scsiio.h>
     59        1.1     fvdl #include <sys/reboot.h>
     60        1.1     fvdl #include <sys/kthread.h>
     61        1.1     fvdl 
     62        1.1     fvdl #include <dev/pci/pcireg.h>
     63        1.1     fvdl #include <dev/pci/pcivar.h>
     64        1.1     fvdl 
     65        1.1     fvdl #include <machine/bus.h>
     66        1.1     fvdl #include <machine/intr.h>
     67        1.1     fvdl 
     68        1.1     fvdl #include <dev/scsipi/scsi_all.h>
     69        1.1     fvdl #include <dev/scsipi/scsipi_all.h>
     70        1.1     fvdl #include <dev/scsipi/scsi_message.h>
     71        1.1     fvdl #include <dev/scsipi/scsipi_debug.h>
     72        1.1     fvdl #include <dev/scsipi/scsiconf.h>
     73        1.1     fvdl #include <dev/scsipi/scsi_iu.h>
     74        1.1     fvdl 
     75        1.1     fvdl #include <uvm/uvm_extern.h>
     76        1.1     fvdl 
     77        1.1     fvdl 
     78        1.1     fvdl /****************************** Platform Macros *******************************/
     79        1.1     fvdl #define	SIM_IS_SCSIBUS_B(ahd, sim)	\
     80        1.1     fvdl 	(0)
     81        1.1     fvdl #define	SIM_CHANNEL(ahd, sim)	\
     82        1.1     fvdl 	('A')
     83        1.1     fvdl #define	SIM_SCSI_ID(ahd, sim)	\
     84        1.1     fvdl 	(ahd->our_id)
     85        1.1     fvdl #define	SIM_PATH(ahd, sim)	\
     86        1.1     fvdl 	(ahd->platform_data->path)
     87        1.1     fvdl #define BUILD_SCSIID(ahd, sim, target_id, our_id) \
     88        1.1     fvdl         ((((target_id) << TID_SHIFT) & TID) | (our_id))
     89        1.7    perry 
     90        1.1     fvdl 
     91        1.1     fvdl #define SCB_GET_SIM(ahd, scb) \
     92        1.1     fvdl 	((ahd)->platform_data->sim)
     93        1.1     fvdl 
     94        1.1     fvdl #ifndef offsetof
     95        1.1     fvdl #define offsetof(type, member)  ((size_t)(&((type *)0)->member))
     96        1.1     fvdl #endif
     97        1.1     fvdl 
     98        1.1     fvdl /************************* Forward Declarations *******************************/
     99        1.1     fvdl typedef pcireg_t ahd_dev_softc_t;
    100        1.1     fvdl /***************************** Bus Space/DMA **********************************/
    101        1.1     fvdl #define ahd_dma_tag_create(ahd, parent_tag, alignment, boundary,	\
    102        1.1     fvdl 			   lowaddr, highaddr, filter, filterarg,	\
    103        1.1     fvdl 			   maxsize, nsegments, maxsegsz, flags,		\
    104        1.1     fvdl 			   dma_tagp)					\
    105        1.1     fvdl 	bus_dma_tag_create(parent_tag, alignment, boundary,		\
    106        1.1     fvdl 			   lowaddr, highaddr, filter, filterarg,	\
    107        1.1     fvdl 			   maxsize, nsegments, maxsegsz, flags,		\
    108        1.1     fvdl 			   dma_tagp)
    109        1.1     fvdl 
    110        1.1     fvdl #define ahd_dma_tag_destroy(ahd, tag)					\
    111        1.1     fvdl 	bus_dma_tag_destroy(tag)
    112        1.1     fvdl 
    113        1.1     fvdl #define ahd_dmamem_alloc(ahd, dmat, vaddr, flags, mapp)			\
    114        1.1     fvdl 	bus_dmamem_alloc(dmat, vaddr, flags, mapp)
    115        1.1     fvdl 
    116        1.1     fvdl #define ahd_dmamem_free(ahd, dmat, vaddr, map)				\
    117        1.1     fvdl 	bus_dmamem_free(dmat, vaddr, map)
    118        1.1     fvdl 
    119        1.1     fvdl #define ahd_dmamap_create(ahd, tag, flags, mapp)			\
    120        1.1     fvdl 	bus_dmamap_create(tag, flags, mapp)
    121        1.1     fvdl 
    122        1.1     fvdl #define ahd_dmamap_destroy(ahd, tag, map)				\
    123        1.1     fvdl 	bus_dmamap_destroy(tag, map)
    124        1.1     fvdl 
    125        1.1     fvdl #define ahd_dmamap_load(ahd, dmat, map, addr, buflen, callback,		\
    126        1.1     fvdl 			callback_arg, flags)				\
    127        1.1     fvdl 	bus_dmamap_load(dmat, map, addr, buflen, callback, callback_arg, flags)
    128        1.1     fvdl 
    129        1.1     fvdl #define ahd_dmamap_unload(ahd, tag, map)				\
    130        1.1     fvdl 	bus_dmamap_unload(tag, map)
    131        1.1     fvdl 
    132        1.1     fvdl /* XXX Need to update Bus DMA for partial map syncs */
    133        1.1     fvdl #define ahd_dmamap_sync(ahd, dma_tag, dmamap, offset, len, op)		\
    134        1.1     fvdl 	bus_dmamap_sync(dma_tag, dmamap, offset, len, op)
    135        1.1     fvdl 
    136        1.1     fvdl /************************ Tunable Driver Parameters  **************************/
    137        1.1     fvdl /*
    138        1.2      wiz  * The number of DMA segments supported.  The sequencer can handle any number
    139        1.1     fvdl  * of physically contiguous S/G entrys.  To reduce the driver's memory
    140        1.1     fvdl  * consumption, we limit the number supported to be sufficient to handle
    141        1.1     fvdl  * the largest mapping supported by the kernel, MAXPHYS.  Assuming the
    142        1.1     fvdl  * transfer is as fragmented as possible and unaligned, this turns out to
    143        1.1     fvdl  * be the number of paged sized transfers in MAXPHYS plus an extra element
    144        1.1     fvdl  * to handle any unaligned residual.  The sequencer fetches SG elements
    145        1.1     fvdl  * in cacheline sized chucks, so make the number per-transaction an even
    146        1.1     fvdl  * multiple of 16 which should align us on even the largest of cacheline
    147        1.7    perry  * boundaries.
    148        1.1     fvdl  */
    149        1.1     fvdl #define AHD_NSEG (roundup(btoc(MAXPHYS) + 1, 16))
    150        1.1     fvdl 
    151        1.1     fvdl /* This driver supports target mode */
    152        1.1     fvdl #if NOT_YET
    153        1.1     fvdl #define AHD_TARGET_MODE 1
    154        1.1     fvdl #endif
    155        1.1     fvdl 
    156        1.1     fvdl /************************** Softc/SCB Platform Data ***************************/
    157        1.1     fvdl struct ahd_platform_data {
    158        1.1     fvdl };
    159        1.1     fvdl 
    160        1.1     fvdl struct scb_platform_data {
    161        1.1     fvdl };
    162        1.1     fvdl 
    163        1.1     fvdl /********************************* Byte Order *********************************/
    164        1.1     fvdl #define ahd_htobe16(x) htobe16(x)
    165        1.1     fvdl #define ahd_htobe32(x) htobe32(x)
    166        1.1     fvdl #define ahd_htobe64(x) htobe64(x)
    167        1.1     fvdl #define ahd_htole16(x) htole16(x)
    168        1.1     fvdl #define ahd_htole32(x) htole32(x)
    169        1.1     fvdl #define ahd_htole64(x) htole64(x)
    170        1.1     fvdl 
    171        1.1     fvdl #define ahd_be16toh(x) be16toh(x)
    172        1.1     fvdl #define ahd_be32toh(x) be32toh(x)
    173        1.1     fvdl #define ahd_be64toh(x) be64toh(x)
    174        1.1     fvdl #define ahd_le16toh(x) le16toh(x)
    175        1.1     fvdl #define ahd_le32toh(x) le32toh(x)
    176        1.1     fvdl #define ahd_le64toh(x) le64toh(x)
    177        1.1     fvdl 
    178        1.1     fvdl /************************** Timer DataStructures ******************************/
    179        1.1     fvdl typedef struct callout ahd_timer_t;
    180        1.1     fvdl 
    181        1.1     fvdl /***************************** Core Includes **********************************/
    182        1.1     fvdl #if AHD_REG_PRETTY_PRINT
    183        1.1     fvdl #define AIC_DEBUG_REGISTERS 1
    184        1.1     fvdl #else
    185        1.1     fvdl #define AIC_DEBUG_REGISTERS 0
    186        1.1     fvdl #endif
    187        1.1     fvdl #include <dev/ic/aic79xxvar.h>
    188        1.1     fvdl 
    189        1.1     fvdl /***************************** Timer Facilities *******************************/
    190        1.1     fvdl void ahd_timeout(void*);
    191        1.1     fvdl #define ahd_timer_init(timer) callout_init(timer)
    192        1.1     fvdl #define ahd_timer_stop callout_stop
    193        1.1     fvdl 
    194       1.10    perry static __inline void
    195        1.1     fvdl ahd_timer_reset(ahd_timer_t *timer, u_int usec, ahd_callback_t *func, void *arg)
    196        1.1     fvdl {
    197        1.1     fvdl 	callout_reset(timer, (usec * hz)/1000000, func, arg);
    198        1.1     fvdl }
    199        1.1     fvdl 
    200       1.10    perry static __inline void
    201        1.1     fvdl ahd_scb_timer_reset(struct scb *scb, u_int usec)
    202        1.1     fvdl {
    203        1.1     fvdl 	if (!(scb->xs->xs_control & XS_CTL_POLL)) {
    204        1.1     fvdl 		callout_reset(&scb->xs->xs_callout,
    205        1.1     fvdl 			      (usec * hz)/1000000, ahd_timeout, scb);
    206        1.1     fvdl 	}
    207        1.1     fvdl }
    208        1.1     fvdl 
    209        1.1     fvdl /*************************** Device Access ************************************/
    210        1.1     fvdl #define ahd_inb(ahd, port)					\
    211        1.1     fvdl 	bus_space_read_1((ahd)->tags[(port) >> 8],		\
    212        1.1     fvdl 			 (ahd)->bshs[(port) >> 8], (port) & 0xFF)
    213        1.1     fvdl 
    214        1.1     fvdl #define ahd_outb(ahd, port, value)				\
    215        1.1     fvdl 	bus_space_write_1((ahd)->tags[(port) >> 8],		\
    216        1.1     fvdl 			  (ahd)->bshs[(port) >> 8], (port) & 0xFF, value)
    217        1.1     fvdl 
    218        1.1     fvdl #define ahd_inw_atomic(ahd, port)				\
    219        1.1     fvdl 	ahd_le16toh(bus_space_read_2((ahd)->tags[(port) >> 8],	\
    220        1.1     fvdl 				     (ahd)->bshs[(port) >> 8], (port) & 0xFF))
    221        1.1     fvdl 
    222        1.1     fvdl #define ahd_outw_atomic(ahd, port, value)			\
    223        1.1     fvdl 	bus_space_write_2((ahd)->tags[(port) >> 8],		\
    224        1.1     fvdl 			  (ahd)->bshs[(port) >> 8],		\
    225        1.1     fvdl 			  (port & 0xFF), ahd_htole16(value))
    226        1.1     fvdl 
    227        1.1     fvdl #define ahd_outsb(ahd, port, valp, count)			\
    228        1.1     fvdl 	bus_space_write_multi_1((ahd)->tags[(port) >> 8],	\
    229        1.1     fvdl 				(ahd)->bshs[(port) >> 8],	\
    230        1.1     fvdl 				(port & 0xFF), valp, count)
    231        1.1     fvdl 
    232        1.1     fvdl #define ahd_insb(ahd, port, valp, count)			\
    233        1.1     fvdl 	bus_space_read_multi_1((ahd)->tags[(port) >> 8],	\
    234        1.1     fvdl 			       (ahd)->bshs[(port) >> 8],	\
    235        1.1     fvdl 			       (port & 0xFF), valp, count)
    236        1.1     fvdl 
    237       1.10    perry static __inline void ahd_flush_device_writes(struct ahd_softc *);
    238        1.1     fvdl 
    239       1.10    perry static __inline void
    240        1.1     fvdl ahd_flush_device_writes(struct ahd_softc *ahd)
    241        1.1     fvdl {
    242        1.1     fvdl 	/* XXX Is this sufficient for all architectures??? */
    243        1.1     fvdl 	ahd_inb(ahd, INTSTAT);
    244        1.1     fvdl }
    245        1.1     fvdl 
    246        1.1     fvdl /**************************** Locking Primitives ******************************/
    247        1.1     fvdl /* Lock protecting internal data structures */
    248       1.10    perry static __inline void ahd_lockinit(struct ahd_softc *);
    249       1.10    perry static __inline void ahd_lock(struct ahd_softc *, int *);
    250       1.10    perry static __inline void ahd_unlock(struct ahd_softc *, int *);
    251        1.1     fvdl 
    252        1.5      wiz /* Lock held during command completion to the upper layer */
    253       1.10    perry static __inline void ahd_done_lockinit(struct ahd_softc *);
    254       1.10    perry static __inline void ahd_done_lock(struct ahd_softc *, unsigned long *);
    255       1.10    perry static __inline void ahd_done_unlock(struct ahd_softc *, unsigned long *);
    256        1.1     fvdl 
    257        1.1     fvdl /* Lock held during ahd_list manipulation and ahd softc frees */
    258       1.10    perry static __inline void ahd_list_lockinit(void);
    259       1.10    perry static __inline void ahd_list_lock(unsigned long *);
    260       1.10    perry static __inline void ahd_list_unlock(unsigned long *);
    261        1.1     fvdl 
    262       1.10    perry static __inline void
    263  1.10.16.1     yamt ahd_lockinit(struct ahd_softc *ahd __unused)
    264        1.1     fvdl {
    265        1.1     fvdl }
    266        1.1     fvdl 
    267       1.10    perry static __inline void
    268  1.10.16.1     yamt ahd_lock(struct ahd_softc *ahd __unused, int *flags)
    269        1.1     fvdl {
    270        1.7    perry 	*flags = splbio();
    271        1.1     fvdl }
    272        1.1     fvdl 
    273       1.10    perry static __inline void
    274  1.10.16.1     yamt ahd_unlock(struct ahd_softc *ahd __unused, int *flags)
    275        1.1     fvdl {
    276        1.1     fvdl 	splx(*flags);
    277        1.1     fvdl }
    278        1.1     fvdl 
    279        1.5      wiz /* Lock held during command completion to the upper layer */
    280       1.10    perry static __inline void
    281  1.10.16.1     yamt ahd_done_lockinit(struct ahd_softc *ahd __unused)
    282        1.1     fvdl {
    283        1.1     fvdl }
    284        1.1     fvdl 
    285       1.10    perry static __inline void
    286  1.10.16.1     yamt ahd_done_lock(struct ahd_softc *ahd __unused, unsigned long *flags __unused)
    287        1.1     fvdl {
    288        1.1     fvdl }
    289        1.1     fvdl 
    290       1.10    perry static __inline void
    291  1.10.16.1     yamt ahd_done_unlock(struct ahd_softc *ahd __unused, unsigned long *flags __unused)
    292        1.1     fvdl {
    293        1.1     fvdl }
    294        1.1     fvdl 
    295        1.1     fvdl /* Lock held during ahd_list manipulation and ahd softc frees */
    296       1.10    perry static __inline void
    297        1.4  thorpej ahd_list_lockinit(void)
    298        1.1     fvdl {
    299        1.1     fvdl }
    300        1.1     fvdl 
    301       1.10    perry static __inline void
    302  1.10.16.1     yamt ahd_list_lock(unsigned long *flags __unused)
    303        1.1     fvdl {
    304        1.1     fvdl }
    305        1.1     fvdl 
    306       1.10    perry static __inline void
    307  1.10.16.1     yamt ahd_list_unlock(unsigned long *flags __unused)
    308        1.1     fvdl {
    309        1.1     fvdl }
    310        1.1     fvdl /****************************** OS Primitives *********************************/
    311        1.1     fvdl #define ahd_delay DELAY
    312        1.1     fvdl 
    313        1.1     fvdl /************************** Transaction Operations ****************************/
    314       1.10    perry static __inline void ahd_set_transaction_status(struct scb *, uint32_t);
    315       1.10    perry static __inline void ahd_set_scsi_status(struct scb *, uint32_t);
    316       1.10    perry static __inline void ahd_set_xfer_status(struct scb *, uint32_t);
    317       1.10    perry static __inline uint32_t ahd_get_transaction_status(struct scb *);
    318       1.10    perry static __inline uint32_t ahd_get_scsi_status(struct scb *);
    319       1.10    perry static __inline void ahd_set_transaction_tag(struct scb *, int, u_int);
    320       1.10    perry static __inline u_long ahd_get_transfer_length(struct scb *);
    321       1.10    perry static __inline int ahd_get_transfer_dir(struct scb *);
    322       1.10    perry static __inline void ahd_set_residual(struct scb *, u_long);
    323       1.10    perry static __inline void ahd_set_sense_residual(struct scb *, u_long);
    324       1.10    perry static __inline u_long ahd_get_residual(struct scb *);
    325       1.10    perry static __inline int ahd_perform_autosense(struct scb *);
    326       1.10    perry static __inline uint32_t ahd_get_sense_bufsize(struct ahd_softc*, struct scb*);
    327       1.10    perry static __inline void ahd_freeze_simq(struct ahd_softc *);
    328       1.10    perry static __inline void ahd_release_simq(struct ahd_softc *);
    329       1.10    perry static __inline void ahd_freeze_scb(struct scb *);
    330       1.10    perry static __inline void ahd_platform_freeze_devq(struct ahd_softc *, struct scb *);
    331       1.10    perry static __inline int  ahd_platform_abort_scbs(struct ahd_softc *, int,
    332        1.3   itojun     char, int, u_int, role_t, uint32_t);
    333        1.1     fvdl 
    334       1.10    perry static __inline
    335        1.1     fvdl void ahd_set_transaction_status(struct scb *scb, uint32_t status)
    336        1.1     fvdl {
    337        1.1     fvdl 	scb->xs->error = status;
    338        1.1     fvdl }
    339        1.1     fvdl 
    340       1.10    perry static __inline
    341        1.1     fvdl void ahd_set_scsi_status(struct scb *scb, uint32_t status)
    342        1.1     fvdl {
    343        1.1     fvdl 	scb->xs->xs_status = status;
    344        1.1     fvdl }
    345        1.1     fvdl 
    346       1.10    perry static __inline
    347        1.1     fvdl void ahd_set_xfer_status(struct scb *scb, uint32_t status)
    348        1.1     fvdl {
    349        1.1     fvdl 	scb->xs->status = status;
    350        1.1     fvdl }
    351        1.1     fvdl 
    352       1.10    perry static __inline
    353        1.1     fvdl uint32_t ahd_get_transaction_status(struct scb *scb)
    354        1.1     fvdl {
    355        1.1     fvdl 	return (scb->xs->error);
    356        1.1     fvdl }
    357        1.1     fvdl 
    358       1.10    perry static __inline
    359        1.1     fvdl uint32_t ahd_get_scsi_status(struct scb *scb)
    360        1.1     fvdl {
    361        1.1     fvdl 	return (scb->xs->xs_status);
    362        1.1     fvdl }
    363        1.1     fvdl 
    364       1.10    perry static __inline
    365  1.10.16.1     yamt void ahd_set_transaction_tag(struct scb *scb, int enabled __unused, u_int type)
    366        1.1     fvdl {
    367        1.1     fvdl 	scb->xs->xs_tag_type = type;
    368        1.1     fvdl }
    369        1.1     fvdl 
    370       1.10    perry static __inline
    371        1.1     fvdl u_long ahd_get_transfer_length(struct scb *scb)
    372        1.1     fvdl {
    373        1.1     fvdl 	return (scb->xs->datalen);
    374        1.1     fvdl }
    375        1.1     fvdl 
    376       1.10    perry static __inline
    377        1.1     fvdl int ahd_get_transfer_dir(struct scb *scb)
    378        1.1     fvdl {
    379        1.1     fvdl 	return (scb->xs->xs_control & (XS_CTL_DATA_IN|XS_CTL_DATA_OUT));
    380        1.1     fvdl }
    381        1.1     fvdl 
    382       1.10    perry static __inline
    383        1.1     fvdl void ahd_set_residual(struct scb *scb, u_long resid)
    384        1.1     fvdl {
    385        1.1     fvdl 	scb->xs->resid = resid;
    386        1.1     fvdl }
    387        1.1     fvdl 
    388        1.1     fvdl 
    389       1.10    perry static __inline
    390  1.10.16.1     yamt void ahd_set_sense_residual(struct scb *scb __unused, u_long resid __unused)
    391        1.1     fvdl {
    392        1.7    perry   //scb->xs->sense.scsi_sense.extra_len = resid; /* ??? */
    393        1.1     fvdl }
    394        1.1     fvdl 
    395        1.1     fvdl 
    396       1.10    perry static __inline
    397        1.1     fvdl u_long ahd_get_residual(struct scb *scb)
    398        1.1     fvdl {
    399        1.1     fvdl 	return (scb->xs->resid);
    400        1.1     fvdl }
    401        1.1     fvdl 
    402       1.10    perry static __inline
    403        1.1     fvdl int ahd_perform_autosense(struct scb *scb)
    404        1.1     fvdl {
    405        1.1     fvdl 	return (!(scb->flags & SCB_SENSE));
    406        1.1     fvdl }
    407        1.1     fvdl 
    408       1.10    perry static __inline uint32_t
    409  1.10.16.1     yamt ahd_get_sense_bufsize(struct ahd_softc *ahd __unused, struct scb *scb __unused)
    410        1.1     fvdl {
    411        1.6  thorpej 	return (sizeof(struct scsi_sense_data));
    412        1.1     fvdl }
    413        1.1     fvdl 
    414       1.10    perry static __inline void
    415  1.10.16.1     yamt ahd_freeze_simq(struct ahd_softc *ahd __unused)
    416        1.1     fvdl {
    417        1.1     fvdl 	/* do nothing for now */
    418        1.1     fvdl }
    419        1.1     fvdl 
    420       1.10    perry static __inline void
    421  1.10.16.1     yamt ahd_release_simq(struct ahd_softc *ahd __unused)
    422        1.1     fvdl {
    423        1.1     fvdl 	/* do nothing for now */
    424        1.1     fvdl }
    425        1.1     fvdl 
    426       1.10    perry static __inline void
    427        1.1     fvdl ahd_freeze_scb(struct scb *scb)
    428        1.1     fvdl {
    429        1.1     fvdl   	struct scsipi_xfer *xs = scb->xs;
    430        1.1     fvdl 
    431        1.1     fvdl 	if (!(scb->flags & SCB_FREEZE_QUEUE)) {
    432        1.1     fvdl 	 	scsipi_periph_freeze(xs->xs_periph, 1);
    433        1.1     fvdl 		scb->flags |= SCB_FREEZE_QUEUE;
    434        1.1     fvdl 	}
    435        1.1     fvdl }
    436        1.1     fvdl 
    437       1.10    perry static __inline void
    438  1.10.16.1     yamt ahd_platform_freeze_devq(struct ahd_softc *ahd __unused, struct scb *scb __unused)
    439        1.1     fvdl {
    440        1.1     fvdl 	/* Nothing to do here for NetBSD */
    441        1.1     fvdl }
    442        1.1     fvdl 
    443       1.10    perry static __inline int
    444  1.10.16.1     yamt ahd_platform_abort_scbs(struct ahd_softc *ahd __unused, int target __unused,
    445  1.10.16.1     yamt     char channel __unused, int lun __unused, u_int tag __unused,
    446  1.10.16.1     yamt     role_t role __unused, uint32_t status __unused)
    447        1.1     fvdl {
    448        1.1     fvdl 	/* Nothing to do here for NetBSD */
    449        1.1     fvdl 	return (0);
    450        1.1     fvdl }
    451        1.1     fvdl 
    452       1.10    perry static __inline void
    453  1.10.16.1     yamt ahd_platform_scb_free(struct ahd_softc *ahd __unused, struct scb *scb __unused)
    454        1.1     fvdl {
    455  1.10.16.1     yamt #ifdef __FreeBSD__
    456        1.1     fvdl 	/* What do we do to generically handle driver resource shortages??? */
    457        1.1     fvdl 	if ((ahd->flags & AHD_RESOURCE_SHORTAGE) != 0
    458        1.1     fvdl 	 && scb->io_ctx != NULL
    459        1.1     fvdl 	 && (scb->io_ctx->ccb_h.status & CAM_RELEASE_SIMQ) == 0) {
    460        1.1     fvdl 		scb->io_ctx->ccb_h.status |= CAM_RELEASE_SIMQ;
    461        1.1     fvdl 		ahd->flags &= ~AHD_RESOURCE_SHORTAGE;
    462        1.1     fvdl 	}
    463        1.1     fvdl 	scb->io_ctx = NULL;
    464        1.1     fvdl #endif /* end of modification */
    465        1.1     fvdl }
    466        1.1     fvdl 
    467        1.1     fvdl /********************************** PCI ***************************************/
    468        1.1     fvdl #if AHD_PCI_CONFIG > 0
    469       1.10    perry static __inline uint32_t ahd_pci_read_config(ahd_dev_softc_t, int, int);
    470       1.10    perry static __inline void	 ahd_pci_write_config(ahd_dev_softc_t, int,
    471        1.3   itojun     uint32_t, int);
    472       1.10    perry static __inline int	 ahd_get_pci_function(ahd_dev_softc_t);
    473       1.10    perry static __inline int	 ahd_get_pci_slot(ahd_dev_softc_t);
    474       1.10    perry static __inline int	 ahd_get_pci_bus(ahd_dev_softc_t);
    475        1.1     fvdl 
    476        1.3   itojun int			 ahd_pci_map_registers(struct ahd_softc *);
    477        1.3   itojun int			 ahd_pci_map_int(struct ahd_softc *);
    478        1.1     fvdl 
    479       1.10    perry static __inline uint32_t
    480        1.1     fvdl ahd_pci_read_config(ahd_dev_softc_t pci, int reg, int width)
    481        1.1     fvdl {
    482        1.1     fvdl 	return (pci_read_config(pci, reg, width));
    483        1.1     fvdl }
    484        1.1     fvdl 
    485       1.10    perry static __inline void
    486        1.1     fvdl ahd_pci_write_config(ahd_dev_softc_t pci, int reg, uint32_t value, int width)
    487        1.1     fvdl {
    488        1.1     fvdl 	pci_write_config(pci, reg, value, width);
    489        1.1     fvdl }
    490        1.1     fvdl 
    491       1.10    perry static __inline int
    492        1.1     fvdl ahd_get_pci_function(ahd_dev_softc_t pci)
    493        1.1     fvdl {
    494        1.1     fvdl 	return (pci_get_function(pci));
    495        1.1     fvdl }
    496        1.1     fvdl 
    497       1.10    perry static __inline int
    498        1.1     fvdl ahd_get_pci_slot(ahd_dev_softc_t pci)
    499        1.1     fvdl {
    500        1.1     fvdl 	return (pci_get_slot(pci));
    501        1.1     fvdl }
    502        1.1     fvdl 
    503        1.1     fvdl 
    504       1.10    perry static __inline int
    505        1.1     fvdl ahd_get_pci_bus(ahd_dev_softc_t pci)
    506        1.1     fvdl {
    507        1.1     fvdl 	return (pci_get_bus(pci));
    508        1.1     fvdl }
    509        1.1     fvdl #endif
    510        1.1     fvdl 
    511        1.1     fvdl typedef enum
    512        1.1     fvdl {
    513        1.1     fvdl 	AHD_POWER_STATE_D0,
    514        1.1     fvdl 	AHD_POWER_STATE_D1,
    515        1.1     fvdl 	AHD_POWER_STATE_D2,
    516        1.1     fvdl 	AHD_POWER_STATE_D3
    517        1.1     fvdl } ahd_power_state;
    518        1.1     fvdl 
    519        1.3   itojun void ahd_power_state_change(struct ahd_softc *, ahd_power_state);
    520        1.1     fvdl 
    521        1.1     fvdl /******************************** VL/EISA *************************************/
    522        1.3   itojun int aic7770_map_registers(struct ahd_softc *);
    523        1.3   itojun int aic7770_map_int(struct ahd_softc *, int);
    524        1.1     fvdl 
    525        1.1     fvdl /********************************* Debug **************************************/
    526       1.10    perry static __inline void	ahd_print_path(struct ahd_softc *, struct scb *);
    527       1.10    perry static __inline void	ahd_platform_dump_card_state(struct ahd_softc *);
    528       1.10    perry static __inline void
    529  1.10.16.1     yamt ahd_print_path(struct ahd_softc *ahd, struct scb *scb __unused)
    530        1.1     fvdl {
    531        1.1     fvdl 	printf("%s:", ahd->sc_dev.dv_xname);
    532        1.1     fvdl }
    533        1.1     fvdl 
    534       1.10    perry static __inline void
    535  1.10.16.1     yamt ahd_platform_dump_card_state(struct ahd_softc *ahd __unused)
    536        1.1     fvdl {
    537        1.1     fvdl 	/* Nothing to do here for NetBSD */
    538        1.1     fvdl }
    539        1.1     fvdl /**************************** Transfer Settings *******************************/
    540        1.1     fvdl void	  ahd_notify_xfer_settings_change(struct ahd_softc *,
    541        1.1     fvdl 					  struct ahd_devinfo *);
    542        1.1     fvdl void	  ahd_platform_set_tags(struct ahd_softc *, struct ahd_devinfo *,
    543        1.1     fvdl 				ahd_queue_alg);
    544        1.1     fvdl 
    545        1.1     fvdl /************************* Initialization/Teardown ****************************/
    546        1.3   itojun int	  ahd_platform_alloc(struct ahd_softc *, void *);
    547        1.3   itojun void	  ahd_platform_free(struct ahd_softc *);
    548        1.3   itojun int	  ahd_map_int(struct ahd_softc *);
    549        1.1     fvdl int	  ahd_attach(struct ahd_softc *);
    550        1.3   itojun int	  ahd_softc_comp(struct ahd_softc *, struct ahd_softc *);
    551        1.3   itojun int 	  ahd_detach(struct device *, int);
    552        1.1     fvdl #define	ahd_platform_init(arg)
    553        1.1     fvdl 
    554        1.1     fvdl 
    555        1.1     fvdl /****************************** Interrupts ************************************/
    556        1.1     fvdl void			ahd_platform_intr(void *);
    557       1.10    perry static __inline void	ahd_platform_flushwork(struct ahd_softc *);
    558       1.10    perry static __inline void
    559  1.10.16.1     yamt ahd_platform_flushwork(struct ahd_softc *ahd __unused)
    560        1.1     fvdl {
    561        1.1     fvdl 	/* Nothing to do here for NetBSD */
    562        1.1     fvdl }
    563        1.1     fvdl 
    564        1.1     fvdl /************************ Misc Function Declarations **************************/
    565        1.3   itojun void	ahd_done(struct ahd_softc *, struct scb *);
    566        1.3   itojun void	ahd_send_async(struct ahd_softc *, char , u_int, u_int, u_int, void *);
    567        1.1     fvdl 
    568        1.1     fvdl #endif  /* _AIC79XX_NETBSD_H_ */
    569