blob: 5f12cf9d99d071344b6929beeb11c3fb11edbe33 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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 *
Hannes Reinecke53467e62006-01-24 10:43:26 +010040 * $Id: //depot/aic7xxx/aic7xxx/aic79xx_inline.h#59 $
Linus Torvalds1da177e2005-04-16 15:20:36 -070041 *
42 * $FreeBSD$
43 */
44
45#ifndef _AIC79XX_INLINE_H_
46#define _AIC79XX_INLINE_H_
47
48/******************************** Debugging ***********************************/
49static __inline char *ahd_name(struct ahd_softc *ahd);
50
51static __inline char *
52ahd_name(struct ahd_softc *ahd)
53{
54 return (ahd->name);
55}
56
57/************************ Sequencer Execution Control *************************/
58static __inline void ahd_known_modes(struct ahd_softc *ahd,
59 ahd_mode src, ahd_mode dst);
60static __inline ahd_mode_state ahd_build_mode_state(struct ahd_softc *ahd,
61 ahd_mode src,
62 ahd_mode dst);
63static __inline void ahd_extract_mode_state(struct ahd_softc *ahd,
64 ahd_mode_state state,
65 ahd_mode *src, ahd_mode *dst);
Denys Vlasenkobe0d6762008-03-23 04:41:22 +010066
67void ahd_set_modes(struct ahd_softc *ahd, ahd_mode src,
68 ahd_mode dst);
Denys Vlasenkobe0d6762008-03-23 04:41:22 +010069ahd_mode_state ahd_save_modes(struct ahd_softc *ahd);
70void ahd_restore_modes(struct ahd_softc *ahd,
71 ahd_mode_state state);
72int ahd_is_paused(struct ahd_softc *ahd);
73void ahd_pause(struct ahd_softc *ahd);
74void ahd_unpause(struct ahd_softc *ahd);
Linus Torvalds1da177e2005-04-16 15:20:36 -070075
76static __inline void
77ahd_known_modes(struct ahd_softc *ahd, ahd_mode src, ahd_mode dst)
78{
79 ahd->src_mode = src;
80 ahd->dst_mode = dst;
81 ahd->saved_src_mode = src;
82 ahd->saved_dst_mode = dst;
83}
84
85static __inline ahd_mode_state
86ahd_build_mode_state(struct ahd_softc *ahd, ahd_mode src, ahd_mode dst)
87{
88 return ((src << SRC_MODE_SHIFT) | (dst << DST_MODE_SHIFT));
89}
90
91static __inline void
92ahd_extract_mode_state(struct ahd_softc *ahd, ahd_mode_state state,
93 ahd_mode *src, ahd_mode *dst)
94{
95 *src = (state & SRC_MODE) >> SRC_MODE_SHIFT;
96 *dst = (state & DST_MODE) >> DST_MODE_SHIFT;
97}
98
Linus Torvalds1da177e2005-04-16 15:20:36 -070099/*********************** Scatter Gather List Handling *************************/
Denys Vlasenkobe0d6762008-03-23 04:41:22 +0100100void *ahd_sg_setup(struct ahd_softc *ahd, struct scb *scb,
101 void *sgptr, dma_addr_t addr,
102 bus_size_t len, int last);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103
104/************************** Memory mapping routines ***************************/
105static __inline size_t ahd_sg_size(struct ahd_softc *ahd);
Denys Vlasenkobe0d6762008-03-23 04:41:22 +0100106
Denys Vlasenkobe0d6762008-03-23 04:41:22 +0100107void ahd_sync_sglist(struct ahd_softc *ahd,
108 struct scb *scb, int op);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109
110static __inline size_t
111ahd_sg_size(struct ahd_softc *ahd)
112{
113 if ((ahd->flags & AHD_64BIT_ADDRESSING) != 0)
114 return (sizeof(struct ahd_dma64_seg));
115 return (sizeof(struct ahd_dma_seg));
116}
117
Joe Perchesb1c11812008-02-03 17:28:22 +0200118/*********************** Miscellaneous Support Functions ***********************/
Denys Vlasenkobe0d6762008-03-23 04:41:22 +0100119struct ahd_initiator_tinfo *
120 ahd_fetch_transinfo(struct ahd_softc *ahd,
121 char channel, u_int our_id,
122 u_int remote_id,
123 struct ahd_tmode_tstate **tstate);
124uint16_t
125 ahd_inw(struct ahd_softc *ahd, u_int port);
126void ahd_outw(struct ahd_softc *ahd, u_int port,
127 u_int value);
128uint32_t
129 ahd_inl(struct ahd_softc *ahd, u_int port);
130void ahd_outl(struct ahd_softc *ahd, u_int port,
131 uint32_t value);
132uint64_t
133 ahd_inq(struct ahd_softc *ahd, u_int port);
134void ahd_outq(struct ahd_softc *ahd, u_int port,
135 uint64_t value);
136u_int ahd_get_scbptr(struct ahd_softc *ahd);
137void ahd_set_scbptr(struct ahd_softc *ahd, u_int scbptr);
Denys Vlasenkobe0d6762008-03-23 04:41:22 +0100138u_int ahd_inb_scbram(struct ahd_softc *ahd, u_int offset);
139u_int ahd_inw_scbram(struct ahd_softc *ahd, u_int offset);
Denys Vlasenkobe0d6762008-03-23 04:41:22 +0100140struct scb *
141 ahd_lookup_scb(struct ahd_softc *ahd, u_int tag);
Denys Vlasenkobe0d6762008-03-23 04:41:22 +0100142void ahd_queue_scb(struct ahd_softc *ahd, struct scb *scb);
143
Linus Torvalds1da177e2005-04-16 15:20:36 -0700144static __inline uint8_t *
145 ahd_get_sense_buf(struct ahd_softc *ahd,
146 struct scb *scb);
147static __inline uint32_t
148 ahd_get_sense_bufaddr(struct ahd_softc *ahd,
149 struct scb *scb);
150
Denys Vlasenkobe0d6762008-03-23 04:41:22 +0100151#if 0 /* unused */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700152
153#define AHD_COPY_COL_IDX(dst, src) \
154do { \
155 dst->hscb->scsiid = src->hscb->scsiid; \
156 dst->hscb->lun = src->hscb->lun; \
157} while (0)
158
Linus Torvalds1da177e2005-04-16 15:20:36 -0700159#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700160
161static __inline uint8_t *
162ahd_get_sense_buf(struct ahd_softc *ahd, struct scb *scb)
163{
164 return (scb->sense_data);
165}
166
167static __inline uint32_t
168ahd_get_sense_bufaddr(struct ahd_softc *ahd, struct scb *scb)
169{
170 return (scb->sense_busaddr);
171}
172
173/************************** Interrupt Processing ******************************/
Denys Vlasenkobe0d6762008-03-23 04:41:22 +0100174int ahd_intr(struct ahd_softc *ahd);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700175
176#endif /* _AIC79XX_INLINE_H_ */