1*6dab29ddSmarco /* $OpenBSD: aic79xx_inline.h,v 1.4 2004/08/23 20:16:01 marco Exp $ */ 2*6dab29ddSmarco 3*6dab29ddSmarco /* 4*6dab29ddSmarco * Copyright (c) 2004 Milos Urbanek, Kenneth R. Westerback & Marco Peereboom 5*6dab29ddSmarco * All rights reserved. 6*6dab29ddSmarco * 7*6dab29ddSmarco * Redistribution and use in source and binary forms, with or without 8*6dab29ddSmarco * modification, are permitted provided that the following conditions 9*6dab29ddSmarco * are met: 10*6dab29ddSmarco * 1. Redistributions of source code must retain the above copyright 11*6dab29ddSmarco * notice, this list of conditions and the following disclaimer. 12*6dab29ddSmarco * 2. Redistributions in binary form must reproduce the above copyright 13*6dab29ddSmarco * notice, this list of conditions and the following disclaimer in the 14*6dab29ddSmarco * documentation and/or other materials provided with the distribution. 15*6dab29ddSmarco * 16*6dab29ddSmarco * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND 17*6dab29ddSmarco * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18*6dab29ddSmarco * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19*6dab29ddSmarco * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR 20*6dab29ddSmarco * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21*6dab29ddSmarco * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22*6dab29ddSmarco * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23*6dab29ddSmarco * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24*6dab29ddSmarco * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25*6dab29ddSmarco * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26*6dab29ddSmarco * SUCH DAMAGE. 27*6dab29ddSmarco * 28*6dab29ddSmarco */ 29*6dab29ddSmarco 3056007914Smarco /* 3156007914Smarco * Inline routines shareable across OS platforms. 3256007914Smarco * 3356007914Smarco * Copyright (c) 1994-2001 Justin T. Gibbs. 3456007914Smarco * Copyright (c) 2000-2003 Adaptec Inc. 3556007914Smarco * All rights reserved. 3656007914Smarco * 3756007914Smarco * Redistribution and use in source and binary forms, with or without 3856007914Smarco * modification, are permitted provided that the following conditions 3956007914Smarco * are met: 4056007914Smarco * 1. Redistributions of source code must retain the above copyright 4156007914Smarco * notice, this list of conditions, and the following disclaimer, 4256007914Smarco * without modification. 4356007914Smarco * 2. Redistributions in binary form must reproduce at minimum a disclaimer 4456007914Smarco * substantially similar to the "NO WARRANTY" disclaimer below 4556007914Smarco * ("Disclaimer") and any redistribution must be conditioned upon 4656007914Smarco * including a substantially similar Disclaimer requirement for further 4756007914Smarco * binary redistribution. 4856007914Smarco * 3. Neither the names of the above-listed copyright holders nor the names 4956007914Smarco * of any contributors may be used to endorse or promote products derived 5056007914Smarco * from this software without specific prior written permission. 5156007914Smarco * 5256007914Smarco * Alternatively, this software may be distributed under the terms of the 5356007914Smarco * GNU General Public License ("GPL") version 2 as published by the Free 5456007914Smarco * Software Foundation. 5556007914Smarco * 5656007914Smarco * NO WARRANTY 5756007914Smarco * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 5856007914Smarco * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 5956007914Smarco * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 6056007914Smarco * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 6156007914Smarco * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 6256007914Smarco * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 6356007914Smarco * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 6456007914Smarco * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 6556007914Smarco * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 6656007914Smarco * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 6756007914Smarco * POSSIBILITY OF SUCH DAMAGES. 6856007914Smarco * 6956007914Smarco * $FreeBSD: src/sys/dev/aic7xxx/aic79xx_inline.h,v 1.14 2004/02/04 16:38:38 gibbs Exp $ 7056007914Smarco * 7156007914Smarco */ 7256007914Smarco 7356007914Smarco #ifndef _AIC79XX_INLINE_H_ 7456007914Smarco #define _AIC79XX_INLINE_H_ 7556007914Smarco 7656007914Smarco /******************************** Debugging ***********************************/ 77e5238fd1Smarco char *ahd_name(struct ahd_softc *ahd); 7856007914Smarco 7956007914Smarco /************************ Sequencer Execution Control *************************/ 80e5238fd1Smarco void ahd_known_modes(struct ahd_softc *, ahd_mode, ahd_mode); 81e5238fd1Smarco ahd_mode_state ahd_build_mode_state(struct ahd_softc *, 8256007914Smarco ahd_mode , ahd_mode ); 83e5238fd1Smarco void ahd_extract_mode_state(struct ahd_softc *, ahd_mode_state, 8456007914Smarco ahd_mode *, ahd_mode *); 85e5238fd1Smarco void ahd_set_modes(struct ahd_softc *, ahd_mode, ahd_mode ); 86e5238fd1Smarco void ahd_update_modes(struct ahd_softc *); 87e5238fd1Smarco void ahd_assert_modes(struct ahd_softc *, ahd_mode, 8856007914Smarco ahd_mode, const char *, int); 89e5238fd1Smarco ahd_mode_state ahd_save_modes(struct ahd_softc *); 90e5238fd1Smarco void ahd_restore_modes(struct ahd_softc *, ahd_mode_state); 91e5238fd1Smarco int ahd_is_paused(struct ahd_softc *); 92e5238fd1Smarco void ahd_pause(struct ahd_softc *); 9356007914Smarco 94e5238fd1Smarco void ahd_unpause(struct ahd_softc *); 9556007914Smarco 96e5238fd1Smarco /*********************** Scatter Gather List Handling *************************/ 97e5238fd1Smarco void *ahd_sg_setup(struct ahd_softc *ahd, struct scb *scb, 98e5238fd1Smarco void *sgptr, bus_addr_t addr, 99e5238fd1Smarco bus_size_t len, int last); 100e5238fd1Smarco void ahd_setup_scb_common(struct ahd_softc *ahd, 101e5238fd1Smarco struct scb *scb); 102e5238fd1Smarco void ahd_setup_data_scb(struct ahd_softc *ahd, 103e5238fd1Smarco struct scb *scb); 104e5238fd1Smarco void ahd_setup_noxfer_scb(struct ahd_softc *ahd, 105e5238fd1Smarco struct scb *scb); 10656007914Smarco 107e5238fd1Smarco /************************** Memory mapping routines ***************************/ 108e5238fd1Smarco size_t ahd_sg_size(struct ahd_softc *); 109e5238fd1Smarco void * 110e5238fd1Smarco ahd_sg_bus_to_virt(struct ahd_softc *, struct scb *, 111e5238fd1Smarco uint32_t); 112e5238fd1Smarco uint32_t 113e5238fd1Smarco ahd_sg_virt_to_bus(struct ahd_softc *, struct scb *, 114e5238fd1Smarco void *); 115e5238fd1Smarco void ahd_sync_scb(struct ahd_softc *, struct scb *, int); 116e5238fd1Smarco void ahd_sync_sglist(struct ahd_softc *, struct scb *, int); 117e5238fd1Smarco void ahd_sync_sense(struct ahd_softc *, struct scb *, int); 118e5238fd1Smarco uint32_t 119e5238fd1Smarco ahd_targetcmd_offset(struct ahd_softc *, u_int); 12056007914Smarco 121e5238fd1Smarco /*********************** Miscelaneous Support Functions ***********************/ 122e5238fd1Smarco void ahd_complete_scb(struct ahd_softc *, struct scb *); 123e5238fd1Smarco void ahd_update_residual(struct ahd_softc *, struct scb *); 124e5238fd1Smarco struct ahd_initiator_tinfo * 125e5238fd1Smarco ahd_fetch_transinfo(struct ahd_softc *, char , u_int, 126e5238fd1Smarco u_int, struct ahd_tmode_tstate **); 127e5238fd1Smarco uint16_t 128e5238fd1Smarco ahd_inw(struct ahd_softc *, u_int); 129e5238fd1Smarco void ahd_outw(struct ahd_softc *, u_int, u_int); 130e5238fd1Smarco uint32_t 131e5238fd1Smarco ahd_inl(struct ahd_softc *, u_int); 132e5238fd1Smarco void ahd_outl(struct ahd_softc *, u_int, uint32_t); 133e5238fd1Smarco uint64_t ahd_inq(struct ahd_softc *, u_int); 134e5238fd1Smarco void ahd_outq(struct ahd_softc *, u_int, uint64_t); 135e5238fd1Smarco u_int ahd_get_scbptr(struct ahd_softc *ahd); 136e5238fd1Smarco void ahd_set_scbptr(struct ahd_softc *ahd, u_int scbptr); 137e5238fd1Smarco u_int ahd_get_hnscb_qoff(struct ahd_softc *ahd); 138e5238fd1Smarco void ahd_set_hnscb_qoff(struct ahd_softc *ahd, u_int value); 139e5238fd1Smarco u_int ahd_get_hescb_qoff(struct ahd_softc *ahd); 140e5238fd1Smarco void ahd_set_hescb_qoff(struct ahd_softc *ahd, u_int value); 141e5238fd1Smarco u_int ahd_get_snscb_qoff(struct ahd_softc *ahd); 142e5238fd1Smarco void ahd_set_snscb_qoff(struct ahd_softc *ahd, u_int value); 143e5238fd1Smarco u_int ahd_get_sescb_qoff(struct ahd_softc *ahd); 144e5238fd1Smarco void ahd_set_sescb_qoff(struct ahd_softc *ahd, u_int value); 145e5238fd1Smarco u_int ahd_get_sdscb_qoff(struct ahd_softc *ahd); 146e5238fd1Smarco void ahd_set_sdscb_qoff(struct ahd_softc *ahd, u_int value); 147e5238fd1Smarco u_int ahd_inb_scbram(struct ahd_softc *ahd, u_int offset); 148e5238fd1Smarco u_int ahd_inw_scbram(struct ahd_softc *ahd, u_int offset); 149e5238fd1Smarco uint32_t ahd_inl_scbram(struct ahd_softc *ahd, u_int offset); 150e5238fd1Smarco uint64_t ahd_inq_scbram(struct ahd_softc *ahd, u_int offset); 151e5238fd1Smarco struct scb *ahd_lookup_scb(struct ahd_softc *, u_int); 152e5238fd1Smarco void ahd_swap_with_next_hscb(struct ahd_softc *ahd, struct scb *scb); 153e5238fd1Smarco void ahd_queue_scb(struct ahd_softc *ahd, struct scb *scb); 154e5238fd1Smarco uint8_t *ahd_get_sense_buf(struct ahd_softc *ahd, struct scb *scb); 155e5238fd1Smarco uint32_t ahd_get_sense_bufaddr(struct ahd_softc *ahd, struct scb *scb); 15656007914Smarco 157e5238fd1Smarco /************************** Interrupt Processing ******************************/ 158e5238fd1Smarco void ahd_sync_qoutfifo(struct ahd_softc *ahd, int op); 159e5238fd1Smarco void ahd_sync_tqinfifo(struct ahd_softc *ahd, int op); 160e5238fd1Smarco u_int ahd_check_cmdcmpltqueues(struct ahd_softc *ahd); 161e5238fd1Smarco int ahd_intr(struct ahd_softc *ahd); 16256007914Smarco 16356007914Smarco #define AHD_ASSERT_MODES(ahd, source, dest) \ 16456007914Smarco ahd_assert_modes(ahd, source, dest, __FILE__, __LINE__); 16556007914Smarco 16656007914Smarco #endif /* _AIC79XX_INLINE_H_ */ 167