]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - drivers/scsi/aic7xxx/aic79xx_inline.h
[SCSI] aic7xxx, aic79xx: deinline functions
[linux-2.6-omap-h63xx.git] / drivers / scsi / aic7xxx / aic79xx_inline.h
1 /*
2  * Inline routines shareable across OS platforms.
3  *
4  * Copyright (c) 1994-2001 Justin T. Gibbs.
5  * Copyright (c) 2000-2003 Adaptec Inc.
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  *    without modification.
14  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
15  *    substantially similar to the "NO WARRANTY" disclaimer below
16  *    ("Disclaimer") and any redistribution must be conditioned upon
17  *    including a substantially similar Disclaimer requirement for further
18  *    binary redistribution.
19  * 3. Neither the names of the above-listed copyright holders nor the names
20  *    of any contributors may be used to endorse or promote products derived
21  *    from this software without specific prior written permission.
22  *
23  * Alternatively, this software may be distributed under the terms of the
24  * GNU General Public License ("GPL") version 2 as published by the Free
25  * Software Foundation.
26  *
27  * NO WARRANTY
28  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
31  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
33  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
34  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
35  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
36  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
37  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
38  * POSSIBILITY OF SUCH DAMAGES.
39  *
40  * $Id: //depot/aic7xxx/aic7xxx/aic79xx_inline.h#59 $
41  *
42  * $FreeBSD$
43  */
44
45 #ifndef _AIC79XX_INLINE_H_
46 #define _AIC79XX_INLINE_H_
47
48 /******************************** Debugging ***********************************/
49 static __inline char *ahd_name(struct ahd_softc *ahd);
50
51 static __inline char *
52 ahd_name(struct ahd_softc *ahd)
53 {
54         return (ahd->name);
55 }
56
57 /************************ Sequencer Execution Control *************************/
58 static __inline void ahd_known_modes(struct ahd_softc *ahd,
59                                      ahd_mode src, ahd_mode dst);
60 static __inline ahd_mode_state ahd_build_mode_state(struct ahd_softc *ahd,
61                                                     ahd_mode src,
62                                                     ahd_mode dst);
63 static __inline void ahd_extract_mode_state(struct ahd_softc *ahd,
64                                             ahd_mode_state state,
65                                             ahd_mode *src, ahd_mode *dst);
66
67 void ahd_set_modes(struct ahd_softc *ahd, ahd_mode src,
68                    ahd_mode dst);
69 void ahd_update_modes(struct ahd_softc *ahd);
70 void ahd_assert_modes(struct ahd_softc *ahd, ahd_mode srcmode,
71                       ahd_mode dstmode, const char *file,
72                       int line);
73 ahd_mode_state ahd_save_modes(struct ahd_softc *ahd);
74 void ahd_restore_modes(struct ahd_softc *ahd,
75                        ahd_mode_state state);
76 int  ahd_is_paused(struct ahd_softc *ahd);
77 void ahd_pause(struct ahd_softc *ahd);
78 void ahd_unpause(struct ahd_softc *ahd);
79
80 static __inline void
81 ahd_known_modes(struct ahd_softc *ahd, ahd_mode src, ahd_mode dst)
82 {
83         ahd->src_mode = src;
84         ahd->dst_mode = dst;
85         ahd->saved_src_mode = src;
86         ahd->saved_dst_mode = dst;
87 }
88
89 static __inline ahd_mode_state
90 ahd_build_mode_state(struct ahd_softc *ahd, ahd_mode src, ahd_mode dst)
91 {
92         return ((src << SRC_MODE_SHIFT) | (dst << DST_MODE_SHIFT));
93 }
94
95 static __inline void
96 ahd_extract_mode_state(struct ahd_softc *ahd, ahd_mode_state state,
97                        ahd_mode *src, ahd_mode *dst)
98 {
99         *src = (state & SRC_MODE) >> SRC_MODE_SHIFT;
100         *dst = (state & DST_MODE) >> DST_MODE_SHIFT;
101 }
102
103 /*********************** Scatter Gather List Handling *************************/
104 void    *ahd_sg_setup(struct ahd_softc *ahd, struct scb *scb,
105                       void *sgptr, dma_addr_t addr,
106                       bus_size_t len, int last);
107 void     ahd_setup_scb_common(struct ahd_softc *ahd,
108                               struct scb *scb);
109 void     ahd_setup_data_scb(struct ahd_softc *ahd,
110                             struct scb *scb);
111 void     ahd_setup_noxfer_scb(struct ahd_softc *ahd,
112                               struct scb *scb);
113
114 /************************** Memory mapping routines ***************************/
115 static __inline size_t  ahd_sg_size(struct ahd_softc *ahd);
116
117 void *
118         ahd_sg_bus_to_virt(struct ahd_softc *ahd,
119                            struct scb *scb,
120                            uint32_t sg_busaddr);
121 uint32_t
122         ahd_sg_virt_to_bus(struct ahd_softc *ahd,
123                            struct scb *scb,
124                            void *sg);
125 void    ahd_sync_scb(struct ahd_softc *ahd,
126                      struct scb *scb, int op);
127 void    ahd_sync_sglist(struct ahd_softc *ahd,
128                         struct scb *scb, int op);
129 void    ahd_sync_sense(struct ahd_softc *ahd,
130                        struct scb *scb, int op);
131 uint32_t
132         ahd_targetcmd_offset(struct ahd_softc *ahd,
133                              u_int index);
134
135 static __inline size_t
136 ahd_sg_size(struct ahd_softc *ahd)
137 {
138         if ((ahd->flags & AHD_64BIT_ADDRESSING) != 0)
139                 return (sizeof(struct ahd_dma64_seg));
140         return (sizeof(struct ahd_dma_seg));
141 }
142
143 /*********************** Miscellaneous Support Functions ***********************/
144 struct ahd_initiator_tinfo *
145         ahd_fetch_transinfo(struct ahd_softc *ahd,
146                             char channel, u_int our_id,
147                             u_int remote_id,
148                             struct ahd_tmode_tstate **tstate);
149 uint16_t
150         ahd_inw(struct ahd_softc *ahd, u_int port);
151 void    ahd_outw(struct ahd_softc *ahd, u_int port,
152                  u_int value);
153 uint32_t
154         ahd_inl(struct ahd_softc *ahd, u_int port);
155 void    ahd_outl(struct ahd_softc *ahd, u_int port,
156                  uint32_t value);
157 uint64_t
158         ahd_inq(struct ahd_softc *ahd, u_int port);
159 void    ahd_outq(struct ahd_softc *ahd, u_int port,
160                  uint64_t value);
161 u_int   ahd_get_scbptr(struct ahd_softc *ahd);
162 void    ahd_set_scbptr(struct ahd_softc *ahd, u_int scbptr);
163 u_int   ahd_get_hnscb_qoff(struct ahd_softc *ahd);
164 void    ahd_set_hnscb_qoff(struct ahd_softc *ahd, u_int value);
165 u_int   ahd_get_hescb_qoff(struct ahd_softc *ahd);
166 void    ahd_set_hescb_qoff(struct ahd_softc *ahd, u_int value);
167 u_int   ahd_get_snscb_qoff(struct ahd_softc *ahd);
168 void    ahd_set_snscb_qoff(struct ahd_softc *ahd, u_int value);
169 u_int   ahd_get_sescb_qoff(struct ahd_softc *ahd);
170 void    ahd_set_sescb_qoff(struct ahd_softc *ahd, u_int value);
171 u_int   ahd_get_sdscb_qoff(struct ahd_softc *ahd);
172 void    ahd_set_sdscb_qoff(struct ahd_softc *ahd, u_int value);
173 u_int   ahd_inb_scbram(struct ahd_softc *ahd, u_int offset);
174 u_int   ahd_inw_scbram(struct ahd_softc *ahd, u_int offset);
175 uint32_t
176         ahd_inl_scbram(struct ahd_softc *ahd, u_int offset);
177 uint64_t
178         ahd_inq_scbram(struct ahd_softc *ahd, u_int offset);
179 struct scb *
180         ahd_lookup_scb(struct ahd_softc *ahd, u_int tag);
181 void    ahd_swap_with_next_hscb(struct ahd_softc *ahd,
182                                 struct scb *scb);
183 void    ahd_queue_scb(struct ahd_softc *ahd, struct scb *scb);
184
185 static __inline uint8_t *
186                         ahd_get_sense_buf(struct ahd_softc *ahd,
187                                           struct scb *scb);
188 static __inline uint32_t
189                         ahd_get_sense_bufaddr(struct ahd_softc *ahd,
190                                               struct scb *scb);
191
192 #if 0 /* unused */
193
194 #define AHD_COPY_COL_IDX(dst, src)                              \
195 do {                                                            \
196         dst->hscb->scsiid = src->hscb->scsiid;                  \
197         dst->hscb->lun = src->hscb->lun;                        \
198 } while (0)
199
200 #endif
201
202 static __inline uint8_t *
203 ahd_get_sense_buf(struct ahd_softc *ahd, struct scb *scb)
204 {
205         return (scb->sense_data);
206 }
207
208 static __inline uint32_t
209 ahd_get_sense_bufaddr(struct ahd_softc *ahd, struct scb *scb)
210 {
211         return (scb->sense_busaddr);
212 }
213
214 /************************** Interrupt Processing ******************************/
215 void    ahd_sync_qoutfifo(struct ahd_softc *ahd, int op);
216 void    ahd_sync_tqinfifo(struct ahd_softc *ahd, int op);
217 u_int   ahd_check_cmdcmpltqueues(struct ahd_softc *ahd);
218 int     ahd_intr(struct ahd_softc *ahd);
219
220 #endif  /* _AIC79XX_INLINE_H_ */