xref: /openbsd/sys/dev/ic/aic79xx_inline.h (revision e5238fd1)
1*e5238fd1Smarco /*	$OpenBSD: aic79xx_inline.h,v 1.3 2004/08/06 01:29:19 marco Exp $	*/
256007914Smarco /*
356007914Smarco  * Inline routines shareable across OS platforms.
456007914Smarco  *
556007914Smarco  * Copyright (c) 1994-2001 Justin T. Gibbs.
656007914Smarco  * Copyright (c) 2000-2003 Adaptec Inc.
756007914Smarco  * All rights reserved.
856007914Smarco  *
956007914Smarco  * Redistribution and use in source and binary forms, with or without
1056007914Smarco  * modification, are permitted provided that the following conditions
1156007914Smarco  * are met:
1256007914Smarco  * 1. Redistributions of source code must retain the above copyright
1356007914Smarco  *    notice, this list of conditions, and the following disclaimer,
1456007914Smarco  *    without modification.
1556007914Smarco  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
1656007914Smarco  *    substantially similar to the "NO WARRANTY" disclaimer below
1756007914Smarco  *    ("Disclaimer") and any redistribution must be conditioned upon
1856007914Smarco  *    including a substantially similar Disclaimer requirement for further
1956007914Smarco  *    binary redistribution.
2056007914Smarco  * 3. Neither the names of the above-listed copyright holders nor the names
2156007914Smarco  *    of any contributors may be used to endorse or promote products derived
2256007914Smarco  *    from this software without specific prior written permission.
2356007914Smarco  *
2456007914Smarco  * Alternatively, this software may be distributed under the terms of the
2556007914Smarco  * GNU General Public License ("GPL") version 2 as published by the Free
2656007914Smarco  * Software Foundation.
2756007914Smarco  *
2856007914Smarco  * NO WARRANTY
2956007914Smarco  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
3056007914Smarco  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
3156007914Smarco  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
3256007914Smarco  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
3356007914Smarco  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
3456007914Smarco  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
3556007914Smarco  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3656007914Smarco  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
3756007914Smarco  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
3856007914Smarco  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
3956007914Smarco  * POSSIBILITY OF SUCH DAMAGES.
4056007914Smarco  *
4156007914Smarco  * $FreeBSD: src/sys/dev/aic7xxx/aic79xx_inline.h,v 1.14 2004/02/04 16:38:38 gibbs Exp $
4256007914Smarco  *
4356007914Smarco  * Additional copyrights by:
4456007914Smarco  * Milos Urbanek
4556007914Smarco  * Kenneth R. Westerback
4656007914Smarco  * Marco Peereboom
4756007914Smarco  *
4856007914Smarco  */
4956007914Smarco 
5056007914Smarco #ifndef _AIC79XX_INLINE_H_
5156007914Smarco #define _AIC79XX_INLINE_H_
5256007914Smarco 
5356007914Smarco /******************************** Debugging ***********************************/
54*e5238fd1Smarco char *ahd_name(struct ahd_softc *ahd);
5556007914Smarco 
5656007914Smarco /************************ Sequencer Execution Control *************************/
57*e5238fd1Smarco void ahd_known_modes(struct ahd_softc *, ahd_mode, ahd_mode);
58*e5238fd1Smarco ahd_mode_state ahd_build_mode_state(struct ahd_softc *,
5956007914Smarco 					    ahd_mode , ahd_mode );
60*e5238fd1Smarco void ahd_extract_mode_state(struct ahd_softc *, ahd_mode_state,
6156007914Smarco 					    ahd_mode *, ahd_mode *);
62*e5238fd1Smarco void ahd_set_modes(struct ahd_softc *, ahd_mode, ahd_mode );
63*e5238fd1Smarco void ahd_update_modes(struct ahd_softc *);
64*e5238fd1Smarco void ahd_assert_modes(struct ahd_softc *, ahd_mode,
6556007914Smarco 				      ahd_mode, const char *, int);
66*e5238fd1Smarco ahd_mode_state ahd_save_modes(struct ahd_softc *);
67*e5238fd1Smarco void ahd_restore_modes(struct ahd_softc *, ahd_mode_state);
68*e5238fd1Smarco int  ahd_is_paused(struct ahd_softc *);
69*e5238fd1Smarco void ahd_pause(struct ahd_softc *);
7056007914Smarco 
71*e5238fd1Smarco void ahd_unpause(struct ahd_softc *);
7256007914Smarco 
73*e5238fd1Smarco /*********************** Scatter Gather List Handling *************************/
74*e5238fd1Smarco void	*ahd_sg_setup(struct ahd_softc *ahd, struct scb *scb,
75*e5238fd1Smarco 				      void *sgptr, bus_addr_t addr,
76*e5238fd1Smarco 				      bus_size_t len, int last);
77*e5238fd1Smarco void	 ahd_setup_scb_common(struct ahd_softc *ahd,
78*e5238fd1Smarco 					      struct scb *scb);
79*e5238fd1Smarco void	 ahd_setup_data_scb(struct ahd_softc *ahd,
80*e5238fd1Smarco 					    struct scb *scb);
81*e5238fd1Smarco void	 ahd_setup_noxfer_scb(struct ahd_softc *ahd,
82*e5238fd1Smarco 					      struct scb *scb);
8356007914Smarco 
84*e5238fd1Smarco /************************** Memory mapping routines ***************************/
85*e5238fd1Smarco size_t	ahd_sg_size(struct ahd_softc *);
86*e5238fd1Smarco void *
87*e5238fd1Smarco 			ahd_sg_bus_to_virt(struct ahd_softc *, struct scb *,
88*e5238fd1Smarco 					   uint32_t);
89*e5238fd1Smarco uint32_t
90*e5238fd1Smarco 			ahd_sg_virt_to_bus(struct ahd_softc *, struct scb *,
91*e5238fd1Smarco 					   void *);
92*e5238fd1Smarco void	ahd_sync_scb(struct ahd_softc *, struct scb *, int);
93*e5238fd1Smarco void	ahd_sync_sglist(struct ahd_softc *, struct scb *, int);
94*e5238fd1Smarco void	ahd_sync_sense(struct ahd_softc *, struct scb *, int);
95*e5238fd1Smarco uint32_t
96*e5238fd1Smarco 			ahd_targetcmd_offset(struct ahd_softc *, u_int);
9756007914Smarco 
98*e5238fd1Smarco /*********************** Miscelaneous Support Functions ***********************/
99*e5238fd1Smarco void	ahd_complete_scb(struct ahd_softc *, struct scb *);
100*e5238fd1Smarco void	ahd_update_residual(struct ahd_softc *, struct scb *);
101*e5238fd1Smarco struct ahd_initiator_tinfo *
102*e5238fd1Smarco 			ahd_fetch_transinfo(struct ahd_softc *, char , u_int,
103*e5238fd1Smarco 					    u_int, struct ahd_tmode_tstate **);
104*e5238fd1Smarco uint16_t
105*e5238fd1Smarco 			ahd_inw(struct ahd_softc *, u_int);
106*e5238fd1Smarco void	ahd_outw(struct ahd_softc *, u_int, u_int);
107*e5238fd1Smarco uint32_t
108*e5238fd1Smarco 			ahd_inl(struct ahd_softc *, u_int);
109*e5238fd1Smarco void	ahd_outl(struct ahd_softc *, u_int, uint32_t);
110*e5238fd1Smarco uint64_t		ahd_inq(struct ahd_softc *, u_int);
111*e5238fd1Smarco void			ahd_outq(struct ahd_softc *, u_int, uint64_t);
112*e5238fd1Smarco u_int	ahd_get_scbptr(struct ahd_softc *ahd);
113*e5238fd1Smarco void	ahd_set_scbptr(struct ahd_softc *ahd, u_int scbptr);
114*e5238fd1Smarco u_int	ahd_get_hnscb_qoff(struct ahd_softc *ahd);
115*e5238fd1Smarco void	ahd_set_hnscb_qoff(struct ahd_softc *ahd, u_int value);
116*e5238fd1Smarco u_int	ahd_get_hescb_qoff(struct ahd_softc *ahd);
117*e5238fd1Smarco void	ahd_set_hescb_qoff(struct ahd_softc *ahd, u_int value);
118*e5238fd1Smarco u_int	ahd_get_snscb_qoff(struct ahd_softc *ahd);
119*e5238fd1Smarco void	ahd_set_snscb_qoff(struct ahd_softc *ahd, u_int value);
120*e5238fd1Smarco u_int	ahd_get_sescb_qoff(struct ahd_softc *ahd);
121*e5238fd1Smarco void	ahd_set_sescb_qoff(struct ahd_softc *ahd, u_int value);
122*e5238fd1Smarco u_int	ahd_get_sdscb_qoff(struct ahd_softc *ahd);
123*e5238fd1Smarco void	ahd_set_sdscb_qoff(struct ahd_softc *ahd, u_int value);
124*e5238fd1Smarco u_int	ahd_inb_scbram(struct ahd_softc *ahd, u_int offset);
125*e5238fd1Smarco u_int	ahd_inw_scbram(struct ahd_softc *ahd, u_int offset);
126*e5238fd1Smarco uint32_t ahd_inl_scbram(struct ahd_softc *ahd, u_int offset);
127*e5238fd1Smarco uint64_t ahd_inq_scbram(struct ahd_softc *ahd, u_int offset);
128*e5238fd1Smarco struct	scb *ahd_lookup_scb(struct ahd_softc *, u_int);
129*e5238fd1Smarco void	ahd_swap_with_next_hscb(struct ahd_softc *ahd, struct scb *scb);
130*e5238fd1Smarco void	ahd_queue_scb(struct ahd_softc *ahd, struct scb *scb);
131*e5238fd1Smarco uint8_t *ahd_get_sense_buf(struct ahd_softc *ahd, struct scb *scb);
132*e5238fd1Smarco uint32_t ahd_get_sense_bufaddr(struct ahd_softc *ahd, struct scb *scb);
13356007914Smarco 
134*e5238fd1Smarco /************************** Interrupt Processing ******************************/
135*e5238fd1Smarco void	ahd_sync_qoutfifo(struct ahd_softc *ahd, int op);
136*e5238fd1Smarco void	ahd_sync_tqinfifo(struct ahd_softc *ahd, int op);
137*e5238fd1Smarco u_int			ahd_check_cmdcmpltqueues(struct ahd_softc *ahd);
138*e5238fd1Smarco int			ahd_intr(struct ahd_softc *ahd);
13956007914Smarco 
14056007914Smarco #define AHD_ASSERT_MODES(ahd, source, dest) \
14156007914Smarco 	ahd_assert_modes(ahd, source, dest, __FILE__, __LINE__);
14256007914Smarco 
14356007914Smarco #endif  /* _AIC79XX_INLINE_H_ */
144