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