cpufreq: cpufreq-cpu0: remove dependency on THERMAL and REGULATOR
[linux/fpc-iii.git] / drivers / scsi / sym53c8xx_2 / sym_fw1.h
blob63952ee300b56034fcd4e25930c280e3c16a0b49
1 /*
2 * Device driver for the SYMBIOS/LSILOGIC 53C8XX and 53C1010 family
3 * of PCI-SCSI IO processors.
5 * Copyright (C) 1999-2001 Gerard Roudier <groudier@free.fr>
7 * This driver is derived from the Linux sym53c8xx driver.
8 * Copyright (C) 1998-2000 Gerard Roudier
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.
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
18 * Other major contributions:
20 * NVRAM detection and reading.
21 * Copyright (C) 1997 Richard Waltham <dormouse@farsrobt.demon.co.uk>
23 *-----------------------------------------------------------------------------
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.
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.
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
41 * Scripts for SYMBIOS-Processor
43 * We have to know the offsets of all labels before we reach
44 * them (for forward jumps). Therefore we declare a struct
45 * here. If you make changes inside the script,
47 * DONT FORGET TO CHANGE THE LENGTHS HERE!
51 * Script fragments which are loaded into the on-chip RAM
52 * of 825A, 875, 876, 895, 895A, 896 and 1010 chips.
53 * Must not exceed 4K bytes.
55 struct SYM_FWA_SCR {
56 u32 start [ 11];
57 u32 getjob_begin [ 4];
58 u32 _sms_a10 [ 5];
59 u32 getjob_end [ 4];
60 u32 _sms_a20 [ 4];
61 #ifdef SYM_CONF_TARGET_ROLE_SUPPORT
62 u32 select [ 8];
63 #else
64 u32 select [ 6];
65 #endif
66 u32 _sms_a30 [ 5];
67 u32 wf_sel_done [ 2];
68 u32 send_ident [ 2];
69 #ifdef SYM_CONF_IARB_SUPPORT
70 u32 select2 [ 8];
71 #else
72 u32 select2 [ 2];
73 #endif
74 u32 command [ 2];
75 u32 dispatch [ 28];
76 u32 sel_no_cmd [ 10];
77 u32 init [ 6];
78 u32 clrack [ 4];
79 u32 datai_done [ 11];
80 u32 datai_done_wsr [ 20];
81 u32 datao_done [ 11];
82 u32 datao_done_wss [ 6];
83 u32 datai_phase [ 5];
84 u32 datao_phase [ 5];
85 u32 msg_in [ 2];
86 u32 msg_in2 [ 10];
87 #ifdef SYM_CONF_IARB_SUPPORT
88 u32 status [ 14];
89 #else
90 u32 status [ 10];
91 #endif
92 u32 complete [ 6];
93 u32 complete2 [ 8];
94 u32 _sms_a40 [ 12];
95 u32 done [ 5];
96 u32 _sms_a50 [ 5];
97 u32 _sms_a60 [ 2];
98 u32 done_end [ 4];
99 u32 complete_error [ 5];
100 u32 save_dp [ 11];
101 u32 restore_dp [ 7];
102 u32 disconnect [ 11];
103 u32 disconnect2 [ 5];
104 u32 _sms_a65 [ 3];
105 #ifdef SYM_CONF_IARB_SUPPORT
106 u32 idle [ 4];
107 #else
108 u32 idle [ 2];
109 #endif
110 #ifdef SYM_CONF_IARB_SUPPORT
111 u32 ungetjob [ 7];
112 #else
113 u32 ungetjob [ 5];
114 #endif
115 #ifdef SYM_CONF_TARGET_ROLE_SUPPORT
116 u32 reselect [ 4];
117 #else
118 u32 reselect [ 2];
119 #endif
120 u32 reselected [ 19];
121 u32 _sms_a70 [ 6];
122 u32 _sms_a80 [ 4];
123 u32 reselected1 [ 25];
124 u32 _sms_a90 [ 4];
125 u32 resel_lun0 [ 7];
126 u32 _sms_a100 [ 4];
127 u32 resel_tag [ 8];
128 #if SYM_CONF_MAX_TASK*4 > 512
129 u32 _sms_a110 [ 23];
130 #elif SYM_CONF_MAX_TASK*4 > 256
131 u32 _sms_a110 [ 17];
132 #else
133 u32 _sms_a110 [ 13];
134 #endif
135 u32 _sms_a120 [ 2];
136 u32 resel_go [ 4];
137 u32 _sms_a130 [ 7];
138 u32 resel_dsa [ 2];
139 u32 resel_dsa1 [ 4];
140 u32 _sms_a140 [ 7];
141 u32 resel_no_tag [ 4];
142 u32 _sms_a145 [ 7];
143 u32 data_in [SYM_CONF_MAX_SG * 2];
144 u32 data_in2 [ 4];
145 u32 data_out [SYM_CONF_MAX_SG * 2];
146 u32 data_out2 [ 4];
147 u32 pm0_data [ 12];
148 u32 pm0_data_out [ 6];
149 u32 pm0_data_end [ 7];
150 u32 pm_data_end [ 4];
151 u32 _sms_a150 [ 4];
152 u32 pm1_data [ 12];
153 u32 pm1_data_out [ 6];
154 u32 pm1_data_end [ 9];
158 * Script fragments which stay in main memory for all chips
159 * except for chips that support 8K on-chip RAM.
161 struct SYM_FWB_SCR {
162 u32 no_data [ 2];
163 #ifdef SYM_CONF_TARGET_ROLE_SUPPORT
164 u32 sel_for_abort [ 18];
165 #else
166 u32 sel_for_abort [ 16];
167 #endif
168 u32 sel_for_abort_1 [ 2];
169 u32 msg_in_etc [ 12];
170 u32 msg_received [ 5];
171 u32 msg_weird_seen [ 5];
172 u32 msg_extended [ 17];
173 u32 _sms_b10 [ 4];
174 u32 msg_bad [ 6];
175 u32 msg_weird [ 4];
176 u32 msg_weird1 [ 8];
177 u32 wdtr_resp [ 6];
178 u32 send_wdtr [ 4];
179 u32 sdtr_resp [ 6];
180 u32 send_sdtr [ 4];
181 u32 ppr_resp [ 6];
182 u32 send_ppr [ 4];
183 u32 nego_bad_phase [ 4];
184 u32 msg_out [ 4];
185 u32 msg_out_done [ 4];
186 u32 data_ovrun [ 3];
187 u32 data_ovrun1 [ 22];
188 u32 data_ovrun2 [ 8];
189 u32 abort_resel [ 16];
190 u32 resend_ident [ 4];
191 u32 ident_break [ 4];
192 u32 ident_break_atn [ 4];
193 u32 sdata_in [ 6];
194 u32 resel_bad_lun [ 4];
195 u32 bad_i_t_l [ 4];
196 u32 bad_i_t_l_q [ 4];
197 u32 bad_status [ 7];
198 u32 wsr_ma_helper [ 4];
200 /* Data area */
201 u32 zero [ 1];
202 u32 scratch [ 1];
203 u32 scratch1 [ 1];
204 u32 prev_done [ 1];
205 u32 done_pos [ 1];
206 u32 nextjob [ 1];
207 u32 startpos [ 1];
208 u32 targtbl [ 1];
212 * Script fragments used at initialisations.
213 * Only runs out of main memory.
215 struct SYM_FWZ_SCR {
216 u32 snooptest [ 9];
217 u32 snoopend [ 2];
220 static struct SYM_FWA_SCR SYM_FWA_SCR = {
221 /*--------------------------< START >----------------------------*/ {
223 * Switch the LED on.
224 * Will be patched with a NO_OP if LED
225 * not needed or not desired.
227 SCR_REG_REG (gpreg, SCR_AND, 0xfe),
230 * Clear SIGP.
232 SCR_FROM_REG (ctest2),
235 * Stop here if the C code wants to perform
236 * some error recovery procedure manually.
237 * (Indicate this by setting SEM in ISTAT)
239 SCR_FROM_REG (istat),
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.
246 SCR_COPY (4),
247 PADDR_B (startpos),
248 RADDR_1 (scratcha),
249 SCR_INT ^ IFTRUE (MASK (SEM, SEM)),
250 SIR_SCRIPT_STOPPED,
252 * Start the next job.
254 * @DSA = start point for this job.
255 * SCRATCHA = address of this job in the start queue.
257 * We will restore startpos with SCRATCHA if we fails the
258 * arbitration or if it is the idle job.
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.
265 }/*-------------------------< GETJOB_BEGIN >---------------------*/,{
267 * Copy to a fixed location both the next STARTPOS
268 * and the current JOB address, using self modifying
269 * SCRIPTS.
271 SCR_COPY (4),
272 RADDR_1 (scratcha),
273 PADDR_A (_sms_a10),
274 SCR_COPY (8),
275 }/*-------------------------< _SMS_A10 >-------------------------*/,{
277 PADDR_B (nextjob),
279 * Move the start address to TEMP using self-
280 * modifying SCRIPTS and jump indirectly to
281 * that address.
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 >-------------------------*/,{
293 RADDR_1 (temp),
294 SCR_RETURN,
296 }/*-------------------------< SELECT >---------------------------*/,{
298 * DSA contains the address of a scheduled
299 * data structure.
301 * SCRATCHA contains the address of the start queue
302 * entry which points to the next job.
304 * Set Initiator mode.
306 * (Target mode is left as an exercise for the reader)
308 #ifdef SYM_CONF_TARGET_ROLE_SUPPORT
309 SCR_CLR (SCR_TRG),
311 #endif
313 * And try to select this target.
315 SCR_SEL_TBL_ATN ^ offsetof (struct sym_dsb, select),
316 PADDR_A (ungetjob),
318 * Now there are 4 possibilities:
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!)
325 * (2) The chip is reselected.
326 * Then the script processor takes the jump
327 * to the RESELECT label.
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.
335 * After having won arbitration, the SCRIPTS
336 * processor is able to execute instructions while
337 * the SCSI core is performing SCSI selection.
341 * Copy the CCB header to a fixed location
342 * in the HCB using self-modifying SCRIPTS.
344 SCR_COPY (4),
345 RADDR_1 (dsa),
346 PADDR_A (_sms_a30),
347 SCR_COPY (sizeof(struct sym_ccbh)),
348 }/*-------------------------< _SMS_A30 >-------------------------*/,{
350 HADDR_1 (ccb_head),
352 * Initialize the status register
354 SCR_COPY (4),
355 HADDR_1 (ccb_head.status),
356 RADDR_1 (scr0),
357 }/*-------------------------< WF_SEL_DONE >----------------------*/,{
358 SCR_INT ^ IFFALSE (WHEN (SCR_MSG_OUT)),
359 SIR_SEL_ATN_NO_MSG_OUT,
360 }/*-------------------------< SEND_IDENT >-----------------------*/,{
362 * Selection complete.
363 * Send the IDENTIFY and possibly the TAG message
364 * and negotiation message if present.
366 SCR_MOVE_TBL ^ SCR_MSG_OUT,
367 offsetof (struct sym_dsb, smsg),
368 }/*-------------------------< SELECT2 >--------------------------*/,{
369 #ifdef SYM_CONF_IARB_SUPPORT
371 * Set IMMEDIATE ARBITRATION if we have been given
372 * a hint to do so. (Some job to do after this one).
374 SCR_FROM_REG (HF_REG),
376 SCR_JUMPR ^ IFFALSE (MASK (HF_HINT_IARB, HF_HINT_IARB)),
378 SCR_REG_REG (scntl1, SCR_OR, IARB),
380 #endif
382 * Anticipate the COMMAND phase.
383 * This is the PHASE we expect at this point.
385 SCR_JUMP ^ IFFALSE (WHEN (SCR_COMMAND)),
386 PADDR_A (sel_no_cmd),
387 }/*-------------------------< COMMAND >--------------------------*/,{
389 * ... and send the command
391 SCR_MOVE_TBL ^ SCR_COMMAND,
392 offsetof (struct sym_dsb, cmd),
393 }/*-------------------------< DISPATCH >-------------------------*/,{
395 * MSG_IN is the only phase that shall be
396 * entered at least once for each (re)selection.
397 * So we test it first.
399 SCR_JUMP ^ IFTRUE (WHEN (SCR_MSG_IN)),
400 PADDR_A (msg_in),
401 SCR_JUMP ^ IFTRUE (IF (SCR_DATA_OUT)),
402 PADDR_A (datao_phase),
403 SCR_JUMP ^ IFTRUE (IF (SCR_DATA_IN)),
404 PADDR_A (datai_phase),
405 SCR_JUMP ^ IFTRUE (IF (SCR_STATUS)),
406 PADDR_A (status),
407 SCR_JUMP ^ IFTRUE (IF (SCR_COMMAND)),
408 PADDR_A (command),
409 SCR_JUMP ^ IFTRUE (IF (SCR_MSG_OUT)),
410 PADDR_B (msg_out),
412 * Discard as many illegal phases as
413 * required and tell the C code about.
415 SCR_JUMPR ^ IFFALSE (WHEN (SCR_ILG_OUT)),
417 SCR_MOVE_ABS (1) ^ SCR_ILG_OUT,
418 HADDR_1 (scratch),
419 SCR_JUMPR ^ IFTRUE (WHEN (SCR_ILG_OUT)),
420 -16,
421 SCR_JUMPR ^ IFFALSE (WHEN (SCR_ILG_IN)),
423 SCR_MOVE_ABS (1) ^ SCR_ILG_IN,
424 HADDR_1 (scratch),
425 SCR_JUMPR ^ IFTRUE (WHEN (SCR_ILG_IN)),
426 -16,
427 SCR_INT,
428 SIR_BAD_PHASE,
429 SCR_JUMP,
430 PADDR_A (dispatch),
431 }/*-------------------------< SEL_NO_CMD >-----------------------*/,{
433 * The target does not switch to command
434 * phase after IDENTIFY has been sent.
436 * If it stays in MSG OUT phase send it
437 * the IDENTIFY again.
439 SCR_JUMP ^ IFTRUE (WHEN (SCR_MSG_OUT)),
440 PADDR_B (resend_ident),
442 * If target does not switch to MSG IN phase
443 * and we sent a negotiation, assert the
444 * failure immediately.
446 SCR_JUMP ^ IFTRUE (WHEN (SCR_MSG_IN)),
447 PADDR_A (dispatch),
448 SCR_FROM_REG (HS_REG),
450 SCR_INT ^ IFTRUE (DATA (HS_NEGOTIATE)),
451 SIR_NEGO_FAILED,
453 * Jump to dispatcher.
455 SCR_JUMP,
456 PADDR_A (dispatch),
457 }/*-------------------------< INIT >-----------------------------*/,{
459 * Wait for the SCSI RESET signal to be
460 * inactive before restarting operations,
461 * since the chip may hang on SEL_ATN
462 * if SCSI RESET is active.
464 SCR_FROM_REG (sstat0),
466 SCR_JUMPR ^ IFTRUE (MASK (IRST, IRST)),
467 -16,
468 SCR_JUMP,
469 PADDR_A (start),
470 }/*-------------------------< CLRACK >---------------------------*/,{
472 * Terminate possible pending message phase.
474 SCR_CLR (SCR_ACK),
476 SCR_JUMP,
477 PADDR_A (dispatch),
478 }/*-------------------------< DATAI_DONE >-----------------------*/,{
480 * Save current pointer to LASTP.
482 SCR_COPY (4),
483 RADDR_1 (temp),
484 HADDR_1 (ccb_head.lastp),
486 * If the SWIDE is not full, jump to dispatcher.
487 * We anticipate a STATUS phase.
489 SCR_FROM_REG (scntl2),
491 SCR_JUMP ^ IFTRUE (MASK (WSR, WSR)),
492 PADDR_A (datai_done_wsr),
493 SCR_JUMP ^ IFTRUE (WHEN (SCR_STATUS)),
494 PADDR_A (status),
495 SCR_JUMP,
496 PADDR_A (dispatch),
497 }/*-------------------------< DATAI_DONE_WSR >-------------------*/,{
499 * The SWIDE is full.
500 * Clear this condition.
502 SCR_REG_REG (scntl2, SCR_OR, WSR),
505 * We are expecting an IGNORE RESIDUE message
506 * from the device, otherwise we are in data
507 * overrun condition. Check against MSG_IN phase.
509 SCR_INT ^ IFFALSE (WHEN (SCR_MSG_IN)),
510 SIR_SWIDE_OVERRUN,
511 SCR_JUMP ^ IFFALSE (WHEN (SCR_MSG_IN)),
512 PADDR_A (dispatch),
514 * We are in MSG_IN phase,
515 * Read the first byte of the message.
516 * If it is not an IGNORE RESIDUE message,
517 * signal overrun and jump to message
518 * processing.
520 SCR_MOVE_ABS (1) ^ SCR_MSG_IN,
521 HADDR_1 (msgin[0]),
522 SCR_INT ^ IFFALSE (DATA (M_IGN_RESIDUE)),
523 SIR_SWIDE_OVERRUN,
524 SCR_JUMP ^ IFFALSE (DATA (M_IGN_RESIDUE)),
525 PADDR_A (msg_in2),
527 * We got the message we expected.
528 * Read the 2nd byte, and jump to dispatcher.
530 SCR_CLR (SCR_ACK),
532 SCR_MOVE_ABS (1) ^ SCR_MSG_IN,
533 HADDR_1 (msgin[1]),
534 SCR_CLR (SCR_ACK),
536 SCR_JUMP,
537 PADDR_A (dispatch),
538 }/*-------------------------< DATAO_DONE >-----------------------*/,{
540 * Save current pointer to LASTP.
542 SCR_COPY (4),
543 RADDR_1 (temp),
544 HADDR_1 (ccb_head.lastp),
546 * If the SODL is not full jump to dispatcher.
547 * We anticipate a STATUS phase.
549 SCR_FROM_REG (scntl2),
551 SCR_JUMP ^ IFTRUE (MASK (WSS, WSS)),
552 PADDR_A (datao_done_wss),
553 SCR_JUMP ^ IFTRUE (WHEN (SCR_STATUS)),
554 PADDR_A (status),
555 SCR_JUMP,
556 PADDR_A (dispatch),
557 }/*-------------------------< DATAO_DONE_WSS >-------------------*/,{
559 * The SODL is full, clear this condition.
561 SCR_REG_REG (scntl2, SCR_OR, WSS),
564 * And signal a DATA UNDERRUN condition
565 * to the C code.
567 SCR_INT,
568 SIR_SODL_UNDERRUN,
569 SCR_JUMP,
570 PADDR_A (dispatch),
571 }/*-------------------------< DATAI_PHASE >----------------------*/,{
573 * Jump to current pointer.
575 SCR_COPY (4),
576 HADDR_1 (ccb_head.lastp),
577 RADDR_1 (temp),
578 SCR_RETURN,
580 }/*-------------------------< DATAO_PHASE >----------------------*/,{
582 * Jump to current pointer.
584 SCR_COPY (4),
585 HADDR_1 (ccb_head.lastp),
586 RADDR_1 (temp),
587 SCR_RETURN,
589 }/*-------------------------< MSG_IN >---------------------------*/,{
591 * Get the first byte of the message.
593 * The script processor doesn't negate the
594 * ACK signal after this transfer.
596 SCR_MOVE_ABS (1) ^ SCR_MSG_IN,
597 HADDR_1 (msgin[0]),
598 }/*-------------------------< MSG_IN2 >--------------------------*/,{
600 * Check first against 1 byte messages
601 * that we handle from SCRIPTS.
603 SCR_JUMP ^ IFTRUE (DATA (M_COMPLETE)),
604 PADDR_A (complete),
605 SCR_JUMP ^ IFTRUE (DATA (M_DISCONNECT)),
606 PADDR_A (disconnect),
607 SCR_JUMP ^ IFTRUE (DATA (M_SAVE_DP)),
608 PADDR_A (save_dp),
609 SCR_JUMP ^ IFTRUE (DATA (M_RESTORE_DP)),
610 PADDR_A (restore_dp),
612 * We handle all other messages from the
613 * C code, so no need to waste on-chip RAM
614 * for those ones.
616 SCR_JUMP,
617 PADDR_B (msg_in_etc),
618 }/*-------------------------< STATUS >---------------------------*/,{
620 * get the status
622 SCR_MOVE_ABS (1) ^ SCR_STATUS,
623 HADDR_1 (scratch),
624 #ifdef SYM_CONF_IARB_SUPPORT
626 * If STATUS is not GOOD, clear IMMEDIATE ARBITRATION,
627 * since we may have to tamper the start queue from
628 * the C code.
630 SCR_JUMPR ^ IFTRUE (DATA (S_GOOD)),
632 SCR_REG_REG (scntl1, SCR_AND, ~IARB),
634 #endif
636 * save status to scsi_status.
637 * mark as complete.
639 SCR_TO_REG (SS_REG),
641 SCR_LOAD_REG (HS_REG, HS_COMPLETE),
644 * Anticipate the MESSAGE PHASE for
645 * the TASK COMPLETE message.
647 SCR_JUMP ^ IFTRUE (WHEN (SCR_MSG_IN)),
648 PADDR_A (msg_in),
649 SCR_JUMP,
650 PADDR_A (dispatch),
651 }/*-------------------------< COMPLETE >-------------------------*/,{
653 * Complete message.
655 * When we terminate the cycle by clearing ACK,
656 * the target may disconnect immediately.
658 * We don't want to be told of an "unexpected disconnect",
659 * so we disable this feature.
661 SCR_REG_REG (scntl2, SCR_AND, 0x7f),
664 * Terminate cycle ...
666 SCR_CLR (SCR_ACK|SCR_ATN),
669 * ... and wait for the disconnect.
671 SCR_WAIT_DISC,
673 }/*-------------------------< COMPLETE2 >------------------------*/,{
675 * Save host status.
677 SCR_COPY (4),
678 RADDR_1 (scr0),
679 HADDR_1 (ccb_head.status),
681 * Move back the CCB header using self-modifying
682 * SCRIPTS.
684 SCR_COPY (4),
685 RADDR_1 (dsa),
686 PADDR_A (_sms_a40),
687 SCR_COPY (sizeof(struct sym_ccbh)),
688 HADDR_1 (ccb_head),
689 }/*-------------------------< _SMS_A40 >-------------------------*/,{
692 * Some bridges may reorder DMA writes to memory.
693 * We donnot want the CPU to deal with completions
694 * without all the posted write having been flushed
695 * to memory. This DUMMY READ should flush posted
696 * buffers prior to the CPU having to deal with
697 * completions.
699 SCR_COPY (4), /* DUMMY READ */
700 HADDR_1 (ccb_head.status),
701 RADDR_1 (scr0),
703 * If command resulted in not GOOD status,
704 * call the C code if needed.
706 SCR_FROM_REG (SS_REG),
708 SCR_CALL ^ IFFALSE (DATA (S_GOOD)),
709 PADDR_B (bad_status),
711 * If we performed an auto-sense, call
712 * the C code to synchronyze task aborts
713 * with UNIT ATTENTION conditions.
715 SCR_FROM_REG (HF_REG),
717 SCR_JUMP ^ IFFALSE (MASK (0 ,(HF_SENSE|HF_EXT_ERR))),
718 PADDR_A (complete_error),
719 }/*-------------------------< DONE >-----------------------------*/,{
721 * Copy the DSA to the DONE QUEUE and
722 * signal completion to the host.
723 * If we are interrupted between DONE
724 * and DONE_END, we must reset, otherwise
725 * the completed CCB may be lost.
727 SCR_COPY (4),
728 PADDR_B (done_pos),
729 PADDR_A (_sms_a50),
730 SCR_COPY (4),
731 RADDR_1 (dsa),
732 }/*-------------------------< _SMS_A50 >-------------------------*/,{
734 SCR_COPY (4),
735 PADDR_B (done_pos),
736 PADDR_A (_sms_a60),
738 * The instruction below reads the DONE QUEUE next
739 * free position from memory.
740 * In addition it ensures that all PCI posted writes
741 * are flushed and so the DSA value of the done
742 * CCB is visible by the CPU before INTFLY is raised.
744 SCR_COPY (8),
745 }/*-------------------------< _SMS_A60 >-------------------------*/,{
747 PADDR_B (prev_done),
748 }/*-------------------------< DONE_END >-------------------------*/,{
749 SCR_INT_FLY,
751 SCR_JUMP,
752 PADDR_A (start),
753 }/*-------------------------< COMPLETE_ERROR >-------------------*/,{
754 SCR_COPY (4),
755 PADDR_B (startpos),
756 RADDR_1 (scratcha),
757 SCR_INT,
758 SIR_COMPLETE_ERROR,
759 }/*-------------------------< SAVE_DP >--------------------------*/,{
761 * Clear ACK immediately.
762 * No need to delay it.
764 SCR_CLR (SCR_ACK),
767 * Keep track we received a SAVE DP, so
768 * we will switch to the other PM context
769 * on the next PM since the DP may point
770 * to the current PM context.
772 SCR_REG_REG (HF_REG, SCR_OR, HF_DP_SAVED),
775 * SAVE_DP message:
776 * Copy LASTP to SAVEP.
778 SCR_COPY (4),
779 HADDR_1 (ccb_head.lastp),
780 HADDR_1 (ccb_head.savep),
782 * Anticipate the MESSAGE PHASE for
783 * the DISCONNECT message.
785 SCR_JUMP ^ IFTRUE (WHEN (SCR_MSG_IN)),
786 PADDR_A (msg_in),
787 SCR_JUMP,
788 PADDR_A (dispatch),
789 }/*-------------------------< RESTORE_DP >-----------------------*/,{
791 * Clear ACK immediately.
792 * No need to delay it.
794 SCR_CLR (SCR_ACK),
797 * Copy SAVEP to LASTP.
799 SCR_COPY (4),
800 HADDR_1 (ccb_head.savep),
801 HADDR_1 (ccb_head.lastp),
802 SCR_JUMP,
803 PADDR_A (dispatch),
804 }/*-------------------------< DISCONNECT >-----------------------*/,{
806 * DISCONNECTing ...
808 * disable the "unexpected disconnect" feature,
809 * and remove the ACK signal.
811 SCR_REG_REG (scntl2, SCR_AND, 0x7f),
813 SCR_CLR (SCR_ACK|SCR_ATN),
816 * Wait for the disconnect.
818 SCR_WAIT_DISC,
821 * Status is: DISCONNECTED.
823 SCR_LOAD_REG (HS_REG, HS_DISCONNECT),
826 * Save host status.
828 SCR_COPY (4),
829 RADDR_1 (scr0),
830 HADDR_1 (ccb_head.status),
831 }/*-------------------------< DISCONNECT2 >----------------------*/,{
833 * Move back the CCB header using self-modifying
834 * SCRIPTS.
836 SCR_COPY (4),
837 RADDR_1 (dsa),
838 PADDR_A (_sms_a65),
839 SCR_COPY (sizeof(struct sym_ccbh)),
840 HADDR_1 (ccb_head),
841 }/*-------------------------< _SMS_A65 >-------------------------*/,{
843 SCR_JUMP,
844 PADDR_A (start),
845 }/*-------------------------< IDLE >-----------------------------*/,{
847 * Nothing to do?
848 * Switch the LED off and wait for reselect.
849 * Will be patched with a NO_OP if LED
850 * not needed or not desired.
852 SCR_REG_REG (gpreg, SCR_OR, 0x01),
854 #ifdef SYM_CONF_IARB_SUPPORT
855 SCR_JUMPR,
857 #endif
858 }/*-------------------------< UNGETJOB >-------------------------*/,{
859 #ifdef SYM_CONF_IARB_SUPPORT
861 * Set IMMEDIATE ARBITRATION, for the next time.
862 * This will give us better chance to win arbitration
863 * for the job we just wanted to do.
865 SCR_REG_REG (scntl1, SCR_OR, IARB),
867 #endif
869 * We are not able to restart the SCRIPTS if we are
870 * interrupted and these instruction haven't been
871 * all executed. BTW, this is very unlikely to
872 * happen, but we check that from the C code.
874 SCR_LOAD_REG (dsa, 0xff),
876 SCR_COPY (4),
877 RADDR_1 (scratcha),
878 PADDR_B (startpos),
879 }/*-------------------------< RESELECT >-------------------------*/,{
880 #ifdef SYM_CONF_TARGET_ROLE_SUPPORT
882 * Make sure we are in initiator mode.
884 SCR_CLR (SCR_TRG),
886 #endif
888 * Sleep waiting for a reselection.
890 SCR_WAIT_RESEL,
891 PADDR_A(start),
892 }/*-------------------------< RESELECTED >-----------------------*/,{
894 * Switch the LED on.
895 * Will be patched with a NO_OP if LED
896 * not needed or not desired.
898 SCR_REG_REG (gpreg, SCR_AND, 0xfe),
901 * load the target id into the sdid
903 SCR_REG_SFBR (ssid, SCR_AND, 0x8F),
905 SCR_TO_REG (sdid),
908 * Load the target control block address
910 SCR_COPY (4),
911 PADDR_B (targtbl),
912 RADDR_1 (dsa),
913 SCR_SFBR_REG (dsa, SCR_SHL, 0),
915 SCR_REG_REG (dsa, SCR_SHL, 0),
917 SCR_REG_REG (dsa, SCR_AND, 0x3c),
919 SCR_COPY (4),
920 RADDR_1 (dsa),
921 PADDR_A (_sms_a70),
922 SCR_COPY (4),
923 }/*-------------------------< _SMS_A70 >-------------------------*/,{
925 RADDR_1 (dsa),
927 * Copy the TCB header to a fixed place in
928 * the HCB.
930 SCR_COPY (4),
931 RADDR_1 (dsa),
932 PADDR_A (_sms_a80),
933 SCR_COPY (sizeof(struct sym_tcbh)),
934 }/*-------------------------< _SMS_A80 >-------------------------*/,{
936 HADDR_1 (tcb_head),
938 * We expect MESSAGE IN phase.
939 * If not, get help from the C code.
941 SCR_INT ^ IFFALSE (WHEN (SCR_MSG_IN)),
942 SIR_RESEL_NO_MSG_IN,
943 }/*-------------------------< RESELECTED1 >----------------------*/,{
945 * Load the synchronous transfer registers.
947 SCR_COPY (1),
948 HADDR_1 (tcb_head.wval),
949 RADDR_1 (scntl3),
950 SCR_COPY (1),
951 HADDR_1 (tcb_head.sval),
952 RADDR_1 (sxfer),
954 * Get the IDENTIFY message.
956 SCR_MOVE_ABS (1) ^ SCR_MSG_IN,
957 HADDR_1 (msgin),
959 * If IDENTIFY LUN #0, use a faster path
960 * to find the LCB structure.
962 SCR_JUMP ^ IFTRUE (MASK (0x80, 0xbf)),
963 PADDR_A (resel_lun0),
965 * If message isn't an IDENTIFY,
966 * tell the C code about.
968 SCR_INT ^ IFFALSE (MASK (0x80, 0x80)),
969 SIR_RESEL_NO_IDENTIFY,
971 * It is an IDENTIFY message,
972 * Load the LUN control block address.
974 SCR_COPY (4),
975 HADDR_1 (tcb_head.luntbl_sa),
976 RADDR_1 (dsa),
977 SCR_SFBR_REG (dsa, SCR_SHL, 0),
979 SCR_REG_REG (dsa, SCR_SHL, 0),
981 SCR_REG_REG (dsa, SCR_AND, 0xfc),
983 SCR_COPY (4),
984 RADDR_1 (dsa),
985 PADDR_A (_sms_a90),
986 SCR_COPY (4),
987 }/*-------------------------< _SMS_A90 >-------------------------*/,{
989 RADDR_1 (dsa),
990 SCR_JUMPR,
992 }/*-------------------------< RESEL_LUN0 >-----------------------*/,{
994 * LUN 0 special case (but usual one :))
996 SCR_COPY (4),
997 HADDR_1 (tcb_head.lun0_sa),
998 RADDR_1 (dsa),
1000 * Jump indirectly to the reselect action for this LUN.
1001 * (lcb.head.resel_sa assumed at offset zero of lcb).
1003 SCR_COPY (4),
1004 RADDR_1 (dsa),
1005 PADDR_A (_sms_a100),
1006 SCR_COPY (4),
1007 }/*-------------------------< _SMS_A100 >------------------------*/,{
1009 RADDR_1 (temp),
1010 SCR_RETURN,
1012 /* In normal situations, we jump to RESEL_TAG or RESEL_NO_TAG */
1013 }/*-------------------------< RESEL_TAG >------------------------*/,{
1015 * ACK the IDENTIFY previously received.
1017 SCR_CLR (SCR_ACK),
1020 * It shall be a tagged command.
1021 * Read SIMPLE+TAG.
1022 * The C code will deal with errors.
1023 * Aggressive optimization, isn't it? :)
1025 SCR_MOVE_ABS (2) ^ SCR_MSG_IN,
1026 HADDR_1 (msgin),
1028 * Copy the LCB header to a fixed place in
1029 * the HCB using self-modifying SCRIPTS.
1031 SCR_COPY (4),
1032 RADDR_1 (dsa),
1033 PADDR_A (_sms_a110),
1034 SCR_COPY (sizeof(struct sym_lcbh)),
1035 }/*-------------------------< _SMS_A110 >------------------------*/,{
1037 HADDR_1 (lcb_head),
1039 * Load the pointer to the tagged task
1040 * table for this LUN.
1042 SCR_COPY (4),
1043 HADDR_1 (lcb_head.itlq_tbl_sa),
1044 RADDR_1 (dsa),
1046 * The SIDL still contains the TAG value.
1047 * Aggressive optimization, isn't it? :):)
1049 SCR_REG_SFBR (sidl, SCR_SHL, 0),
1051 #if SYM_CONF_MAX_TASK*4 > 512
1052 SCR_JUMPR ^ IFFALSE (CARRYSET),
1054 SCR_REG_REG (dsa1, SCR_OR, 2),
1056 SCR_REG_REG (sfbr, SCR_SHL, 0),
1058 SCR_JUMPR ^ IFFALSE (CARRYSET),
1060 SCR_REG_REG (dsa1, SCR_OR, 1),
1062 #elif SYM_CONF_MAX_TASK*4 > 256
1063 SCR_JUMPR ^ IFFALSE (CARRYSET),
1065 SCR_REG_REG (dsa1, SCR_OR, 1),
1067 #endif
1069 * Retrieve the DSA of this task.
1070 * JUMP indirectly to the restart point of the CCB.
1072 SCR_SFBR_REG (dsa, SCR_AND, 0xfc),
1074 SCR_COPY (4),
1075 RADDR_1 (dsa),
1076 PADDR_A (_sms_a120),
1077 SCR_COPY (4),
1078 }/*-------------------------< _SMS_A120 >------------------------*/,{
1080 RADDR_1 (dsa),
1081 }/*-------------------------< RESEL_GO >-------------------------*/,{
1082 SCR_COPY (4),
1083 RADDR_1 (dsa),
1084 PADDR_A (_sms_a130),
1086 * Move 'ccb.phys.head.go' action to
1087 * scratch/scratch1. So scratch1 will
1088 * contain the 'restart' field of the
1089 * 'go' structure.
1091 SCR_COPY (8),
1092 }/*-------------------------< _SMS_A130 >------------------------*/,{
1094 PADDR_B (scratch),
1095 SCR_COPY (4),
1096 PADDR_B (scratch1), /* phys.head.go.restart */
1097 RADDR_1 (temp),
1098 SCR_RETURN,
1100 /* In normal situations we branch to RESEL_DSA */
1101 }/*-------------------------< RESEL_DSA >------------------------*/,{
1103 * ACK the IDENTIFY or TAG previously received.
1105 SCR_CLR (SCR_ACK),
1107 }/*-------------------------< RESEL_DSA1 >-----------------------*/,{
1109 * Copy the CCB header to a fixed location
1110 * in the HCB using self-modifying SCRIPTS.
1112 SCR_COPY (4),
1113 RADDR_1 (dsa),
1114 PADDR_A (_sms_a140),
1115 SCR_COPY (sizeof(struct sym_ccbh)),
1116 }/*-------------------------< _SMS_A140 >------------------------*/,{
1118 HADDR_1 (ccb_head),
1120 * Initialize the status register
1122 SCR_COPY (4),
1123 HADDR_1 (ccb_head.status),
1124 RADDR_1 (scr0),
1126 * Jump to dispatcher.
1128 SCR_JUMP,
1129 PADDR_A (dispatch),
1130 }/*-------------------------< RESEL_NO_TAG >---------------------*/,{
1132 * Copy the LCB header to a fixed place in
1133 * the HCB using self-modifying SCRIPTS.
1135 SCR_COPY (4),
1136 RADDR_1 (dsa),
1137 PADDR_A (_sms_a145),
1138 SCR_COPY (sizeof(struct sym_lcbh)),
1139 }/*-------------------------< _SMS_A145 >------------------------*/,{
1141 HADDR_1 (lcb_head),
1143 * Load the DSA with the unique ITL task.
1145 SCR_COPY (4),
1146 HADDR_1 (lcb_head.itl_task_sa),
1147 RADDR_1 (dsa),
1148 SCR_JUMP,
1149 PADDR_A (resel_go),
1150 }/*-------------------------< DATA_IN >--------------------------*/,{
1152 * Because the size depends on the
1153 * #define SYM_CONF_MAX_SG parameter,
1154 * it is filled in at runtime.
1156 * ##===========< i=0; i<SYM_CONF_MAX_SG >=========
1157 * || SCR_CHMOV_TBL ^ SCR_DATA_IN,
1158 * || offsetof (struct sym_dsb, data[ i]),
1159 * ##==========================================
1162 }/*-------------------------< DATA_IN2 >-------------------------*/,{
1163 SCR_CALL,
1164 PADDR_A (datai_done),
1165 SCR_JUMP,
1166 PADDR_B (data_ovrun),
1167 }/*-------------------------< DATA_OUT >-------------------------*/,{
1169 * Because the size depends on the
1170 * #define SYM_CONF_MAX_SG parameter,
1171 * it is filled in at runtime.
1173 * ##===========< i=0; i<SYM_CONF_MAX_SG >=========
1174 * || SCR_CHMOV_TBL ^ SCR_DATA_OUT,
1175 * || offsetof (struct sym_dsb, data[ i]),
1176 * ##==========================================
1179 }/*-------------------------< DATA_OUT2 >------------------------*/,{
1180 SCR_CALL,
1181 PADDR_A (datao_done),
1182 SCR_JUMP,
1183 PADDR_B (data_ovrun),
1184 }/*-------------------------< PM0_DATA >-------------------------*/,{
1186 * Read our host flags to SFBR, so we will be able
1187 * to check against the data direction we expect.
1189 SCR_FROM_REG (HF_REG),
1192 * Check against actual DATA PHASE.
1194 SCR_JUMP ^ IFFALSE (WHEN (SCR_DATA_IN)),
1195 PADDR_A (pm0_data_out),
1197 * Actual phase is DATA IN.
1198 * Check against expected direction.
1200 SCR_JUMP ^ IFFALSE (MASK (HF_DATA_IN, HF_DATA_IN)),
1201 PADDR_B (data_ovrun),
1203 * Keep track we are moving data from the
1204 * PM0 DATA mini-script.
1206 SCR_REG_REG (HF_REG, SCR_OR, HF_IN_PM0),
1209 * Move the data to memory.
1211 SCR_CHMOV_TBL ^ SCR_DATA_IN,
1212 offsetof (struct sym_ccb, phys.pm0.sg),
1213 SCR_JUMP,
1214 PADDR_A (pm0_data_end),
1215 }/*-------------------------< PM0_DATA_OUT >---------------------*/,{
1217 * Actual phase is DATA OUT.
1218 * Check against expected direction.
1220 SCR_JUMP ^ IFTRUE (MASK (HF_DATA_IN, HF_DATA_IN)),
1221 PADDR_B (data_ovrun),
1223 * Keep track we are moving data from the
1224 * PM0 DATA mini-script.
1226 SCR_REG_REG (HF_REG, SCR_OR, HF_IN_PM0),
1229 * Move the data from memory.
1231 SCR_CHMOV_TBL ^ SCR_DATA_OUT,
1232 offsetof (struct sym_ccb, phys.pm0.sg),
1233 }/*-------------------------< PM0_DATA_END >---------------------*/,{
1235 * Clear the flag that told we were moving
1236 * data from the PM0 DATA mini-script.
1238 SCR_REG_REG (HF_REG, SCR_AND, (~HF_IN_PM0)),
1241 * Return to the previous DATA script which
1242 * is guaranteed by design (if no bug) to be
1243 * the main DATA script for this transfer.
1245 SCR_COPY (4),
1246 RADDR_1 (dsa),
1247 RADDR_1 (scratcha),
1248 SCR_REG_REG (scratcha, SCR_ADD, offsetof (struct sym_ccb,phys.pm0.ret)),
1250 }/*-------------------------< PM_DATA_END >----------------------*/,{
1251 SCR_COPY (4),
1252 RADDR_1 (scratcha),
1253 PADDR_A (_sms_a150),
1254 SCR_COPY (4),
1255 }/*-------------------------< _SMS_A150 >------------------------*/,{
1257 RADDR_1 (temp),
1258 SCR_RETURN,
1260 }/*-------------------------< PM1_DATA >-------------------------*/,{
1262 * Read our host flags to SFBR, so we will be able
1263 * to check against the data direction we expect.
1265 SCR_FROM_REG (HF_REG),
1268 * Check against actual DATA PHASE.
1270 SCR_JUMP ^ IFFALSE (WHEN (SCR_DATA_IN)),
1271 PADDR_A (pm1_data_out),
1273 * Actual phase is DATA IN.
1274 * Check against expected direction.
1276 SCR_JUMP ^ IFFALSE (MASK (HF_DATA_IN, HF_DATA_IN)),
1277 PADDR_B (data_ovrun),
1279 * Keep track we are moving data from the
1280 * PM1 DATA mini-script.
1282 SCR_REG_REG (HF_REG, SCR_OR, HF_IN_PM1),
1285 * Move the data to memory.
1287 SCR_CHMOV_TBL ^ SCR_DATA_IN,
1288 offsetof (struct sym_ccb, phys.pm1.sg),
1289 SCR_JUMP,
1290 PADDR_A (pm1_data_end),
1291 }/*-------------------------< PM1_DATA_OUT >---------------------*/,{
1293 * Actual phase is DATA OUT.
1294 * Check against expected direction.
1296 SCR_JUMP ^ IFTRUE (MASK (HF_DATA_IN, HF_DATA_IN)),
1297 PADDR_B (data_ovrun),
1299 * Keep track we are moving data from the
1300 * PM1 DATA mini-script.
1302 SCR_REG_REG (HF_REG, SCR_OR, HF_IN_PM1),
1305 * Move the data from memory.
1307 SCR_CHMOV_TBL ^ SCR_DATA_OUT,
1308 offsetof (struct sym_ccb, phys.pm1.sg),
1309 }/*-------------------------< PM1_DATA_END >---------------------*/,{
1311 * Clear the flag that told we were moving
1312 * data from the PM1 DATA mini-script.
1314 SCR_REG_REG (HF_REG, SCR_AND, (~HF_IN_PM1)),
1317 * Return to the previous DATA script which
1318 * is guaranteed by design (if no bug) to be
1319 * the main DATA script for this transfer.
1321 SCR_COPY (4),
1322 RADDR_1 (dsa),
1323 RADDR_1 (scratcha),
1324 SCR_REG_REG (scratcha, SCR_ADD, offsetof (struct sym_ccb,phys.pm1.ret)),
1326 SCR_JUMP,
1327 PADDR_A (pm_data_end),
1328 }/*--------------------------<>----------------------------------*/
1331 static struct SYM_FWB_SCR SYM_FWB_SCR = {
1332 /*-------------------------< NO_DATA >--------------------------*/ {
1333 SCR_JUMP,
1334 PADDR_B (data_ovrun),
1335 }/*-------------------------< SEL_FOR_ABORT >--------------------*/,{
1337 * We are jumped here by the C code, if we have
1338 * some target to reset or some disconnected
1339 * job to abort. Since error recovery is a serious
1340 * busyness, we will really reset the SCSI BUS, if
1341 * case of a SCSI interrupt occurring in this path.
1344 #ifdef SYM_CONF_TARGET_ROLE_SUPPORT
1346 * Set initiator mode.
1348 SCR_CLR (SCR_TRG),
1350 #endif
1352 * And try to select this target.
1354 SCR_SEL_TBL_ATN ^ offsetof (struct sym_hcb, abrt_sel),
1355 PADDR_A (reselect),
1357 * Wait for the selection to complete or
1358 * the selection to time out.
1360 SCR_JUMPR ^ IFFALSE (WHEN (SCR_MSG_OUT)),
1363 * Call the C code.
1365 SCR_INT,
1366 SIR_TARGET_SELECTED,
1368 * The C code should let us continue here.
1369 * Send the 'kiss of death' message.
1370 * We expect an immediate disconnect once
1371 * the target has eaten the message.
1373 SCR_REG_REG (scntl2, SCR_AND, 0x7f),
1375 SCR_MOVE_TBL ^ SCR_MSG_OUT,
1376 offsetof (struct sym_hcb, abrt_tbl),
1377 SCR_CLR (SCR_ACK|SCR_ATN),
1379 SCR_WAIT_DISC,
1382 * Tell the C code that we are done.
1384 SCR_INT,
1385 SIR_ABORT_SENT,
1386 }/*-------------------------< SEL_FOR_ABORT_1 >------------------*/,{
1388 * Jump at scheduler.
1390 SCR_JUMP,
1391 PADDR_A (start),
1392 }/*-------------------------< MSG_IN_ETC >-----------------------*/,{
1394 * If it is an EXTENDED (variable size message)
1395 * Handle it.
1397 SCR_JUMP ^ IFTRUE (DATA (M_EXTENDED)),
1398 PADDR_B (msg_extended),
1400 * Let the C code handle any other
1401 * 1 byte message.
1403 SCR_JUMP ^ IFTRUE (MASK (0x00, 0xf0)),
1404 PADDR_B (msg_received),
1405 SCR_JUMP ^ IFTRUE (MASK (0x10, 0xf0)),
1406 PADDR_B (msg_received),
1408 * We donnot handle 2 bytes messages from SCRIPTS.
1409 * So, let the C code deal with these ones too.
1411 SCR_JUMP ^ IFFALSE (MASK (0x20, 0xf0)),
1412 PADDR_B (msg_weird_seen),
1413 SCR_CLR (SCR_ACK),
1415 SCR_MOVE_ABS (1) ^ SCR_MSG_IN,
1416 HADDR_1 (msgin[1]),
1417 }/*-------------------------< MSG_RECEIVED >---------------------*/,{
1418 SCR_COPY (4), /* DUMMY READ */
1419 HADDR_1 (scratch),
1420 RADDR_1 (scratcha),
1421 SCR_INT,
1422 SIR_MSG_RECEIVED,
1423 }/*-------------------------< MSG_WEIRD_SEEN >-------------------*/,{
1424 SCR_COPY (4), /* DUMMY READ */
1425 HADDR_1 (scratch),
1426 RADDR_1 (scratcha),
1427 SCR_INT,
1428 SIR_MSG_WEIRD,
1429 }/*-------------------------< MSG_EXTENDED >---------------------*/,{
1431 * Clear ACK and get the next byte
1432 * assumed to be the message length.
1434 SCR_CLR (SCR_ACK),
1436 SCR_MOVE_ABS (1) ^ SCR_MSG_IN,
1437 HADDR_1 (msgin[1]),
1439 * Try to catch some unlikely situations as 0 length
1440 * or too large the length.
1442 SCR_JUMP ^ IFTRUE (DATA (0)),
1443 PADDR_B (msg_weird_seen),
1444 SCR_TO_REG (scratcha),
1446 SCR_REG_REG (sfbr, SCR_ADD, (256-8)),
1448 SCR_JUMP ^ IFTRUE (CARRYSET),
1449 PADDR_B (msg_weird_seen),
1451 * We donnot handle extended messages from SCRIPTS.
1452 * Read the amount of data corresponding to the
1453 * message length and call the C code.
1455 SCR_COPY (1),
1456 RADDR_1 (scratcha),
1457 PADDR_B (_sms_b10),
1458 SCR_CLR (SCR_ACK),
1460 }/*-------------------------< _SMS_B10 >-------------------------*/,{
1461 SCR_MOVE_ABS (0) ^ SCR_MSG_IN,
1462 HADDR_1 (msgin[2]),
1463 SCR_JUMP,
1464 PADDR_B (msg_received),
1465 }/*-------------------------< MSG_BAD >--------------------------*/,{
1467 * unimplemented message - reject it.
1469 SCR_INT,
1470 SIR_REJECT_TO_SEND,
1471 SCR_SET (SCR_ATN),
1473 SCR_JUMP,
1474 PADDR_A (clrack),
1475 }/*-------------------------< MSG_WEIRD >------------------------*/,{
1477 * weird message received
1478 * ignore all MSG IN phases and reject it.
1480 SCR_INT,
1481 SIR_REJECT_TO_SEND,
1482 SCR_SET (SCR_ATN),
1484 }/*-------------------------< MSG_WEIRD1 >-----------------------*/,{
1485 SCR_CLR (SCR_ACK),
1487 SCR_JUMP ^ IFFALSE (WHEN (SCR_MSG_IN)),
1488 PADDR_A (dispatch),
1489 SCR_MOVE_ABS (1) ^ SCR_MSG_IN,
1490 HADDR_1 (scratch),
1491 SCR_JUMP,
1492 PADDR_B (msg_weird1),
1493 }/*-------------------------< WDTR_RESP >------------------------*/,{
1495 * let the target fetch our answer.
1497 SCR_SET (SCR_ATN),
1499 SCR_CLR (SCR_ACK),
1501 SCR_JUMP ^ IFFALSE (WHEN (SCR_MSG_OUT)),
1502 PADDR_B (nego_bad_phase),
1503 }/*-------------------------< SEND_WDTR >------------------------*/,{
1505 * Send the M_X_WIDE_REQ
1507 SCR_MOVE_ABS (4) ^ SCR_MSG_OUT,
1508 HADDR_1 (msgout),
1509 SCR_JUMP,
1510 PADDR_B (msg_out_done),
1511 }/*-------------------------< SDTR_RESP >------------------------*/,{
1513 * let the target fetch our answer.
1515 SCR_SET (SCR_ATN),
1517 SCR_CLR (SCR_ACK),
1519 SCR_JUMP ^ IFFALSE (WHEN (SCR_MSG_OUT)),
1520 PADDR_B (nego_bad_phase),
1521 }/*-------------------------< SEND_SDTR >------------------------*/,{
1523 * Send the M_X_SYNC_REQ
1525 SCR_MOVE_ABS (5) ^ SCR_MSG_OUT,
1526 HADDR_1 (msgout),
1527 SCR_JUMP,
1528 PADDR_B (msg_out_done),
1529 }/*-------------------------< PPR_RESP >-------------------------*/,{
1531 * let the target fetch our answer.
1533 SCR_SET (SCR_ATN),
1535 SCR_CLR (SCR_ACK),
1537 SCR_JUMP ^ IFFALSE (WHEN (SCR_MSG_OUT)),
1538 PADDR_B (nego_bad_phase),
1539 }/*-------------------------< SEND_PPR >-------------------------*/,{
1541 * Send the M_X_PPR_REQ
1543 SCR_MOVE_ABS (8) ^ SCR_MSG_OUT,
1544 HADDR_1 (msgout),
1545 SCR_JUMP,
1546 PADDR_B (msg_out_done),
1547 }/*-------------------------< NEGO_BAD_PHASE >-------------------*/,{
1548 SCR_INT,
1549 SIR_NEGO_PROTO,
1550 SCR_JUMP,
1551 PADDR_A (dispatch),
1552 }/*-------------------------< MSG_OUT >--------------------------*/,{
1554 * The target requests a message.
1555 * We donnot send messages that may
1556 * require the device to go to bus free.
1558 SCR_MOVE_ABS (1) ^ SCR_MSG_OUT,
1559 HADDR_1 (msgout),
1561 * ... wait for the next phase
1562 * if it's a message out, send it again, ...
1564 SCR_JUMP ^ IFTRUE (WHEN (SCR_MSG_OUT)),
1565 PADDR_B (msg_out),
1566 }/*-------------------------< MSG_OUT_DONE >---------------------*/,{
1568 * Let the C code be aware of the
1569 * sent message and clear the message.
1571 SCR_INT,
1572 SIR_MSG_OUT_DONE,
1574 * ... and process the next phase
1576 SCR_JUMP,
1577 PADDR_A (dispatch),
1578 }/*-------------------------< DATA_OVRUN >-----------------------*/,{
1580 * Zero scratcha that will count the
1581 * extras bytes.
1583 SCR_COPY (4),
1584 PADDR_B (zero),
1585 RADDR_1 (scratcha),
1586 }/*-------------------------< DATA_OVRUN1 >----------------------*/,{
1588 * The target may want to transfer too much data.
1590 * If phase is DATA OUT write 1 byte and count it.
1592 SCR_JUMPR ^ IFFALSE (WHEN (SCR_DATA_OUT)),
1594 SCR_CHMOV_ABS (1) ^ SCR_DATA_OUT,
1595 HADDR_1 (scratch),
1596 SCR_JUMP,
1597 PADDR_B (data_ovrun2),
1599 * If WSR is set, clear this condition, and
1600 * count this byte.
1602 SCR_FROM_REG (scntl2),
1604 SCR_JUMPR ^ IFFALSE (MASK (WSR, WSR)),
1606 SCR_REG_REG (scntl2, SCR_OR, WSR),
1608 SCR_JUMP,
1609 PADDR_B (data_ovrun2),
1611 * Finally check against DATA IN phase.
1612 * Signal data overrun to the C code
1613 * and jump to dispatcher if not so.
1614 * Read 1 byte otherwise and count it.
1616 SCR_JUMPR ^ IFTRUE (WHEN (SCR_DATA_IN)),
1618 SCR_INT,
1619 SIR_DATA_OVERRUN,
1620 SCR_JUMP,
1621 PADDR_A (dispatch),
1622 SCR_CHMOV_ABS (1) ^ SCR_DATA_IN,
1623 HADDR_1 (scratch),
1624 }/*-------------------------< DATA_OVRUN2 >----------------------*/,{
1626 * Count this byte.
1627 * This will allow to return a negative
1628 * residual to user.
1630 SCR_REG_REG (scratcha, SCR_ADD, 0x01),
1632 SCR_REG_REG (scratcha1, SCR_ADDC, 0),
1634 SCR_REG_REG (scratcha2, SCR_ADDC, 0),
1637 * .. and repeat as required.
1639 SCR_JUMP,
1640 PADDR_B (data_ovrun1),
1641 }/*-------------------------< ABORT_RESEL >----------------------*/,{
1642 SCR_SET (SCR_ATN),
1644 SCR_CLR (SCR_ACK),
1647 * send the abort/abortag/reset message
1648 * we expect an immediate disconnect
1650 SCR_REG_REG (scntl2, SCR_AND, 0x7f),
1652 SCR_MOVE_ABS (1) ^ SCR_MSG_OUT,
1653 HADDR_1 (msgout),
1654 SCR_CLR (SCR_ACK|SCR_ATN),
1656 SCR_WAIT_DISC,
1658 SCR_INT,
1659 SIR_RESEL_ABORTED,
1660 SCR_JUMP,
1661 PADDR_A (start),
1662 }/*-------------------------< RESEND_IDENT >---------------------*/,{
1664 * The target stays in MSG OUT phase after having acked
1665 * Identify [+ Tag [+ Extended message ]]. Targets shall
1666 * behave this way on parity error.
1667 * We must send it again all the messages.
1669 SCR_SET (SCR_ATN), /* Shall be asserted 2 deskew delays before the */
1670 0, /* 1rst ACK = 90 ns. Hope the chip isn't too fast */
1671 SCR_JUMP,
1672 PADDR_A (send_ident),
1673 }/*-------------------------< IDENT_BREAK >----------------------*/,{
1674 SCR_CLR (SCR_ATN),
1676 SCR_JUMP,
1677 PADDR_A (select2),
1678 }/*-------------------------< IDENT_BREAK_ATN >------------------*/,{
1679 SCR_SET (SCR_ATN),
1681 SCR_JUMP,
1682 PADDR_A (select2),
1683 }/*-------------------------< SDATA_IN >-------------------------*/,{
1684 SCR_CHMOV_TBL ^ SCR_DATA_IN,
1685 offsetof (struct sym_dsb, sense),
1686 SCR_CALL,
1687 PADDR_A (datai_done),
1688 SCR_JUMP,
1689 PADDR_B (data_ovrun),
1690 }/*-------------------------< RESEL_BAD_LUN >--------------------*/,{
1692 * Message is an IDENTIFY, but lun is unknown.
1693 * Signal problem to C code for logging the event.
1694 * Send a M_ABORT to clear all pending tasks.
1696 SCR_INT,
1697 SIR_RESEL_BAD_LUN,
1698 SCR_JUMP,
1699 PADDR_B (abort_resel),
1700 }/*-------------------------< BAD_I_T_L >------------------------*/,{
1702 * We donnot have a task for that I_T_L.
1703 * Signal problem to C code for logging the event.
1704 * Send a M_ABORT message.
1706 SCR_INT,
1707 SIR_RESEL_BAD_I_T_L,
1708 SCR_JUMP,
1709 PADDR_B (abort_resel),
1710 }/*-------------------------< BAD_I_T_L_Q >----------------------*/,{
1712 * We donnot have a task that matches the tag.
1713 * Signal problem to C code for logging the event.
1714 * Send a M_ABORTTAG message.
1716 SCR_INT,
1717 SIR_RESEL_BAD_I_T_L_Q,
1718 SCR_JUMP,
1719 PADDR_B (abort_resel),
1720 }/*-------------------------< BAD_STATUS >-----------------------*/,{
1722 * Anything different from INTERMEDIATE
1723 * CONDITION MET should be a bad SCSI status,
1724 * given that GOOD status has already been tested.
1725 * Call the C code.
1727 SCR_COPY (4),
1728 PADDR_B (startpos),
1729 RADDR_1 (scratcha),
1730 SCR_INT ^ IFFALSE (DATA (S_COND_MET)),
1731 SIR_BAD_SCSI_STATUS,
1732 SCR_RETURN,
1734 }/*-------------------------< WSR_MA_HELPER >--------------------*/,{
1736 * Helper for the C code when WSR bit is set.
1737 * Perform the move of the residual byte.
1739 SCR_CHMOV_TBL ^ SCR_DATA_IN,
1740 offsetof (struct sym_ccb, phys.wresid),
1741 SCR_JUMP,
1742 PADDR_A (dispatch),
1744 }/*-------------------------< ZERO >-----------------------------*/,{
1745 SCR_DATA_ZERO,
1746 }/*-------------------------< SCRATCH >--------------------------*/,{
1747 SCR_DATA_ZERO, /* MUST BE BEFORE SCRATCH1 */
1748 }/*-------------------------< SCRATCH1 >-------------------------*/,{
1749 SCR_DATA_ZERO,
1750 }/*-------------------------< PREV_DONE >------------------------*/,{
1751 SCR_DATA_ZERO, /* MUST BE BEFORE DONE_POS ! */
1752 }/*-------------------------< DONE_POS >-------------------------*/,{
1753 SCR_DATA_ZERO,
1754 }/*-------------------------< NEXTJOB >--------------------------*/,{
1755 SCR_DATA_ZERO, /* MUST BE BEFORE STARTPOS ! */
1756 }/*-------------------------< STARTPOS >-------------------------*/,{
1757 SCR_DATA_ZERO,
1758 }/*-------------------------< TARGTBL >--------------------------*/,{
1759 SCR_DATA_ZERO,
1760 }/*--------------------------<>----------------------------------*/
1763 static struct SYM_FWZ_SCR SYM_FWZ_SCR = {
1764 /*-------------------------< SNOOPTEST >------------------------*/{
1766 * Read the variable.
1768 SCR_COPY (4),
1769 HADDR_1 (scratch),
1770 RADDR_1 (scratcha),
1772 * Write the variable.
1774 SCR_COPY (4),
1775 RADDR_1 (temp),
1776 HADDR_1 (scratch),
1778 * Read back the variable.
1780 SCR_COPY (4),
1781 HADDR_1 (scratch),
1782 RADDR_1 (temp),
1783 }/*-------------------------< SNOOPEND >-------------------------*/,{
1785 * And stop.
1787 SCR_INT,
1789 }/*--------------------------<>----------------------------------*/