2 * Inline routines shareable across OS platforms.
4 * Copyright (c) 1994-2001 Justin T. Gibbs.
5 * Copyright (c) 2000-2003 Adaptec Inc.
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
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.
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.
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.
40 * $Id: //depot/aic7xxx/aic7xxx/aic79xx_inline.h#59 $
45 #ifndef _AIC79XX_INLINE_H_
46 #define _AIC79XX_INLINE_H_
48 /******************************** Debugging ***********************************/
49 static __inline
char *ahd_name(struct ahd_softc
*ahd
);
51 static __inline
char *
52 ahd_name(struct ahd_softc
*ahd
)
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
,
63 static __inline
void ahd_extract_mode_state(struct ahd_softc
*ahd
,
65 ahd_mode
*src
, ahd_mode
*dst
);
67 void ahd_set_modes(struct ahd_softc
*ahd
, ahd_mode src
,
69 ahd_mode_state
ahd_save_modes(struct ahd_softc
*ahd
);
70 void ahd_restore_modes(struct ahd_softc
*ahd
,
71 ahd_mode_state state
);
72 int ahd_is_paused(struct ahd_softc
*ahd
);
73 void ahd_pause(struct ahd_softc
*ahd
);
74 void ahd_unpause(struct ahd_softc
*ahd
);
77 ahd_known_modes(struct ahd_softc
*ahd
, ahd_mode src
, ahd_mode dst
)
81 ahd
->saved_src_mode
= src
;
82 ahd
->saved_dst_mode
= dst
;
85 static __inline ahd_mode_state
86 ahd_build_mode_state(struct ahd_softc
*ahd
, ahd_mode src
, ahd_mode dst
)
88 return ((src
<< SRC_MODE_SHIFT
) | (dst
<< DST_MODE_SHIFT
));
92 ahd_extract_mode_state(struct ahd_softc
*ahd
, ahd_mode_state state
,
93 ahd_mode
*src
, ahd_mode
*dst
)
95 *src
= (state
& SRC_MODE
) >> SRC_MODE_SHIFT
;
96 *dst
= (state
& DST_MODE
) >> DST_MODE_SHIFT
;
99 /*********************** Scatter Gather List Handling *************************/
100 void *ahd_sg_setup(struct ahd_softc
*ahd
, struct scb
*scb
,
101 void *sgptr
, dma_addr_t addr
,
102 bus_size_t len
, int last
);
104 /************************** Memory mapping routines ***************************/
105 static __inline
size_t ahd_sg_size(struct ahd_softc
*ahd
);
107 void ahd_sync_sglist(struct ahd_softc
*ahd
,
108 struct scb
*scb
, int op
);
110 static __inline
size_t
111 ahd_sg_size(struct ahd_softc
*ahd
)
113 if ((ahd
->flags
& AHD_64BIT_ADDRESSING
) != 0)
114 return (sizeof(struct ahd_dma64_seg
));
115 return (sizeof(struct ahd_dma_seg
));
118 /*********************** Miscellaneous Support Functions ***********************/
119 struct ahd_initiator_tinfo
*
120 ahd_fetch_transinfo(struct ahd_softc
*ahd
,
121 char channel
, u_int our_id
,
123 struct ahd_tmode_tstate
**tstate
);
125 ahd_inw(struct ahd_softc
*ahd
, u_int port
);
126 void ahd_outw(struct ahd_softc
*ahd
, u_int port
,
129 ahd_inl(struct ahd_softc
*ahd
, u_int port
);
130 void ahd_outl(struct ahd_softc
*ahd
, u_int port
,
133 ahd_inq(struct ahd_softc
*ahd
, u_int port
);
134 void ahd_outq(struct ahd_softc
*ahd
, u_int port
,
136 u_int
ahd_get_scbptr(struct ahd_softc
*ahd
);
137 void ahd_set_scbptr(struct ahd_softc
*ahd
, u_int scbptr
);
138 u_int
ahd_inb_scbram(struct ahd_softc
*ahd
, u_int offset
);
139 u_int
ahd_inw_scbram(struct ahd_softc
*ahd
, u_int offset
);
141 ahd_lookup_scb(struct ahd_softc
*ahd
, u_int tag
);
142 void ahd_queue_scb(struct ahd_softc
*ahd
, struct scb
*scb
);
144 static __inline
uint8_t *
145 ahd_get_sense_buf(struct ahd_softc
*ahd
,
147 static __inline
uint32_t
148 ahd_get_sense_bufaddr(struct ahd_softc
*ahd
,
153 #define AHD_COPY_COL_IDX(dst, src) \
155 dst->hscb->scsiid = src->hscb->scsiid; \
156 dst->hscb->lun = src->hscb->lun; \
161 static __inline
uint8_t *
162 ahd_get_sense_buf(struct ahd_softc
*ahd
, struct scb
*scb
)
164 return (scb
->sense_data
);
167 static __inline
uint32_t
168 ahd_get_sense_bufaddr(struct ahd_softc
*ahd
, struct scb
*scb
)
170 return (scb
->sense_busaddr
);
173 /************************** Interrupt Processing ******************************/
174 int ahd_intr(struct ahd_softc
*ahd
);
176 #endif /* _AIC79XX_INLINE_H_ */