treewide: remove redundant IS_ERR() before error code check
[linux/fpc-iii.git] / drivers / scsi / sym53c8xx_2 / sym_fw2.h
blob4d1779b2a4091b9a67073c9a7db3d91b17cdea44
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3 * Device driver for the SYMBIOS/LSILOGIC 53C8XX and 53C1010 family
4 * of PCI-SCSI IO processors.
6 * Copyright (C) 1999-2001 Gerard Roudier <groudier@free.fr>
8 * This driver is derived from the Linux sym53c8xx driver.
9 * Copyright (C) 1998-2000 Gerard Roudier
11 * The sym53c8xx driver is derived from the ncr53c8xx driver that had been
12 * a port of the FreeBSD ncr driver to Linux-1.2.13.
14 * The original ncr driver has been written for 386bsd and FreeBSD by
15 * Wolfgang Stanglmeier <wolf@cologne.de>
16 * Stefan Esser <se@mi.Uni-Koeln.de>
17 * Copyright (C) 1994 Wolfgang Stanglmeier
19 * Other major contributions:
21 * NVRAM detection and reading.
22 * Copyright (C) 1997 Richard Waltham <dormouse@farsrobt.demon.co.uk>
24 *-----------------------------------------------------------------------------
28 * Scripts for SYMBIOS-Processor
30 * We have to know the offsets of all labels before we reach
31 * them (for forward jumps). Therefore we declare a struct
32 * here. If you make changes inside the script,
34 * DONT FORGET TO CHANGE THE LENGTHS HERE!
38 * Script fragments which are loaded into the on-chip RAM
39 * of 825A, 875, 876, 895, 895A, 896 and 1010 chips.
40 * Must not exceed 4K bytes.
42 struct SYM_FWA_SCR {
43 u32 start [ 14];
44 u32 getjob_begin [ 4];
45 u32 getjob_end [ 4];
46 #ifdef SYM_CONF_TARGET_ROLE_SUPPORT
47 u32 select [ 6];
48 #else
49 u32 select [ 4];
50 #endif
51 #if SYM_CONF_DMA_ADDRESSING_MODE == 2
52 u32 is_dmap_dirty [ 4];
53 #endif
54 u32 wf_sel_done [ 2];
55 u32 sel_done [ 2];
56 u32 send_ident [ 2];
57 #ifdef SYM_CONF_IARB_SUPPORT
58 u32 select2 [ 8];
59 #else
60 u32 select2 [ 2];
61 #endif
62 u32 command [ 2];
63 u32 dispatch [ 28];
64 u32 sel_no_cmd [ 10];
65 u32 init [ 6];
66 u32 clrack [ 4];
67 u32 datai_done [ 10];
68 u32 datai_done_wsr [ 20];
69 u32 datao_done [ 10];
70 u32 datao_done_wss [ 6];
71 u32 datai_phase [ 4];
72 u32 datao_phase [ 6];
73 u32 msg_in [ 2];
74 u32 msg_in2 [ 10];
75 #ifdef SYM_CONF_IARB_SUPPORT
76 u32 status [ 14];
77 #else
78 u32 status [ 10];
79 #endif
80 u32 complete [ 6];
81 u32 complete2 [ 12];
82 u32 done [ 14];
83 u32 done_end [ 2];
84 u32 complete_error [ 4];
85 u32 save_dp [ 12];
86 u32 restore_dp [ 8];
87 u32 disconnect [ 12];
88 #ifdef SYM_CONF_IARB_SUPPORT
89 u32 idle [ 4];
90 #else
91 u32 idle [ 2];
92 #endif
93 #ifdef SYM_CONF_IARB_SUPPORT
94 u32 ungetjob [ 6];
95 #else
96 u32 ungetjob [ 4];
97 #endif
98 #ifdef SYM_CONF_TARGET_ROLE_SUPPORT
99 u32 reselect [ 4];
100 #else
101 u32 reselect [ 2];
102 #endif
103 u32 reselected [ 22];
104 u32 resel_scntl4 [ 20];
105 u32 resel_lun0 [ 6];
106 #if SYM_CONF_MAX_TASK*4 > 512
107 u32 resel_tag [ 26];
108 #elif SYM_CONF_MAX_TASK*4 > 256
109 u32 resel_tag [ 20];
110 #else
111 u32 resel_tag [ 16];
112 #endif
113 u32 resel_dsa [ 2];
114 u32 resel_dsa1 [ 4];
115 u32 resel_no_tag [ 6];
116 u32 data_in [SYM_CONF_MAX_SG * 2];
117 u32 data_in2 [ 4];
118 u32 data_out [SYM_CONF_MAX_SG * 2];
119 u32 data_out2 [ 4];
120 u32 pm0_data [ 12];
121 u32 pm0_data_out [ 6];
122 u32 pm0_data_end [ 6];
123 u32 pm1_data [ 12];
124 u32 pm1_data_out [ 6];
125 u32 pm1_data_end [ 6];
129 * Script fragments which stay in main memory for all chips
130 * except for chips that support 8K on-chip RAM.
132 struct SYM_FWB_SCR {
133 u32 start64 [ 2];
134 u32 no_data [ 2];
135 #ifdef SYM_CONF_TARGET_ROLE_SUPPORT
136 u32 sel_for_abort [ 18];
137 #else
138 u32 sel_for_abort [ 16];
139 #endif
140 u32 sel_for_abort_1 [ 2];
141 u32 msg_in_etc [ 12];
142 u32 msg_received [ 4];
143 u32 msg_weird_seen [ 4];
144 u32 msg_extended [ 20];
145 u32 msg_bad [ 6];
146 u32 msg_weird [ 4];
147 u32 msg_weird1 [ 8];
149 u32 wdtr_resp [ 6];
150 u32 send_wdtr [ 4];
151 u32 sdtr_resp [ 6];
152 u32 send_sdtr [ 4];
153 u32 ppr_resp [ 6];
154 u32 send_ppr [ 4];
155 u32 nego_bad_phase [ 4];
156 u32 msg_out [ 4];
157 u32 msg_out_done [ 4];
158 u32 data_ovrun [ 2];
159 u32 data_ovrun1 [ 22];
160 u32 data_ovrun2 [ 8];
161 u32 abort_resel [ 16];
162 u32 resend_ident [ 4];
163 u32 ident_break [ 4];
164 u32 ident_break_atn [ 4];
165 u32 sdata_in [ 6];
166 u32 resel_bad_lun [ 4];
167 u32 bad_i_t_l [ 4];
168 u32 bad_i_t_l_q [ 4];
169 u32 bad_status [ 6];
170 u32 pm_handle [ 20];
171 u32 pm_handle1 [ 4];
172 u32 pm_save [ 4];
173 u32 pm0_save [ 12];
174 u32 pm_save_end [ 4];
175 u32 pm1_save [ 14];
177 /* WSR handling */
178 u32 pm_wsr_handle [ 38];
179 u32 wsr_ma_helper [ 4];
181 /* Data area */
182 u32 zero [ 1];
183 u32 scratch [ 1];
184 u32 pm0_data_addr [ 1];
185 u32 pm1_data_addr [ 1];
186 u32 done_pos [ 1];
187 u32 startpos [ 1];
188 u32 targtbl [ 1];
192 * Script fragments used at initialisations.
193 * Only runs out of main memory.
195 struct SYM_FWZ_SCR {
196 u32 snooptest [ 6];
197 u32 snoopend [ 2];
200 static struct SYM_FWA_SCR SYM_FWA_SCR = {
201 /*--------------------------< START >----------------------------*/ {
203 * Switch the LED on.
204 * Will be patched with a NO_OP if LED
205 * not needed or not desired.
207 SCR_REG_REG (gpreg, SCR_AND, 0xfe),
210 * Clear SIGP.
212 SCR_FROM_REG (ctest2),
215 * Stop here if the C code wants to perform
216 * some error recovery procedure manually.
217 * (Indicate this by setting SEM in ISTAT)
219 SCR_FROM_REG (istat),
222 * Report to the C code the next position in
223 * the start queue the SCRIPTS will schedule.
224 * The C code must not change SCRATCHA.
226 SCR_LOAD_ABS (scratcha, 4),
227 PADDR_B (startpos),
228 SCR_INT ^ IFTRUE (MASK (SEM, SEM)),
229 SIR_SCRIPT_STOPPED,
231 * Start the next job.
233 * @DSA = start point for this job.
234 * SCRATCHA = address of this job in the start queue.
236 * We will restore startpos with SCRATCHA if we fails the
237 * arbitration or if it is the idle job.
239 * The below GETJOB_BEGIN to GETJOB_END section of SCRIPTS
240 * is a critical path. If it is partially executed, it then
241 * may happen that the job address is not yet in the DSA
242 * and the next queue position points to the next JOB.
244 SCR_LOAD_ABS (dsa, 4),
245 PADDR_B (startpos),
246 SCR_LOAD_REL (temp, 4),
248 }/*-------------------------< GETJOB_BEGIN >---------------------*/,{
249 SCR_STORE_ABS (temp, 4),
250 PADDR_B (startpos),
251 SCR_LOAD_REL (dsa, 4),
253 }/*-------------------------< GETJOB_END >-----------------------*/,{
254 SCR_LOAD_REL (temp, 4),
256 SCR_RETURN,
258 }/*-------------------------< SELECT >---------------------------*/,{
260 * DSA contains the address of a scheduled
261 * data structure.
263 * SCRATCHA contains the address of the start queue
264 * entry which points to the next job.
266 * Set Initiator mode.
268 * (Target mode is left as an exercise for the reader)
270 #ifdef SYM_CONF_TARGET_ROLE_SUPPORT
271 SCR_CLR (SCR_TRG),
273 #endif
275 * And try to select this target.
277 SCR_SEL_TBL_ATN ^ offsetof (struct sym_dsb, select),
278 PADDR_A (ungetjob),
280 * Now there are 4 possibilities:
282 * (1) The chip loses arbitration.
283 * This is ok, because it will try again,
284 * when the bus becomes idle.
285 * (But beware of the timeout function!)
287 * (2) The chip is reselected.
288 * Then the script processor takes the jump
289 * to the RESELECT label.
291 * (3) The chip wins arbitration.
292 * Then it will execute SCRIPTS instruction until
293 * the next instruction that checks SCSI phase.
294 * Then will stop and wait for selection to be
295 * complete or selection time-out to occur.
297 * After having won arbitration, the SCRIPTS
298 * processor is able to execute instructions while
299 * the SCSI core is performing SCSI selection.
302 * Initialize the status registers
304 SCR_LOAD_REL (scr0, 4),
305 offsetof (struct sym_ccb, phys.head.status),
307 * We may need help from CPU if the DMA segment
308 * registers aren't up-to-date for this IO.
309 * Patched with NOOP for chips that donnot
310 * support DAC addressing.
312 #if SYM_CONF_DMA_ADDRESSING_MODE == 2
313 }/*-------------------------< IS_DMAP_DIRTY >--------------------*/,{
314 SCR_FROM_REG (HX_REG),
316 SCR_INT ^ IFTRUE (MASK (HX_DMAP_DIRTY, HX_DMAP_DIRTY)),
317 SIR_DMAP_DIRTY,
318 #endif
319 }/*-------------------------< WF_SEL_DONE >----------------------*/,{
320 SCR_INT ^ IFFALSE (WHEN (SCR_MSG_OUT)),
321 SIR_SEL_ATN_NO_MSG_OUT,
322 }/*-------------------------< SEL_DONE >-------------------------*/,{
324 * C1010-33 errata work-around.
325 * Due to a race, the SCSI core may not have
326 * loaded SCNTL3 on SEL_TBL instruction.
327 * We reload it once phase is stable.
328 * Patched with a NOOP for other chips.
330 SCR_LOAD_REL (scntl3, 1),
331 offsetof(struct sym_dsb, select.sel_scntl3),
332 }/*-------------------------< SEND_IDENT >-----------------------*/,{
334 * Selection complete.
335 * Send the IDENTIFY and possibly the TAG message
336 * and negotiation message if present.
338 SCR_MOVE_TBL ^ SCR_MSG_OUT,
339 offsetof (struct sym_dsb, smsg),
340 }/*-------------------------< SELECT2 >--------------------------*/,{
341 #ifdef SYM_CONF_IARB_SUPPORT
343 * Set IMMEDIATE ARBITRATION if we have been given
344 * a hint to do so. (Some job to do after this one).
346 SCR_FROM_REG (HF_REG),
348 SCR_JUMPR ^ IFFALSE (MASK (HF_HINT_IARB, HF_HINT_IARB)),
350 SCR_REG_REG (scntl1, SCR_OR, IARB),
352 #endif
354 * Anticipate the COMMAND phase.
355 * This is the PHASE we expect at this point.
357 SCR_JUMP ^ IFFALSE (WHEN (SCR_COMMAND)),
358 PADDR_A (sel_no_cmd),
359 }/*-------------------------< COMMAND >--------------------------*/,{
361 * ... and send the command
363 SCR_MOVE_TBL ^ SCR_COMMAND,
364 offsetof (struct sym_dsb, cmd),
365 }/*-------------------------< DISPATCH >-------------------------*/,{
367 * MSG_IN is the only phase that shall be
368 * entered at least once for each (re)selection.
369 * So we test it first.
371 SCR_JUMP ^ IFTRUE (WHEN (SCR_MSG_IN)),
372 PADDR_A (msg_in),
373 SCR_JUMP ^ IFTRUE (IF (SCR_DATA_OUT)),
374 PADDR_A (datao_phase),
375 SCR_JUMP ^ IFTRUE (IF (SCR_DATA_IN)),
376 PADDR_A (datai_phase),
377 SCR_JUMP ^ IFTRUE (IF (SCR_STATUS)),
378 PADDR_A (status),
379 SCR_JUMP ^ IFTRUE (IF (SCR_COMMAND)),
380 PADDR_A (command),
381 SCR_JUMP ^ IFTRUE (IF (SCR_MSG_OUT)),
382 PADDR_B (msg_out),
384 * Discard as many illegal phases as
385 * required and tell the C code about.
387 SCR_JUMPR ^ IFFALSE (WHEN (SCR_ILG_OUT)),
389 SCR_MOVE_ABS (1) ^ SCR_ILG_OUT,
390 HADDR_1 (scratch),
391 SCR_JUMPR ^ IFTRUE (WHEN (SCR_ILG_OUT)),
392 -16,
393 SCR_JUMPR ^ IFFALSE (WHEN (SCR_ILG_IN)),
395 SCR_MOVE_ABS (1) ^ SCR_ILG_IN,
396 HADDR_1 (scratch),
397 SCR_JUMPR ^ IFTRUE (WHEN (SCR_ILG_IN)),
398 -16,
399 SCR_INT,
400 SIR_BAD_PHASE,
401 SCR_JUMP,
402 PADDR_A (dispatch),
403 }/*-------------------------< SEL_NO_CMD >-----------------------*/,{
405 * The target does not switch to command
406 * phase after IDENTIFY has been sent.
408 * If it stays in MSG OUT phase send it
409 * the IDENTIFY again.
411 SCR_JUMP ^ IFTRUE (WHEN (SCR_MSG_OUT)),
412 PADDR_B (resend_ident),
414 * If target does not switch to MSG IN phase
415 * and we sent a negotiation, assert the
416 * failure immediately.
418 SCR_JUMP ^ IFTRUE (WHEN (SCR_MSG_IN)),
419 PADDR_A (dispatch),
420 SCR_FROM_REG (HS_REG),
422 SCR_INT ^ IFTRUE (DATA (HS_NEGOTIATE)),
423 SIR_NEGO_FAILED,
425 * Jump to dispatcher.
427 SCR_JUMP,
428 PADDR_A (dispatch),
429 }/*-------------------------< INIT >-----------------------------*/,{
431 * Wait for the SCSI RESET signal to be
432 * inactive before restarting operations,
433 * since the chip may hang on SEL_ATN
434 * if SCSI RESET is active.
436 SCR_FROM_REG (sstat0),
438 SCR_JUMPR ^ IFTRUE (MASK (IRST, IRST)),
439 -16,
440 SCR_JUMP,
441 PADDR_A (start),
442 }/*-------------------------< CLRACK >---------------------------*/,{
444 * Terminate possible pending message phase.
446 SCR_CLR (SCR_ACK),
448 SCR_JUMP,
449 PADDR_A (dispatch),
450 }/*-------------------------< DATAI_DONE >-----------------------*/,{
452 * Save current pointer to LASTP.
454 SCR_STORE_REL (temp, 4),
455 offsetof (struct sym_ccb, phys.head.lastp),
457 * If the SWIDE is not full, jump to dispatcher.
458 * We anticipate a STATUS phase.
460 SCR_FROM_REG (scntl2),
462 SCR_JUMP ^ IFTRUE (MASK (WSR, WSR)),
463 PADDR_A (datai_done_wsr),
464 SCR_JUMP ^ IFTRUE (WHEN (SCR_STATUS)),
465 PADDR_A (status),
466 SCR_JUMP,
467 PADDR_A (dispatch),
468 }/*-------------------------< DATAI_DONE_WSR >-------------------*/,{
470 * The SWIDE is full.
471 * Clear this condition.
473 SCR_REG_REG (scntl2, SCR_OR, WSR),
476 * We are expecting an IGNORE RESIDUE message
477 * from the device, otherwise we are in data
478 * overrun condition. Check against MSG_IN phase.
480 SCR_INT ^ IFFALSE (WHEN (SCR_MSG_IN)),
481 SIR_SWIDE_OVERRUN,
482 SCR_JUMP ^ IFFALSE (WHEN (SCR_MSG_IN)),
483 PADDR_A (dispatch),
485 * We are in MSG_IN phase,
486 * Read the first byte of the message.
487 * If it is not an IGNORE RESIDUE message,
488 * signal overrun and jump to message
489 * processing.
491 SCR_MOVE_ABS (1) ^ SCR_MSG_IN,
492 HADDR_1 (msgin[0]),
493 SCR_INT ^ IFFALSE (DATA (M_IGN_RESIDUE)),
494 SIR_SWIDE_OVERRUN,
495 SCR_JUMP ^ IFFALSE (DATA (M_IGN_RESIDUE)),
496 PADDR_A (msg_in2),
498 * We got the message we expected.
499 * Read the 2nd byte, and jump to dispatcher.
501 SCR_CLR (SCR_ACK),
503 SCR_MOVE_ABS (1) ^ SCR_MSG_IN,
504 HADDR_1 (msgin[1]),
505 SCR_CLR (SCR_ACK),
507 SCR_JUMP,
508 PADDR_A (dispatch),
509 }/*-------------------------< DATAO_DONE >-----------------------*/,{
511 * Save current pointer to LASTP.
513 SCR_STORE_REL (temp, 4),
514 offsetof (struct sym_ccb, phys.head.lastp),
516 * If the SODL is not full jump to dispatcher.
517 * We anticipate a STATUS phase.
519 SCR_FROM_REG (scntl2),
521 SCR_JUMP ^ IFTRUE (MASK (WSS, WSS)),
522 PADDR_A (datao_done_wss),
523 SCR_JUMP ^ IFTRUE (WHEN (SCR_STATUS)),
524 PADDR_A (status),
525 SCR_JUMP,
526 PADDR_A (dispatch),
527 }/*-------------------------< DATAO_DONE_WSS >-------------------*/,{
529 * The SODL is full, clear this condition.
531 SCR_REG_REG (scntl2, SCR_OR, WSS),
534 * And signal a DATA UNDERRUN condition
535 * to the C code.
537 SCR_INT,
538 SIR_SODL_UNDERRUN,
539 SCR_JUMP,
540 PADDR_A (dispatch),
541 }/*-------------------------< DATAI_PHASE >----------------------*/,{
543 * Jump to current pointer.
545 SCR_LOAD_REL (temp, 4),
546 offsetof (struct sym_ccb, phys.head.lastp),
547 SCR_RETURN,
549 }/*-------------------------< DATAO_PHASE >----------------------*/,{
551 * C1010-66 errata work-around.
552 * Extra clocks of data hold must be inserted
553 * in DATA OUT phase on 33 MHz PCI BUS.
554 * Patched with a NOOP for other chips.
556 SCR_REG_REG (scntl4, SCR_OR, (XCLKH_DT|XCLKH_ST)),
559 * Jump to current pointer.
561 SCR_LOAD_REL (temp, 4),
562 offsetof (struct sym_ccb, phys.head.lastp),
563 SCR_RETURN,
565 }/*-------------------------< MSG_IN >---------------------------*/,{
567 * Get the first byte of the message.
569 * The script processor doesn't negate the
570 * ACK signal after this transfer.
572 SCR_MOVE_ABS (1) ^ SCR_MSG_IN,
573 HADDR_1 (msgin[0]),
574 }/*-------------------------< MSG_IN2 >--------------------------*/,{
576 * Check first against 1 byte messages
577 * that we handle from SCRIPTS.
579 SCR_JUMP ^ IFTRUE (DATA (M_COMPLETE)),
580 PADDR_A (complete),
581 SCR_JUMP ^ IFTRUE (DATA (M_DISCONNECT)),
582 PADDR_A (disconnect),
583 SCR_JUMP ^ IFTRUE (DATA (M_SAVE_DP)),
584 PADDR_A (save_dp),
585 SCR_JUMP ^ IFTRUE (DATA (M_RESTORE_DP)),
586 PADDR_A (restore_dp),
588 * We handle all other messages from the
589 * C code, so no need to waste on-chip RAM
590 * for those ones.
592 SCR_JUMP,
593 PADDR_B (msg_in_etc),
594 }/*-------------------------< STATUS >---------------------------*/,{
596 * get the status
598 SCR_MOVE_ABS (1) ^ SCR_STATUS,
599 HADDR_1 (scratch),
600 #ifdef SYM_CONF_IARB_SUPPORT
602 * If STATUS is not GOOD, clear IMMEDIATE ARBITRATION,
603 * since we may have to tamper the start queue from
604 * the C code.
606 SCR_JUMPR ^ IFTRUE (DATA (S_GOOD)),
608 SCR_REG_REG (scntl1, SCR_AND, ~IARB),
610 #endif
612 * save status to scsi_status.
613 * mark as complete.
615 SCR_TO_REG (SS_REG),
617 SCR_LOAD_REG (HS_REG, HS_COMPLETE),
620 * Anticipate the MESSAGE PHASE for
621 * the TASK COMPLETE message.
623 SCR_JUMP ^ IFTRUE (WHEN (SCR_MSG_IN)),
624 PADDR_A (msg_in),
625 SCR_JUMP,
626 PADDR_A (dispatch),
627 }/*-------------------------< COMPLETE >-------------------------*/,{
629 * Complete message.
631 * When we terminate the cycle by clearing ACK,
632 * the target may disconnect immediately.
634 * We don't want to be told of an "unexpected disconnect",
635 * so we disable this feature.
637 SCR_REG_REG (scntl2, SCR_AND, 0x7f),
640 * Terminate cycle ...
642 SCR_CLR (SCR_ACK|SCR_ATN),
645 * ... and wait for the disconnect.
647 SCR_WAIT_DISC,
649 }/*-------------------------< COMPLETE2 >------------------------*/,{
651 * Save host status.
653 SCR_STORE_REL (scr0, 4),
654 offsetof (struct sym_ccb, phys.head.status),
656 * Some bridges may reorder DMA writes to memory.
657 * We donnot want the CPU to deal with completions
658 * without all the posted write having been flushed
659 * to memory. This DUMMY READ should flush posted
660 * buffers prior to the CPU having to deal with
661 * completions.
663 SCR_LOAD_REL (scr0, 4), /* DUMMY READ */
664 offsetof (struct sym_ccb, phys.head.status),
667 * If command resulted in not GOOD status,
668 * call the C code if needed.
670 SCR_FROM_REG (SS_REG),
672 SCR_CALL ^ IFFALSE (DATA (S_GOOD)),
673 PADDR_B (bad_status),
675 * If we performed an auto-sense, call
676 * the C code to synchronyze task aborts
677 * with UNIT ATTENTION conditions.
679 SCR_FROM_REG (HF_REG),
681 SCR_JUMP ^ IFFALSE (MASK (0 ,(HF_SENSE|HF_EXT_ERR))),
682 PADDR_A (complete_error),
683 }/*-------------------------< DONE >-----------------------------*/,{
685 * Copy the DSA to the DONE QUEUE and
686 * signal completion to the host.
687 * If we are interrupted between DONE
688 * and DONE_END, we must reset, otherwise
689 * the completed CCB may be lost.
691 SCR_STORE_ABS (dsa, 4),
692 PADDR_B (scratch),
693 SCR_LOAD_ABS (dsa, 4),
694 PADDR_B (done_pos),
695 SCR_LOAD_ABS (scratcha, 4),
696 PADDR_B (scratch),
697 SCR_STORE_REL (scratcha, 4),
700 * The instruction below reads the DONE QUEUE next
701 * free position from memory.
702 * In addition it ensures that all PCI posted writes
703 * are flushed and so the DSA value of the done
704 * CCB is visible by the CPU before INTFLY is raised.
706 SCR_LOAD_REL (scratcha, 4),
708 SCR_INT_FLY,
710 SCR_STORE_ABS (scratcha, 4),
711 PADDR_B (done_pos),
712 }/*-------------------------< DONE_END >-------------------------*/,{
713 SCR_JUMP,
714 PADDR_A (start),
715 }/*-------------------------< COMPLETE_ERROR >-------------------*/,{
716 SCR_LOAD_ABS (scratcha, 4),
717 PADDR_B (startpos),
718 SCR_INT,
719 SIR_COMPLETE_ERROR,
720 }/*-------------------------< SAVE_DP >--------------------------*/,{
722 * Clear ACK immediately.
723 * No need to delay it.
725 SCR_CLR (SCR_ACK),
728 * Keep track we received a SAVE DP, so
729 * we will switch to the other PM context
730 * on the next PM since the DP may point
731 * to the current PM context.
733 SCR_REG_REG (HF_REG, SCR_OR, HF_DP_SAVED),
736 * SAVE_DP message:
737 * Copy LASTP to SAVEP.
739 SCR_LOAD_REL (scratcha, 4),
740 offsetof (struct sym_ccb, phys.head.lastp),
741 SCR_STORE_REL (scratcha, 4),
742 offsetof (struct sym_ccb, phys.head.savep),
744 * Anticipate the MESSAGE PHASE for
745 * the DISCONNECT message.
747 SCR_JUMP ^ IFTRUE (WHEN (SCR_MSG_IN)),
748 PADDR_A (msg_in),
749 SCR_JUMP,
750 PADDR_A (dispatch),
751 }/*-------------------------< RESTORE_DP >-----------------------*/,{
753 * Clear ACK immediately.
754 * No need to delay it.
756 SCR_CLR (SCR_ACK),
759 * Copy SAVEP to LASTP.
761 SCR_LOAD_REL (scratcha, 4),
762 offsetof (struct sym_ccb, phys.head.savep),
763 SCR_STORE_REL (scratcha, 4),
764 offsetof (struct sym_ccb, phys.head.lastp),
765 SCR_JUMP,
766 PADDR_A (dispatch),
767 }/*-------------------------< DISCONNECT >-----------------------*/,{
769 * DISCONNECTing ...
771 * disable the "unexpected disconnect" feature,
772 * and remove the ACK signal.
774 SCR_REG_REG (scntl2, SCR_AND, 0x7f),
776 SCR_CLR (SCR_ACK|SCR_ATN),
779 * Wait for the disconnect.
781 SCR_WAIT_DISC,
784 * Status is: DISCONNECTED.
786 SCR_LOAD_REG (HS_REG, HS_DISCONNECT),
789 * Save host status.
791 SCR_STORE_REL (scr0, 4),
792 offsetof (struct sym_ccb, phys.head.status),
793 SCR_JUMP,
794 PADDR_A (start),
795 }/*-------------------------< IDLE >-----------------------------*/,{
797 * Nothing to do?
798 * Switch the LED off and wait for reselect.
799 * Will be patched with a NO_OP if LED
800 * not needed or not desired.
802 SCR_REG_REG (gpreg, SCR_OR, 0x01),
804 #ifdef SYM_CONF_IARB_SUPPORT
805 SCR_JUMPR,
807 #endif
808 }/*-------------------------< UNGETJOB >-------------------------*/,{
809 #ifdef SYM_CONF_IARB_SUPPORT
811 * Set IMMEDIATE ARBITRATION, for the next time.
812 * This will give us better chance to win arbitration
813 * for the job we just wanted to do.
815 SCR_REG_REG (scntl1, SCR_OR, IARB),
817 #endif
819 * We are not able to restart the SCRIPTS if we are
820 * interrupted and these instruction haven't been
821 * all executed. BTW, this is very unlikely to
822 * happen, but we check that from the C code.
824 SCR_LOAD_REG (dsa, 0xff),
826 SCR_STORE_ABS (scratcha, 4),
827 PADDR_B (startpos),
828 }/*-------------------------< RESELECT >-------------------------*/,{
829 #ifdef SYM_CONF_TARGET_ROLE_SUPPORT
831 * Make sure we are in initiator mode.
833 SCR_CLR (SCR_TRG),
835 #endif
837 * Sleep waiting for a reselection.
839 SCR_WAIT_RESEL,
840 PADDR_A(start),
841 }/*-------------------------< RESELECTED >-----------------------*/,{
843 * Switch the LED on.
844 * Will be patched with a NO_OP if LED
845 * not needed or not desired.
847 SCR_REG_REG (gpreg, SCR_AND, 0xfe),
850 * load the target id into the sdid
852 SCR_REG_SFBR (ssid, SCR_AND, 0x8F),
854 SCR_TO_REG (sdid),
857 * Load the target control block address
859 SCR_LOAD_ABS (dsa, 4),
860 PADDR_B (targtbl),
861 SCR_SFBR_REG (dsa, SCR_SHL, 0),
863 SCR_REG_REG (dsa, SCR_SHL, 0),
865 SCR_REG_REG (dsa, SCR_AND, 0x3c),
867 SCR_LOAD_REL (dsa, 4),
870 * We expect MESSAGE IN phase.
871 * If not, get help from the C code.
873 SCR_INT ^ IFFALSE (WHEN (SCR_MSG_IN)),
874 SIR_RESEL_NO_MSG_IN,
876 * Load the legacy synchronous transfer registers.
878 SCR_LOAD_REL (scntl3, 1),
879 offsetof(struct sym_tcb, head.wval),
880 SCR_LOAD_REL (sxfer, 1),
881 offsetof(struct sym_tcb, head.sval),
882 }/*-------------------------< RESEL_SCNTL4 >---------------------*/,{
884 * The C1010 uses a new synchronous timing scheme.
885 * Will be patched with a NO_OP if not a C1010.
887 SCR_LOAD_REL (scntl4, 1),
888 offsetof(struct sym_tcb, head.uval),
890 * Get the IDENTIFY message.
892 SCR_MOVE_ABS (1) ^ SCR_MSG_IN,
893 HADDR_1 (msgin),
895 * If IDENTIFY LUN #0, use a faster path
896 * to find the LCB structure.
898 SCR_JUMP ^ IFTRUE (MASK (0x80, 0xbf)),
899 PADDR_A (resel_lun0),
901 * If message isn't an IDENTIFY,
902 * tell the C code about.
904 SCR_INT ^ IFFALSE (MASK (0x80, 0x80)),
905 SIR_RESEL_NO_IDENTIFY,
907 * It is an IDENTIFY message,
908 * Load the LUN control block address.
910 SCR_LOAD_REL (dsa, 4),
911 offsetof(struct sym_tcb, head.luntbl_sa),
912 SCR_SFBR_REG (dsa, SCR_SHL, 0),
914 SCR_REG_REG (dsa, SCR_SHL, 0),
916 SCR_REG_REG (dsa, SCR_AND, 0xfc),
918 SCR_LOAD_REL (dsa, 4),
920 SCR_JUMPR,
922 }/*-------------------------< RESEL_LUN0 >-----------------------*/,{
924 * LUN 0 special case (but usual one :))
926 SCR_LOAD_REL (dsa, 4),
927 offsetof(struct sym_tcb, head.lun0_sa),
929 * Jump indirectly to the reselect action for this LUN.
931 SCR_LOAD_REL (temp, 4),
932 offsetof(struct sym_lcb, head.resel_sa),
933 SCR_RETURN,
935 /* In normal situations, we jump to RESEL_TAG or RESEL_NO_TAG */
936 }/*-------------------------< RESEL_TAG >------------------------*/,{
938 * ACK the IDENTIFY previously received.
940 SCR_CLR (SCR_ACK),
943 * It shall be a tagged command.
944 * Read SIMPLE+TAG.
945 * The C code will deal with errors.
946 * Aggressive optimization, isn't it? :)
948 SCR_MOVE_ABS (2) ^ SCR_MSG_IN,
949 HADDR_1 (msgin),
951 * Load the pointer to the tagged task
952 * table for this LUN.
954 SCR_LOAD_REL (dsa, 4),
955 offsetof(struct sym_lcb, head.itlq_tbl_sa),
957 * The SIDL still contains the TAG value.
958 * Aggressive optimization, isn't it? :):)
960 SCR_REG_SFBR (sidl, SCR_SHL, 0),
962 #if SYM_CONF_MAX_TASK*4 > 512
963 SCR_JUMPR ^ IFFALSE (CARRYSET),
965 SCR_REG_REG (dsa1, SCR_OR, 2),
967 SCR_REG_REG (sfbr, SCR_SHL, 0),
969 SCR_JUMPR ^ IFFALSE (CARRYSET),
971 SCR_REG_REG (dsa1, SCR_OR, 1),
973 #elif SYM_CONF_MAX_TASK*4 > 256
974 SCR_JUMPR ^ IFFALSE (CARRYSET),
976 SCR_REG_REG (dsa1, SCR_OR, 1),
978 #endif
980 * Retrieve the DSA of this task.
981 * JUMP indirectly to the restart point of the CCB.
983 SCR_SFBR_REG (dsa, SCR_AND, 0xfc),
985 SCR_LOAD_REL (dsa, 4),
987 SCR_LOAD_REL (temp, 4),
988 offsetof(struct sym_ccb, phys.head.go.restart),
989 SCR_RETURN,
991 /* In normal situations we branch to RESEL_DSA */
992 }/*-------------------------< RESEL_DSA >------------------------*/,{
994 * ACK the IDENTIFY or TAG previously received.
996 SCR_CLR (SCR_ACK),
998 }/*-------------------------< RESEL_DSA1 >-----------------------*/,{
1000 * Initialize the status registers
1002 SCR_LOAD_REL (scr0, 4),
1003 offsetof (struct sym_ccb, phys.head.status),
1005 * Jump to dispatcher.
1007 SCR_JUMP,
1008 PADDR_A (dispatch),
1009 }/*-------------------------< RESEL_NO_TAG >---------------------*/,{
1011 * Load the DSA with the unique ITL task.
1013 SCR_LOAD_REL (dsa, 4),
1014 offsetof(struct sym_lcb, head.itl_task_sa),
1016 * JUMP indirectly to the restart point of the CCB.
1018 SCR_LOAD_REL (temp, 4),
1019 offsetof(struct sym_ccb, phys.head.go.restart),
1020 SCR_RETURN,
1022 /* In normal situations we branch to RESEL_DSA */
1023 }/*-------------------------< DATA_IN >--------------------------*/,{
1025 * Because the size depends on the
1026 * #define SYM_CONF_MAX_SG parameter,
1027 * it is filled in at runtime.
1029 * ##===========< i=0; i<SYM_CONF_MAX_SG >=========
1030 * || SCR_CHMOV_TBL ^ SCR_DATA_IN,
1031 * || offsetof (struct sym_dsb, data[ i]),
1032 * ##==========================================
1035 }/*-------------------------< DATA_IN2 >-------------------------*/,{
1036 SCR_CALL,
1037 PADDR_A (datai_done),
1038 SCR_JUMP,
1039 PADDR_B (data_ovrun),
1040 }/*-------------------------< DATA_OUT >-------------------------*/,{
1042 * Because the size depends on the
1043 * #define SYM_CONF_MAX_SG parameter,
1044 * it is filled in at runtime.
1046 * ##===========< i=0; i<SYM_CONF_MAX_SG >=========
1047 * || SCR_CHMOV_TBL ^ SCR_DATA_OUT,
1048 * || offsetof (struct sym_dsb, data[ i]),
1049 * ##==========================================
1052 }/*-------------------------< DATA_OUT2 >------------------------*/,{
1053 SCR_CALL,
1054 PADDR_A (datao_done),
1055 SCR_JUMP,
1056 PADDR_B (data_ovrun),
1057 }/*-------------------------< PM0_DATA >-------------------------*/,{
1059 * Read our host flags to SFBR, so we will be able
1060 * to check against the data direction we expect.
1062 SCR_FROM_REG (HF_REG),
1065 * Check against actual DATA PHASE.
1067 SCR_JUMP ^ IFFALSE (WHEN (SCR_DATA_IN)),
1068 PADDR_A (pm0_data_out),
1070 * Actual phase is DATA IN.
1071 * Check against expected direction.
1073 SCR_JUMP ^ IFFALSE (MASK (HF_DATA_IN, HF_DATA_IN)),
1074 PADDR_B (data_ovrun),
1076 * Keep track we are moving data from the
1077 * PM0 DATA mini-script.
1079 SCR_REG_REG (HF_REG, SCR_OR, HF_IN_PM0),
1082 * Move the data to memory.
1084 SCR_CHMOV_TBL ^ SCR_DATA_IN,
1085 offsetof (struct sym_ccb, phys.pm0.sg),
1086 SCR_JUMP,
1087 PADDR_A (pm0_data_end),
1088 }/*-------------------------< PM0_DATA_OUT >---------------------*/,{
1090 * Actual phase is DATA OUT.
1091 * Check against expected direction.
1093 SCR_JUMP ^ IFTRUE (MASK (HF_DATA_IN, HF_DATA_IN)),
1094 PADDR_B (data_ovrun),
1096 * Keep track we are moving data from the
1097 * PM0 DATA mini-script.
1099 SCR_REG_REG (HF_REG, SCR_OR, HF_IN_PM0),
1102 * Move the data from memory.
1104 SCR_CHMOV_TBL ^ SCR_DATA_OUT,
1105 offsetof (struct sym_ccb, phys.pm0.sg),
1106 }/*-------------------------< PM0_DATA_END >---------------------*/,{
1108 * Clear the flag that told we were moving
1109 * data from the PM0 DATA mini-script.
1111 SCR_REG_REG (HF_REG, SCR_AND, (~HF_IN_PM0)),
1114 * Return to the previous DATA script which
1115 * is guaranteed by design (if no bug) to be
1116 * the main DATA script for this transfer.
1118 SCR_LOAD_REL (temp, 4),
1119 offsetof (struct sym_ccb, phys.pm0.ret),
1120 SCR_RETURN,
1122 }/*-------------------------< PM1_DATA >-------------------------*/,{
1124 * Read our host flags to SFBR, so we will be able
1125 * to check against the data direction we expect.
1127 SCR_FROM_REG (HF_REG),
1130 * Check against actual DATA PHASE.
1132 SCR_JUMP ^ IFFALSE (WHEN (SCR_DATA_IN)),
1133 PADDR_A (pm1_data_out),
1135 * Actual phase is DATA IN.
1136 * Check against expected direction.
1138 SCR_JUMP ^ IFFALSE (MASK (HF_DATA_IN, HF_DATA_IN)),
1139 PADDR_B (data_ovrun),
1141 * Keep track we are moving data from the
1142 * PM1 DATA mini-script.
1144 SCR_REG_REG (HF_REG, SCR_OR, HF_IN_PM1),
1147 * Move the data to memory.
1149 SCR_CHMOV_TBL ^ SCR_DATA_IN,
1150 offsetof (struct sym_ccb, phys.pm1.sg),
1151 SCR_JUMP,
1152 PADDR_A (pm1_data_end),
1153 }/*-------------------------< PM1_DATA_OUT >---------------------*/,{
1155 * Actual phase is DATA OUT.
1156 * Check against expected direction.
1158 SCR_JUMP ^ IFTRUE (MASK (HF_DATA_IN, HF_DATA_IN)),
1159 PADDR_B (data_ovrun),
1161 * Keep track we are moving data from the
1162 * PM1 DATA mini-script.
1164 SCR_REG_REG (HF_REG, SCR_OR, HF_IN_PM1),
1167 * Move the data from memory.
1169 SCR_CHMOV_TBL ^ SCR_DATA_OUT,
1170 offsetof (struct sym_ccb, phys.pm1.sg),
1171 }/*-------------------------< PM1_DATA_END >---------------------*/,{
1173 * Clear the flag that told we were moving
1174 * data from the PM1 DATA mini-script.
1176 SCR_REG_REG (HF_REG, SCR_AND, (~HF_IN_PM1)),
1179 * Return to the previous DATA script which
1180 * is guaranteed by design (if no bug) to be
1181 * the main DATA script for this transfer.
1183 SCR_LOAD_REL (temp, 4),
1184 offsetof (struct sym_ccb, phys.pm1.ret),
1185 SCR_RETURN,
1187 }/*-------------------------<>-----------------------------------*/
1190 static struct SYM_FWB_SCR SYM_FWB_SCR = {
1191 /*--------------------------< START64 >--------------------------*/ {
1193 * SCRIPT entry point for the 895A, 896 and 1010.
1194 * For now, there is no specific stuff for those
1195 * chips at this point, but this may come.
1197 SCR_JUMP,
1198 PADDR_A (init),
1199 }/*-------------------------< NO_DATA >--------------------------*/,{
1200 SCR_JUMP,
1201 PADDR_B (data_ovrun),
1202 }/*-------------------------< SEL_FOR_ABORT >--------------------*/,{
1204 * We are jumped here by the C code, if we have
1205 * some target to reset or some disconnected
1206 * job to abort. Since error recovery is a serious
1207 * busyness, we will really reset the SCSI BUS, if
1208 * case of a SCSI interrupt occurring in this path.
1210 #ifdef SYM_CONF_TARGET_ROLE_SUPPORT
1212 * Set initiator mode.
1214 SCR_CLR (SCR_TRG),
1216 #endif
1218 * And try to select this target.
1220 SCR_SEL_TBL_ATN ^ offsetof (struct sym_hcb, abrt_sel),
1221 PADDR_A (reselect),
1223 * Wait for the selection to complete or
1224 * the selection to time out.
1226 SCR_JUMPR ^ IFFALSE (WHEN (SCR_MSG_OUT)),
1229 * Call the C code.
1231 SCR_INT,
1232 SIR_TARGET_SELECTED,
1234 * The C code should let us continue here.
1235 * Send the 'kiss of death' message.
1236 * We expect an immediate disconnect once
1237 * the target has eaten the message.
1239 SCR_REG_REG (scntl2, SCR_AND, 0x7f),
1241 SCR_MOVE_TBL ^ SCR_MSG_OUT,
1242 offsetof (struct sym_hcb, abrt_tbl),
1243 SCR_CLR (SCR_ACK|SCR_ATN),
1245 SCR_WAIT_DISC,
1248 * Tell the C code that we are done.
1250 SCR_INT,
1251 SIR_ABORT_SENT,
1252 }/*-------------------------< SEL_FOR_ABORT_1 >------------------*/,{
1254 * Jump at scheduler.
1256 SCR_JUMP,
1257 PADDR_A (start),
1258 }/*-------------------------< MSG_IN_ETC >-----------------------*/,{
1260 * If it is an EXTENDED (variable size message)
1261 * Handle it.
1263 SCR_JUMP ^ IFTRUE (DATA (M_EXTENDED)),
1264 PADDR_B (msg_extended),
1266 * Let the C code handle any other
1267 * 1 byte message.
1269 SCR_JUMP ^ IFTRUE (MASK (0x00, 0xf0)),
1270 PADDR_B (msg_received),
1271 SCR_JUMP ^ IFTRUE (MASK (0x10, 0xf0)),
1272 PADDR_B (msg_received),
1274 * We donnot handle 2 bytes messages from SCRIPTS.
1275 * So, let the C code deal with these ones too.
1277 SCR_JUMP ^ IFFALSE (MASK (0x20, 0xf0)),
1278 PADDR_B (msg_weird_seen),
1279 SCR_CLR (SCR_ACK),
1281 SCR_MOVE_ABS (1) ^ SCR_MSG_IN,
1282 HADDR_1 (msgin[1]),
1283 }/*-------------------------< MSG_RECEIVED >---------------------*/,{
1284 SCR_LOAD_REL (scratcha, 4), /* DUMMY READ */
1286 SCR_INT,
1287 SIR_MSG_RECEIVED,
1288 }/*-------------------------< MSG_WEIRD_SEEN >-------------------*/,{
1289 SCR_LOAD_REL (scratcha, 4), /* DUMMY READ */
1291 SCR_INT,
1292 SIR_MSG_WEIRD,
1293 }/*-------------------------< MSG_EXTENDED >---------------------*/,{
1295 * Clear ACK and get the next byte
1296 * assumed to be the message length.
1298 SCR_CLR (SCR_ACK),
1300 SCR_MOVE_ABS (1) ^ SCR_MSG_IN,
1301 HADDR_1 (msgin[1]),
1303 * Try to catch some unlikely situations as 0 length
1304 * or too large the length.
1306 SCR_JUMP ^ IFTRUE (DATA (0)),
1307 PADDR_B (msg_weird_seen),
1308 SCR_TO_REG (scratcha),
1310 SCR_REG_REG (sfbr, SCR_ADD, (256-8)),
1312 SCR_JUMP ^ IFTRUE (CARRYSET),
1313 PADDR_B (msg_weird_seen),
1315 * We donnot handle extended messages from SCRIPTS.
1316 * Read the amount of data corresponding to the
1317 * message length and call the C code.
1319 SCR_STORE_REL (scratcha, 1),
1320 offsetof (struct sym_dsb, smsg_ext.size),
1321 SCR_CLR (SCR_ACK),
1323 SCR_MOVE_TBL ^ SCR_MSG_IN,
1324 offsetof (struct sym_dsb, smsg_ext),
1325 SCR_JUMP,
1326 PADDR_B (msg_received),
1327 }/*-------------------------< MSG_BAD >--------------------------*/,{
1329 * unimplemented message - reject it.
1331 SCR_INT,
1332 SIR_REJECT_TO_SEND,
1333 SCR_SET (SCR_ATN),
1335 SCR_JUMP,
1336 PADDR_A (clrack),
1337 }/*-------------------------< MSG_WEIRD >------------------------*/,{
1339 * weird message received
1340 * ignore all MSG IN phases and reject it.
1342 SCR_INT,
1343 SIR_REJECT_TO_SEND,
1344 SCR_SET (SCR_ATN),
1346 }/*-------------------------< MSG_WEIRD1 >-----------------------*/,{
1347 SCR_CLR (SCR_ACK),
1349 SCR_JUMP ^ IFFALSE (WHEN (SCR_MSG_IN)),
1350 PADDR_A (dispatch),
1351 SCR_MOVE_ABS (1) ^ SCR_MSG_IN,
1352 HADDR_1 (scratch),
1353 SCR_JUMP,
1354 PADDR_B (msg_weird1),
1355 }/*-------------------------< WDTR_RESP >------------------------*/,{
1357 * let the target fetch our answer.
1359 SCR_SET (SCR_ATN),
1361 SCR_CLR (SCR_ACK),
1363 SCR_JUMP ^ IFFALSE (WHEN (SCR_MSG_OUT)),
1364 PADDR_B (nego_bad_phase),
1365 }/*-------------------------< SEND_WDTR >------------------------*/,{
1367 * Send the M_X_WIDE_REQ
1369 SCR_MOVE_ABS (4) ^ SCR_MSG_OUT,
1370 HADDR_1 (msgout),
1371 SCR_JUMP,
1372 PADDR_B (msg_out_done),
1373 }/*-------------------------< SDTR_RESP >------------------------*/,{
1375 * let the target fetch our answer.
1377 SCR_SET (SCR_ATN),
1379 SCR_CLR (SCR_ACK),
1381 SCR_JUMP ^ IFFALSE (WHEN (SCR_MSG_OUT)),
1382 PADDR_B (nego_bad_phase),
1383 }/*-------------------------< SEND_SDTR >------------------------*/,{
1385 * Send the M_X_SYNC_REQ
1387 SCR_MOVE_ABS (5) ^ SCR_MSG_OUT,
1388 HADDR_1 (msgout),
1389 SCR_JUMP,
1390 PADDR_B (msg_out_done),
1391 }/*-------------------------< PPR_RESP >-------------------------*/,{
1393 * let the target fetch our answer.
1395 SCR_SET (SCR_ATN),
1397 SCR_CLR (SCR_ACK),
1399 SCR_JUMP ^ IFFALSE (WHEN (SCR_MSG_OUT)),
1400 PADDR_B (nego_bad_phase),
1401 }/*-------------------------< SEND_PPR >-------------------------*/,{
1403 * Send the M_X_PPR_REQ
1405 SCR_MOVE_ABS (8) ^ SCR_MSG_OUT,
1406 HADDR_1 (msgout),
1407 SCR_JUMP,
1408 PADDR_B (msg_out_done),
1409 }/*-------------------------< NEGO_BAD_PHASE >-------------------*/,{
1410 SCR_INT,
1411 SIR_NEGO_PROTO,
1412 SCR_JUMP,
1413 PADDR_A (dispatch),
1414 }/*-------------------------< MSG_OUT >--------------------------*/,{
1416 * The target requests a message.
1417 * We donnot send messages that may
1418 * require the device to go to bus free.
1420 SCR_MOVE_ABS (1) ^ SCR_MSG_OUT,
1421 HADDR_1 (msgout),
1423 * ... wait for the next phase
1424 * if it's a message out, send it again, ...
1426 SCR_JUMP ^ IFTRUE (WHEN (SCR_MSG_OUT)),
1427 PADDR_B (msg_out),
1428 }/*-------------------------< MSG_OUT_DONE >---------------------*/,{
1430 * Let the C code be aware of the
1431 * sent message and clear the message.
1433 SCR_INT,
1434 SIR_MSG_OUT_DONE,
1436 * ... and process the next phase
1438 SCR_JUMP,
1439 PADDR_A (dispatch),
1440 }/*-------------------------< DATA_OVRUN >-----------------------*/,{
1442 * Use scratcha to count the extra bytes.
1444 SCR_LOAD_ABS (scratcha, 4),
1445 PADDR_B (zero),
1446 }/*-------------------------< DATA_OVRUN1 >----------------------*/,{
1448 * The target may want to transfer too much data.
1450 * If phase is DATA OUT write 1 byte and count it.
1452 SCR_JUMPR ^ IFFALSE (WHEN (SCR_DATA_OUT)),
1454 SCR_CHMOV_ABS (1) ^ SCR_DATA_OUT,
1455 HADDR_1 (scratch),
1456 SCR_JUMP,
1457 PADDR_B (data_ovrun2),
1459 * If WSR is set, clear this condition, and
1460 * count this byte.
1462 SCR_FROM_REG (scntl2),
1464 SCR_JUMPR ^ IFFALSE (MASK (WSR, WSR)),
1466 SCR_REG_REG (scntl2, SCR_OR, WSR),
1468 SCR_JUMP,
1469 PADDR_B (data_ovrun2),
1471 * Finally check against DATA IN phase.
1472 * Signal data overrun to the C code
1473 * and jump to dispatcher if not so.
1474 * Read 1 byte otherwise and count it.
1476 SCR_JUMPR ^ IFTRUE (WHEN (SCR_DATA_IN)),
1478 SCR_INT,
1479 SIR_DATA_OVERRUN,
1480 SCR_JUMP,
1481 PADDR_A (dispatch),
1482 SCR_CHMOV_ABS (1) ^ SCR_DATA_IN,
1483 HADDR_1 (scratch),
1484 }/*-------------------------< DATA_OVRUN2 >----------------------*/,{
1486 * Count this byte.
1487 * This will allow to return a negative
1488 * residual to user.
1490 SCR_REG_REG (scratcha, SCR_ADD, 0x01),
1492 SCR_REG_REG (scratcha1, SCR_ADDC, 0),
1494 SCR_REG_REG (scratcha2, SCR_ADDC, 0),
1497 * .. and repeat as required.
1499 SCR_JUMP,
1500 PADDR_B (data_ovrun1),
1501 }/*-------------------------< ABORT_RESEL >----------------------*/,{
1502 SCR_SET (SCR_ATN),
1504 SCR_CLR (SCR_ACK),
1507 * send the abort/abortag/reset message
1508 * we expect an immediate disconnect
1510 SCR_REG_REG (scntl2, SCR_AND, 0x7f),
1512 SCR_MOVE_ABS (1) ^ SCR_MSG_OUT,
1513 HADDR_1 (msgout),
1514 SCR_CLR (SCR_ACK|SCR_ATN),
1516 SCR_WAIT_DISC,
1518 SCR_INT,
1519 SIR_RESEL_ABORTED,
1520 SCR_JUMP,
1521 PADDR_A (start),
1522 }/*-------------------------< RESEND_IDENT >---------------------*/,{
1524 * The target stays in MSG OUT phase after having acked
1525 * Identify [+ Tag [+ Extended message ]]. Targets shall
1526 * behave this way on parity error.
1527 * We must send it again all the messages.
1529 SCR_SET (SCR_ATN), /* Shall be asserted 2 deskew delays before the */
1530 0, /* 1rst ACK = 90 ns. Hope the chip isn't too fast */
1531 SCR_JUMP,
1532 PADDR_A (send_ident),
1533 }/*-------------------------< IDENT_BREAK >----------------------*/,{
1534 SCR_CLR (SCR_ATN),
1536 SCR_JUMP,
1537 PADDR_A (select2),
1538 }/*-------------------------< IDENT_BREAK_ATN >------------------*/,{
1539 SCR_SET (SCR_ATN),
1541 SCR_JUMP,
1542 PADDR_A (select2),
1543 }/*-------------------------< SDATA_IN >-------------------------*/,{
1544 SCR_CHMOV_TBL ^ SCR_DATA_IN,
1545 offsetof (struct sym_dsb, sense),
1546 SCR_CALL,
1547 PADDR_A (datai_done),
1548 SCR_JUMP,
1549 PADDR_B (data_ovrun),
1550 }/*-------------------------< RESEL_BAD_LUN >--------------------*/,{
1552 * Message is an IDENTIFY, but lun is unknown.
1553 * Signal problem to C code for logging the event.
1554 * Send a M_ABORT to clear all pending tasks.
1556 SCR_INT,
1557 SIR_RESEL_BAD_LUN,
1558 SCR_JUMP,
1559 PADDR_B (abort_resel),
1560 }/*-------------------------< BAD_I_T_L >------------------------*/,{
1562 * We donnot have a task for that I_T_L.
1563 * Signal problem to C code for logging the event.
1564 * Send a M_ABORT message.
1566 SCR_INT,
1567 SIR_RESEL_BAD_I_T_L,
1568 SCR_JUMP,
1569 PADDR_B (abort_resel),
1570 }/*-------------------------< BAD_I_T_L_Q >----------------------*/,{
1572 * We donnot have a task that matches the tag.
1573 * Signal problem to C code for logging the event.
1574 * Send a M_ABORTTAG message.
1576 SCR_INT,
1577 SIR_RESEL_BAD_I_T_L_Q,
1578 SCR_JUMP,
1579 PADDR_B (abort_resel),
1580 }/*-------------------------< BAD_STATUS >-----------------------*/,{
1582 * Anything different from INTERMEDIATE
1583 * CONDITION MET should be a bad SCSI status,
1584 * given that GOOD status has already been tested.
1585 * Call the C code.
1587 SCR_LOAD_ABS (scratcha, 4),
1588 PADDR_B (startpos),
1589 SCR_INT ^ IFFALSE (DATA (S_COND_MET)),
1590 SIR_BAD_SCSI_STATUS,
1591 SCR_RETURN,
1593 }/*-------------------------< PM_HANDLE >------------------------*/,{
1595 * Phase mismatch handling.
1597 * Since we have to deal with 2 SCSI data pointers
1598 * (current and saved), we need at least 2 contexts.
1599 * Each context (pm0 and pm1) has a saved area, a
1600 * SAVE mini-script and a DATA phase mini-script.
1603 * Get the PM handling flags.
1605 SCR_FROM_REG (HF_REG),
1608 * If no flags (1rst PM for example), avoid
1609 * all the below heavy flags testing.
1610 * This makes the normal case a bit faster.
1612 SCR_JUMP ^ IFTRUE (MASK (0, (HF_IN_PM0 | HF_IN_PM1 | HF_DP_SAVED))),
1613 PADDR_B (pm_handle1),
1615 * If we received a SAVE DP, switch to the
1616 * other PM context since the savep may point
1617 * to the current PM context.
1619 SCR_JUMPR ^ IFFALSE (MASK (HF_DP_SAVED, HF_DP_SAVED)),
1621 SCR_REG_REG (sfbr, SCR_XOR, HF_ACT_PM),
1624 * If we have been interrupt in a PM DATA mini-script,
1625 * we take the return address from the corresponding
1626 * saved area.
1627 * This ensure the return address always points to the
1628 * main DATA script for this transfer.
1630 SCR_JUMP ^ IFTRUE (MASK (0, (HF_IN_PM0 | HF_IN_PM1))),
1631 PADDR_B (pm_handle1),
1632 SCR_JUMPR ^ IFFALSE (MASK (HF_IN_PM0, HF_IN_PM0)),
1634 SCR_LOAD_REL (ia, 4),
1635 offsetof(struct sym_ccb, phys.pm0.ret),
1636 SCR_JUMP,
1637 PADDR_B (pm_save),
1638 SCR_LOAD_REL (ia, 4),
1639 offsetof(struct sym_ccb, phys.pm1.ret),
1640 SCR_JUMP,
1641 PADDR_B (pm_save),
1642 }/*-------------------------< PM_HANDLE1 >-----------------------*/,{
1644 * Normal case.
1645 * Update the return address so that it
1646 * will point after the interrupted MOVE.
1648 SCR_REG_REG (ia, SCR_ADD, 8),
1650 SCR_REG_REG (ia1, SCR_ADDC, 0),
1652 }/*-------------------------< PM_SAVE >--------------------------*/,{
1654 * Clear all the flags that told us if we were
1655 * interrupted in a PM DATA mini-script and/or
1656 * we received a SAVE DP.
1658 SCR_SFBR_REG (HF_REG, SCR_AND, (~(HF_IN_PM0|HF_IN_PM1|HF_DP_SAVED))),
1661 * Choose the current PM context.
1663 SCR_JUMP ^ IFTRUE (MASK (HF_ACT_PM, HF_ACT_PM)),
1664 PADDR_B (pm1_save),
1665 }/*-------------------------< PM0_SAVE >-------------------------*/,{
1666 SCR_STORE_REL (ia, 4),
1667 offsetof(struct sym_ccb, phys.pm0.ret),
1669 * If WSR bit is set, either UA and RBC may
1670 * have to be changed whether the device wants
1671 * to ignore this residue or not.
1673 SCR_FROM_REG (scntl2),
1675 SCR_CALL ^ IFTRUE (MASK (WSR, WSR)),
1676 PADDR_B (pm_wsr_handle),
1678 * Save the remaining byte count, the updated
1679 * address and the return address.
1681 SCR_STORE_REL (rbc, 4),
1682 offsetof(struct sym_ccb, phys.pm0.sg.size),
1683 SCR_STORE_REL (ua, 4),
1684 offsetof(struct sym_ccb, phys.pm0.sg.addr),
1686 * Set the current pointer at the PM0 DATA mini-script.
1688 SCR_LOAD_ABS (ia, 4),
1689 PADDR_B (pm0_data_addr),
1690 }/*-------------------------< PM_SAVE_END >----------------------*/,{
1691 SCR_STORE_REL (ia, 4),
1692 offsetof(struct sym_ccb, phys.head.lastp),
1693 SCR_JUMP,
1694 PADDR_A (dispatch),
1695 }/*-------------------------< PM1_SAVE >-------------------------*/,{
1696 SCR_STORE_REL (ia, 4),
1697 offsetof(struct sym_ccb, phys.pm1.ret),
1699 * If WSR bit is set, either UA and RBC may
1700 * have to be changed whether the device wants
1701 * to ignore this residue or not.
1703 SCR_FROM_REG (scntl2),
1705 SCR_CALL ^ IFTRUE (MASK (WSR, WSR)),
1706 PADDR_B (pm_wsr_handle),
1708 * Save the remaining byte count, the updated
1709 * address and the return address.
1711 SCR_STORE_REL (rbc, 4),
1712 offsetof(struct sym_ccb, phys.pm1.sg.size),
1713 SCR_STORE_REL (ua, 4),
1714 offsetof(struct sym_ccb, phys.pm1.sg.addr),
1716 * Set the current pointer at the PM1 DATA mini-script.
1718 SCR_LOAD_ABS (ia, 4),
1719 PADDR_B (pm1_data_addr),
1720 SCR_JUMP,
1721 PADDR_B (pm_save_end),
1722 }/*-------------------------< PM_WSR_HANDLE >--------------------*/,{
1724 * Phase mismatch handling from SCRIPT with WSR set.
1725 * Such a condition can occur if the chip wants to
1726 * execute a CHMOV(size > 1) when the WSR bit is
1727 * set and the target changes PHASE.
1729 * We must move the residual byte to memory.
1731 * UA contains bit 0..31 of the address to
1732 * move the residual byte.
1733 * Move it to the table indirect.
1735 SCR_STORE_REL (ua, 4),
1736 offsetof (struct sym_ccb, phys.wresid.addr),
1738 * Increment UA (move address to next position).
1740 SCR_REG_REG (ua, SCR_ADD, 1),
1742 SCR_REG_REG (ua1, SCR_ADDC, 0),
1744 SCR_REG_REG (ua2, SCR_ADDC, 0),
1746 SCR_REG_REG (ua3, SCR_ADDC, 0),
1749 * Compute SCRATCHA as:
1750 * - size to transfer = 1 byte.
1751 * - bit 24..31 = high address bit [32...39].
1753 SCR_LOAD_ABS (scratcha, 4),
1754 PADDR_B (zero),
1755 SCR_REG_REG (scratcha, SCR_OR, 1),
1757 SCR_FROM_REG (rbc3),
1759 SCR_TO_REG (scratcha3),
1762 * Move this value to the table indirect.
1764 SCR_STORE_REL (scratcha, 4),
1765 offsetof (struct sym_ccb, phys.wresid.size),
1767 * Wait for a valid phase.
1768 * While testing with bogus QUANTUM drives, the C1010
1769 * sometimes raised a spurious phase mismatch with
1770 * WSR and the CHMOV(1) triggered another PM.
1771 * Waiting explicitly for the PHASE seemed to avoid
1772 * the nested phase mismatch. Btw, this didn't happen
1773 * using my IBM drives.
1775 SCR_JUMPR ^ IFFALSE (WHEN (SCR_DATA_IN)),
1778 * Perform the move of the residual byte.
1780 SCR_CHMOV_TBL ^ SCR_DATA_IN,
1781 offsetof (struct sym_ccb, phys.wresid),
1783 * We can now handle the phase mismatch with UA fixed.
1784 * RBC[0..23]=0 is a special case that does not require
1785 * a PM context. The C code also checks against this.
1787 SCR_FROM_REG (rbc),
1789 SCR_RETURN ^ IFFALSE (DATA (0)),
1791 SCR_FROM_REG (rbc1),
1793 SCR_RETURN ^ IFFALSE (DATA (0)),
1795 SCR_FROM_REG (rbc2),
1797 SCR_RETURN ^ IFFALSE (DATA (0)),
1800 * RBC[0..23]=0.
1801 * Not only we donnot need a PM context, but this would
1802 * lead to a bogus CHMOV(0). This condition means that
1803 * the residual was the last byte to move from this CHMOV.
1804 * So, we just have to move the current data script pointer
1805 * (i.e. TEMP) to the SCRIPTS address following the
1806 * interrupted CHMOV and jump to dispatcher.
1807 * IA contains the data pointer to save.
1809 SCR_JUMP,
1810 PADDR_B (pm_save_end),
1811 }/*-------------------------< WSR_MA_HELPER >--------------------*/,{
1813 * Helper for the C code when WSR bit is set.
1814 * Perform the move of the residual byte.
1816 SCR_CHMOV_TBL ^ SCR_DATA_IN,
1817 offsetof (struct sym_ccb, phys.wresid),
1818 SCR_JUMP,
1819 PADDR_A (dispatch),
1821 }/*-------------------------< ZERO >-----------------------------*/,{
1822 SCR_DATA_ZERO,
1823 }/*-------------------------< SCRATCH >--------------------------*/,{
1824 SCR_DATA_ZERO,
1825 }/*-------------------------< PM0_DATA_ADDR >--------------------*/,{
1826 SCR_DATA_ZERO,
1827 }/*-------------------------< PM1_DATA_ADDR >--------------------*/,{
1828 SCR_DATA_ZERO,
1829 }/*-------------------------< DONE_POS >-------------------------*/,{
1830 SCR_DATA_ZERO,
1831 }/*-------------------------< STARTPOS >-------------------------*/,{
1832 SCR_DATA_ZERO,
1833 }/*-------------------------< TARGTBL >--------------------------*/,{
1834 SCR_DATA_ZERO,
1835 }/*-------------------------<>-----------------------------------*/
1838 static struct SYM_FWZ_SCR SYM_FWZ_SCR = {
1839 /*-------------------------< SNOOPTEST >------------------------*/{
1841 * Read the variable from memory.
1843 SCR_LOAD_REL (scratcha, 4),
1844 offsetof(struct sym_hcb, scratch),
1846 * Write the variable to memory.
1848 SCR_STORE_REL (temp, 4),
1849 offsetof(struct sym_hcb, scratch),
1851 * Read back the variable from memory.
1853 SCR_LOAD_REL (temp, 4),
1854 offsetof(struct sym_hcb, scratch),
1855 }/*-------------------------< SNOOPEND >-------------------------*/,{
1857 * And stop.
1859 SCR_INT,
1861 }/*-------------------------<>-----------------------------------*/