sym_fw.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. /*
  2. * Device driver for the SYMBIOS/LSILOGIC 53C8XX and 53C1010 family
  3. * of PCI-SCSI IO processors.
  4. *
  5. * Copyright (C) 1999-2001 Gerard Roudier <groudier@free.fr>
  6. *
  7. * This driver is derived from the Linux sym53c8xx driver.
  8. * Copyright (C) 1998-2000 Gerard Roudier
  9. *
  10. * The sym53c8xx driver is derived from the ncr53c8xx driver that had been
  11. * a port of the FreeBSD ncr driver to Linux-1.2.13.
  12. *
  13. * The original ncr driver has been written for 386bsd and FreeBSD by
  14. * Wolfgang Stanglmeier <wolf@cologne.de>
  15. * Stefan Esser <se@mi.Uni-Koeln.de>
  16. * Copyright (C) 1994 Wolfgang Stanglmeier
  17. *
  18. * Other major contributions:
  19. *
  20. * NVRAM detection and reading.
  21. * Copyright (C) 1997 Richard Waltham <dormouse@farsrobt.demon.co.uk>
  22. *
  23. *-----------------------------------------------------------------------------
  24. *
  25. * This program is free software; you can redistribute it and/or modify
  26. * it under the terms of the GNU General Public License as published by
  27. * the Free Software Foundation; either version 2 of the License, or
  28. * (at your option) any later version.
  29. *
  30. * This program is distributed in the hope that it will be useful,
  31. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  32. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  33. * GNU General Public License for more details.
  34. *
  35. * You should have received a copy of the GNU General Public License
  36. * along with this program; if not, write to the Free Software
  37. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  38. */
  39. #ifndef SYM_FW_H
  40. #define SYM_FW_H
  41. /*
  42. * Macro used to generate interfaces for script A.
  43. */
  44. #define SYM_GEN_FW_A(s) \
  45. SYM_GEN_A(s, start) SYM_GEN_A(s, getjob_begin) \
  46. SYM_GEN_A(s, getjob_end) \
  47. SYM_GEN_A(s, select) SYM_GEN_A(s, wf_sel_done) \
  48. SYM_GEN_A(s, send_ident) \
  49. SYM_GEN_A(s, dispatch) SYM_GEN_A(s, init) \
  50. SYM_GEN_A(s, clrack) SYM_GEN_A(s, complete_error) \
  51. SYM_GEN_A(s, done) SYM_GEN_A(s, done_end) \
  52. SYM_GEN_A(s, idle) SYM_GEN_A(s, ungetjob) \
  53. SYM_GEN_A(s, reselect) \
  54. SYM_GEN_A(s, resel_tag) SYM_GEN_A(s, resel_dsa) \
  55. SYM_GEN_A(s, resel_no_tag) \
  56. SYM_GEN_A(s, data_in) SYM_GEN_A(s, data_in2) \
  57. SYM_GEN_A(s, data_out) SYM_GEN_A(s, data_out2) \
  58. SYM_GEN_A(s, pm0_data) SYM_GEN_A(s, pm1_data)
  59. /*
  60. * Macro used to generate interfaces for script B.
  61. */
  62. #define SYM_GEN_FW_B(s) \
  63. SYM_GEN_B(s, no_data) \
  64. SYM_GEN_B(s, sel_for_abort) SYM_GEN_B(s, sel_for_abort_1) \
  65. SYM_GEN_B(s, msg_bad) SYM_GEN_B(s, msg_weird) \
  66. SYM_GEN_B(s, wdtr_resp) SYM_GEN_B(s, send_wdtr) \
  67. SYM_GEN_B(s, sdtr_resp) SYM_GEN_B(s, send_sdtr) \
  68. SYM_GEN_B(s, ppr_resp) SYM_GEN_B(s, send_ppr) \
  69. SYM_GEN_B(s, nego_bad_phase) \
  70. SYM_GEN_B(s, ident_break) SYM_GEN_B(s, ident_break_atn) \
  71. SYM_GEN_B(s, sdata_in) SYM_GEN_B(s, resel_bad_lun) \
  72. SYM_GEN_B(s, bad_i_t_l) SYM_GEN_B(s, bad_i_t_l_q) \
  73. SYM_GEN_B(s, wsr_ma_helper)
  74. /*
  75. * Macro used to generate interfaces for script Z.
  76. */
  77. #define SYM_GEN_FW_Z(s) \
  78. SYM_GEN_Z(s, snooptest) SYM_GEN_Z(s, snoopend)
  79. /*
  80. * Generates structure interface that contains
  81. * offsets within script A, B and Z.
  82. */
  83. #define SYM_GEN_A(s, label) s label;
  84. #define SYM_GEN_B(s, label) s label;
  85. #define SYM_GEN_Z(s, label) s label;
  86. struct sym_fwa_ofs {
  87. SYM_GEN_FW_A(u_short)
  88. };
  89. struct sym_fwb_ofs {
  90. SYM_GEN_FW_B(u_short)
  91. SYM_GEN_B(u_short, start64)
  92. SYM_GEN_B(u_short, pm_handle)
  93. };
  94. struct sym_fwz_ofs {
  95. SYM_GEN_FW_Z(u_short)
  96. };
  97. /*
  98. * Generates structure interface that contains
  99. * bus addresses within script A, B and Z.
  100. */
  101. struct sym_fwa_ba {
  102. SYM_GEN_FW_A(u32)
  103. };
  104. struct sym_fwb_ba {
  105. SYM_GEN_FW_B(u32)
  106. SYM_GEN_B(u32, start64);
  107. SYM_GEN_B(u32, pm_handle);
  108. };
  109. struct sym_fwz_ba {
  110. SYM_GEN_FW_Z(u32)
  111. };
  112. #undef SYM_GEN_A
  113. #undef SYM_GEN_B
  114. #undef SYM_GEN_Z
  115. /*
  116. * Let cc know about the name of the controller data structure.
  117. * We need this for function prototype declarations just below.
  118. */
  119. struct sym_hcb;
  120. /*
  121. * Generic structure that defines a firmware.
  122. */
  123. struct sym_fw {
  124. char *name; /* Name we want to print out */
  125. u32 *a_base; /* Pointer to script A template */
  126. int a_size; /* Size of script A */
  127. struct sym_fwa_ofs
  128. *a_ofs; /* Useful offsets in script A */
  129. u32 *b_base; /* Pointer to script B template */
  130. int b_size; /* Size of script B */
  131. struct sym_fwb_ofs
  132. *b_ofs; /* Useful offsets in script B */
  133. u32 *z_base; /* Pointer to script Z template */
  134. int z_size; /* Size of script Z */
  135. struct sym_fwz_ofs
  136. *z_ofs; /* Useful offsets in script Z */
  137. /* Setup and patch methods for this firmware */
  138. void (*setup)(struct sym_hcb *, struct sym_fw *);
  139. void (*patch)(struct Scsi_Host *);
  140. };
  141. /*
  142. * Macro used to declare a firmware.
  143. */
  144. #define SYM_FW_ENTRY(fw, name) \
  145. { \
  146. name, \
  147. (u32 *) &fw##a_scr, sizeof(fw##a_scr), &fw##a_ofs, \
  148. (u32 *) &fw##b_scr, sizeof(fw##b_scr), &fw##b_ofs, \
  149. (u32 *) &fw##z_scr, sizeof(fw##z_scr), &fw##z_ofs, \
  150. fw##_setup, fw##_patch \
  151. }
  152. /*
  153. * Macros used from the C code to get useful
  154. * SCRIPTS bus addresses.
  155. */
  156. #define SCRIPTA_BA(np, label) (np->fwa_bas.label)
  157. #define SCRIPTB_BA(np, label) (np->fwb_bas.label)
  158. #define SCRIPTZ_BA(np, label) (np->fwz_bas.label)
  159. /*
  160. * Macros used by scripts definitions.
  161. *
  162. * HADDR_1 generates a reference to a field of the controller data.
  163. * HADDR_2 generates a reference to a field of the controller data
  164. * with offset.
  165. * RADDR_1 generates a reference to a script processor register.
  166. * RADDR_2 generates a reference to a script processor register
  167. * with offset.
  168. * PADDR_A generates a reference to another part of script A.
  169. * PADDR_B generates a reference to another part of script B.
  170. *
  171. * SYM_GEN_PADDR_A and SYM_GEN_PADDR_B are used to define respectively
  172. * the PADDR_A and PADDR_B macros for each firmware by setting argument
  173. * `s' to the name of the corresponding structure.
  174. *
  175. * SCR_DATA_ZERO is used to allocate a DWORD of data in scripts areas.
  176. */
  177. #define RELOC_SOFTC 0x40000000
  178. #define RELOC_LABEL_A 0x50000000
  179. #define RELOC_REGISTER 0x60000000
  180. #define RELOC_LABEL_B 0x80000000
  181. #define RELOC_MASK 0xf0000000
  182. #define HADDR_1(label) (RELOC_SOFTC | offsetof(struct sym_hcb, label))
  183. #define HADDR_2(label,ofs) (RELOC_SOFTC | \
  184. (offsetof(struct sym_hcb, label)+(ofs)))
  185. #define RADDR_1(label) (RELOC_REGISTER | REG(label))
  186. #define RADDR_2(label,ofs) (RELOC_REGISTER | ((REG(label))+(ofs)))
  187. #define SYM_GEN_PADDR_A(s, label) (RELOC_LABEL_A | offsetof(s, label))
  188. #define SYM_GEN_PADDR_B(s, label) (RELOC_LABEL_B | offsetof(s, label))
  189. #define SCR_DATA_ZERO 0xf00ff00f
  190. #endif /* SYM_FW_H */