sym_fw1.h 46 KB

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