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.
57 u32 getjob_begin [ 4];
61 #ifdef SYM_CONF_TARGET_ROLE_SUPPORT
69 #ifdef SYM_CONF_IARB_SUPPORT
80 u32 datai_done_wsr [ 20];
82 u32 datao_done_wss [ 6];
87 #ifdef SYM_CONF_IARB_SUPPORT
99 u32 complete_error [ 5];
102 u32 disconnect [ 11];
103 u32 disconnect2 [ 5];
105 #ifdef SYM_CONF_IARB_SUPPORT
110 #ifdef SYM_CONF_IARB_SUPPORT
115 #ifdef SYM_CONF_TARGET_ROLE_SUPPORT
120 u32 reselected [ 19];
123 u32 reselected1 [ 25];
128 #if SYM_CONF_MAX_TASK*4 > 512
130 #elif SYM_CONF_MAX_TASK*4 > 256
141 u32 resel_no_tag [ 4];
143 u32 data_in [SYM_CONF_MAX_SG * 2];
145 u32 data_out [SYM_CONF_MAX_SG * 2];
148 u32 pm0_data_out [ 6];
149 u32 pm0_data_end [ 7];
150 u32 pm_data_end [ 4];
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.
163 #ifdef SYM_CONF_TARGET_ROLE_SUPPORT
164 u32 sel_for_abort [ 18];
166 u32 sel_for_abort [ 16];
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];
183 u32 nego_bad_phase [ 4];
185 u32 msg_out_done [ 4];
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];
194 u32 resel_bad_lun [ 4];
196 u32 bad_i_t_l_q [ 4];
198 u32 wsr_ma_helper [ 4];
200 #ifdef SYM_OPT_HANDLE_DIR_UNKNOWN
201 /* Unknown direction handling */
203 u32 data_io_com [ 8];
204 u32 data_io_out [ 7];
218 * Script fragments used at initialisations.
219 * Only runs out of main memory.
226 static struct SYM_FWA_SCR SYM_FWA_SCR = {
227 /*--------------------------< START >----------------------------*/ {
230 * Will be patched with a NO_OP if LED
231 * not needed or not desired.
233 SCR_REG_REG (gpreg, SCR_AND, 0xfe),
238 SCR_FROM_REG (ctest2),
241 * Stop here if the C code wants to perform
242 * some error recovery procedure manually.
243 * (Indicate this by setting SEM in ISTAT)
245 SCR_FROM_REG (istat),
248 * Report to the C code the next position in
249 * the start queue the SCRIPTS will schedule.
250 * The C code must not change SCRATCHA.
255 SCR_INT ^ IFTRUE (MASK (SEM, SEM)),
258 * Start the next job.
260 * @DSA = start point for this job.
261 * SCRATCHA = address of this job in the start queue.
263 * We will restore startpos with SCRATCHA if we fails the
264 * arbitration or if it is the idle job.
266 * The below GETJOB_BEGIN to GETJOB_END section of SCRIPTS
267 * is a critical path. If it is partially executed, it then
268 * may happen that the job address is not yet in the DSA
269 * and the next queue position points to the next JOB.
271 }/*-------------------------< GETJOB_BEGIN >---------------------*/,{
273 * Copy to a fixed location both the next STARTPOS
274 * and the current JOB address, using self modifying
281 }/*-------------------------< _SMS_A10 >-------------------------*/,{
285 * Move the start address to TEMP using self-
286 * modifying SCRIPTS and jump indirectly to
292 }/*-------------------------< GETJOB_END >-----------------------*/,{
297 }/*-------------------------< _SMS_A20 >-------------------------*/,{
302 }/*-------------------------< SELECT >---------------------------*/,{
304 * DSA contains the address of a scheduled
307 * SCRATCHA contains the address of the start queue
308 * entry which points to the next job.
310 * Set Initiator mode.
312 * (Target mode is left as an exercise for the reader)
314 #ifdef SYM_CONF_TARGET_ROLE_SUPPORT
319 * And try to select this target.
321 SCR_SEL_TBL_ATN ^ offsetof (struct sym_dsb, select),
324 * Now there are 4 possibilities:
326 * (1) The chip loses arbitration.
327 * This is ok, because it will try again,
328 * when the bus becomes idle.
329 * (But beware of the timeout function!)
331 * (2) The chip is reselected.
332 * Then the script processor takes the jump
333 * to the RESELECT label.
335 * (3) The chip wins arbitration.
336 * Then it will execute SCRIPTS instruction until
337 * the next instruction that checks SCSI phase.
338 * Then will stop and wait for selection to be
339 * complete or selection time-out to occur.
341 * After having won arbitration, the SCRIPTS
342 * processor is able to execute instructions while
343 * the SCSI core is performing SCSI selection.
347 * Copy the CCB header to a fixed location
348 * in the HCB using self-modifying SCRIPTS.
353 SCR_COPY (sizeof(struct sym_ccbh)),
354 }/*-------------------------< _SMS_A30 >-------------------------*/,{
358 * Initialize the status register
361 HADDR_1 (ccb_head.status),
363 }/*-------------------------< WF_SEL_DONE >----------------------*/,{
364 SCR_INT ^ IFFALSE (WHEN (SCR_MSG_OUT)),
365 SIR_SEL_ATN_NO_MSG_OUT,
366 }/*-------------------------< SEND_IDENT >-----------------------*/,{
368 * Selection complete.
369 * Send the IDENTIFY and possibly the TAG message
370 * and negotiation message if present.
372 SCR_MOVE_TBL ^ SCR_MSG_OUT,
373 offsetof (struct sym_dsb, smsg),
374 }/*-------------------------< SELECT2 >--------------------------*/,{
375 #ifdef SYM_CONF_IARB_SUPPORT
377 * Set IMMEDIATE ARBITRATION if we have been given
378 * a hint to do so. (Some job to do after this one).
380 SCR_FROM_REG (HF_REG),
382 SCR_JUMPR ^ IFFALSE (MASK (HF_HINT_IARB, HF_HINT_IARB)),
384 SCR_REG_REG (scntl1, SCR_OR, IARB),
388 * Anticipate the COMMAND phase.
389 * This is the PHASE we expect at this point.
391 SCR_JUMP ^ IFFALSE (WHEN (SCR_COMMAND)),
392 PADDR_A (sel_no_cmd),
393 }/*-------------------------< COMMAND >--------------------------*/,{
395 * ... and send the command
397 SCR_MOVE_TBL ^ SCR_COMMAND,
398 offsetof (struct sym_dsb, cmd),
399 }/*-------------------------< DISPATCH >-------------------------*/,{
401 * MSG_IN is the only phase that shall be
402 * entered at least once for each (re)selection.
403 * So we test it first.
405 SCR_JUMP ^ IFTRUE (WHEN (SCR_MSG_IN)),
407 SCR_JUMP ^ IFTRUE (IF (SCR_DATA_OUT)),
408 PADDR_A (datao_phase),
409 SCR_JUMP ^ IFTRUE (IF (SCR_DATA_IN)),
410 PADDR_A (datai_phase),
411 SCR_JUMP ^ IFTRUE (IF (SCR_STATUS)),
413 SCR_JUMP ^ IFTRUE (IF (SCR_COMMAND)),
415 SCR_JUMP ^ IFTRUE (IF (SCR_MSG_OUT)),
418 * Discard as many illegal phases as
419 * required and tell the C code about.
421 SCR_JUMPR ^ IFFALSE (WHEN (SCR_ILG_OUT)),
423 SCR_MOVE_ABS (1) ^ SCR_ILG_OUT,
425 SCR_JUMPR ^ IFTRUE (WHEN (SCR_ILG_OUT)),
427 SCR_JUMPR ^ IFFALSE (WHEN (SCR_ILG_IN)),
429 SCR_MOVE_ABS (1) ^ SCR_ILG_IN,
431 SCR_JUMPR ^ IFTRUE (WHEN (SCR_ILG_IN)),
437 }/*-------------------------< SEL_NO_CMD >-----------------------*/,{
439 * The target does not switch to command
440 * phase after IDENTIFY has been sent.
442 * If it stays in MSG OUT phase send it
443 * the IDENTIFY again.
445 SCR_JUMP ^ IFTRUE (WHEN (SCR_MSG_OUT)),
446 PADDR_B (resend_ident),
448 * If target does not switch to MSG IN phase
449 * and we sent a negotiation, assert the
450 * failure immediately.
452 SCR_JUMP ^ IFTRUE (WHEN (SCR_MSG_IN)),
454 SCR_FROM_REG (HS_REG),
456 SCR_INT ^ IFTRUE (DATA (HS_NEGOTIATE)),
459 * Jump to dispatcher.
463 }/*-------------------------< INIT >-----------------------------*/,{
465 * Wait for the SCSI RESET signal to be
466 * inactive before restarting operations,
467 * since the chip may hang on SEL_ATN
468 * if SCSI RESET is active.
470 SCR_FROM_REG (sstat0),
472 SCR_JUMPR ^ IFTRUE (MASK (IRST, IRST)),
476 }/*-------------------------< CLRACK >---------------------------*/,{
478 * Terminate possible pending message phase.
484 }/*-------------------------< DATAI_DONE >-----------------------*/,{
486 * Save current pointer to LASTP.
490 HADDR_1 (ccb_head.lastp),
492 * If the SWIDE is not full, jump to dispatcher.
493 * We anticipate a STATUS phase.
495 SCR_FROM_REG (scntl2),
497 SCR_JUMP ^ IFTRUE (MASK (WSR, WSR)),
498 PADDR_A (datai_done_wsr),
499 SCR_JUMP ^ IFTRUE (WHEN (SCR_STATUS)),
503 }/*-------------------------< DATAI_DONE_WSR >-------------------*/,{
506 * Clear this condition.
508 SCR_REG_REG (scntl2, SCR_OR, WSR),
511 * We are expecting an IGNORE RESIDUE message
512 * from the device, otherwise we are in data
513 * overrun condition. Check against MSG_IN phase.
515 SCR_INT ^ IFFALSE (WHEN (SCR_MSG_IN)),
517 SCR_JUMP ^ IFFALSE (WHEN (SCR_MSG_IN)),
520 * We are in MSG_IN phase,
521 * Read the first byte of the message.
522 * If it is not an IGNORE RESIDUE message,
523 * signal overrun and jump to message
526 SCR_MOVE_ABS (1) ^ SCR_MSG_IN,
528 SCR_INT ^ IFFALSE (DATA (M_IGN_RESIDUE)),
530 SCR_JUMP ^ IFFALSE (DATA (M_IGN_RESIDUE)),
533 * We got the message we expected.
534 * Read the 2nd byte, and jump to dispatcher.
538 SCR_MOVE_ABS (1) ^ SCR_MSG_IN,
544 }/*-------------------------< DATAO_DONE >-----------------------*/,{
546 * Save current pointer to LASTP.
550 HADDR_1 (ccb_head.lastp),
552 * If the SODL is not full jump to dispatcher.
553 * We anticipate a STATUS phase.
555 SCR_FROM_REG (scntl2),
557 SCR_JUMP ^ IFTRUE (MASK (WSS, WSS)),
558 PADDR_A (datao_done_wss),
559 SCR_JUMP ^ IFTRUE (WHEN (SCR_STATUS)),
563 }/*-------------------------< DATAO_DONE_WSS >-------------------*/,{
565 * The SODL is full, clear this condition.
567 SCR_REG_REG (scntl2, SCR_OR, WSS),
570 * And signal a DATA UNDERRUN condition
577 }/*-------------------------< DATAI_PHASE >----------------------*/,{
579 * Jump to current pointer.
582 HADDR_1 (ccb_head.lastp),
586 }/*-------------------------< DATAO_PHASE >----------------------*/,{
588 * Jump to current pointer.
591 HADDR_1 (ccb_head.lastp),
595 }/*-------------------------< MSG_IN >---------------------------*/,{
597 * Get the first byte of the message.
599 * The script processor doesn't negate the
600 * ACK signal after this transfer.
602 SCR_MOVE_ABS (1) ^ SCR_MSG_IN,
604 }/*-------------------------< MSG_IN2 >--------------------------*/,{
606 * Check first against 1 byte messages
607 * that we handle from SCRIPTS.
609 SCR_JUMP ^ IFTRUE (DATA (M_COMPLETE)),
611 SCR_JUMP ^ IFTRUE (DATA (M_DISCONNECT)),
612 PADDR_A (disconnect),
613 SCR_JUMP ^ IFTRUE (DATA (M_SAVE_DP)),
615 SCR_JUMP ^ IFTRUE (DATA (M_RESTORE_DP)),
616 PADDR_A (restore_dp),
618 * We handle all other messages from the
619 * C code, so no need to waste on-chip RAM
623 PADDR_B (msg_in_etc),
624 }/*-------------------------< STATUS >---------------------------*/,{
628 SCR_MOVE_ABS (1) ^ SCR_STATUS,
630 #ifdef SYM_CONF_IARB_SUPPORT
632 * If STATUS is not GOOD, clear IMMEDIATE ARBITRATION,
633 * since we may have to tamper the start queue from
636 SCR_JUMPR ^ IFTRUE (DATA (S_GOOD)),
638 SCR_REG_REG (scntl1, SCR_AND, ~IARB),
642 * save status to scsi_status.
647 SCR_LOAD_REG (HS_REG, HS_COMPLETE),
650 * Anticipate the MESSAGE PHASE for
651 * the TASK COMPLETE message.
653 SCR_JUMP ^ IFTRUE (WHEN (SCR_MSG_IN)),
657 }/*-------------------------< COMPLETE >-------------------------*/,{
661 * When we terminate the cycle by clearing ACK,
662 * the target may disconnect immediately.
664 * We don't want to be told of an "unexpected disconnect",
665 * so we disable this feature.
667 SCR_REG_REG (scntl2, SCR_AND, 0x7f),
670 * Terminate cycle ...
672 SCR_CLR (SCR_ACK|SCR_ATN),
675 * ... and wait for the disconnect.
679 }/*-------------------------< COMPLETE2 >------------------------*/,{
685 HADDR_1 (ccb_head.status),
687 * Move back the CCB header using self-modifying
693 SCR_COPY (sizeof(struct sym_ccbh)),
695 }/*-------------------------< _SMS_A40 >-------------------------*/,{
698 * Some bridges may reorder DMA writes to memory.
699 * We donnot want the CPU to deal with completions
700 * without all the posted write having been flushed
701 * to memory. This DUMMY READ should flush posted
702 * buffers prior to the CPU having to deal with
705 SCR_COPY (4), /* DUMMY READ */
706 HADDR_1 (ccb_head.status),
709 * If command resulted in not GOOD status,
710 * call the C code if needed.
712 SCR_FROM_REG (SS_REG),
714 SCR_CALL ^ IFFALSE (DATA (S_GOOD)),
715 PADDR_B (bad_status),
717 * If we performed an auto-sense, call
718 * the C code to synchronyze task aborts
719 * with UNIT ATTENTION conditions.
721 SCR_FROM_REG (HF_REG),
723 SCR_JUMP ^ IFFALSE (MASK (0 ,(HF_SENSE|HF_EXT_ERR))),
724 PADDR_A (complete_error),
725 }/*-------------------------< DONE >-----------------------------*/,{
727 * Copy the DSA to the DONE QUEUE and
728 * signal completion to the host.
729 * If we are interrupted between DONE
730 * and DONE_END, we must reset, otherwise
731 * the completed CCB may be lost.
738 }/*-------------------------< _SMS_A50 >-------------------------*/,{
744 * The instruction below reads the DONE QUEUE next
745 * free position from memory.
746 * In addition it ensures that all PCI posted writes
747 * are flushed and so the DSA value of the done
748 * CCB is visible by the CPU before INTFLY is raised.
751 }/*-------------------------< _SMS_A60 >-------------------------*/,{
754 }/*-------------------------< DONE_END >-------------------------*/,{
759 }/*-------------------------< COMPLETE_ERROR >-------------------*/,{
765 }/*-------------------------< SAVE_DP >--------------------------*/,{
767 * Clear ACK immediately.
768 * No need to delay it.
773 * Keep track we received a SAVE DP, so
774 * we will switch to the other PM context
775 * on the next PM since the DP may point
776 * to the current PM context.
778 SCR_REG_REG (HF_REG, SCR_OR, HF_DP_SAVED),
782 * Copy LASTP to SAVEP.
785 HADDR_1 (ccb_head.lastp),
786 HADDR_1 (ccb_head.savep),
788 * Anticipate the MESSAGE PHASE for
789 * the DISCONNECT message.
791 SCR_JUMP ^ IFTRUE (WHEN (SCR_MSG_IN)),
795 }/*-------------------------< RESTORE_DP >-----------------------*/,{
797 * Clear ACK immediately.
798 * No need to delay it.
803 * Copy SAVEP to LASTP.
806 HADDR_1 (ccb_head.savep),
807 HADDR_1 (ccb_head.lastp),
810 }/*-------------------------< DISCONNECT >-----------------------*/,{
814 * disable the "unexpected disconnect" feature,
815 * and remove the ACK signal.
817 SCR_REG_REG (scntl2, SCR_AND, 0x7f),
819 SCR_CLR (SCR_ACK|SCR_ATN),
822 * Wait for the disconnect.
827 * Status is: DISCONNECTED.
829 SCR_LOAD_REG (HS_REG, HS_DISCONNECT),
836 HADDR_1 (ccb_head.status),
837 }/*-------------------------< DISCONNECT2 >----------------------*/,{
839 * Move back the CCB header using self-modifying
845 SCR_COPY (sizeof(struct sym_ccbh)),
847 }/*-------------------------< _SMS_A65 >-------------------------*/,{
851 }/*-------------------------< IDLE >-----------------------------*/,{
854 * Switch the LED off and wait for reselect.
855 * Will be patched with a NO_OP if LED
856 * not needed or not desired.
858 SCR_REG_REG (gpreg, SCR_OR, 0x01),
860 #ifdef SYM_CONF_IARB_SUPPORT
864 }/*-------------------------< UNGETJOB >-------------------------*/,{
865 #ifdef SYM_CONF_IARB_SUPPORT
867 * Set IMMEDIATE ARBITRATION, for the next time.
868 * This will give us better chance to win arbitration
869 * for the job we just wanted to do.
871 SCR_REG_REG (scntl1, SCR_OR, IARB),
875 * We are not able to restart the SCRIPTS if we are
876 * interrupted and these instruction haven't been
877 * all executed. BTW, this is very unlikely to
878 * happen, but we check that from the C code.
880 SCR_LOAD_REG (dsa, 0xff),
885 }/*-------------------------< RESELECT >-------------------------*/,{
886 #ifdef SYM_CONF_TARGET_ROLE_SUPPORT
888 * Make sure we are in initiator mode.
894 * Sleep waiting for a reselection.
898 }/*-------------------------< RESELECTED >-----------------------*/,{
901 * Will be patched with a NO_OP if LED
902 * not needed or not desired.
904 SCR_REG_REG (gpreg, SCR_AND, 0xfe),
907 * load the target id into the sdid
909 SCR_REG_SFBR (ssid, SCR_AND, 0x8F),
914 * Load the target control block address
919 SCR_SFBR_REG (dsa, SCR_SHL, 0),
921 SCR_REG_REG (dsa, SCR_SHL, 0),
923 SCR_REG_REG (dsa, SCR_AND, 0x3c),
929 }/*-------------------------< _SMS_A70 >-------------------------*/,{
933 * Copy the TCB header to a fixed place in
939 SCR_COPY (sizeof(struct sym_tcbh)),
940 }/*-------------------------< _SMS_A80 >-------------------------*/,{
944 * We expect MESSAGE IN phase.
945 * If not, get help from the C code.
947 SCR_INT ^ IFFALSE (WHEN (SCR_MSG_IN)),
949 }/*-------------------------< RESELECTED1 >----------------------*/,{
951 * Load the synchronous transfer registers.
954 HADDR_1 (tcb_head.wval),
957 HADDR_1 (tcb_head.sval),
960 * Get the IDENTIFY message.
962 SCR_MOVE_ABS (1) ^ SCR_MSG_IN,
965 * If IDENTIFY LUN #0, use a faster path
966 * to find the LCB structure.
968 SCR_JUMP ^ IFTRUE (MASK (0x80, 0xbf)),
969 PADDR_A (resel_lun0),
971 * If message isn't an IDENTIFY,
972 * tell the C code about.
974 SCR_INT ^ IFFALSE (MASK (0x80, 0x80)),
975 SIR_RESEL_NO_IDENTIFY,
977 * It is an IDENTIFY message,
978 * Load the LUN control block address.
981 HADDR_1 (tcb_head.luntbl_sa),
983 SCR_SFBR_REG (dsa, SCR_SHL, 0),
985 SCR_REG_REG (dsa, SCR_SHL, 0),
987 SCR_REG_REG (dsa, SCR_AND, 0xfc),
993 }/*-------------------------< _SMS_A90 >-------------------------*/,{
998 }/*-------------------------< RESEL_LUN0 >-----------------------*/,{
1000 * LUN 0 special case (but usual one :))
1003 HADDR_1 (tcb_head.lun0_sa),
1006 * Jump indirectly to the reselect action for this LUN.
1007 * (lcb.head.resel_sa assumed at offset zero of lcb).
1011 PADDR_A (_sms_a100),
1013 }/*-------------------------< _SMS_A100 >------------------------*/,{
1018 /* In normal situations, we jump to RESEL_TAG or RESEL_NO_TAG */
1019 }/*-------------------------< RESEL_TAG >------------------------*/,{
1021 * ACK the IDENTIFY previously received.
1026 * It shall be a tagged command.
1028 * The C code will deal with errors.
1029 * Agressive optimization, is'nt it? :)
1031 SCR_MOVE_ABS (2) ^ SCR_MSG_IN,
1034 * Copy the LCB header to a fixed place in
1035 * the HCB using self-modifying SCRIPTS.
1039 PADDR_A (_sms_a110),
1040 SCR_COPY (sizeof(struct sym_lcbh)),
1041 }/*-------------------------< _SMS_A110 >------------------------*/,{
1045 * Load the pointer to the tagged task
1046 * table for this LUN.
1049 HADDR_1 (lcb_head.itlq_tbl_sa),
1052 * The SIDL still contains the TAG value.
1053 * Agressive optimization, isn't it? :):)
1055 SCR_REG_SFBR (sidl, SCR_SHL, 0),
1057 #if SYM_CONF_MAX_TASK*4 > 512
1058 SCR_JUMPR ^ IFFALSE (CARRYSET),
1060 SCR_REG_REG (dsa1, SCR_OR, 2),
1062 SCR_REG_REG (sfbr, SCR_SHL, 0),
1064 SCR_JUMPR ^ IFFALSE (CARRYSET),
1066 SCR_REG_REG (dsa1, SCR_OR, 1),
1068 #elif SYM_CONF_MAX_TASK*4 > 256
1069 SCR_JUMPR ^ IFFALSE (CARRYSET),
1071 SCR_REG_REG (dsa1, SCR_OR, 1),
1075 * Retrieve the DSA of this task.
1076 * JUMP indirectly to the restart point of the CCB.
1078 SCR_SFBR_REG (dsa, SCR_AND, 0xfc),
1082 PADDR_A (_sms_a120),
1084 }/*-------------------------< _SMS_A120 >------------------------*/,{
1087 }/*-------------------------< RESEL_GO >-------------------------*/,{
1090 PADDR_A (_sms_a130),
1092 * Move 'ccb.phys.head.go' action to
1093 * scratch/scratch1. So scratch1 will
1094 * contain the 'restart' field of the
1098 }/*-------------------------< _SMS_A130 >------------------------*/,{
1102 PADDR_B (scratch1), /* phys.head.go.restart */
1106 /* In normal situations we branch to RESEL_DSA */
1107 }/*-------------------------< RESEL_DSA >------------------------*/,{
1109 * ACK the IDENTIFY or TAG previously received.
1113 }/*-------------------------< RESEL_DSA1 >-----------------------*/,{
1115 * Copy the CCB header to a fixed location
1116 * in the HCB using self-modifying SCRIPTS.
1120 PADDR_A (_sms_a140),
1121 SCR_COPY (sizeof(struct sym_ccbh)),
1122 }/*-------------------------< _SMS_A140 >------------------------*/,{
1126 * Initialize the status register
1129 HADDR_1 (ccb_head.status),
1132 * Jump to dispatcher.
1136 }/*-------------------------< RESEL_NO_TAG >---------------------*/,{
1138 * Copy the LCB header to a fixed place in
1139 * the HCB using self-modifying SCRIPTS.
1143 PADDR_A (_sms_a145),
1144 SCR_COPY (sizeof(struct sym_lcbh)),
1145 }/*-------------------------< _SMS_A145 >------------------------*/,{
1149 * Load the DSA with the unique ITL task.
1152 HADDR_1 (lcb_head.itl_task_sa),
1156 }/*-------------------------< DATA_IN >--------------------------*/,{
1158 * Because the size depends on the
1159 * #define SYM_CONF_MAX_SG parameter,
1160 * it is filled in at runtime.
1162 * ##===========< i=0; i<SYM_CONF_MAX_SG >=========
1163 * || SCR_CHMOV_TBL ^ SCR_DATA_IN,
1164 * || offsetof (struct sym_dsb, data[ i]),
1165 * ##==========================================
1168 }/*-------------------------< DATA_IN2 >-------------------------*/,{
1170 PADDR_A (datai_done),
1172 PADDR_B (data_ovrun),
1173 }/*-------------------------< DATA_OUT >-------------------------*/,{
1175 * Because the size depends on the
1176 * #define SYM_CONF_MAX_SG parameter,
1177 * it is filled in at runtime.
1179 * ##===========< i=0; i<SYM_CONF_MAX_SG >=========
1180 * || SCR_CHMOV_TBL ^ SCR_DATA_OUT,
1181 * || offsetof (struct sym_dsb, data[ i]),
1182 * ##==========================================
1185 }/*-------------------------< DATA_OUT2 >------------------------*/,{
1187 PADDR_A (datao_done),
1189 PADDR_B (data_ovrun),
1190 }/*-------------------------< PM0_DATA >-------------------------*/,{
1192 * Read our host flags to SFBR, so we will be able
1193 * to check against the data direction we expect.
1195 SCR_FROM_REG (HF_REG),
1198 * Check against actual DATA PHASE.
1200 SCR_JUMP ^ IFFALSE (WHEN (SCR_DATA_IN)),
1201 PADDR_A (pm0_data_out),
1203 * Actual phase is DATA IN.
1204 * Check against expected direction.
1206 SCR_JUMP ^ IFFALSE (MASK (HF_DATA_IN, HF_DATA_IN)),
1207 PADDR_B (data_ovrun),
1209 * Keep track we are moving data from the
1210 * PM0 DATA mini-script.
1212 SCR_REG_REG (HF_REG, SCR_OR, HF_IN_PM0),
1215 * Move the data to memory.
1217 SCR_CHMOV_TBL ^ SCR_DATA_IN,
1218 offsetof (struct sym_ccb, phys.pm0.sg),
1220 PADDR_A (pm0_data_end),
1221 }/*-------------------------< PM0_DATA_OUT >---------------------*/,{
1223 * Actual phase is DATA OUT.
1224 * Check against expected direction.
1226 SCR_JUMP ^ IFTRUE (MASK (HF_DATA_IN, HF_DATA_IN)),
1227 PADDR_B (data_ovrun),
1229 * Keep track we are moving data from the
1230 * PM0 DATA mini-script.
1232 SCR_REG_REG (HF_REG, SCR_OR, HF_IN_PM0),
1235 * Move the data from memory.
1237 SCR_CHMOV_TBL ^ SCR_DATA_OUT,
1238 offsetof (struct sym_ccb, phys.pm0.sg),
1239 }/*-------------------------< PM0_DATA_END >---------------------*/,{
1241 * Clear the flag that told we were moving
1242 * data from the PM0 DATA mini-script.
1244 SCR_REG_REG (HF_REG, SCR_AND, (~HF_IN_PM0)),
1247 * Return to the previous DATA script which
1248 * is guaranteed by design (if no bug) to be
1249 * the main DATA script for this transfer.
1254 SCR_REG_REG (scratcha, SCR_ADD, offsetof (struct sym_ccb,phys.pm0.ret)),
1256 }/*-------------------------< PM_DATA_END >----------------------*/,{
1259 PADDR_A (_sms_a150),
1261 }/*-------------------------< _SMS_A150 >------------------------*/,{
1266 }/*-------------------------< PM1_DATA >-------------------------*/,{
1268 * Read our host flags to SFBR, so we will be able
1269 * to check against the data direction we expect.
1271 SCR_FROM_REG (HF_REG),
1274 * Check against actual DATA PHASE.
1276 SCR_JUMP ^ IFFALSE (WHEN (SCR_DATA_IN)),
1277 PADDR_A (pm1_data_out),
1279 * Actual phase is DATA IN.
1280 * Check against expected direction.
1282 SCR_JUMP ^ IFFALSE (MASK (HF_DATA_IN, HF_DATA_IN)),
1283 PADDR_B (data_ovrun),
1285 * Keep track we are moving data from the
1286 * PM1 DATA mini-script.
1288 SCR_REG_REG (HF_REG, SCR_OR, HF_IN_PM1),
1291 * Move the data to memory.
1293 SCR_CHMOV_TBL ^ SCR_DATA_IN,
1294 offsetof (struct sym_ccb, phys.pm1.sg),
1296 PADDR_A (pm1_data_end),
1297 }/*-------------------------< PM1_DATA_OUT >---------------------*/,{
1299 * Actual phase is DATA OUT.
1300 * Check against expected direction.
1302 SCR_JUMP ^ IFTRUE (MASK (HF_DATA_IN, HF_DATA_IN)),
1303 PADDR_B (data_ovrun),
1305 * Keep track we are moving data from the
1306 * PM1 DATA mini-script.
1308 SCR_REG_REG (HF_REG, SCR_OR, HF_IN_PM1),
1311 * Move the data from memory.
1313 SCR_CHMOV_TBL ^ SCR_DATA_OUT,
1314 offsetof (struct sym_ccb, phys.pm1.sg),
1315 }/*-------------------------< PM1_DATA_END >---------------------*/,{
1317 * Clear the flag that told we were moving
1318 * data from the PM1 DATA mini-script.
1320 SCR_REG_REG (HF_REG, SCR_AND, (~HF_IN_PM1)),
1323 * Return to the previous DATA script which
1324 * is guaranteed by design (if no bug) to be
1325 * the main DATA script for this transfer.
1330 SCR_REG_REG (scratcha, SCR_ADD, offsetof (struct sym_ccb,phys.pm1.ret)),
1333 PADDR_A (pm_data_end),
1334 }/*--------------------------<>----------------------------------*/
1337 static struct SYM_FWB_SCR SYM_FWB_SCR = {
1338 /*-------------------------< NO_DATA >--------------------------*/ {
1340 PADDR_B (data_ovrun),
1341 }/*-------------------------< SEL_FOR_ABORT >--------------------*/,{
1343 * We are jumped here by the C code, if we have
1344 * some target to reset or some disconnected
1345 * job to abort. Since error recovery is a serious
1346 * busyness, we will really reset the SCSI BUS, if
1347 * case of a SCSI interrupt occurring in this path.
1350 #ifdef SYM_CONF_TARGET_ROLE_SUPPORT
1352 * Set initiator mode.
1358 * And try to select this target.
1360 SCR_SEL_TBL_ATN ^ offsetof (struct sym_hcb, abrt_sel),
1363 * Wait for the selection to complete or
1364 * the selection to time out.
1366 SCR_JUMPR ^ IFFALSE (WHEN (SCR_MSG_OUT)),
1372 SIR_TARGET_SELECTED,
1374 * The C code should let us continue here.
1375 * Send the 'kiss of death' message.
1376 * We expect an immediate disconnect once
1377 * the target has eaten the message.
1379 SCR_REG_REG (scntl2, SCR_AND, 0x7f),
1381 SCR_MOVE_TBL ^ SCR_MSG_OUT,
1382 offsetof (struct sym_hcb, abrt_tbl),
1383 SCR_CLR (SCR_ACK|SCR_ATN),
1388 * Tell the C code that we are done.
1392 }/*-------------------------< SEL_FOR_ABORT_1 >------------------*/,{
1394 * Jump at scheduler.
1398 }/*-------------------------< MSG_IN_ETC >-----------------------*/,{
1400 * If it is an EXTENDED (variable size message)
1403 SCR_JUMP ^ IFTRUE (DATA (M_EXTENDED)),
1404 PADDR_B (msg_extended),
1406 * Let the C code handle any other
1409 SCR_JUMP ^ IFTRUE (MASK (0x00, 0xf0)),
1410 PADDR_B (msg_received),
1411 SCR_JUMP ^ IFTRUE (MASK (0x10, 0xf0)),
1412 PADDR_B (msg_received),
1414 * We donnot handle 2 bytes messages from SCRIPTS.
1415 * So, let the C code deal with these ones too.
1417 SCR_JUMP ^ IFFALSE (MASK (0x20, 0xf0)),
1418 PADDR_B (msg_weird_seen),
1421 SCR_MOVE_ABS (1) ^ SCR_MSG_IN,
1423 }/*-------------------------< MSG_RECEIVED >---------------------*/,{
1424 SCR_COPY (4), /* DUMMY READ */
1429 }/*-------------------------< MSG_WEIRD_SEEN >-------------------*/,{
1430 SCR_COPY (4), /* DUMMY READ */
1435 }/*-------------------------< MSG_EXTENDED >---------------------*/,{
1437 * Clear ACK and get the next byte
1438 * assumed to be the message length.
1442 SCR_MOVE_ABS (1) ^ SCR_MSG_IN,
1445 * Try to catch some unlikely situations as 0 length
1446 * or too large the length.
1448 SCR_JUMP ^ IFTRUE (DATA (0)),
1449 PADDR_B (msg_weird_seen),
1450 SCR_TO_REG (scratcha),
1452 SCR_REG_REG (sfbr, SCR_ADD, (256-8)),
1454 SCR_JUMP ^ IFTRUE (CARRYSET),
1455 PADDR_B (msg_weird_seen),
1457 * We donnot handle extended messages from SCRIPTS.
1458 * Read the amount of data correponding to the
1459 * message length and call the C code.
1466 }/*-------------------------< _SMS_B10 >-------------------------*/,{
1467 SCR_MOVE_ABS (0) ^ SCR_MSG_IN,
1470 PADDR_B (msg_received),
1471 }/*-------------------------< MSG_BAD >--------------------------*/,{
1473 * unimplemented message - reject it.
1481 }/*-------------------------< MSG_WEIRD >------------------------*/,{
1483 * weird message received
1484 * ignore all MSG IN phases and reject it.
1490 }/*-------------------------< MSG_WEIRD1 >-----------------------*/,{
1493 SCR_JUMP ^ IFFALSE (WHEN (SCR_MSG_IN)),
1495 SCR_MOVE_ABS (1) ^ SCR_MSG_IN,
1498 PADDR_B (msg_weird1),
1499 }/*-------------------------< WDTR_RESP >------------------------*/,{
1501 * let the target fetch our answer.
1507 SCR_JUMP ^ IFFALSE (WHEN (SCR_MSG_OUT)),
1508 PADDR_B (nego_bad_phase),
1509 }/*-------------------------< SEND_WDTR >------------------------*/,{
1511 * Send the M_X_WIDE_REQ
1513 SCR_MOVE_ABS (4) ^ SCR_MSG_OUT,
1516 PADDR_B (msg_out_done),
1517 }/*-------------------------< SDTR_RESP >------------------------*/,{
1519 * let the target fetch our answer.
1525 SCR_JUMP ^ IFFALSE (WHEN (SCR_MSG_OUT)),
1526 PADDR_B (nego_bad_phase),
1527 }/*-------------------------< SEND_SDTR >------------------------*/,{
1529 * Send the M_X_SYNC_REQ
1531 SCR_MOVE_ABS (5) ^ SCR_MSG_OUT,
1534 PADDR_B (msg_out_done),
1535 }/*-------------------------< PPR_RESP >-------------------------*/,{
1537 * let the target fetch our answer.
1543 SCR_JUMP ^ IFFALSE (WHEN (SCR_MSG_OUT)),
1544 PADDR_B (nego_bad_phase),
1545 }/*-------------------------< SEND_PPR >-------------------------*/,{
1547 * Send the M_X_PPR_REQ
1549 SCR_MOVE_ABS (8) ^ SCR_MSG_OUT,
1552 PADDR_B (msg_out_done),
1553 }/*-------------------------< NEGO_BAD_PHASE >-------------------*/,{
1558 }/*-------------------------< MSG_OUT >--------------------------*/,{
1560 * The target requests a message.
1561 * We donnot send messages that may
1562 * require the device to go to bus free.
1564 SCR_MOVE_ABS (1) ^ SCR_MSG_OUT,
1567 * ... wait for the next phase
1568 * if it's a message out, send it again, ...
1570 SCR_JUMP ^ IFTRUE (WHEN (SCR_MSG_OUT)),
1572 }/*-------------------------< MSG_OUT_DONE >---------------------*/,{
1574 * Let the C code be aware of the
1575 * sent message and clear the message.
1580 * ... and process the next phase
1584 }/*-------------------------< DATA_OVRUN >-----------------------*/,{
1586 * Zero scratcha that will count the
1592 }/*-------------------------< DATA_OVRUN1 >----------------------*/,{
1594 * The target may want to transfer too much data.
1596 * If phase is DATA OUT write 1 byte and count it.
1598 SCR_JUMPR ^ IFFALSE (WHEN (SCR_DATA_OUT)),
1600 SCR_CHMOV_ABS (1) ^ SCR_DATA_OUT,
1603 PADDR_B (data_ovrun2),
1605 * If WSR is set, clear this condition, and
1608 SCR_FROM_REG (scntl2),
1610 SCR_JUMPR ^ IFFALSE (MASK (WSR, WSR)),
1612 SCR_REG_REG (scntl2, SCR_OR, WSR),
1615 PADDR_B (data_ovrun2),
1617 * Finally check against DATA IN phase.
1618 * Signal data overrun to the C code
1619 * and jump to dispatcher if not so.
1620 * Read 1 byte otherwise and count it.
1622 SCR_JUMPR ^ IFTRUE (WHEN (SCR_DATA_IN)),
1628 SCR_CHMOV_ABS (1) ^ SCR_DATA_IN,
1630 }/*-------------------------< DATA_OVRUN2 >----------------------*/,{
1633 * This will allow to return a negative
1636 SCR_REG_REG (scratcha, SCR_ADD, 0x01),
1638 SCR_REG_REG (scratcha1, SCR_ADDC, 0),
1640 SCR_REG_REG (scratcha2, SCR_ADDC, 0),
1643 * .. and repeat as required.
1646 PADDR_B (data_ovrun1),
1647 }/*-------------------------< ABORT_RESEL >----------------------*/,{
1653 * send the abort/abortag/reset message
1654 * we expect an immediate disconnect
1656 SCR_REG_REG (scntl2, SCR_AND, 0x7f),
1658 SCR_MOVE_ABS (1) ^ SCR_MSG_OUT,
1660 SCR_CLR (SCR_ACK|SCR_ATN),
1668 }/*-------------------------< RESEND_IDENT >---------------------*/,{
1670 * The target stays in MSG OUT phase after having acked
1671 * Identify [+ Tag [+ Extended message ]]. Targets shall
1672 * behave this way on parity error.
1673 * We must send it again all the messages.
1675 SCR_SET (SCR_ATN), /* Shall be asserted 2 deskew delays before the */
1676 0, /* 1rst ACK = 90 ns. Hope the chip isn't too fast */
1678 PADDR_A (send_ident),
1679 }/*-------------------------< IDENT_BREAK >----------------------*/,{
1684 }/*-------------------------< IDENT_BREAK_ATN >------------------*/,{
1689 }/*-------------------------< SDATA_IN >-------------------------*/,{
1690 SCR_CHMOV_TBL ^ SCR_DATA_IN,
1691 offsetof (struct sym_dsb, sense),
1693 PADDR_A (datai_done),
1695 PADDR_B (data_ovrun),
1696 }/*-------------------------< RESEL_BAD_LUN >--------------------*/,{
1698 * Message is an IDENTIFY, but lun is unknown.
1699 * Signal problem to C code for logging the event.
1700 * Send a M_ABORT to clear all pending tasks.
1705 PADDR_B (abort_resel),
1706 }/*-------------------------< BAD_I_T_L >------------------------*/,{
1708 * We donnot have a task for that I_T_L.
1709 * Signal problem to C code for logging the event.
1710 * Send a M_ABORT message.
1713 SIR_RESEL_BAD_I_T_L,
1715 PADDR_B (abort_resel),
1716 }/*-------------------------< BAD_I_T_L_Q >----------------------*/,{
1718 * We donnot have a task that matches the tag.
1719 * Signal problem to C code for logging the event.
1720 * Send a M_ABORTTAG message.
1723 SIR_RESEL_BAD_I_T_L_Q,
1725 PADDR_B (abort_resel),
1726 }/*-------------------------< BAD_STATUS >-----------------------*/,{
1728 * Anything different from INTERMEDIATE
1729 * CONDITION MET should be a bad SCSI status,
1730 * given that GOOD status has already been tested.
1736 SCR_INT ^ IFFALSE (DATA (S_COND_MET)),
1737 SIR_BAD_SCSI_STATUS,
1740 }/*-------------------------< WSR_MA_HELPER >--------------------*/,{
1742 * Helper for the C code when WSR bit is set.
1743 * Perform the move of the residual byte.
1745 SCR_CHMOV_TBL ^ SCR_DATA_IN,
1746 offsetof (struct sym_ccb, phys.wresid),
1750 #ifdef SYM_OPT_HANDLE_DIR_UNKNOWN
1751 }/*-------------------------< DATA_IO >--------------------------*/,{
1753 * We jump here if the data direction was unknown at the
1754 * time we had to queue the command to the scripts processor.
1755 * Pointers had been set as follow in this situation:
1757 * lastp --> start pointer when DATA_IN
1758 * wlastp --> start pointer when DATA_OUT
1759 * This script sets savep and lastp according to the
1760 * direction chosen by the target.
1762 SCR_JUMP ^ IFTRUE (WHEN (SCR_DATA_OUT)),
1763 PADDR_B (data_io_out),
1764 }/*-------------------------< DATA_IO_COM >----------------------*/,{
1766 * Direction is DATA IN.
1769 HADDR_1 (ccb_head.lastp),
1770 HADDR_1 (ccb_head.savep),
1772 * Jump to the SCRIPTS according to actual direction.
1775 HADDR_1 (ccb_head.savep),
1779 }/*-------------------------< DATA_IO_OUT >----------------------*/,{
1781 * Direction is DATA OUT.
1783 SCR_REG_REG (HF_REG, SCR_AND, (~HF_DATA_IN)),
1786 HADDR_1 (ccb_head.wlastp),
1787 HADDR_1 (ccb_head.lastp),
1789 PADDR_B(data_io_com),
1790 #endif /* SYM_OPT_HANDLE_DIR_UNKNOWN */
1792 }/*-------------------------< ZERO >-----------------------------*/,{
1794 }/*-------------------------< SCRATCH >--------------------------*/,{
1795 SCR_DATA_ZERO, /* MUST BE BEFORE SCRATCH1 */
1796 }/*-------------------------< SCRATCH1 >-------------------------*/,{
1798 }/*-------------------------< PREV_DONE >------------------------*/,{
1799 SCR_DATA_ZERO, /* MUST BE BEFORE DONE_POS ! */
1800 }/*-------------------------< DONE_POS >-------------------------*/,{
1802 }/*-------------------------< NEXTJOB >--------------------------*/,{
1803 SCR_DATA_ZERO, /* MUST BE BEFORE STARTPOS ! */
1804 }/*-------------------------< STARTPOS >-------------------------*/,{
1806 }/*-------------------------< TARGTBL >--------------------------*/,{
1808 }/*--------------------------<>----------------------------------*/
1811 static struct SYM_FWZ_SCR SYM_FWZ_SCR = {
1812 /*-------------------------< SNOOPTEST >------------------------*/{
1814 * Read the variable.
1820 * Write the variable.
1826 * Read back the variable.
1831 }/*-------------------------< SNOOPEND >-------------------------*/,{
1837 }/*--------------------------<>----------------------------------*/