Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Inline routines shareable across OS platforms.
0003  *
0004  * Copyright (c) 1994-2001 Justin T. Gibbs.
0005  * Copyright (c) 2000-2003 Adaptec Inc.
0006  * All rights reserved.
0007  *
0008  * Redistribution and use in source and binary forms, with or without
0009  * modification, are permitted provided that the following conditions
0010  * are met:
0011  * 1. Redistributions of source code must retain the above copyright
0012  *    notice, this list of conditions, and the following disclaimer,
0013  *    without modification.
0014  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
0015  *    substantially similar to the "NO WARRANTY" disclaimer below
0016  *    ("Disclaimer") and any redistribution must be conditioned upon
0017  *    including a substantially similar Disclaimer requirement for further
0018  *    binary redistribution.
0019  * 3. Neither the names of the above-listed copyright holders nor the names
0020  *    of any contributors may be used to endorse or promote products derived
0021  *    from this software without specific prior written permission.
0022  *
0023  * Alternatively, this software may be distributed under the terms of the
0024  * GNU General Public License ("GPL") version 2 as published by the Free
0025  * Software Foundation.
0026  *
0027  * NO WARRANTY
0028  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
0029  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
0030  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
0031  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
0032  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
0033  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
0034  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
0035  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
0036  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
0037  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0038  * POSSIBILITY OF SUCH DAMAGES.
0039  *
0040  * $Id: //depot/aic7xxx/aic7xxx/aic79xx_inline.h#59 $
0041  *
0042  * $FreeBSD$
0043  */
0044 
0045 #ifndef _AIC79XX_INLINE_H_
0046 #define _AIC79XX_INLINE_H_
0047 
0048 /******************************** Debugging ***********************************/
0049 static inline char *ahd_name(struct ahd_softc *ahd);
0050 
0051 static inline char *ahd_name(struct ahd_softc *ahd)
0052 {
0053     return (ahd->name);
0054 }
0055 
0056 /************************ Sequencer Execution Control *************************/
0057 static inline void ahd_known_modes(struct ahd_softc *ahd,
0058                      ahd_mode src, ahd_mode dst);
0059 static inline ahd_mode_state ahd_build_mode_state(struct ahd_softc *ahd,
0060                             ahd_mode src,
0061                             ahd_mode dst);
0062 static inline void ahd_extract_mode_state(struct ahd_softc *ahd,
0063                         ahd_mode_state state,
0064                         ahd_mode *src, ahd_mode *dst);
0065 
0066 void ahd_set_modes(struct ahd_softc *ahd, ahd_mode src,
0067            ahd_mode dst);
0068 ahd_mode_state ahd_save_modes(struct ahd_softc *ahd);
0069 void ahd_restore_modes(struct ahd_softc *ahd,
0070                ahd_mode_state state);
0071 int  ahd_is_paused(struct ahd_softc *ahd);
0072 void ahd_pause(struct ahd_softc *ahd);
0073 void ahd_unpause(struct ahd_softc *ahd);
0074 
0075 static inline void
0076 ahd_known_modes(struct ahd_softc *ahd, ahd_mode src, ahd_mode dst)
0077 {
0078     ahd->src_mode = src;
0079     ahd->dst_mode = dst;
0080     ahd->saved_src_mode = src;
0081     ahd->saved_dst_mode = dst;
0082 }
0083 
0084 static inline ahd_mode_state
0085 ahd_build_mode_state(struct ahd_softc *ahd, ahd_mode src, ahd_mode dst)
0086 {
0087     return ((src << SRC_MODE_SHIFT) | (dst << DST_MODE_SHIFT));
0088 }
0089 
0090 static inline void
0091 ahd_extract_mode_state(struct ahd_softc *ahd, ahd_mode_state state,
0092                ahd_mode *src, ahd_mode *dst)
0093 {
0094     *src = (state & SRC_MODE) >> SRC_MODE_SHIFT;
0095     *dst = (state & DST_MODE) >> DST_MODE_SHIFT;
0096 }
0097 
0098 /*********************** Scatter Gather List Handling *************************/
0099 void    *ahd_sg_setup(struct ahd_softc *ahd, struct scb *scb,
0100               void *sgptr, dma_addr_t addr,
0101               bus_size_t len, int last);
0102 
0103 /************************** Memory mapping routines ***************************/
0104 static inline size_t    ahd_sg_size(struct ahd_softc *ahd);
0105 
0106 void    ahd_sync_sglist(struct ahd_softc *ahd,
0107             struct scb *scb, int op);
0108 
0109 static inline size_t ahd_sg_size(struct ahd_softc *ahd)
0110 {
0111     if ((ahd->flags & AHD_64BIT_ADDRESSING) != 0)
0112         return (sizeof(struct ahd_dma64_seg));
0113     return (sizeof(struct ahd_dma_seg));
0114 }
0115 
0116 /*********************** Miscellaneous Support Functions ***********************/
0117 struct ahd_initiator_tinfo *
0118     ahd_fetch_transinfo(struct ahd_softc *ahd,
0119                 char channel, u_int our_id,
0120                 u_int remote_id,
0121                 struct ahd_tmode_tstate **tstate);
0122 uint16_t
0123     ahd_inw(struct ahd_softc *ahd, u_int port);
0124 void    ahd_outw(struct ahd_softc *ahd, u_int port,
0125          u_int value);
0126 uint32_t
0127     ahd_inl(struct ahd_softc *ahd, u_int port);
0128 void    ahd_outl(struct ahd_softc *ahd, u_int port,
0129          uint32_t value);
0130 uint64_t
0131     ahd_inq(struct ahd_softc *ahd, u_int port);
0132 void    ahd_outq(struct ahd_softc *ahd, u_int port,
0133          uint64_t value);
0134 u_int   ahd_get_scbptr(struct ahd_softc *ahd);
0135 void    ahd_set_scbptr(struct ahd_softc *ahd, u_int scbptr);
0136 u_int   ahd_inb_scbram(struct ahd_softc *ahd, u_int offset);
0137 u_int   ahd_inw_scbram(struct ahd_softc *ahd, u_int offset);
0138 struct scb *
0139     ahd_lookup_scb(struct ahd_softc *ahd, u_int tag);
0140 void    ahd_queue_scb(struct ahd_softc *ahd, struct scb *scb);
0141 
0142 static inline uint8_t *ahd_get_sense_buf(struct ahd_softc *ahd,
0143                       struct scb *scb);
0144 static inline uint32_t ahd_get_sense_bufaddr(struct ahd_softc *ahd,
0145                           struct scb *scb);
0146 
0147 #if 0 /* unused */
0148 
0149 #define AHD_COPY_COL_IDX(dst, src)              \
0150 do {                                \
0151     dst->hscb->scsiid = src->hscb->scsiid;          \
0152     dst->hscb->lun = src->hscb->lun;            \
0153 } while (0)
0154 
0155 #endif
0156 
0157 static inline uint8_t *
0158 ahd_get_sense_buf(struct ahd_softc *ahd, struct scb *scb)
0159 {
0160     return (scb->sense_data);
0161 }
0162 
0163 static inline uint32_t
0164 ahd_get_sense_bufaddr(struct ahd_softc *ahd, struct scb *scb)
0165 {
0166     return (scb->sense_busaddr);
0167 }
0168 
0169 /************************** Interrupt Processing ******************************/
0170 int ahd_intr(struct ahd_softc *ahd);
0171 
0172 #endif  /* _AIC79XX_INLINE_H_ */