sym_fw2.h 48 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876
  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. };