sym_fw2.h 48 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875
  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. /*
  40. * Scripts for SYMBIOS-Processor
  41. *
  42. * We have to know the offsets of all labels before we reach
  43. * them (for forward jumps). Therefore we declare a struct
  44. * here. If you make changes inside the script,
  45. *
  46. * DONT FORGET TO CHANGE THE LENGTHS HERE!
  47. */
  48. /*
  49. * Script fragments which are loaded into the on-chip RAM
  50. * of 825A, 875, 876, 895, 895A, 896 and 1010 chips.
  51. * Must not exceed 4K bytes.
  52. */
  53. struct SYM_FWA_SCR {
  54. u32 start [ 14];
  55. u32 getjob_begin [ 4];
  56. u32 getjob_end [ 4];
  57. #ifdef SYM_CONF_TARGET_ROLE_SUPPORT
  58. u32 select [ 6];
  59. #else
  60. u32 select [ 4];
  61. #endif
  62. #if SYM_CONF_DMA_ADDRESSING_MODE == 2
  63. u32 is_dmap_dirty [ 4];
  64. #endif
  65. u32 wf_sel_done [ 2];
  66. u32 sel_done [ 2];
  67. u32 send_ident [ 2];
  68. #ifdef SYM_CONF_IARB_SUPPORT
  69. u32 select2 [ 8];
  70. #else
  71. u32 select2 [ 2];
  72. #endif
  73. u32 command [ 2];
  74. u32 dispatch [ 28];
  75. u32 sel_no_cmd [ 10];
  76. u32 init [ 6];
  77. u32 clrack [ 4];
  78. u32 datai_done [ 10];
  79. u32 datai_done_wsr [ 20];
  80. u32 datao_done [ 10];
  81. u32 datao_done_wss [ 6];
  82. u32 datai_phase [ 4];
  83. u32 datao_phase [ 6];
  84. u32 msg_in [ 2];
  85. u32 msg_in2 [ 10];
  86. #ifdef SYM_CONF_IARB_SUPPORT
  87. u32 status [ 14];
  88. #else
  89. u32 status [ 10];
  90. #endif
  91. u32 complete [ 6];
  92. u32 complete2 [ 12];
  93. u32 done [ 14];
  94. u32 done_end [ 2];
  95. u32 complete_error [ 4];
  96. u32 save_dp [ 12];
  97. u32 restore_dp [ 8];
  98. u32 disconnect [ 12];
  99. #ifdef SYM_CONF_IARB_SUPPORT
  100. u32 idle [ 4];
  101. #else
  102. u32 idle [ 2];
  103. #endif
  104. #ifdef SYM_CONF_IARB_SUPPORT
  105. u32 ungetjob [ 6];
  106. #else
  107. u32 ungetjob [ 4];
  108. #endif
  109. #ifdef SYM_CONF_TARGET_ROLE_SUPPORT
  110. u32 reselect [ 4];
  111. #else
  112. u32 reselect [ 2];
  113. #endif
  114. u32 reselected [ 22];
  115. u32 resel_scntl4 [ 20];
  116. u32 resel_lun0 [ 6];
  117. #if SYM_CONF_MAX_TASK*4 > 512
  118. u32 resel_tag [ 26];
  119. #elif SYM_CONF_MAX_TASK*4 > 256
  120. u32 resel_tag [ 20];
  121. #else
  122. u32 resel_tag [ 16];
  123. #endif
  124. u32 resel_dsa [ 2];
  125. u32 resel_dsa1 [ 4];
  126. u32 resel_no_tag [ 6];
  127. u32 data_in [SYM_CONF_MAX_SG * 2];
  128. u32 data_in2 [ 4];
  129. u32 data_out [SYM_CONF_MAX_SG * 2];
  130. u32 data_out2 [ 4];
  131. u32 pm0_data [ 12];
  132. u32 pm0_data_out [ 6];
  133. u32 pm0_data_end [ 6];
  134. u32 pm1_data [ 12];
  135. u32 pm1_data_out [ 6];
  136. u32 pm1_data_end [ 6];
  137. };
  138. /*
  139. * Script fragments which stay in main memory for all chips
  140. * except for chips that support 8K on-chip RAM.
  141. */
  142. struct SYM_FWB_SCR {
  143. u32 start64 [ 2];
  144. u32 no_data [ 2];
  145. #ifdef SYM_CONF_TARGET_ROLE_SUPPORT
  146. u32 sel_for_abort [ 18];
  147. #else
  148. u32 sel_for_abort [ 16];
  149. #endif
  150. u32 sel_for_abort_1 [ 2];
  151. u32 msg_in_etc [ 12];
  152. u32 msg_received [ 4];
  153. u32 msg_weird_seen [ 4];
  154. u32 msg_extended [ 20];
  155. u32 msg_bad [ 6];
  156. u32 msg_weird [ 4];
  157. u32 msg_weird1 [ 8];
  158. u32 wdtr_resp [ 6];
  159. u32 send_wdtr [ 4];
  160. u32 sdtr_resp [ 6];
  161. u32 send_sdtr [ 4];
  162. u32 ppr_resp [ 6];
  163. u32 send_ppr [ 4];
  164. u32 nego_bad_phase [ 4];
  165. u32 msg_out [ 4];
  166. u32 msg_out_done [ 4];
  167. u32 data_ovrun [ 2];
  168. u32 data_ovrun1 [ 22];
  169. u32 data_ovrun2 [ 8];
  170. u32 abort_resel [ 16];
  171. u32 resend_ident [ 4];
  172. u32 ident_break [ 4];
  173. u32 ident_break_atn [ 4];
  174. u32 sdata_in [ 6];
  175. u32 resel_bad_lun [ 4];
  176. u32 bad_i_t_l [ 4];
  177. u32 bad_i_t_l_q [ 4];
  178. u32 bad_status [ 6];
  179. u32 pm_handle [ 20];
  180. u32 pm_handle1 [ 4];
  181. u32 pm_save [ 4];
  182. u32 pm0_save [ 12];
  183. u32 pm_save_end [ 4];
  184. u32 pm1_save [ 14];
  185. /* WSR handling */
  186. u32 pm_wsr_handle [ 38];
  187. u32 wsr_ma_helper [ 4];
  188. /* Data area */
  189. u32 zero [ 1];
  190. u32 scratch [ 1];
  191. u32 pm0_data_addr [ 1];
  192. u32 pm1_data_addr [ 1];
  193. u32 done_pos [ 1];
  194. u32 startpos [ 1];
  195. u32 targtbl [ 1];
  196. };
  197. /*
  198. * Script fragments used at initialisations.
  199. * Only runs out of main memory.
  200. */
  201. struct SYM_FWZ_SCR {
  202. u32 snooptest [ 6];
  203. u32 snoopend [ 2];
  204. };
  205. static struct SYM_FWA_SCR SYM_FWA_SCR = {
  206. /*--------------------------< START >----------------------------*/ {
  207. /*
  208. * Switch the LED on.
  209. * Will be patched with a NO_OP if LED
  210. * not needed or not desired.
  211. */
  212. SCR_REG_REG (gpreg, SCR_AND, 0xfe),
  213. 0,
  214. /*
  215. * Clear SIGP.
  216. */
  217. SCR_FROM_REG (ctest2),
  218. 0,
  219. /*
  220. * Stop here if the C code wants to perform
  221. * some error recovery procedure manually.
  222. * (Indicate this by setting SEM in ISTAT)
  223. */
  224. SCR_FROM_REG (istat),
  225. 0,
  226. /*
  227. * Report to the C code the next position in
  228. * the start queue the SCRIPTS will schedule.
  229. * The C code must not change SCRATCHA.
  230. */
  231. SCR_LOAD_ABS (scratcha, 4),
  232. PADDR_B (startpos),
  233. SCR_INT ^ IFTRUE (MASK (SEM, SEM)),
  234. SIR_SCRIPT_STOPPED,
  235. /*
  236. * Start the next job.
  237. *
  238. * @DSA = start point for this job.
  239. * SCRATCHA = address of this job in the start queue.
  240. *
  241. * We will restore startpos with SCRATCHA if we fails the
  242. * arbitration or if it is the idle job.
  243. *
  244. * The below GETJOB_BEGIN to GETJOB_END section of SCRIPTS
  245. * is a critical path. If it is partially executed, it then
  246. * may happen that the job address is not yet in the DSA
  247. * and the next queue position points to the next JOB.
  248. */
  249. SCR_LOAD_ABS (dsa, 4),
  250. PADDR_B (startpos),
  251. SCR_LOAD_REL (temp, 4),
  252. 4,
  253. }/*-------------------------< GETJOB_BEGIN >---------------------*/,{
  254. SCR_STORE_ABS (temp, 4),
  255. PADDR_B (startpos),
  256. SCR_LOAD_REL (dsa, 4),
  257. 0,
  258. }/*-------------------------< GETJOB_END >-----------------------*/,{
  259. SCR_LOAD_REL (temp, 4),
  260. 0,
  261. SCR_RETURN,
  262. 0,
  263. }/*-------------------------< SELECT >---------------------------*/,{
  264. /*
  265. * DSA contains the address of a scheduled
  266. * data structure.
  267. *
  268. * SCRATCHA contains the address of the start queue
  269. * entry which points to the next job.
  270. *
  271. * Set Initiator mode.
  272. *
  273. * (Target mode is left as an exercise for the reader)
  274. */
  275. #ifdef SYM_CONF_TARGET_ROLE_SUPPORT
  276. SCR_CLR (SCR_TRG),
  277. 0,
  278. #endif
  279. /*
  280. * And try to select this target.
  281. */
  282. SCR_SEL_TBL_ATN ^ offsetof (struct sym_dsb, select),
  283. PADDR_A (ungetjob),
  284. /*
  285. * Now there are 4 possibilities:
  286. *
  287. * (1) The chip loses arbitration.
  288. * This is ok, because it will try again,
  289. * when the bus becomes idle.
  290. * (But beware of the timeout function!)
  291. *
  292. * (2) The chip is reselected.
  293. * Then the script processor takes the jump
  294. * to the RESELECT label.
  295. *
  296. * (3) The chip wins arbitration.
  297. * Then it will execute SCRIPTS instruction until
  298. * the next instruction that checks SCSI phase.
  299. * Then will stop and wait for selection to be
  300. * complete or selection time-out to occur.
  301. *
  302. * After having won arbitration, the SCRIPTS
  303. * processor is able to execute instructions while
  304. * the SCSI core is performing SCSI selection.
  305. */
  306. /*
  307. * Initialize the status registers
  308. */
  309. SCR_LOAD_REL (scr0, 4),
  310. offsetof (struct sym_ccb, phys.head.status),
  311. /*
  312. * We may need help from CPU if the DMA segment
  313. * registers aren't up-to-date for this IO.
  314. * Patched with NOOP for chips that donnot
  315. * support DAC addressing.
  316. */
  317. #if SYM_CONF_DMA_ADDRESSING_MODE == 2
  318. }/*-------------------------< IS_DMAP_DIRTY >--------------------*/,{
  319. SCR_FROM_REG (HX_REG),
  320. 0,
  321. SCR_INT ^ IFTRUE (MASK (HX_DMAP_DIRTY, HX_DMAP_DIRTY)),
  322. SIR_DMAP_DIRTY,
  323. #endif
  324. }/*-------------------------< WF_SEL_DONE >----------------------*/,{
  325. SCR_INT ^ IFFALSE (WHEN (SCR_MSG_OUT)),
  326. SIR_SEL_ATN_NO_MSG_OUT,
  327. }/*-------------------------< SEL_DONE >-------------------------*/,{
  328. /*
  329. * C1010-33 errata work-around.
  330. * Due to a race, the SCSI core may not have
  331. * loaded SCNTL3 on SEL_TBL instruction.
  332. * We reload it once phase is stable.
  333. * Patched with a NOOP for other chips.
  334. */
  335. SCR_LOAD_REL (scntl3, 1),
  336. offsetof(struct sym_dsb, select.sel_scntl3),
  337. }/*-------------------------< SEND_IDENT >-----------------------*/,{
  338. /*
  339. * Selection complete.
  340. * Send the IDENTIFY and possibly the TAG message
  341. * and negotiation message if present.
  342. */
  343. SCR_MOVE_TBL ^ SCR_MSG_OUT,
  344. offsetof (struct sym_dsb, smsg),
  345. }/*-------------------------< SELECT2 >--------------------------*/,{
  346. #ifdef SYM_CONF_IARB_SUPPORT
  347. /*
  348. * Set IMMEDIATE ARBITRATION if we have been given
  349. * a hint to do so. (Some job to do after this one).
  350. */
  351. SCR_FROM_REG (HF_REG),
  352. 0,
  353. SCR_JUMPR ^ IFFALSE (MASK (HF_HINT_IARB, HF_HINT_IARB)),
  354. 8,
  355. SCR_REG_REG (scntl1, SCR_OR, IARB),
  356. 0,
  357. #endif
  358. /*
  359. * Anticipate the COMMAND phase.
  360. * This is the PHASE we expect at this point.
  361. */
  362. SCR_JUMP ^ IFFALSE (WHEN (SCR_COMMAND)),
  363. PADDR_A (sel_no_cmd),
  364. }/*-------------------------< COMMAND >--------------------------*/,{
  365. /*
  366. * ... and send the command
  367. */
  368. SCR_MOVE_TBL ^ SCR_COMMAND,
  369. offsetof (struct sym_dsb, cmd),
  370. }/*-------------------------< DISPATCH >-------------------------*/,{
  371. /*
  372. * MSG_IN is the only phase that shall be
  373. * entered at least once for each (re)selection.
  374. * So we test it first.
  375. */
  376. SCR_JUMP ^ IFTRUE (WHEN (SCR_MSG_IN)),
  377. PADDR_A (msg_in),
  378. SCR_JUMP ^ IFTRUE (IF (SCR_DATA_OUT)),
  379. PADDR_A (datao_phase),
  380. SCR_JUMP ^ IFTRUE (IF (SCR_DATA_IN)),
  381. PADDR_A (datai_phase),
  382. SCR_JUMP ^ IFTRUE (IF (SCR_STATUS)),
  383. PADDR_A (status),
  384. SCR_JUMP ^ IFTRUE (IF (SCR_COMMAND)),
  385. PADDR_A (command),
  386. SCR_JUMP ^ IFTRUE (IF (SCR_MSG_OUT)),
  387. PADDR_B (msg_out),
  388. /*
  389. * Discard as many illegal phases as
  390. * required and tell the C code about.
  391. */
  392. SCR_JUMPR ^ IFFALSE (WHEN (SCR_ILG_OUT)),
  393. 16,
  394. SCR_MOVE_ABS (1) ^ SCR_ILG_OUT,
  395. HADDR_1 (scratch),
  396. SCR_JUMPR ^ IFTRUE (WHEN (SCR_ILG_OUT)),
  397. -16,
  398. SCR_JUMPR ^ IFFALSE (WHEN (SCR_ILG_IN)),
  399. 16,
  400. SCR_MOVE_ABS (1) ^ SCR_ILG_IN,
  401. HADDR_1 (scratch),
  402. SCR_JUMPR ^ IFTRUE (WHEN (SCR_ILG_IN)),
  403. -16,
  404. SCR_INT,
  405. SIR_BAD_PHASE,
  406. SCR_JUMP,
  407. PADDR_A (dispatch),
  408. }/*-------------------------< SEL_NO_CMD >-----------------------*/,{
  409. /*
  410. * The target does not switch to command
  411. * phase after IDENTIFY has been sent.
  412. *
  413. * If it stays in MSG OUT phase send it
  414. * the IDENTIFY again.
  415. */
  416. SCR_JUMP ^ IFTRUE (WHEN (SCR_MSG_OUT)),
  417. PADDR_B (resend_ident),
  418. /*
  419. * If target does not switch to MSG IN phase
  420. * and we sent a negotiation, assert the
  421. * failure immediately.
  422. */
  423. SCR_JUMP ^ IFTRUE (WHEN (SCR_MSG_IN)),
  424. PADDR_A (dispatch),
  425. SCR_FROM_REG (HS_REG),
  426. 0,
  427. SCR_INT ^ IFTRUE (DATA (HS_NEGOTIATE)),
  428. SIR_NEGO_FAILED,
  429. /*
  430. * Jump to dispatcher.
  431. */
  432. SCR_JUMP,
  433. PADDR_A (dispatch),
  434. }/*-------------------------< INIT >-----------------------------*/,{
  435. /*
  436. * Wait for the SCSI RESET signal to be
  437. * inactive before restarting operations,
  438. * since the chip may hang on SEL_ATN
  439. * if SCSI RESET is active.
  440. */
  441. SCR_FROM_REG (sstat0),
  442. 0,
  443. SCR_JUMPR ^ IFTRUE (MASK (IRST, IRST)),
  444. -16,
  445. SCR_JUMP,
  446. PADDR_A (start),
  447. }/*-------------------------< CLRACK >---------------------------*/,{
  448. /*
  449. * Terminate possible pending message phase.
  450. */
  451. SCR_CLR (SCR_ACK),
  452. 0,
  453. SCR_JUMP,
  454. PADDR_A (dispatch),
  455. }/*-------------------------< DATAI_DONE >-----------------------*/,{
  456. /*
  457. * Save current pointer to LASTP.
  458. */
  459. SCR_STORE_REL (temp, 4),
  460. offsetof (struct sym_ccb, phys.head.lastp),
  461. /*
  462. * If the SWIDE is not full, jump to dispatcher.
  463. * We anticipate a STATUS phase.
  464. */
  465. SCR_FROM_REG (scntl2),
  466. 0,
  467. SCR_JUMP ^ IFTRUE (MASK (WSR, WSR)),
  468. PADDR_A (datai_done_wsr),
  469. SCR_JUMP ^ IFTRUE (WHEN (SCR_STATUS)),
  470. PADDR_A (status),
  471. SCR_JUMP,
  472. PADDR_A (dispatch),
  473. }/*-------------------------< DATAI_DONE_WSR >-------------------*/,{
  474. /*
  475. * The SWIDE is full.
  476. * Clear this condition.
  477. */
  478. SCR_REG_REG (scntl2, SCR_OR, WSR),
  479. 0,
  480. /*
  481. * We are expecting an IGNORE RESIDUE message
  482. * from the device, otherwise we are in data
  483. * overrun condition. Check against MSG_IN phase.
  484. */
  485. SCR_INT ^ IFFALSE (WHEN (SCR_MSG_IN)),
  486. SIR_SWIDE_OVERRUN,
  487. SCR_JUMP ^ IFFALSE (WHEN (SCR_MSG_IN)),
  488. PADDR_A (dispatch),
  489. /*
  490. * We are in MSG_IN phase,
  491. * Read the first byte of the message.
  492. * If it is not an IGNORE RESIDUE message,
  493. * signal overrun and jump to message
  494. * processing.
  495. */
  496. SCR_MOVE_ABS (1) ^ SCR_MSG_IN,
  497. HADDR_1 (msgin[0]),
  498. SCR_INT ^ IFFALSE (DATA (M_IGN_RESIDUE)),
  499. SIR_SWIDE_OVERRUN,
  500. SCR_JUMP ^ IFFALSE (DATA (M_IGN_RESIDUE)),
  501. PADDR_A (msg_in2),
  502. /*
  503. * We got the message we expected.
  504. * Read the 2nd byte, and jump to dispatcher.
  505. */
  506. SCR_CLR (SCR_ACK),
  507. 0,
  508. SCR_MOVE_ABS (1) ^ SCR_MSG_IN,
  509. HADDR_1 (msgin[1]),
  510. SCR_CLR (SCR_ACK),
  511. 0,
  512. SCR_JUMP,
  513. PADDR_A (dispatch),
  514. }/*-------------------------< DATAO_DONE >-----------------------*/,{
  515. /*
  516. * Save current pointer to LASTP.
  517. */
  518. SCR_STORE_REL (temp, 4),
  519. offsetof (struct sym_ccb, phys.head.lastp),
  520. /*
  521. * If the SODL is not full jump to dispatcher.
  522. * We anticipate a STATUS phase.
  523. */
  524. SCR_FROM_REG (scntl2),
  525. 0,
  526. SCR_JUMP ^ IFTRUE (MASK (WSS, WSS)),
  527. PADDR_A (datao_done_wss),
  528. SCR_JUMP ^ IFTRUE (WHEN (SCR_STATUS)),
  529. PADDR_A (status),
  530. SCR_JUMP,
  531. PADDR_A (dispatch),
  532. }/*-------------------------< DATAO_DONE_WSS >-------------------*/,{
  533. /*
  534. * The SODL is full, clear this condition.
  535. */
  536. SCR_REG_REG (scntl2, SCR_OR, WSS),
  537. 0,
  538. /*
  539. * And signal a DATA UNDERRUN condition
  540. * to the C code.
  541. */
  542. SCR_INT,
  543. SIR_SODL_UNDERRUN,
  544. SCR_JUMP,
  545. PADDR_A (dispatch),
  546. }/*-------------------------< DATAI_PHASE >----------------------*/,{
  547. /*
  548. * Jump to current pointer.
  549. */
  550. SCR_LOAD_REL (temp, 4),
  551. offsetof (struct sym_ccb, phys.head.lastp),
  552. SCR_RETURN,
  553. 0,
  554. }/*-------------------------< DATAO_PHASE >----------------------*/,{
  555. /*
  556. * C1010-66 errata work-around.
  557. * Extra clocks of data hold must be inserted
  558. * in DATA OUT phase on 33 MHz PCI BUS.
  559. * Patched with a NOOP for other chips.
  560. */
  561. SCR_REG_REG (scntl4, SCR_OR, (XCLKH_DT|XCLKH_ST)),
  562. 0,
  563. /*
  564. * Jump to current pointer.
  565. */
  566. SCR_LOAD_REL (temp, 4),
  567. offsetof (struct sym_ccb, phys.head.lastp),
  568. SCR_RETURN,
  569. 0,
  570. }/*-------------------------< MSG_IN >---------------------------*/,{
  571. /*
  572. * Get the first byte of the message.
  573. *
  574. * The script processor doesn't negate the
  575. * ACK signal after this transfer.
  576. */
  577. SCR_MOVE_ABS (1) ^ SCR_MSG_IN,
  578. HADDR_1 (msgin[0]),
  579. }/*-------------------------< MSG_IN2 >--------------------------*/,{
  580. /*
  581. * Check first against 1 byte messages
  582. * that we handle from SCRIPTS.
  583. */
  584. SCR_JUMP ^ IFTRUE (DATA (M_COMPLETE)),
  585. PADDR_A (complete),
  586. SCR_JUMP ^ IFTRUE (DATA (M_DISCONNECT)),
  587. PADDR_A (disconnect),
  588. SCR_JUMP ^ IFTRUE (DATA (M_SAVE_DP)),
  589. PADDR_A (save_dp),
  590. SCR_JUMP ^ IFTRUE (DATA (M_RESTORE_DP)),
  591. PADDR_A (restore_dp),
  592. /*
  593. * We handle all other messages from the
  594. * C code, so no need to waste on-chip RAM
  595. * for those ones.
  596. */
  597. SCR_JUMP,
  598. PADDR_B (msg_in_etc),
  599. }/*-------------------------< STATUS >---------------------------*/,{
  600. /*
  601. * get the status
  602. */
  603. SCR_MOVE_ABS (1) ^ SCR_STATUS,
  604. HADDR_1 (scratch),
  605. #ifdef SYM_CONF_IARB_SUPPORT
  606. /*
  607. * If STATUS is not GOOD, clear IMMEDIATE ARBITRATION,
  608. * since we may have to tamper the start queue from
  609. * the C code.
  610. */
  611. SCR_JUMPR ^ IFTRUE (DATA (S_GOOD)),
  612. 8,
  613. SCR_REG_REG (scntl1, SCR_AND, ~IARB),
  614. 0,
  615. #endif
  616. /*
  617. * save status to scsi_status.
  618. * mark as complete.
  619. */
  620. SCR_TO_REG (SS_REG),
  621. 0,
  622. SCR_LOAD_REG (HS_REG, HS_COMPLETE),
  623. 0,
  624. /*
  625. * Anticipate the MESSAGE PHASE for
  626. * the TASK COMPLETE message.
  627. */
  628. SCR_JUMP ^ IFTRUE (WHEN (SCR_MSG_IN)),
  629. PADDR_A (msg_in),
  630. SCR_JUMP,
  631. PADDR_A (dispatch),
  632. }/*-------------------------< COMPLETE >-------------------------*/,{
  633. /*
  634. * Complete message.
  635. *
  636. * When we terminate the cycle by clearing ACK,
  637. * the target may disconnect immediately.
  638. *
  639. * We don't want to be told of an "unexpected disconnect",
  640. * so we disable this feature.
  641. */
  642. SCR_REG_REG (scntl2, SCR_AND, 0x7f),
  643. 0,
  644. /*
  645. * Terminate cycle ...
  646. */
  647. SCR_CLR (SCR_ACK|SCR_ATN),
  648. 0,
  649. /*
  650. * ... and wait for the disconnect.
  651. */
  652. SCR_WAIT_DISC,
  653. 0,
  654. }/*-------------------------< COMPLETE2 >------------------------*/,{
  655. /*
  656. * Save host status.
  657. */
  658. SCR_STORE_REL (scr0, 4),
  659. offsetof (struct sym_ccb, phys.head.status),
  660. /*
  661. * Some bridges may reorder DMA writes to memory.
  662. * We donnot want the CPU to deal with completions
  663. * without all the posted write having been flushed
  664. * to memory. This DUMMY READ should flush posted
  665. * buffers prior to the CPU having to deal with
  666. * completions.
  667. */
  668. SCR_LOAD_REL (scr0, 4), /* DUMMY READ */
  669. offsetof (struct sym_ccb, phys.head.status),
  670. /*
  671. * If command resulted in not GOOD status,
  672. * call the C code if needed.
  673. */
  674. SCR_FROM_REG (SS_REG),
  675. 0,
  676. SCR_CALL ^ IFFALSE (DATA (S_GOOD)),
  677. PADDR_B (bad_status),
  678. /*
  679. * If we performed an auto-sense, call
  680. * the C code to synchronyze task aborts
  681. * with UNIT ATTENTION conditions.
  682. */
  683. SCR_FROM_REG (HF_REG),
  684. 0,
  685. SCR_JUMP ^ IFFALSE (MASK (0 ,(HF_SENSE|HF_EXT_ERR))),
  686. PADDR_A (complete_error),
  687. }/*-------------------------< DONE >-----------------------------*/,{
  688. /*
  689. * Copy the DSA to the DONE QUEUE and
  690. * signal completion to the host.
  691. * If we are interrupted between DONE
  692. * and DONE_END, we must reset, otherwise
  693. * the completed CCB may be lost.
  694. */
  695. SCR_STORE_ABS (dsa, 4),
  696. PADDR_B (scratch),
  697. SCR_LOAD_ABS (dsa, 4),
  698. PADDR_B (done_pos),
  699. SCR_LOAD_ABS (scratcha, 4),
  700. PADDR_B (scratch),
  701. SCR_STORE_REL (scratcha, 4),
  702. 0,
  703. /*
  704. * The instruction below reads the DONE QUEUE next
  705. * free position from memory.
  706. * In addition it ensures that all PCI posted writes
  707. * are flushed and so the DSA value of the done
  708. * CCB is visible by the CPU before INTFLY is raised.
  709. */
  710. SCR_LOAD_REL (scratcha, 4),
  711. 4,
  712. SCR_INT_FLY,
  713. 0,
  714. SCR_STORE_ABS (scratcha, 4),
  715. PADDR_B (done_pos),
  716. }/*-------------------------< DONE_END >-------------------------*/,{
  717. SCR_JUMP,
  718. PADDR_A (start),
  719. }/*-------------------------< COMPLETE_ERROR >-------------------*/,{
  720. SCR_LOAD_ABS (scratcha, 4),
  721. PADDR_B (startpos),
  722. SCR_INT,
  723. SIR_COMPLETE_ERROR,
  724. }/*-------------------------< SAVE_DP >--------------------------*/,{
  725. /*
  726. * Clear ACK immediately.
  727. * No need to delay it.
  728. */
  729. SCR_CLR (SCR_ACK),
  730. 0,
  731. /*
  732. * Keep track we received a SAVE DP, so
  733. * we will switch to the other PM context
  734. * on the next PM since the DP may point
  735. * to the current PM context.
  736. */
  737. SCR_REG_REG (HF_REG, SCR_OR, HF_DP_SAVED),
  738. 0,
  739. /*
  740. * SAVE_DP message:
  741. * Copy LASTP to SAVEP.
  742. */
  743. SCR_LOAD_REL (scratcha, 4),
  744. offsetof (struct sym_ccb, phys.head.lastp),
  745. SCR_STORE_REL (scratcha, 4),
  746. offsetof (struct sym_ccb, phys.head.savep),
  747. /*
  748. * Anticipate the MESSAGE PHASE for
  749. * the DISCONNECT message.
  750. */
  751. SCR_JUMP ^ IFTRUE (WHEN (SCR_MSG_IN)),
  752. PADDR_A (msg_in),
  753. SCR_JUMP,
  754. PADDR_A (dispatch),
  755. }/*-------------------------< RESTORE_DP >-----------------------*/,{
  756. /*
  757. * Clear ACK immediately.
  758. * No need to delay it.
  759. */
  760. SCR_CLR (SCR_ACK),
  761. 0,
  762. /*
  763. * Copy SAVEP to LASTP.
  764. */
  765. SCR_LOAD_REL (scratcha, 4),
  766. offsetof (struct sym_ccb, phys.head.savep),
  767. SCR_STORE_REL (scratcha, 4),
  768. offsetof (struct sym_ccb, phys.head.lastp),
  769. SCR_JUMP,
  770. PADDR_A (dispatch),
  771. }/*-------------------------< DISCONNECT >-----------------------*/,{
  772. /*
  773. * DISCONNECTing ...
  774. *
  775. * disable the "unexpected disconnect" feature,
  776. * and remove the ACK signal.
  777. */
  778. SCR_REG_REG (scntl2, SCR_AND, 0x7f),
  779. 0,
  780. SCR_CLR (SCR_ACK|SCR_ATN),
  781. 0,
  782. /*
  783. * Wait for the disconnect.
  784. */
  785. SCR_WAIT_DISC,
  786. 0,
  787. /*
  788. * Status is: DISCONNECTED.
  789. */
  790. SCR_LOAD_REG (HS_REG, HS_DISCONNECT),
  791. 0,
  792. /*
  793. * Save host status.
  794. */
  795. SCR_STORE_REL (scr0, 4),
  796. offsetof (struct sym_ccb, phys.head.status),
  797. SCR_JUMP,
  798. PADDR_A (start),
  799. }/*-------------------------< IDLE >-----------------------------*/,{
  800. /*
  801. * Nothing to do?
  802. * Switch the LED off and wait for reselect.
  803. * Will be patched with a NO_OP if LED
  804. * not needed or not desired.
  805. */
  806. SCR_REG_REG (gpreg, SCR_OR, 0x01),
  807. 0,
  808. #ifdef SYM_CONF_IARB_SUPPORT
  809. SCR_JUMPR,
  810. 8,
  811. #endif
  812. }/*-------------------------< UNGETJOB >-------------------------*/,{
  813. #ifdef SYM_CONF_IARB_SUPPORT
  814. /*
  815. * Set IMMEDIATE ARBITRATION, for the next time.
  816. * This will give us better chance to win arbitration
  817. * for the job we just wanted to do.
  818. */
  819. SCR_REG_REG (scntl1, SCR_OR, IARB),
  820. 0,
  821. #endif
  822. /*
  823. * We are not able to restart the SCRIPTS if we are
  824. * interrupted and these instruction haven't been
  825. * all executed. BTW, this is very unlikely to
  826. * happen, but we check that from the C code.
  827. */
  828. SCR_LOAD_REG (dsa, 0xff),
  829. 0,
  830. SCR_STORE_ABS (scratcha, 4),
  831. PADDR_B (startpos),
  832. }/*-------------------------< RESELECT >-------------------------*/,{
  833. #ifdef SYM_CONF_TARGET_ROLE_SUPPORT
  834. /*
  835. * Make sure we are in initiator mode.
  836. */
  837. SCR_CLR (SCR_TRG),
  838. 0,
  839. #endif
  840. /*
  841. * Sleep waiting for a reselection.
  842. */
  843. SCR_WAIT_RESEL,
  844. PADDR_A(start),
  845. }/*-------------------------< RESELECTED >-----------------------*/,{
  846. /*
  847. * Switch the LED on.
  848. * Will be patched with a NO_OP if LED
  849. * not needed or not desired.
  850. */
  851. SCR_REG_REG (gpreg, SCR_AND, 0xfe),
  852. 0,
  853. /*
  854. * load the target id into the sdid
  855. */
  856. SCR_REG_SFBR (ssid, SCR_AND, 0x8F),
  857. 0,
  858. SCR_TO_REG (sdid),
  859. 0,
  860. /*
  861. * Load the target control block address
  862. */
  863. SCR_LOAD_ABS (dsa, 4),
  864. PADDR_B (targtbl),
  865. SCR_SFBR_REG (dsa, SCR_SHL, 0),
  866. 0,
  867. SCR_REG_REG (dsa, SCR_SHL, 0),
  868. 0,
  869. SCR_REG_REG (dsa, SCR_AND, 0x3c),
  870. 0,
  871. SCR_LOAD_REL (dsa, 4),
  872. 0,
  873. /*
  874. * We expect MESSAGE IN phase.
  875. * If not, get help from the C code.
  876. */
  877. SCR_INT ^ IFFALSE (WHEN (SCR_MSG_IN)),
  878. SIR_RESEL_NO_MSG_IN,
  879. /*
  880. * Load the legacy synchronous transfer registers.
  881. */
  882. SCR_LOAD_REL (scntl3, 1),
  883. offsetof(struct sym_tcb, head.wval),
  884. SCR_LOAD_REL (sxfer, 1),
  885. offsetof(struct sym_tcb, head.sval),
  886. }/*-------------------------< RESEL_SCNTL4 >---------------------*/,{
  887. /*
  888. * The C1010 uses a new synchronous timing scheme.
  889. * Will be patched with a NO_OP if not a C1010.
  890. */
  891. SCR_LOAD_REL (scntl4, 1),
  892. offsetof(struct sym_tcb, head.uval),
  893. /*
  894. * Get the IDENTIFY message.
  895. */
  896. SCR_MOVE_ABS (1) ^ SCR_MSG_IN,
  897. HADDR_1 (msgin),
  898. /*
  899. * If IDENTIFY LUN #0, use a faster path
  900. * to find the LCB structure.
  901. */
  902. SCR_JUMP ^ IFTRUE (MASK (0x80, 0xbf)),
  903. PADDR_A (resel_lun0),
  904. /*
  905. * If message isn't an IDENTIFY,
  906. * tell the C code about.
  907. */
  908. SCR_INT ^ IFFALSE (MASK (0x80, 0x80)),
  909. SIR_RESEL_NO_IDENTIFY,
  910. /*
  911. * It is an IDENTIFY message,
  912. * Load the LUN control block address.
  913. */
  914. SCR_LOAD_REL (dsa, 4),
  915. offsetof(struct sym_tcb, head.luntbl_sa),
  916. SCR_SFBR_REG (dsa, SCR_SHL, 0),
  917. 0,
  918. SCR_REG_REG (dsa, SCR_SHL, 0),
  919. 0,
  920. SCR_REG_REG (dsa, SCR_AND, 0xfc),
  921. 0,
  922. SCR_LOAD_REL (dsa, 4),
  923. 0,
  924. SCR_JUMPR,
  925. 8,
  926. }/*-------------------------< RESEL_LUN0 >-----------------------*/,{
  927. /*
  928. * LUN 0 special case (but usual one :))
  929. */
  930. SCR_LOAD_REL (dsa, 4),
  931. offsetof(struct sym_tcb, head.lun0_sa),
  932. /*
  933. * Jump indirectly to the reselect action for this LUN.
  934. */
  935. SCR_LOAD_REL (temp, 4),
  936. offsetof(struct sym_lcb, head.resel_sa),
  937. SCR_RETURN,
  938. 0,
  939. /* In normal situations, we jump to RESEL_TAG or RESEL_NO_TAG */
  940. }/*-------------------------< RESEL_TAG >------------------------*/,{
  941. /*
  942. * ACK the IDENTIFY previously received.
  943. */
  944. SCR_CLR (SCR_ACK),
  945. 0,
  946. /*
  947. * It shall be a tagged command.
  948. * Read SIMPLE+TAG.
  949. * The C code will deal with errors.
  950. * Aggressive optimization, isn't it? :)
  951. */
  952. SCR_MOVE_ABS (2) ^ SCR_MSG_IN,
  953. HADDR_1 (msgin),
  954. /*
  955. * Load the pointer to the tagged task
  956. * table for this LUN.
  957. */
  958. SCR_LOAD_REL (dsa, 4),
  959. offsetof(struct sym_lcb, head.itlq_tbl_sa),
  960. /*
  961. * The SIDL still contains the TAG value.
  962. * Aggressive optimization, isn't it? :):)
  963. */
  964. SCR_REG_SFBR (sidl, SCR_SHL, 0),
  965. 0,
  966. #if SYM_CONF_MAX_TASK*4 > 512
  967. SCR_JUMPR ^ IFFALSE (CARRYSET),
  968. 8,
  969. SCR_REG_REG (dsa1, SCR_OR, 2),
  970. 0,
  971. SCR_REG_REG (sfbr, SCR_SHL, 0),
  972. 0,
  973. SCR_JUMPR ^ IFFALSE (CARRYSET),
  974. 8,
  975. SCR_REG_REG (dsa1, SCR_OR, 1),
  976. 0,
  977. #elif SYM_CONF_MAX_TASK*4 > 256
  978. SCR_JUMPR ^ IFFALSE (CARRYSET),
  979. 8,
  980. SCR_REG_REG (dsa1, SCR_OR, 1),
  981. 0,
  982. #endif
  983. /*
  984. * Retrieve the DSA of this task.
  985. * JUMP indirectly to the restart point of the CCB.
  986. */
  987. SCR_SFBR_REG (dsa, SCR_AND, 0xfc),
  988. 0,
  989. SCR_LOAD_REL (dsa, 4),
  990. 0,
  991. SCR_LOAD_REL (temp, 4),
  992. offsetof(struct sym_ccb, phys.head.go.restart),
  993. SCR_RETURN,
  994. 0,
  995. /* In normal situations we branch to RESEL_DSA */
  996. }/*-------------------------< RESEL_DSA >------------------------*/,{
  997. /*
  998. * ACK the IDENTIFY or TAG previously received.
  999. */
  1000. SCR_CLR (SCR_ACK),
  1001. 0,
  1002. }/*-------------------------< RESEL_DSA1 >-----------------------*/,{
  1003. /*
  1004. * Initialize the status registers
  1005. */
  1006. SCR_LOAD_REL (scr0, 4),
  1007. offsetof (struct sym_ccb, phys.head.status),
  1008. /*
  1009. * Jump to dispatcher.
  1010. */
  1011. SCR_JUMP,
  1012. PADDR_A (dispatch),
  1013. }/*-------------------------< RESEL_NO_TAG >---------------------*/,{
  1014. /*
  1015. * Load the DSA with the unique ITL task.
  1016. */
  1017. SCR_LOAD_REL (dsa, 4),
  1018. offsetof(struct sym_lcb, head.itl_task_sa),
  1019. /*
  1020. * JUMP indirectly to the restart point of the CCB.
  1021. */
  1022. SCR_LOAD_REL (temp, 4),
  1023. offsetof(struct sym_ccb, phys.head.go.restart),
  1024. SCR_RETURN,
  1025. 0,
  1026. /* In normal situations we branch to RESEL_DSA */
  1027. }/*-------------------------< DATA_IN >--------------------------*/,{
  1028. /*
  1029. * Because the size depends on the
  1030. * #define SYM_CONF_MAX_SG parameter,
  1031. * it is filled in at runtime.
  1032. *
  1033. * ##===========< i=0; i<SYM_CONF_MAX_SG >=========
  1034. * || SCR_CHMOV_TBL ^ SCR_DATA_IN,
  1035. * || offsetof (struct sym_dsb, data[ i]),
  1036. * ##==========================================
  1037. */
  1038. 0
  1039. }/*-------------------------< DATA_IN2 >-------------------------*/,{
  1040. SCR_CALL,
  1041. PADDR_A (datai_done),
  1042. SCR_JUMP,
  1043. PADDR_B (data_ovrun),
  1044. }/*-------------------------< DATA_OUT >-------------------------*/,{
  1045. /*
  1046. * Because the size depends on the
  1047. * #define SYM_CONF_MAX_SG parameter,
  1048. * it is filled in at runtime.
  1049. *
  1050. * ##===========< i=0; i<SYM_CONF_MAX_SG >=========
  1051. * || SCR_CHMOV_TBL ^ SCR_DATA_OUT,
  1052. * || offsetof (struct sym_dsb, data[ i]),
  1053. * ##==========================================
  1054. */
  1055. 0
  1056. }/*-------------------------< DATA_OUT2 >------------------------*/,{
  1057. SCR_CALL,
  1058. PADDR_A (datao_done),
  1059. SCR_JUMP,
  1060. PADDR_B (data_ovrun),
  1061. }/*-------------------------< PM0_DATA >-------------------------*/,{
  1062. /*
  1063. * Read our host flags to SFBR, so we will be able
  1064. * to check against the data direction we expect.
  1065. */
  1066. SCR_FROM_REG (HF_REG),
  1067. 0,
  1068. /*
  1069. * Check against actual DATA PHASE.
  1070. */
  1071. SCR_JUMP ^ IFFALSE (WHEN (SCR_DATA_IN)),
  1072. PADDR_A (pm0_data_out),
  1073. /*
  1074. * Actual phase is DATA IN.
  1075. * Check against expected direction.
  1076. */
  1077. SCR_JUMP ^ IFFALSE (MASK (HF_DATA_IN, HF_DATA_IN)),
  1078. PADDR_B (data_ovrun),
  1079. /*
  1080. * Keep track we are moving data from the
  1081. * PM0 DATA mini-script.
  1082. */
  1083. SCR_REG_REG (HF_REG, SCR_OR, HF_IN_PM0),
  1084. 0,
  1085. /*
  1086. * Move the data to memory.
  1087. */
  1088. SCR_CHMOV_TBL ^ SCR_DATA_IN,
  1089. offsetof (struct sym_ccb, phys.pm0.sg),
  1090. SCR_JUMP,
  1091. PADDR_A (pm0_data_end),
  1092. }/*-------------------------< PM0_DATA_OUT >---------------------*/,{
  1093. /*
  1094. * Actual phase is DATA OUT.
  1095. * Check against expected direction.
  1096. */
  1097. SCR_JUMP ^ IFTRUE (MASK (HF_DATA_IN, HF_DATA_IN)),
  1098. PADDR_B (data_ovrun),
  1099. /*
  1100. * Keep track we are moving data from the
  1101. * PM0 DATA mini-script.
  1102. */
  1103. SCR_REG_REG (HF_REG, SCR_OR, HF_IN_PM0),
  1104. 0,
  1105. /*
  1106. * Move the data from memory.
  1107. */
  1108. SCR_CHMOV_TBL ^ SCR_DATA_OUT,
  1109. offsetof (struct sym_ccb, phys.pm0.sg),
  1110. }/*-------------------------< PM0_DATA_END >---------------------*/,{
  1111. /*
  1112. * Clear the flag that told we were moving
  1113. * data from the PM0 DATA mini-script.
  1114. */
  1115. SCR_REG_REG (HF_REG, SCR_AND, (~HF_IN_PM0)),
  1116. 0,
  1117. /*
  1118. * Return to the previous DATA script which
  1119. * is guaranteed by design (if no bug) to be
  1120. * the main DATA script for this transfer.
  1121. */
  1122. SCR_LOAD_REL (temp, 4),
  1123. offsetof (struct sym_ccb, phys.pm0.ret),
  1124. SCR_RETURN,
  1125. 0,
  1126. }/*-------------------------< PM1_DATA >-------------------------*/,{
  1127. /*
  1128. * Read our host flags to SFBR, so we will be able
  1129. * to check against the data direction we expect.
  1130. */
  1131. SCR_FROM_REG (HF_REG),
  1132. 0,
  1133. /*
  1134. * Check against actual DATA PHASE.
  1135. */
  1136. SCR_JUMP ^ IFFALSE (WHEN (SCR_DATA_IN)),
  1137. PADDR_A (pm1_data_out),
  1138. /*
  1139. * Actual phase is DATA IN.
  1140. * Check against expected direction.
  1141. */
  1142. SCR_JUMP ^ IFFALSE (MASK (HF_DATA_IN, HF_DATA_IN)),
  1143. PADDR_B (data_ovrun),
  1144. /*
  1145. * Keep track we are moving data from the
  1146. * PM1 DATA mini-script.
  1147. */
  1148. SCR_REG_REG (HF_REG, SCR_OR, HF_IN_PM1),
  1149. 0,
  1150. /*
  1151. * Move the data to memory.
  1152. */
  1153. SCR_CHMOV_TBL ^ SCR_DATA_IN,
  1154. offsetof (struct sym_ccb, phys.pm1.sg),
  1155. SCR_JUMP,
  1156. PADDR_A (pm1_data_end),
  1157. }/*-------------------------< PM1_DATA_OUT >---------------------*/,{
  1158. /*
  1159. * Actual phase is DATA OUT.
  1160. * Check against expected direction.
  1161. */
  1162. SCR_JUMP ^ IFTRUE (MASK (HF_DATA_IN, HF_DATA_IN)),
  1163. PADDR_B (data_ovrun),
  1164. /*
  1165. * Keep track we are moving data from the
  1166. * PM1 DATA mini-script.
  1167. */
  1168. SCR_REG_REG (HF_REG, SCR_OR, HF_IN_PM1),
  1169. 0,
  1170. /*
  1171. * Move the data from memory.
  1172. */
  1173. SCR_CHMOV_TBL ^ SCR_DATA_OUT,
  1174. offsetof (struct sym_ccb, phys.pm1.sg),
  1175. }/*-------------------------< PM1_DATA_END >---------------------*/,{
  1176. /*
  1177. * Clear the flag that told we were moving
  1178. * data from the PM1 DATA mini-script.
  1179. */
  1180. SCR_REG_REG (HF_REG, SCR_AND, (~HF_IN_PM1)),
  1181. 0,
  1182. /*
  1183. * Return to the previous DATA script which
  1184. * is guaranteed by design (if no bug) to be
  1185. * the main DATA script for this transfer.
  1186. */
  1187. SCR_LOAD_REL (temp, 4),
  1188. offsetof (struct sym_ccb, phys.pm1.ret),
  1189. SCR_RETURN,
  1190. 0,
  1191. }/*-------------------------<>-----------------------------------*/
  1192. };
  1193. static struct SYM_FWB_SCR SYM_FWB_SCR = {
  1194. /*--------------------------< START64 >--------------------------*/ {
  1195. /*
  1196. * SCRIPT entry point for the 895A, 896 and 1010.
  1197. * For now, there is no specific stuff for those
  1198. * chips at this point, but this may come.
  1199. */
  1200. SCR_JUMP,
  1201. PADDR_A (init),
  1202. }/*-------------------------< NO_DATA >--------------------------*/,{
  1203. SCR_JUMP,
  1204. PADDR_B (data_ovrun),
  1205. }/*-------------------------< SEL_FOR_ABORT >--------------------*/,{
  1206. /*
  1207. * We are jumped here by the C code, if we have
  1208. * some target to reset or some disconnected
  1209. * job to abort. Since error recovery is a serious
  1210. * busyness, we will really reset the SCSI BUS, if
  1211. * case of a SCSI interrupt occurring in this path.
  1212. */
  1213. #ifdef SYM_CONF_TARGET_ROLE_SUPPORT
  1214. /*
  1215. * Set initiator mode.
  1216. */
  1217. SCR_CLR (SCR_TRG),
  1218. 0,
  1219. #endif
  1220. /*
  1221. * And try to select this target.
  1222. */
  1223. SCR_SEL_TBL_ATN ^ offsetof (struct sym_hcb, abrt_sel),
  1224. PADDR_A (reselect),
  1225. /*
  1226. * Wait for the selection to complete or
  1227. * the selection to time out.
  1228. */
  1229. SCR_JUMPR ^ IFFALSE (WHEN (SCR_MSG_OUT)),
  1230. -8,
  1231. /*
  1232. * Call the C code.
  1233. */
  1234. SCR_INT,
  1235. SIR_TARGET_SELECTED,
  1236. /*
  1237. * The C code should let us continue here.
  1238. * Send the 'kiss of death' message.
  1239. * We expect an immediate disconnect once
  1240. * the target has eaten the message.
  1241. */
  1242. SCR_REG_REG (scntl2, SCR_AND, 0x7f),
  1243. 0,
  1244. SCR_MOVE_TBL ^ SCR_MSG_OUT,
  1245. offsetof (struct sym_hcb, abrt_tbl),
  1246. SCR_CLR (SCR_ACK|SCR_ATN),
  1247. 0,
  1248. SCR_WAIT_DISC,
  1249. 0,
  1250. /*
  1251. * Tell the C code that we are done.
  1252. */
  1253. SCR_INT,
  1254. SIR_ABORT_SENT,
  1255. }/*-------------------------< SEL_FOR_ABORT_1 >------------------*/,{
  1256. /*
  1257. * Jump at scheduler.
  1258. */
  1259. SCR_JUMP,
  1260. PADDR_A (start),
  1261. }/*-------------------------< MSG_IN_ETC >-----------------------*/,{
  1262. /*
  1263. * If it is an EXTENDED (variable size message)
  1264. * Handle it.
  1265. */
  1266. SCR_JUMP ^ IFTRUE (DATA (M_EXTENDED)),
  1267. PADDR_B (msg_extended),
  1268. /*
  1269. * Let the C code handle any other
  1270. * 1 byte message.
  1271. */
  1272. SCR_JUMP ^ IFTRUE (MASK (0x00, 0xf0)),
  1273. PADDR_B (msg_received),
  1274. SCR_JUMP ^ IFTRUE (MASK (0x10, 0xf0)),
  1275. PADDR_B (msg_received),
  1276. /*
  1277. * We donnot handle 2 bytes messages from SCRIPTS.
  1278. * So, let the C code deal with these ones too.
  1279. */
  1280. SCR_JUMP ^ IFFALSE (MASK (0x20, 0xf0)),
  1281. PADDR_B (msg_weird_seen),
  1282. SCR_CLR (SCR_ACK),
  1283. 0,
  1284. SCR_MOVE_ABS (1) ^ SCR_MSG_IN,
  1285. HADDR_1 (msgin[1]),
  1286. }/*-------------------------< MSG_RECEIVED >---------------------*/,{
  1287. SCR_LOAD_REL (scratcha, 4), /* DUMMY READ */
  1288. 0,
  1289. SCR_INT,
  1290. SIR_MSG_RECEIVED,
  1291. }/*-------------------------< MSG_WEIRD_SEEN >-------------------*/,{
  1292. SCR_LOAD_REL (scratcha, 4), /* DUMMY READ */
  1293. 0,
  1294. SCR_INT,
  1295. SIR_MSG_WEIRD,
  1296. }/*-------------------------< MSG_EXTENDED >---------------------*/,{
  1297. /*
  1298. * Clear ACK and get the next byte
  1299. * assumed to be the message length.
  1300. */
  1301. SCR_CLR (SCR_ACK),
  1302. 0,
  1303. SCR_MOVE_ABS (1) ^ SCR_MSG_IN,
  1304. HADDR_1 (msgin[1]),
  1305. /*
  1306. * Try to catch some unlikely situations as 0 length
  1307. * or too large the length.
  1308. */
  1309. SCR_JUMP ^ IFTRUE (DATA (0)),
  1310. PADDR_B (msg_weird_seen),
  1311. SCR_TO_REG (scratcha),
  1312. 0,
  1313. SCR_REG_REG (sfbr, SCR_ADD, (256-8)),
  1314. 0,
  1315. SCR_JUMP ^ IFTRUE (CARRYSET),
  1316. PADDR_B (msg_weird_seen),
  1317. /*
  1318. * We donnot handle extended messages from SCRIPTS.
  1319. * Read the amount of data corresponding to the
  1320. * message length and call the C code.
  1321. */
  1322. SCR_STORE_REL (scratcha, 1),
  1323. offsetof (struct sym_dsb, smsg_ext.size),
  1324. SCR_CLR (SCR_ACK),
  1325. 0,
  1326. SCR_MOVE_TBL ^ SCR_MSG_IN,
  1327. offsetof (struct sym_dsb, smsg_ext),
  1328. SCR_JUMP,
  1329. PADDR_B (msg_received),
  1330. }/*-------------------------< MSG_BAD >--------------------------*/,{
  1331. /*
  1332. * unimplemented message - reject it.
  1333. */
  1334. SCR_INT,
  1335. SIR_REJECT_TO_SEND,
  1336. SCR_SET (SCR_ATN),
  1337. 0,
  1338. SCR_JUMP,
  1339. PADDR_A (clrack),
  1340. }/*-------------------------< MSG_WEIRD >------------------------*/,{
  1341. /*
  1342. * weird message received
  1343. * ignore all MSG IN phases and reject it.
  1344. */
  1345. SCR_INT,
  1346. SIR_REJECT_TO_SEND,
  1347. SCR_SET (SCR_ATN),
  1348. 0,
  1349. }/*-------------------------< MSG_WEIRD1 >-----------------------*/,{
  1350. SCR_CLR (SCR_ACK),
  1351. 0,
  1352. SCR_JUMP ^ IFFALSE (WHEN (SCR_MSG_IN)),
  1353. PADDR_A (dispatch),
  1354. SCR_MOVE_ABS (1) ^ SCR_MSG_IN,
  1355. HADDR_1 (scratch),
  1356. SCR_JUMP,
  1357. PADDR_B (msg_weird1),
  1358. }/*-------------------------< WDTR_RESP >------------------------*/,{
  1359. /*
  1360. * let the target fetch our answer.
  1361. */
  1362. SCR_SET (SCR_ATN),
  1363. 0,
  1364. SCR_CLR (SCR_ACK),
  1365. 0,
  1366. SCR_JUMP ^ IFFALSE (WHEN (SCR_MSG_OUT)),
  1367. PADDR_B (nego_bad_phase),
  1368. }/*-------------------------< SEND_WDTR >------------------------*/,{
  1369. /*
  1370. * Send the M_X_WIDE_REQ
  1371. */
  1372. SCR_MOVE_ABS (4) ^ SCR_MSG_OUT,
  1373. HADDR_1 (msgout),
  1374. SCR_JUMP,
  1375. PADDR_B (msg_out_done),
  1376. }/*-------------------------< SDTR_RESP >------------------------*/,{
  1377. /*
  1378. * let the target fetch our answer.
  1379. */
  1380. SCR_SET (SCR_ATN),
  1381. 0,
  1382. SCR_CLR (SCR_ACK),
  1383. 0,
  1384. SCR_JUMP ^ IFFALSE (WHEN (SCR_MSG_OUT)),
  1385. PADDR_B (nego_bad_phase),
  1386. }/*-------------------------< SEND_SDTR >------------------------*/,{
  1387. /*
  1388. * Send the M_X_SYNC_REQ
  1389. */
  1390. SCR_MOVE_ABS (5) ^ SCR_MSG_OUT,
  1391. HADDR_1 (msgout),
  1392. SCR_JUMP,
  1393. PADDR_B (msg_out_done),
  1394. }/*-------------------------< PPR_RESP >-------------------------*/,{
  1395. /*
  1396. * let the target fetch our answer.
  1397. */
  1398. SCR_SET (SCR_ATN),
  1399. 0,
  1400. SCR_CLR (SCR_ACK),
  1401. 0,
  1402. SCR_JUMP ^ IFFALSE (WHEN (SCR_MSG_OUT)),
  1403. PADDR_B (nego_bad_phase),
  1404. }/*-------------------------< SEND_PPR >-------------------------*/,{
  1405. /*
  1406. * Send the M_X_PPR_REQ
  1407. */
  1408. SCR_MOVE_ABS (8) ^ SCR_MSG_OUT,
  1409. HADDR_1 (msgout),
  1410. SCR_JUMP,
  1411. PADDR_B (msg_out_done),
  1412. }/*-------------------------< NEGO_BAD_PHASE >-------------------*/,{
  1413. SCR_INT,
  1414. SIR_NEGO_PROTO,
  1415. SCR_JUMP,
  1416. PADDR_A (dispatch),
  1417. }/*-------------------------< MSG_OUT >--------------------------*/,{
  1418. /*
  1419. * The target requests a message.
  1420. * We donnot send messages that may
  1421. * require the device to go to bus free.
  1422. */
  1423. SCR_MOVE_ABS (1) ^ SCR_MSG_OUT,
  1424. HADDR_1 (msgout),
  1425. /*
  1426. * ... wait for the next phase
  1427. * if it's a message out, send it again, ...
  1428. */
  1429. SCR_JUMP ^ IFTRUE (WHEN (SCR_MSG_OUT)),
  1430. PADDR_B (msg_out),
  1431. }/*-------------------------< MSG_OUT_DONE >---------------------*/,{
  1432. /*
  1433. * Let the C code be aware of the
  1434. * sent message and clear the message.
  1435. */
  1436. SCR_INT,
  1437. SIR_MSG_OUT_DONE,
  1438. /*
  1439. * ... and process the next phase
  1440. */
  1441. SCR_JUMP,
  1442. PADDR_A (dispatch),
  1443. }/*-------------------------< DATA_OVRUN >-----------------------*/,{
  1444. /*
  1445. * Use scratcha to count the extra bytes.
  1446. */
  1447. SCR_LOAD_ABS (scratcha, 4),
  1448. PADDR_B (zero),
  1449. }/*-------------------------< DATA_OVRUN1 >----------------------*/,{
  1450. /*
  1451. * The target may want to transfer too much data.
  1452. *
  1453. * If phase is DATA OUT write 1 byte and count it.
  1454. */
  1455. SCR_JUMPR ^ IFFALSE (WHEN (SCR_DATA_OUT)),
  1456. 16,
  1457. SCR_CHMOV_ABS (1) ^ SCR_DATA_OUT,
  1458. HADDR_1 (scratch),
  1459. SCR_JUMP,
  1460. PADDR_B (data_ovrun2),
  1461. /*
  1462. * If WSR is set, clear this condition, and
  1463. * count this byte.
  1464. */
  1465. SCR_FROM_REG (scntl2),
  1466. 0,
  1467. SCR_JUMPR ^ IFFALSE (MASK (WSR, WSR)),
  1468. 16,
  1469. SCR_REG_REG (scntl2, SCR_OR, WSR),
  1470. 0,
  1471. SCR_JUMP,
  1472. PADDR_B (data_ovrun2),
  1473. /*
  1474. * Finally check against DATA IN phase.
  1475. * Signal data overrun to the C code
  1476. * and jump to dispatcher if not so.
  1477. * Read 1 byte otherwise and count it.
  1478. */
  1479. SCR_JUMPR ^ IFTRUE (WHEN (SCR_DATA_IN)),
  1480. 16,
  1481. SCR_INT,
  1482. SIR_DATA_OVERRUN,
  1483. SCR_JUMP,
  1484. PADDR_A (dispatch),
  1485. SCR_CHMOV_ABS (1) ^ SCR_DATA_IN,
  1486. HADDR_1 (scratch),
  1487. }/*-------------------------< DATA_OVRUN2 >----------------------*/,{
  1488. /*
  1489. * Count this byte.
  1490. * This will allow to return a negative
  1491. * residual to user.
  1492. */
  1493. SCR_REG_REG (scratcha, SCR_ADD, 0x01),
  1494. 0,
  1495. SCR_REG_REG (scratcha1, SCR_ADDC, 0),
  1496. 0,
  1497. SCR_REG_REG (scratcha2, SCR_ADDC, 0),
  1498. 0,
  1499. /*
  1500. * .. and repeat as required.
  1501. */
  1502. SCR_JUMP,
  1503. PADDR_B (data_ovrun1),
  1504. }/*-------------------------< ABORT_RESEL >----------------------*/,{
  1505. SCR_SET (SCR_ATN),
  1506. 0,
  1507. SCR_CLR (SCR_ACK),
  1508. 0,
  1509. /*
  1510. * send the abort/abortag/reset message
  1511. * we expect an immediate disconnect
  1512. */
  1513. SCR_REG_REG (scntl2, SCR_AND, 0x7f),
  1514. 0,
  1515. SCR_MOVE_ABS (1) ^ SCR_MSG_OUT,
  1516. HADDR_1 (msgout),
  1517. SCR_CLR (SCR_ACK|SCR_ATN),
  1518. 0,
  1519. SCR_WAIT_DISC,
  1520. 0,
  1521. SCR_INT,
  1522. SIR_RESEL_ABORTED,
  1523. SCR_JUMP,
  1524. PADDR_A (start),
  1525. }/*-------------------------< RESEND_IDENT >---------------------*/,{
  1526. /*
  1527. * The target stays in MSG OUT phase after having acked
  1528. * Identify [+ Tag [+ Extended message ]]. Targets shall
  1529. * behave this way on parity error.
  1530. * We must send it again all the messages.
  1531. */
  1532. SCR_SET (SCR_ATN), /* Shall be asserted 2 deskew delays before the */
  1533. 0, /* 1rst ACK = 90 ns. Hope the chip isn't too fast */
  1534. SCR_JUMP,
  1535. PADDR_A (send_ident),
  1536. }/*-------------------------< IDENT_BREAK >----------------------*/,{
  1537. SCR_CLR (SCR_ATN),
  1538. 0,
  1539. SCR_JUMP,
  1540. PADDR_A (select2),
  1541. }/*-------------------------< IDENT_BREAK_ATN >------------------*/,{
  1542. SCR_SET (SCR_ATN),
  1543. 0,
  1544. SCR_JUMP,
  1545. PADDR_A (select2),
  1546. }/*-------------------------< SDATA_IN >-------------------------*/,{
  1547. SCR_CHMOV_TBL ^ SCR_DATA_IN,
  1548. offsetof (struct sym_dsb, sense),
  1549. SCR_CALL,
  1550. PADDR_A (datai_done),
  1551. SCR_JUMP,
  1552. PADDR_B (data_ovrun),
  1553. }/*-------------------------< RESEL_BAD_LUN >--------------------*/,{
  1554. /*
  1555. * Message is an IDENTIFY, but lun is unknown.
  1556. * Signal problem to C code for logging the event.
  1557. * Send a M_ABORT to clear all pending tasks.
  1558. */
  1559. SCR_INT,
  1560. SIR_RESEL_BAD_LUN,
  1561. SCR_JUMP,
  1562. PADDR_B (abort_resel),
  1563. }/*-------------------------< BAD_I_T_L >------------------------*/,{
  1564. /*
  1565. * We donnot have a task for that I_T_L.
  1566. * Signal problem to C code for logging the event.
  1567. * Send a M_ABORT message.
  1568. */
  1569. SCR_INT,
  1570. SIR_RESEL_BAD_I_T_L,
  1571. SCR_JUMP,
  1572. PADDR_B (abort_resel),
  1573. }/*-------------------------< BAD_I_T_L_Q >----------------------*/,{
  1574. /*
  1575. * We donnot have a task that matches the tag.
  1576. * Signal problem to C code for logging the event.
  1577. * Send a M_ABORTTAG message.
  1578. */
  1579. SCR_INT,
  1580. SIR_RESEL_BAD_I_T_L_Q,
  1581. SCR_JUMP,
  1582. PADDR_B (abort_resel),
  1583. }/*-------------------------< BAD_STATUS >-----------------------*/,{
  1584. /*
  1585. * Anything different from INTERMEDIATE
  1586. * CONDITION MET should be a bad SCSI status,
  1587. * given that GOOD status has already been tested.
  1588. * Call the C code.
  1589. */
  1590. SCR_LOAD_ABS (scratcha, 4),
  1591. PADDR_B (startpos),
  1592. SCR_INT ^ IFFALSE (DATA (S_COND_MET)),
  1593. SIR_BAD_SCSI_STATUS,
  1594. SCR_RETURN,
  1595. 0,
  1596. }/*-------------------------< PM_HANDLE >------------------------*/,{
  1597. /*
  1598. * Phase mismatch handling.
  1599. *
  1600. * Since we have to deal with 2 SCSI data pointers
  1601. * (current and saved), we need at least 2 contexts.
  1602. * Each context (pm0 and pm1) has a saved area, a
  1603. * SAVE mini-script and a DATA phase mini-script.
  1604. */
  1605. /*
  1606. * Get the PM handling flags.
  1607. */
  1608. SCR_FROM_REG (HF_REG),
  1609. 0,
  1610. /*
  1611. * If no flags (1rst PM for example), avoid
  1612. * all the below heavy flags testing.
  1613. * This makes the normal case a bit faster.
  1614. */
  1615. SCR_JUMP ^ IFTRUE (MASK (0, (HF_IN_PM0 | HF_IN_PM1 | HF_DP_SAVED))),
  1616. PADDR_B (pm_handle1),
  1617. /*
  1618. * If we received a SAVE DP, switch to the
  1619. * other PM context since the savep may point
  1620. * to the current PM context.
  1621. */
  1622. SCR_JUMPR ^ IFFALSE (MASK (HF_DP_SAVED, HF_DP_SAVED)),
  1623. 8,
  1624. SCR_REG_REG (sfbr, SCR_XOR, HF_ACT_PM),
  1625. 0,
  1626. /*
  1627. * If we have been interrupt in a PM DATA mini-script,
  1628. * we take the return address from the corresponding
  1629. * saved area.
  1630. * This ensure the return address always points to the
  1631. * main DATA script for this transfer.
  1632. */
  1633. SCR_JUMP ^ IFTRUE (MASK (0, (HF_IN_PM0 | HF_IN_PM1))),
  1634. PADDR_B (pm_handle1),
  1635. SCR_JUMPR ^ IFFALSE (MASK (HF_IN_PM0, HF_IN_PM0)),
  1636. 16,
  1637. SCR_LOAD_REL (ia, 4),
  1638. offsetof(struct sym_ccb, phys.pm0.ret),
  1639. SCR_JUMP,
  1640. PADDR_B (pm_save),
  1641. SCR_LOAD_REL (ia, 4),
  1642. offsetof(struct sym_ccb, phys.pm1.ret),
  1643. SCR_JUMP,
  1644. PADDR_B (pm_save),
  1645. }/*-------------------------< PM_HANDLE1 >-----------------------*/,{
  1646. /*
  1647. * Normal case.
  1648. * Update the return address so that it
  1649. * will point after the interrupted MOVE.
  1650. */
  1651. SCR_REG_REG (ia, SCR_ADD, 8),
  1652. 0,
  1653. SCR_REG_REG (ia1, SCR_ADDC, 0),
  1654. 0,
  1655. }/*-------------------------< PM_SAVE >--------------------------*/,{
  1656. /*
  1657. * Clear all the flags that told us if we were
  1658. * interrupted in a PM DATA mini-script and/or
  1659. * we received a SAVE DP.
  1660. */
  1661. SCR_SFBR_REG (HF_REG, SCR_AND, (~(HF_IN_PM0|HF_IN_PM1|HF_DP_SAVED))),
  1662. 0,
  1663. /*
  1664. * Choose the current PM context.
  1665. */
  1666. SCR_JUMP ^ IFTRUE (MASK (HF_ACT_PM, HF_ACT_PM)),
  1667. PADDR_B (pm1_save),
  1668. }/*-------------------------< PM0_SAVE >-------------------------*/,{
  1669. SCR_STORE_REL (ia, 4),
  1670. offsetof(struct sym_ccb, phys.pm0.ret),
  1671. /*
  1672. * If WSR bit is set, either UA and RBC may
  1673. * have to be changed whether the device wants
  1674. * to ignore this residue or not.
  1675. */
  1676. SCR_FROM_REG (scntl2),
  1677. 0,
  1678. SCR_CALL ^ IFTRUE (MASK (WSR, WSR)),
  1679. PADDR_B (pm_wsr_handle),
  1680. /*
  1681. * Save the remaining byte count, the updated
  1682. * address and the return address.
  1683. */
  1684. SCR_STORE_REL (rbc, 4),
  1685. offsetof(struct sym_ccb, phys.pm0.sg.size),
  1686. SCR_STORE_REL (ua, 4),
  1687. offsetof(struct sym_ccb, phys.pm0.sg.addr),
  1688. /*
  1689. * Set the current pointer at the PM0 DATA mini-script.
  1690. */
  1691. SCR_LOAD_ABS (ia, 4),
  1692. PADDR_B (pm0_data_addr),
  1693. }/*-------------------------< PM_SAVE_END >----------------------*/,{
  1694. SCR_STORE_REL (ia, 4),
  1695. offsetof(struct sym_ccb, phys.head.lastp),
  1696. SCR_JUMP,
  1697. PADDR_A (dispatch),
  1698. }/*-------------------------< PM1_SAVE >-------------------------*/,{
  1699. SCR_STORE_REL (ia, 4),
  1700. offsetof(struct sym_ccb, phys.pm1.ret),
  1701. /*
  1702. * If WSR bit is set, either UA and RBC may
  1703. * have to be changed whether the device wants
  1704. * to ignore this residue or not.
  1705. */
  1706. SCR_FROM_REG (scntl2),
  1707. 0,
  1708. SCR_CALL ^ IFTRUE (MASK (WSR, WSR)),
  1709. PADDR_B (pm_wsr_handle),
  1710. /*
  1711. * Save the remaining byte count, the updated
  1712. * address and the return address.
  1713. */
  1714. SCR_STORE_REL (rbc, 4),
  1715. offsetof(struct sym_ccb, phys.pm1.sg.size),
  1716. SCR_STORE_REL (ua, 4),
  1717. offsetof(struct sym_ccb, phys.pm1.sg.addr),
  1718. /*
  1719. * Set the current pointer at the PM1 DATA mini-script.
  1720. */
  1721. SCR_LOAD_ABS (ia, 4),
  1722. PADDR_B (pm1_data_addr),
  1723. SCR_JUMP,
  1724. PADDR_B (pm_save_end),
  1725. }/*-------------------------< PM_WSR_HANDLE >--------------------*/,{
  1726. /*
  1727. * Phase mismatch handling from SCRIPT with WSR set.
  1728. * Such a condition can occur if the chip wants to
  1729. * execute a CHMOV(size > 1) when the WSR bit is
  1730. * set and the target changes PHASE.
  1731. *
  1732. * We must move the residual byte to memory.
  1733. *
  1734. * UA contains bit 0..31 of the address to
  1735. * move the residual byte.
  1736. * Move it to the table indirect.
  1737. */
  1738. SCR_STORE_REL (ua, 4),
  1739. offsetof (struct sym_ccb, phys.wresid.addr),
  1740. /*
  1741. * Increment UA (move address to next position).
  1742. */
  1743. SCR_REG_REG (ua, SCR_ADD, 1),
  1744. 0,
  1745. SCR_REG_REG (ua1, SCR_ADDC, 0),
  1746. 0,
  1747. SCR_REG_REG (ua2, SCR_ADDC, 0),
  1748. 0,
  1749. SCR_REG_REG (ua3, SCR_ADDC, 0),
  1750. 0,
  1751. /*
  1752. * Compute SCRATCHA as:
  1753. * - size to transfer = 1 byte.
  1754. * - bit 24..31 = high address bit [32...39].
  1755. */
  1756. SCR_LOAD_ABS (scratcha, 4),
  1757. PADDR_B (zero),
  1758. SCR_REG_REG (scratcha, SCR_OR, 1),
  1759. 0,
  1760. SCR_FROM_REG (rbc3),
  1761. 0,
  1762. SCR_TO_REG (scratcha3),
  1763. 0,
  1764. /*
  1765. * Move this value to the table indirect.
  1766. */
  1767. SCR_STORE_REL (scratcha, 4),
  1768. offsetof (struct sym_ccb, phys.wresid.size),
  1769. /*
  1770. * Wait for a valid phase.
  1771. * While testing with bogus QUANTUM drives, the C1010
  1772. * sometimes raised a spurious phase mismatch with
  1773. * WSR and the CHMOV(1) triggered another PM.
  1774. * Waiting explicitly for the PHASE seemed to avoid
  1775. * the nested phase mismatch. Btw, this didn't happen
  1776. * using my IBM drives.
  1777. */
  1778. SCR_JUMPR ^ IFFALSE (WHEN (SCR_DATA_IN)),
  1779. 0,
  1780. /*
  1781. * Perform the move of the residual byte.
  1782. */
  1783. SCR_CHMOV_TBL ^ SCR_DATA_IN,
  1784. offsetof (struct sym_ccb, phys.wresid),
  1785. /*
  1786. * We can now handle the phase mismatch with UA fixed.
  1787. * RBC[0..23]=0 is a special case that does not require
  1788. * a PM context. The C code also checks against this.
  1789. */
  1790. SCR_FROM_REG (rbc),
  1791. 0,
  1792. SCR_RETURN ^ IFFALSE (DATA (0)),
  1793. 0,
  1794. SCR_FROM_REG (rbc1),
  1795. 0,
  1796. SCR_RETURN ^ IFFALSE (DATA (0)),
  1797. 0,
  1798. SCR_FROM_REG (rbc2),
  1799. 0,
  1800. SCR_RETURN ^ IFFALSE (DATA (0)),
  1801. 0,
  1802. /*
  1803. * RBC[0..23]=0.
  1804. * Not only we donnot need a PM context, but this would
  1805. * lead to a bogus CHMOV(0). This condition means that
  1806. * the residual was the last byte to move from this CHMOV.
  1807. * So, we just have to move the current data script pointer
  1808. * (i.e. TEMP) to the SCRIPTS address following the
  1809. * interrupted CHMOV and jump to dispatcher.
  1810. * IA contains the data pointer to save.
  1811. */
  1812. SCR_JUMP,
  1813. PADDR_B (pm_save_end),
  1814. }/*-------------------------< WSR_MA_HELPER >--------------------*/,{
  1815. /*
  1816. * Helper for the C code when WSR bit is set.
  1817. * Perform the move of the residual byte.
  1818. */
  1819. SCR_CHMOV_TBL ^ SCR_DATA_IN,
  1820. offsetof (struct sym_ccb, phys.wresid),
  1821. SCR_JUMP,
  1822. PADDR_A (dispatch),
  1823. }/*-------------------------< ZERO >-----------------------------*/,{
  1824. SCR_DATA_ZERO,
  1825. }/*-------------------------< SCRATCH >--------------------------*/,{
  1826. SCR_DATA_ZERO,
  1827. }/*-------------------------< PM0_DATA_ADDR >--------------------*/,{
  1828. SCR_DATA_ZERO,
  1829. }/*-------------------------< PM1_DATA_ADDR >--------------------*/,{
  1830. SCR_DATA_ZERO,
  1831. }/*-------------------------< DONE_POS >-------------------------*/,{
  1832. SCR_DATA_ZERO,
  1833. }/*-------------------------< STARTPOS >-------------------------*/,{
  1834. SCR_DATA_ZERO,
  1835. }/*-------------------------< TARGTBL >--------------------------*/,{
  1836. SCR_DATA_ZERO,
  1837. }/*-------------------------<>-----------------------------------*/
  1838. };
  1839. static struct SYM_FWZ_SCR SYM_FWZ_SCR = {
  1840. /*-------------------------< SNOOPTEST >------------------------*/{
  1841. /*
  1842. * Read the variable from memory.
  1843. */
  1844. SCR_LOAD_REL (scratcha, 4),
  1845. offsetof(struct sym_hcb, scratch),
  1846. /*
  1847. * Write the variable to memory.
  1848. */
  1849. SCR_STORE_REL (temp, 4),
  1850. offsetof(struct sym_hcb, scratch),
  1851. /*
  1852. * Read back the variable from memory.
  1853. */
  1854. SCR_LOAD_REL (temp, 4),
  1855. offsetof(struct sym_hcb, scratch),
  1856. }/*-------------------------< SNOOPEND >-------------------------*/,{
  1857. /*
  1858. * And stop.
  1859. */
  1860. SCR_INT,
  1861. 99,
  1862. }/*-------------------------<>-----------------------------------*/
  1863. };