aic79xx_inline.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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. #ifndef _AIC79XX_INLINE_H_
  45. #define _AIC79XX_INLINE_H_
  46. /******************************** Debugging ***********************************/
  47. static __inline char *ahd_name(struct ahd_softc *ahd);
  48. static __inline char *
  49. ahd_name(struct ahd_softc *ahd)
  50. {
  51. return (ahd->name);
  52. }
  53. /************************ Sequencer Execution Control *************************/
  54. static __inline void ahd_known_modes(struct ahd_softc *ahd,
  55. ahd_mode src, ahd_mode dst);
  56. static __inline ahd_mode_state ahd_build_mode_state(struct ahd_softc *ahd,
  57. ahd_mode src,
  58. ahd_mode dst);
  59. static __inline void ahd_extract_mode_state(struct ahd_softc *ahd,
  60. ahd_mode_state state,
  61. ahd_mode *src, ahd_mode *dst);
  62. void ahd_set_modes(struct ahd_softc *ahd, ahd_mode src,
  63. ahd_mode dst);
  64. ahd_mode_state ahd_save_modes(struct ahd_softc *ahd);
  65. void ahd_restore_modes(struct ahd_softc *ahd,
  66. ahd_mode_state state);
  67. int ahd_is_paused(struct ahd_softc *ahd);
  68. void ahd_pause(struct ahd_softc *ahd);
  69. void ahd_unpause(struct ahd_softc *ahd);
  70. static __inline void
  71. ahd_known_modes(struct ahd_softc *ahd, ahd_mode src, ahd_mode dst)
  72. {
  73. ahd->src_mode = src;
  74. ahd->dst_mode = dst;
  75. ahd->saved_src_mode = src;
  76. ahd->saved_dst_mode = dst;
  77. }
  78. static __inline ahd_mode_state
  79. ahd_build_mode_state(struct ahd_softc *ahd, ahd_mode src, ahd_mode dst)
  80. {
  81. return ((src << SRC_MODE_SHIFT) | (dst << DST_MODE_SHIFT));
  82. }
  83. static __inline void
  84. ahd_extract_mode_state(struct ahd_softc *ahd, ahd_mode_state state,
  85. ahd_mode *src, ahd_mode *dst)
  86. {
  87. *src = (state & SRC_MODE) >> SRC_MODE_SHIFT;
  88. *dst = (state & DST_MODE) >> DST_MODE_SHIFT;
  89. }
  90. /*********************** Scatter Gather List Handling *************************/
  91. void *ahd_sg_setup(struct ahd_softc *ahd, struct scb *scb,
  92. void *sgptr, dma_addr_t addr,
  93. bus_size_t len, int last);
  94. /************************** Memory mapping routines ***************************/
  95. static __inline size_t ahd_sg_size(struct ahd_softc *ahd);
  96. void ahd_sync_sglist(struct ahd_softc *ahd,
  97. struct scb *scb, int op);
  98. static __inline size_t
  99. ahd_sg_size(struct ahd_softc *ahd)
  100. {
  101. if ((ahd->flags & AHD_64BIT_ADDRESSING) != 0)
  102. return (sizeof(struct ahd_dma64_seg));
  103. return (sizeof(struct ahd_dma_seg));
  104. }
  105. /*********************** Miscellaneous Support Functions ***********************/
  106. struct ahd_initiator_tinfo *
  107. ahd_fetch_transinfo(struct ahd_softc *ahd,
  108. char channel, u_int our_id,
  109. u_int remote_id,
  110. struct ahd_tmode_tstate **tstate);
  111. uint16_t
  112. ahd_inw(struct ahd_softc *ahd, u_int port);
  113. void ahd_outw(struct ahd_softc *ahd, u_int port,
  114. u_int value);
  115. uint32_t
  116. ahd_inl(struct ahd_softc *ahd, u_int port);
  117. void ahd_outl(struct ahd_softc *ahd, u_int port,
  118. uint32_t value);
  119. uint64_t
  120. ahd_inq(struct ahd_softc *ahd, u_int port);
  121. void ahd_outq(struct ahd_softc *ahd, u_int port,
  122. uint64_t value);
  123. u_int ahd_get_scbptr(struct ahd_softc *ahd);
  124. void ahd_set_scbptr(struct ahd_softc *ahd, u_int scbptr);
  125. u_int ahd_inb_scbram(struct ahd_softc *ahd, u_int offset);
  126. u_int ahd_inw_scbram(struct ahd_softc *ahd, u_int offset);
  127. struct scb *
  128. ahd_lookup_scb(struct ahd_softc *ahd, u_int tag);
  129. void ahd_queue_scb(struct ahd_softc *ahd, struct scb *scb);
  130. static __inline uint8_t *
  131. ahd_get_sense_buf(struct ahd_softc *ahd,
  132. struct scb *scb);
  133. static __inline uint32_t
  134. ahd_get_sense_bufaddr(struct ahd_softc *ahd,
  135. struct scb *scb);
  136. #if 0 /* unused */
  137. #define AHD_COPY_COL_IDX(dst, src) \
  138. do { \
  139. dst->hscb->scsiid = src->hscb->scsiid; \
  140. dst->hscb->lun = src->hscb->lun; \
  141. } while (0)
  142. #endif
  143. static __inline uint8_t *
  144. ahd_get_sense_buf(struct ahd_softc *ahd, struct scb *scb)
  145. {
  146. return (scb->sense_data);
  147. }
  148. static __inline uint32_t
  149. ahd_get_sense_bufaddr(struct ahd_softc *ahd, struct scb *scb)
  150. {
  151. return (scb->sense_busaddr);
  152. }
  153. /************************** Interrupt Processing ******************************/
  154. int ahd_intr(struct ahd_softc *ahd);
  155. #endif /* _AIC79XX_INLINE_H_ */