aic79xx_inline.h 5.9 KB

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