1 /* SPDX-License-Identifier: GPL-2.0-or-later */
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.
44 u32 getjob_begin
[ 4];
48 #ifdef SYM_CONF_TARGET_ROLE_SUPPORT
56 #ifdef SYM_CONF_IARB_SUPPORT
67 u32 datai_done_wsr
[ 20];
69 u32 datao_done_wss
[ 6];
74 #ifdef SYM_CONF_IARB_SUPPORT
86 u32 complete_error
[ 5];
92 #ifdef SYM_CONF_IARB_SUPPORT
97 #ifdef SYM_CONF_IARB_SUPPORT
102 #ifdef SYM_CONF_TARGET_ROLE_SUPPORT
107 u32 reselected
[ 19];
110 u32 reselected1
[ 25];
115 #if SYM_CONF_MAX_TASK*4 > 512
117 #elif SYM_CONF_MAX_TASK*4 > 256
128 u32 resel_no_tag
[ 4];
130 u32 data_in
[SYM_CONF_MAX_SG
* 2];
132 u32 data_out
[SYM_CONF_MAX_SG
* 2];
135 u32 pm0_data_out
[ 6];
136 u32 pm0_data_end
[ 7];
137 u32 pm_data_end
[ 4];
140 u32 pm1_data_out
[ 6];
141 u32 pm1_data_end
[ 9];
145 * Script fragments which stay in main memory for all chips
146 * except for chips that support 8K on-chip RAM.
150 #ifdef SYM_CONF_TARGET_ROLE_SUPPORT
151 u32 sel_for_abort
[ 18];
153 u32 sel_for_abort
[ 16];
155 u32 sel_for_abort_1
[ 2];
156 u32 msg_in_etc
[ 12];
157 u32 msg_received
[ 5];
158 u32 msg_weird_seen
[ 5];
159 u32 msg_extended
[ 17];
170 u32 nego_bad_phase
[ 4];
172 u32 msg_out_done
[ 4];
174 u32 data_ovrun1
[ 22];
175 u32 data_ovrun2
[ 8];
176 u32 abort_resel
[ 16];
177 u32 resend_ident
[ 4];
178 u32 ident_break
[ 4];
179 u32 ident_break_atn
[ 4];
181 u32 resel_bad_lun
[ 4];
183 u32 bad_i_t_l_q
[ 4];
185 u32 wsr_ma_helper
[ 4];
199 * Script fragments used at initialisations.
200 * Only runs out of main memory.
207 static struct SYM_FWA_SCR SYM_FWA_SCR
= {
208 /*--------------------------< START >----------------------------*/ {
211 * Will be patched with a NO_OP if LED
212 * not needed or not desired.
214 SCR_REG_REG (gpreg
, SCR_AND
, 0xfe),
219 SCR_FROM_REG (ctest2
),
222 * Stop here if the C code wants to perform
223 * some error recovery procedure manually.
224 * (Indicate this by setting SEM in ISTAT)
226 SCR_FROM_REG (istat
),
229 * Report to the C code the next position in
230 * the start queue the SCRIPTS will schedule.
231 * The C code must not change SCRATCHA.
236 SCR_INT
^ IFTRUE (MASK (SEM
, SEM
)),
239 * Start the next job.
241 * @DSA = start point for this job.
242 * SCRATCHA = address of this job in the start queue.
244 * We will restore startpos with SCRATCHA if we fails the
245 * arbitration or if it is the idle job.
247 * The below GETJOB_BEGIN to GETJOB_END section of SCRIPTS
248 * is a critical path. If it is partially executed, it then
249 * may happen that the job address is not yet in the DSA
250 * and the next queue position points to the next JOB.
252 }/*-------------------------< GETJOB_BEGIN >---------------------*/,{
254 * Copy to a fixed location both the next STARTPOS
255 * and the current JOB address, using self modifying
262 }/*-------------------------< _SMS_A10 >-------------------------*/,{
266 * Move the start address to TEMP using self-
267 * modifying SCRIPTS and jump indirectly to
273 }/*-------------------------< GETJOB_END >-----------------------*/,{
278 }/*-------------------------< _SMS_A20 >-------------------------*/,{
283 }/*-------------------------< SELECT >---------------------------*/,{
285 * DSA contains the address of a scheduled
288 * SCRATCHA contains the address of the start queue
289 * entry which points to the next job.
291 * Set Initiator mode.
293 * (Target mode is left as an exercise for the reader)
295 #ifdef SYM_CONF_TARGET_ROLE_SUPPORT
300 * And try to select this target.
302 SCR_SEL_TBL_ATN
^ offsetof (struct sym_dsb
, select
),
305 * Now there are 4 possibilities:
307 * (1) The chip loses arbitration.
308 * This is ok, because it will try again,
309 * when the bus becomes idle.
310 * (But beware of the timeout function!)
312 * (2) The chip is reselected.
313 * Then the script processor takes the jump
314 * to the RESELECT label.
316 * (3) The chip wins arbitration.
317 * Then it will execute SCRIPTS instruction until
318 * the next instruction that checks SCSI phase.
319 * Then will stop and wait for selection to be
320 * complete or selection time-out to occur.
322 * After having won arbitration, the SCRIPTS
323 * processor is able to execute instructions while
324 * the SCSI core is performing SCSI selection.
328 * Copy the CCB header to a fixed location
329 * in the HCB using self-modifying SCRIPTS.
334 SCR_COPY (sizeof(struct sym_ccbh
)),
335 }/*-------------------------< _SMS_A30 >-------------------------*/,{
339 * Initialize the status register
342 HADDR_1 (ccb_head
.status
),
344 }/*-------------------------< WF_SEL_DONE >----------------------*/,{
345 SCR_INT
^ IFFALSE (WHEN (SCR_MSG_OUT
)),
346 SIR_SEL_ATN_NO_MSG_OUT
,
347 }/*-------------------------< SEND_IDENT >-----------------------*/,{
349 * Selection complete.
350 * Send the IDENTIFY and possibly the TAG message
351 * and negotiation message if present.
353 SCR_MOVE_TBL
^ SCR_MSG_OUT
,
354 offsetof (struct sym_dsb
, smsg
),
355 }/*-------------------------< SELECT2 >--------------------------*/,{
356 #ifdef SYM_CONF_IARB_SUPPORT
358 * Set IMMEDIATE ARBITRATION if we have been given
359 * a hint to do so. (Some job to do after this one).
361 SCR_FROM_REG (HF_REG
),
363 SCR_JUMPR
^ IFFALSE (MASK (HF_HINT_IARB
, HF_HINT_IARB
)),
365 SCR_REG_REG (scntl1
, SCR_OR
, IARB
),
369 * Anticipate the COMMAND phase.
370 * This is the PHASE we expect at this point.
372 SCR_JUMP
^ IFFALSE (WHEN (SCR_COMMAND
)),
373 PADDR_A (sel_no_cmd
),
374 }/*-------------------------< COMMAND >--------------------------*/,{
376 * ... and send the command
378 SCR_MOVE_TBL
^ SCR_COMMAND
,
379 offsetof (struct sym_dsb
, cmd
),
380 }/*-------------------------< DISPATCH >-------------------------*/,{
382 * MSG_IN is the only phase that shall be
383 * entered at least once for each (re)selection.
384 * So we test it first.
386 SCR_JUMP
^ IFTRUE (WHEN (SCR_MSG_IN
)),
388 SCR_JUMP
^ IFTRUE (IF (SCR_DATA_OUT
)),
389 PADDR_A (datao_phase
),
390 SCR_JUMP
^ IFTRUE (IF (SCR_DATA_IN
)),
391 PADDR_A (datai_phase
),
392 SCR_JUMP
^ IFTRUE (IF (SCR_STATUS
)),
394 SCR_JUMP
^ IFTRUE (IF (SCR_COMMAND
)),
396 SCR_JUMP
^ IFTRUE (IF (SCR_MSG_OUT
)),
399 * Discard as many illegal phases as
400 * required and tell the C code about.
402 SCR_JUMPR
^ IFFALSE (WHEN (SCR_ILG_OUT
)),
404 SCR_MOVE_ABS (1) ^ SCR_ILG_OUT
,
406 SCR_JUMPR
^ IFTRUE (WHEN (SCR_ILG_OUT
)),
408 SCR_JUMPR
^ IFFALSE (WHEN (SCR_ILG_IN
)),
410 SCR_MOVE_ABS (1) ^ SCR_ILG_IN
,
412 SCR_JUMPR
^ IFTRUE (WHEN (SCR_ILG_IN
)),
418 }/*-------------------------< SEL_NO_CMD >-----------------------*/,{
420 * The target does not switch to command
421 * phase after IDENTIFY has been sent.
423 * If it stays in MSG OUT phase send it
424 * the IDENTIFY again.
426 SCR_JUMP
^ IFTRUE (WHEN (SCR_MSG_OUT
)),
427 PADDR_B (resend_ident
),
429 * If target does not switch to MSG IN phase
430 * and we sent a negotiation, assert the
431 * failure immediately.
433 SCR_JUMP
^ IFTRUE (WHEN (SCR_MSG_IN
)),
435 SCR_FROM_REG (HS_REG
),
437 SCR_INT
^ IFTRUE (DATA (HS_NEGOTIATE
)),
440 * Jump to dispatcher.
444 }/*-------------------------< INIT >-----------------------------*/,{
446 * Wait for the SCSI RESET signal to be
447 * inactive before restarting operations,
448 * since the chip may hang on SEL_ATN
449 * if SCSI RESET is active.
451 SCR_FROM_REG (sstat0
),
453 SCR_JUMPR
^ IFTRUE (MASK (IRST
, IRST
)),
457 }/*-------------------------< CLRACK >---------------------------*/,{
459 * Terminate possible pending message phase.
465 }/*-------------------------< DATAI_DONE >-----------------------*/,{
467 * Save current pointer to LASTP.
471 HADDR_1 (ccb_head
.lastp
),
473 * If the SWIDE is not full, jump to dispatcher.
474 * We anticipate a STATUS phase.
476 SCR_FROM_REG (scntl2
),
478 SCR_JUMP
^ IFTRUE (MASK (WSR
, WSR
)),
479 PADDR_A (datai_done_wsr
),
480 SCR_JUMP
^ IFTRUE (WHEN (SCR_STATUS
)),
484 }/*-------------------------< DATAI_DONE_WSR >-------------------*/,{
487 * Clear this condition.
489 SCR_REG_REG (scntl2
, SCR_OR
, WSR
),
492 * We are expecting an IGNORE RESIDUE message
493 * from the device, otherwise we are in data
494 * overrun condition. Check against MSG_IN phase.
496 SCR_INT
^ IFFALSE (WHEN (SCR_MSG_IN
)),
498 SCR_JUMP
^ IFFALSE (WHEN (SCR_MSG_IN
)),
501 * We are in MSG_IN phase,
502 * Read the first byte of the message.
503 * If it is not an IGNORE RESIDUE message,
504 * signal overrun and jump to message
507 SCR_MOVE_ABS (1) ^ SCR_MSG_IN
,
509 SCR_INT
^ IFFALSE (DATA (M_IGN_RESIDUE
)),
511 SCR_JUMP
^ IFFALSE (DATA (M_IGN_RESIDUE
)),
514 * We got the message we expected.
515 * Read the 2nd byte, and jump to dispatcher.
519 SCR_MOVE_ABS (1) ^ SCR_MSG_IN
,
525 }/*-------------------------< DATAO_DONE >-----------------------*/,{
527 * Save current pointer to LASTP.
531 HADDR_1 (ccb_head
.lastp
),
533 * If the SODL is not full jump to dispatcher.
534 * We anticipate a STATUS phase.
536 SCR_FROM_REG (scntl2
),
538 SCR_JUMP
^ IFTRUE (MASK (WSS
, WSS
)),
539 PADDR_A (datao_done_wss
),
540 SCR_JUMP
^ IFTRUE (WHEN (SCR_STATUS
)),
544 }/*-------------------------< DATAO_DONE_WSS >-------------------*/,{
546 * The SODL is full, clear this condition.
548 SCR_REG_REG (scntl2
, SCR_OR
, WSS
),
551 * And signal a DATA UNDERRUN condition
558 }/*-------------------------< DATAI_PHASE >----------------------*/,{
560 * Jump to current pointer.
563 HADDR_1 (ccb_head
.lastp
),
567 }/*-------------------------< DATAO_PHASE >----------------------*/,{
569 * Jump to current pointer.
572 HADDR_1 (ccb_head
.lastp
),
576 }/*-------------------------< MSG_IN >---------------------------*/,{
578 * Get the first byte of the message.
580 * The script processor doesn't negate the
581 * ACK signal after this transfer.
583 SCR_MOVE_ABS (1) ^ SCR_MSG_IN
,
585 }/*-------------------------< MSG_IN2 >--------------------------*/,{
587 * Check first against 1 byte messages
588 * that we handle from SCRIPTS.
590 SCR_JUMP
^ IFTRUE (DATA (M_COMPLETE
)),
592 SCR_JUMP
^ IFTRUE (DATA (M_DISCONNECT
)),
593 PADDR_A (disconnect
),
594 SCR_JUMP
^ IFTRUE (DATA (M_SAVE_DP
)),
596 SCR_JUMP
^ IFTRUE (DATA (M_RESTORE_DP
)),
597 PADDR_A (restore_dp
),
599 * We handle all other messages from the
600 * C code, so no need to waste on-chip RAM
604 PADDR_B (msg_in_etc
),
605 }/*-------------------------< STATUS >---------------------------*/,{
609 SCR_MOVE_ABS (1) ^ SCR_STATUS
,
611 #ifdef SYM_CONF_IARB_SUPPORT
613 * If STATUS is not GOOD, clear IMMEDIATE ARBITRATION,
614 * since we may have to tamper the start queue from
617 SCR_JUMPR
^ IFTRUE (DATA (S_GOOD
)),
619 SCR_REG_REG (scntl1
, SCR_AND
, ~IARB
),
623 * save status to scsi_status.
628 SCR_LOAD_REG (HS_REG
, HS_COMPLETE
),
631 * Anticipate the MESSAGE PHASE for
632 * the TASK COMPLETE message.
634 SCR_JUMP
^ IFTRUE (WHEN (SCR_MSG_IN
)),
638 }/*-------------------------< COMPLETE >-------------------------*/,{
642 * When we terminate the cycle by clearing ACK,
643 * the target may disconnect immediately.
645 * We don't want to be told of an "unexpected disconnect",
646 * so we disable this feature.
648 SCR_REG_REG (scntl2
, SCR_AND
, 0x7f),
651 * Terminate cycle ...
653 SCR_CLR (SCR_ACK
|SCR_ATN
),
656 * ... and wait for the disconnect.
660 }/*-------------------------< COMPLETE2 >------------------------*/,{
666 HADDR_1 (ccb_head
.status
),
668 * Move back the CCB header using self-modifying
674 SCR_COPY (sizeof(struct sym_ccbh
)),
676 }/*-------------------------< _SMS_A40 >-------------------------*/,{
679 * Some bridges may reorder DMA writes to memory.
680 * We donnot want the CPU to deal with completions
681 * without all the posted write having been flushed
682 * to memory. This DUMMY READ should flush posted
683 * buffers prior to the CPU having to deal with
686 SCR_COPY (4), /* DUMMY READ */
687 HADDR_1 (ccb_head
.status
),
690 * If command resulted in not GOOD status,
691 * call the C code if needed.
693 SCR_FROM_REG (SS_REG
),
695 SCR_CALL
^ IFFALSE (DATA (S_GOOD
)),
696 PADDR_B (bad_status
),
698 * If we performed an auto-sense, call
699 * the C code to synchronyze task aborts
700 * with UNIT ATTENTION conditions.
702 SCR_FROM_REG (HF_REG
),
704 SCR_JUMP
^ IFFALSE (MASK (0 ,(HF_SENSE
|HF_EXT_ERR
))),
705 PADDR_A (complete_error
),
706 }/*-------------------------< DONE >-----------------------------*/,{
708 * Copy the DSA to the DONE QUEUE and
709 * signal completion to the host.
710 * If we are interrupted between DONE
711 * and DONE_END, we must reset, otherwise
712 * the completed CCB may be lost.
719 }/*-------------------------< _SMS_A50 >-------------------------*/,{
725 * The instruction below reads the DONE QUEUE next
726 * free position from memory.
727 * In addition it ensures that all PCI posted writes
728 * are flushed and so the DSA value of the done
729 * CCB is visible by the CPU before INTFLY is raised.
732 }/*-------------------------< _SMS_A60 >-------------------------*/,{
735 }/*-------------------------< DONE_END >-------------------------*/,{
740 }/*-------------------------< COMPLETE_ERROR >-------------------*/,{
746 }/*-------------------------< SAVE_DP >--------------------------*/,{
748 * Clear ACK immediately.
749 * No need to delay it.
754 * Keep track we received a SAVE DP, so
755 * we will switch to the other PM context
756 * on the next PM since the DP may point
757 * to the current PM context.
759 SCR_REG_REG (HF_REG
, SCR_OR
, HF_DP_SAVED
),
763 * Copy LASTP to SAVEP.
766 HADDR_1 (ccb_head
.lastp
),
767 HADDR_1 (ccb_head
.savep
),
769 * Anticipate the MESSAGE PHASE for
770 * the DISCONNECT message.
772 SCR_JUMP
^ IFTRUE (WHEN (SCR_MSG_IN
)),
776 }/*-------------------------< RESTORE_DP >-----------------------*/,{
778 * Clear ACK immediately.
779 * No need to delay it.
784 * Copy SAVEP to LASTP.
787 HADDR_1 (ccb_head
.savep
),
788 HADDR_1 (ccb_head
.lastp
),
791 }/*-------------------------< DISCONNECT >-----------------------*/,{
795 * disable the "unexpected disconnect" feature,
796 * and remove the ACK signal.
798 SCR_REG_REG (scntl2
, SCR_AND
, 0x7f),
800 SCR_CLR (SCR_ACK
|SCR_ATN
),
803 * Wait for the disconnect.
808 * Status is: DISCONNECTED.
810 SCR_LOAD_REG (HS_REG
, HS_DISCONNECT
),
817 HADDR_1 (ccb_head
.status
),
818 }/*-------------------------< DISCONNECT2 >----------------------*/,{
820 * Move back the CCB header using self-modifying
826 SCR_COPY (sizeof(struct sym_ccbh
)),
828 }/*-------------------------< _SMS_A65 >-------------------------*/,{
832 }/*-------------------------< IDLE >-----------------------------*/,{
835 * Switch the LED off and wait for reselect.
836 * Will be patched with a NO_OP if LED
837 * not needed or not desired.
839 SCR_REG_REG (gpreg
, SCR_OR
, 0x01),
841 #ifdef SYM_CONF_IARB_SUPPORT
845 }/*-------------------------< UNGETJOB >-------------------------*/,{
846 #ifdef SYM_CONF_IARB_SUPPORT
848 * Set IMMEDIATE ARBITRATION, for the next time.
849 * This will give us better chance to win arbitration
850 * for the job we just wanted to do.
852 SCR_REG_REG (scntl1
, SCR_OR
, IARB
),
856 * We are not able to restart the SCRIPTS if we are
857 * interrupted and these instruction haven't been
858 * all executed. BTW, this is very unlikely to
859 * happen, but we check that from the C code.
861 SCR_LOAD_REG (dsa
, 0xff),
866 }/*-------------------------< RESELECT >-------------------------*/,{
867 #ifdef SYM_CONF_TARGET_ROLE_SUPPORT
869 * Make sure we are in initiator mode.
875 * Sleep waiting for a reselection.
879 }/*-------------------------< RESELECTED >-----------------------*/,{
882 * Will be patched with a NO_OP if LED
883 * not needed or not desired.
885 SCR_REG_REG (gpreg
, SCR_AND
, 0xfe),
888 * load the target id into the sdid
890 SCR_REG_SFBR (ssid
, SCR_AND
, 0x8F),
895 * Load the target control block address
900 SCR_SFBR_REG (dsa
, SCR_SHL
, 0),
902 SCR_REG_REG (dsa
, SCR_SHL
, 0),
904 SCR_REG_REG (dsa
, SCR_AND
, 0x3c),
910 }/*-------------------------< _SMS_A70 >-------------------------*/,{
914 * Copy the TCB header to a fixed place in
920 SCR_COPY (sizeof(struct sym_tcbh
)),
921 }/*-------------------------< _SMS_A80 >-------------------------*/,{
925 * We expect MESSAGE IN phase.
926 * If not, get help from the C code.
928 SCR_INT
^ IFFALSE (WHEN (SCR_MSG_IN
)),
930 }/*-------------------------< RESELECTED1 >----------------------*/,{
932 * Load the synchronous transfer registers.
935 HADDR_1 (tcb_head
.wval
),
938 HADDR_1 (tcb_head
.sval
),
941 * Get the IDENTIFY message.
943 SCR_MOVE_ABS (1) ^ SCR_MSG_IN
,
946 * If IDENTIFY LUN #0, use a faster path
947 * to find the LCB structure.
949 SCR_JUMP
^ IFTRUE (MASK (0x80, 0xbf)),
950 PADDR_A (resel_lun0
),
952 * If message isn't an IDENTIFY,
953 * tell the C code about.
955 SCR_INT
^ IFFALSE (MASK (0x80, 0x80)),
956 SIR_RESEL_NO_IDENTIFY
,
958 * It is an IDENTIFY message,
959 * Load the LUN control block address.
962 HADDR_1 (tcb_head
.luntbl_sa
),
964 SCR_SFBR_REG (dsa
, SCR_SHL
, 0),
966 SCR_REG_REG (dsa
, SCR_SHL
, 0),
968 SCR_REG_REG (dsa
, SCR_AND
, 0xfc),
974 }/*-------------------------< _SMS_A90 >-------------------------*/,{
979 }/*-------------------------< RESEL_LUN0 >-----------------------*/,{
981 * LUN 0 special case (but usual one :))
984 HADDR_1 (tcb_head
.lun0_sa
),
987 * Jump indirectly to the reselect action for this LUN.
988 * (lcb.head.resel_sa assumed at offset zero of lcb).
994 }/*-------------------------< _SMS_A100 >------------------------*/,{
999 /* In normal situations, we jump to RESEL_TAG or RESEL_NO_TAG */
1000 }/*-------------------------< RESEL_TAG >------------------------*/,{
1002 * ACK the IDENTIFY previously received.
1007 * It shall be a tagged command.
1009 * The C code will deal with errors.
1010 * Aggressive optimization, isn't it? :)
1012 SCR_MOVE_ABS (2) ^ SCR_MSG_IN
,
1015 * Copy the LCB header to a fixed place in
1016 * the HCB using self-modifying SCRIPTS.
1020 PADDR_A (_sms_a110
),
1021 SCR_COPY (sizeof(struct sym_lcbh
)),
1022 }/*-------------------------< _SMS_A110 >------------------------*/,{
1026 * Load the pointer to the tagged task
1027 * table for this LUN.
1030 HADDR_1 (lcb_head
.itlq_tbl_sa
),
1033 * The SIDL still contains the TAG value.
1034 * Aggressive optimization, isn't it? :):)
1036 SCR_REG_SFBR (sidl
, SCR_SHL
, 0),
1038 #if SYM_CONF_MAX_TASK*4 > 512
1039 SCR_JUMPR
^ IFFALSE (CARRYSET
),
1041 SCR_REG_REG (dsa1
, SCR_OR
, 2),
1043 SCR_REG_REG (sfbr
, SCR_SHL
, 0),
1045 SCR_JUMPR
^ IFFALSE (CARRYSET
),
1047 SCR_REG_REG (dsa1
, SCR_OR
, 1),
1049 #elif SYM_CONF_MAX_TASK*4 > 256
1050 SCR_JUMPR
^ IFFALSE (CARRYSET
),
1052 SCR_REG_REG (dsa1
, SCR_OR
, 1),
1056 * Retrieve the DSA of this task.
1057 * JUMP indirectly to the restart point of the CCB.
1059 SCR_SFBR_REG (dsa
, SCR_AND
, 0xfc),
1063 PADDR_A (_sms_a120
),
1065 }/*-------------------------< _SMS_A120 >------------------------*/,{
1068 }/*-------------------------< RESEL_GO >-------------------------*/,{
1071 PADDR_A (_sms_a130
),
1073 * Move 'ccb.phys.head.go' action to
1074 * scratch/scratch1. So scratch1 will
1075 * contain the 'restart' field of the
1079 }/*-------------------------< _SMS_A130 >------------------------*/,{
1083 PADDR_B (scratch1
), /* phys.head.go.restart */
1087 /* In normal situations we branch to RESEL_DSA */
1088 }/*-------------------------< RESEL_DSA >------------------------*/,{
1090 * ACK the IDENTIFY or TAG previously received.
1094 }/*-------------------------< RESEL_DSA1 >-----------------------*/,{
1096 * Copy the CCB header to a fixed location
1097 * in the HCB using self-modifying SCRIPTS.
1101 PADDR_A (_sms_a140
),
1102 SCR_COPY (sizeof(struct sym_ccbh
)),
1103 }/*-------------------------< _SMS_A140 >------------------------*/,{
1107 * Initialize the status register
1110 HADDR_1 (ccb_head
.status
),
1113 * Jump to dispatcher.
1117 }/*-------------------------< RESEL_NO_TAG >---------------------*/,{
1119 * Copy the LCB header to a fixed place in
1120 * the HCB using self-modifying SCRIPTS.
1124 PADDR_A (_sms_a145
),
1125 SCR_COPY (sizeof(struct sym_lcbh
)),
1126 }/*-------------------------< _SMS_A145 >------------------------*/,{
1130 * Load the DSA with the unique ITL task.
1133 HADDR_1 (lcb_head
.itl_task_sa
),
1137 }/*-------------------------< DATA_IN >--------------------------*/,{
1139 * Because the size depends on the
1140 * #define SYM_CONF_MAX_SG parameter,
1141 * it is filled in at runtime.
1143 * ##===========< i=0; i<SYM_CONF_MAX_SG >=========
1144 * || SCR_CHMOV_TBL ^ SCR_DATA_IN,
1145 * || offsetof (struct sym_dsb, data[ i]),
1146 * ##==========================================
1149 }/*-------------------------< DATA_IN2 >-------------------------*/,{
1151 PADDR_A (datai_done
),
1153 PADDR_B (data_ovrun
),
1154 }/*-------------------------< DATA_OUT >-------------------------*/,{
1156 * Because the size depends on the
1157 * #define SYM_CONF_MAX_SG parameter,
1158 * it is filled in at runtime.
1160 * ##===========< i=0; i<SYM_CONF_MAX_SG >=========
1161 * || SCR_CHMOV_TBL ^ SCR_DATA_OUT,
1162 * || offsetof (struct sym_dsb, data[ i]),
1163 * ##==========================================
1166 }/*-------------------------< DATA_OUT2 >------------------------*/,{
1168 PADDR_A (datao_done
),
1170 PADDR_B (data_ovrun
),
1171 }/*-------------------------< PM0_DATA >-------------------------*/,{
1173 * Read our host flags to SFBR, so we will be able
1174 * to check against the data direction we expect.
1176 SCR_FROM_REG (HF_REG
),
1179 * Check against actual DATA PHASE.
1181 SCR_JUMP
^ IFFALSE (WHEN (SCR_DATA_IN
)),
1182 PADDR_A (pm0_data_out
),
1184 * Actual phase is DATA IN.
1185 * Check against expected direction.
1187 SCR_JUMP
^ IFFALSE (MASK (HF_DATA_IN
, HF_DATA_IN
)),
1188 PADDR_B (data_ovrun
),
1190 * Keep track we are moving data from the
1191 * PM0 DATA mini-script.
1193 SCR_REG_REG (HF_REG
, SCR_OR
, HF_IN_PM0
),
1196 * Move the data to memory.
1198 SCR_CHMOV_TBL
^ SCR_DATA_IN
,
1199 offsetof (struct sym_ccb
, phys
.pm0
.sg
),
1201 PADDR_A (pm0_data_end
),
1202 }/*-------------------------< PM0_DATA_OUT >---------------------*/,{
1204 * Actual phase is DATA OUT.
1205 * Check against expected direction.
1207 SCR_JUMP
^ IFTRUE (MASK (HF_DATA_IN
, HF_DATA_IN
)),
1208 PADDR_B (data_ovrun
),
1210 * Keep track we are moving data from the
1211 * PM0 DATA mini-script.
1213 SCR_REG_REG (HF_REG
, SCR_OR
, HF_IN_PM0
),
1216 * Move the data from memory.
1218 SCR_CHMOV_TBL
^ SCR_DATA_OUT
,
1219 offsetof (struct sym_ccb
, phys
.pm0
.sg
),
1220 }/*-------------------------< PM0_DATA_END >---------------------*/,{
1222 * Clear the flag that told we were moving
1223 * data from the PM0 DATA mini-script.
1225 SCR_REG_REG (HF_REG
, SCR_AND
, (~HF_IN_PM0
)),
1228 * Return to the previous DATA script which
1229 * is guaranteed by design (if no bug) to be
1230 * the main DATA script for this transfer.
1235 SCR_REG_REG (scratcha
, SCR_ADD
, offsetof (struct sym_ccb
,phys
.pm0
.ret
)),
1237 }/*-------------------------< PM_DATA_END >----------------------*/,{
1240 PADDR_A (_sms_a150
),
1242 }/*-------------------------< _SMS_A150 >------------------------*/,{
1247 }/*-------------------------< PM1_DATA >-------------------------*/,{
1249 * Read our host flags to SFBR, so we will be able
1250 * to check against the data direction we expect.
1252 SCR_FROM_REG (HF_REG
),
1255 * Check against actual DATA PHASE.
1257 SCR_JUMP
^ IFFALSE (WHEN (SCR_DATA_IN
)),
1258 PADDR_A (pm1_data_out
),
1260 * Actual phase is DATA IN.
1261 * Check against expected direction.
1263 SCR_JUMP
^ IFFALSE (MASK (HF_DATA_IN
, HF_DATA_IN
)),
1264 PADDR_B (data_ovrun
),
1266 * Keep track we are moving data from the
1267 * PM1 DATA mini-script.
1269 SCR_REG_REG (HF_REG
, SCR_OR
, HF_IN_PM1
),
1272 * Move the data to memory.
1274 SCR_CHMOV_TBL
^ SCR_DATA_IN
,
1275 offsetof (struct sym_ccb
, phys
.pm1
.sg
),
1277 PADDR_A (pm1_data_end
),
1278 }/*-------------------------< PM1_DATA_OUT >---------------------*/,{
1280 * Actual phase is DATA OUT.
1281 * Check against expected direction.
1283 SCR_JUMP
^ IFTRUE (MASK (HF_DATA_IN
, HF_DATA_IN
)),
1284 PADDR_B (data_ovrun
),
1286 * Keep track we are moving data from the
1287 * PM1 DATA mini-script.
1289 SCR_REG_REG (HF_REG
, SCR_OR
, HF_IN_PM1
),
1292 * Move the data from memory.
1294 SCR_CHMOV_TBL
^ SCR_DATA_OUT
,
1295 offsetof (struct sym_ccb
, phys
.pm1
.sg
),
1296 }/*-------------------------< PM1_DATA_END >---------------------*/,{
1298 * Clear the flag that told we were moving
1299 * data from the PM1 DATA mini-script.
1301 SCR_REG_REG (HF_REG
, SCR_AND
, (~HF_IN_PM1
)),
1304 * Return to the previous DATA script which
1305 * is guaranteed by design (if no bug) to be
1306 * the main DATA script for this transfer.
1311 SCR_REG_REG (scratcha
, SCR_ADD
, offsetof (struct sym_ccb
,phys
.pm1
.ret
)),
1314 PADDR_A (pm_data_end
),
1315 }/*--------------------------<>----------------------------------*/
1318 static struct SYM_FWB_SCR SYM_FWB_SCR
= {
1319 /*-------------------------< NO_DATA >--------------------------*/ {
1321 PADDR_B (data_ovrun
),
1322 }/*-------------------------< SEL_FOR_ABORT >--------------------*/,{
1324 * We are jumped here by the C code, if we have
1325 * some target to reset or some disconnected
1326 * job to abort. Since error recovery is a serious
1327 * busyness, we will really reset the SCSI BUS, if
1328 * case of a SCSI interrupt occurring in this path.
1331 #ifdef SYM_CONF_TARGET_ROLE_SUPPORT
1333 * Set initiator mode.
1339 * And try to select this target.
1341 SCR_SEL_TBL_ATN
^ offsetof (struct sym_hcb
, abrt_sel
),
1344 * Wait for the selection to complete or
1345 * the selection to time out.
1347 SCR_JUMPR
^ IFFALSE (WHEN (SCR_MSG_OUT
)),
1353 SIR_TARGET_SELECTED
,
1355 * The C code should let us continue here.
1356 * Send the 'kiss of death' message.
1357 * We expect an immediate disconnect once
1358 * the target has eaten the message.
1360 SCR_REG_REG (scntl2
, SCR_AND
, 0x7f),
1362 SCR_MOVE_TBL
^ SCR_MSG_OUT
,
1363 offsetof (struct sym_hcb
, abrt_tbl
),
1364 SCR_CLR (SCR_ACK
|SCR_ATN
),
1369 * Tell the C code that we are done.
1373 }/*-------------------------< SEL_FOR_ABORT_1 >------------------*/,{
1375 * Jump at scheduler.
1379 }/*-------------------------< MSG_IN_ETC >-----------------------*/,{
1381 * If it is an EXTENDED (variable size message)
1384 SCR_JUMP
^ IFTRUE (DATA (M_EXTENDED
)),
1385 PADDR_B (msg_extended
),
1387 * Let the C code handle any other
1390 SCR_JUMP
^ IFTRUE (MASK (0x00, 0xf0)),
1391 PADDR_B (msg_received
),
1392 SCR_JUMP
^ IFTRUE (MASK (0x10, 0xf0)),
1393 PADDR_B (msg_received
),
1395 * We donnot handle 2 bytes messages from SCRIPTS.
1396 * So, let the C code deal with these ones too.
1398 SCR_JUMP
^ IFFALSE (MASK (0x20, 0xf0)),
1399 PADDR_B (msg_weird_seen
),
1402 SCR_MOVE_ABS (1) ^ SCR_MSG_IN
,
1404 }/*-------------------------< MSG_RECEIVED >---------------------*/,{
1405 SCR_COPY (4), /* DUMMY READ */
1410 }/*-------------------------< MSG_WEIRD_SEEN >-------------------*/,{
1411 SCR_COPY (4), /* DUMMY READ */
1416 }/*-------------------------< MSG_EXTENDED >---------------------*/,{
1418 * Clear ACK and get the next byte
1419 * assumed to be the message length.
1423 SCR_MOVE_ABS (1) ^ SCR_MSG_IN
,
1426 * Try to catch some unlikely situations as 0 length
1427 * or too large the length.
1429 SCR_JUMP
^ IFTRUE (DATA (0)),
1430 PADDR_B (msg_weird_seen
),
1431 SCR_TO_REG (scratcha
),
1433 SCR_REG_REG (sfbr
, SCR_ADD
, (256-8)),
1435 SCR_JUMP
^ IFTRUE (CARRYSET
),
1436 PADDR_B (msg_weird_seen
),
1438 * We donnot handle extended messages from SCRIPTS.
1439 * Read the amount of data corresponding to the
1440 * message length and call the C code.
1447 }/*-------------------------< _SMS_B10 >-------------------------*/,{
1448 SCR_MOVE_ABS (0) ^ SCR_MSG_IN
,
1451 PADDR_B (msg_received
),
1452 }/*-------------------------< MSG_BAD >--------------------------*/,{
1454 * unimplemented message - reject it.
1462 }/*-------------------------< MSG_WEIRD >------------------------*/,{
1464 * weird message received
1465 * ignore all MSG IN phases and reject it.
1471 }/*-------------------------< MSG_WEIRD1 >-----------------------*/,{
1474 SCR_JUMP
^ IFFALSE (WHEN (SCR_MSG_IN
)),
1476 SCR_MOVE_ABS (1) ^ SCR_MSG_IN
,
1479 PADDR_B (msg_weird1
),
1480 }/*-------------------------< WDTR_RESP >------------------------*/,{
1482 * let the target fetch our answer.
1488 SCR_JUMP
^ IFFALSE (WHEN (SCR_MSG_OUT
)),
1489 PADDR_B (nego_bad_phase
),
1490 }/*-------------------------< SEND_WDTR >------------------------*/,{
1492 * Send the M_X_WIDE_REQ
1494 SCR_MOVE_ABS (4) ^ SCR_MSG_OUT
,
1497 PADDR_B (msg_out_done
),
1498 }/*-------------------------< SDTR_RESP >------------------------*/,{
1500 * let the target fetch our answer.
1506 SCR_JUMP
^ IFFALSE (WHEN (SCR_MSG_OUT
)),
1507 PADDR_B (nego_bad_phase
),
1508 }/*-------------------------< SEND_SDTR >------------------------*/,{
1510 * Send the M_X_SYNC_REQ
1512 SCR_MOVE_ABS (5) ^ SCR_MSG_OUT
,
1515 PADDR_B (msg_out_done
),
1516 }/*-------------------------< PPR_RESP >-------------------------*/,{
1518 * let the target fetch our answer.
1524 SCR_JUMP
^ IFFALSE (WHEN (SCR_MSG_OUT
)),
1525 PADDR_B (nego_bad_phase
),
1526 }/*-------------------------< SEND_PPR >-------------------------*/,{
1528 * Send the M_X_PPR_REQ
1530 SCR_MOVE_ABS (8) ^ SCR_MSG_OUT
,
1533 PADDR_B (msg_out_done
),
1534 }/*-------------------------< NEGO_BAD_PHASE >-------------------*/,{
1539 }/*-------------------------< MSG_OUT >--------------------------*/,{
1541 * The target requests a message.
1542 * We donnot send messages that may
1543 * require the device to go to bus free.
1545 SCR_MOVE_ABS (1) ^ SCR_MSG_OUT
,
1548 * ... wait for the next phase
1549 * if it's a message out, send it again, ...
1551 SCR_JUMP
^ IFTRUE (WHEN (SCR_MSG_OUT
)),
1553 }/*-------------------------< MSG_OUT_DONE >---------------------*/,{
1555 * Let the C code be aware of the
1556 * sent message and clear the message.
1561 * ... and process the next phase
1565 }/*-------------------------< DATA_OVRUN >-----------------------*/,{
1567 * Zero scratcha that will count the
1573 }/*-------------------------< DATA_OVRUN1 >----------------------*/,{
1575 * The target may want to transfer too much data.
1577 * If phase is DATA OUT write 1 byte and count it.
1579 SCR_JUMPR
^ IFFALSE (WHEN (SCR_DATA_OUT
)),
1581 SCR_CHMOV_ABS (1) ^ SCR_DATA_OUT
,
1584 PADDR_B (data_ovrun2
),
1586 * If WSR is set, clear this condition, and
1589 SCR_FROM_REG (scntl2
),
1591 SCR_JUMPR
^ IFFALSE (MASK (WSR
, WSR
)),
1593 SCR_REG_REG (scntl2
, SCR_OR
, WSR
),
1596 PADDR_B (data_ovrun2
),
1598 * Finally check against DATA IN phase.
1599 * Signal data overrun to the C code
1600 * and jump to dispatcher if not so.
1601 * Read 1 byte otherwise and count it.
1603 SCR_JUMPR
^ IFTRUE (WHEN (SCR_DATA_IN
)),
1609 SCR_CHMOV_ABS (1) ^ SCR_DATA_IN
,
1611 }/*-------------------------< DATA_OVRUN2 >----------------------*/,{
1614 * This will allow to return a negative
1617 SCR_REG_REG (scratcha
, SCR_ADD
, 0x01),
1619 SCR_REG_REG (scratcha1
, SCR_ADDC
, 0),
1621 SCR_REG_REG (scratcha2
, SCR_ADDC
, 0),
1624 * .. and repeat as required.
1627 PADDR_B (data_ovrun1
),
1628 }/*-------------------------< ABORT_RESEL >----------------------*/,{
1634 * send the abort/abortag/reset message
1635 * we expect an immediate disconnect
1637 SCR_REG_REG (scntl2
, SCR_AND
, 0x7f),
1639 SCR_MOVE_ABS (1) ^ SCR_MSG_OUT
,
1641 SCR_CLR (SCR_ACK
|SCR_ATN
),
1649 }/*-------------------------< RESEND_IDENT >---------------------*/,{
1651 * The target stays in MSG OUT phase after having acked
1652 * Identify [+ Tag [+ Extended message ]]. Targets shall
1653 * behave this way on parity error.
1654 * We must send it again all the messages.
1656 SCR_SET (SCR_ATN
), /* Shall be asserted 2 deskew delays before the */
1657 0, /* 1rst ACK = 90 ns. Hope the chip isn't too fast */
1659 PADDR_A (send_ident
),
1660 }/*-------------------------< IDENT_BREAK >----------------------*/,{
1665 }/*-------------------------< IDENT_BREAK_ATN >------------------*/,{
1670 }/*-------------------------< SDATA_IN >-------------------------*/,{
1671 SCR_CHMOV_TBL
^ SCR_DATA_IN
,
1672 offsetof (struct sym_dsb
, sense
),
1674 PADDR_A (datai_done
),
1676 PADDR_B (data_ovrun
),
1677 }/*-------------------------< RESEL_BAD_LUN >--------------------*/,{
1679 * Message is an IDENTIFY, but lun is unknown.
1680 * Signal problem to C code for logging the event.
1681 * Send a M_ABORT to clear all pending tasks.
1686 PADDR_B (abort_resel
),
1687 }/*-------------------------< BAD_I_T_L >------------------------*/,{
1689 * We donnot have a task for that I_T_L.
1690 * Signal problem to C code for logging the event.
1691 * Send a M_ABORT message.
1694 SIR_RESEL_BAD_I_T_L
,
1696 PADDR_B (abort_resel
),
1697 }/*-------------------------< BAD_I_T_L_Q >----------------------*/,{
1699 * We donnot have a task that matches the tag.
1700 * Signal problem to C code for logging the event.
1701 * Send a M_ABORTTAG message.
1704 SIR_RESEL_BAD_I_T_L_Q
,
1706 PADDR_B (abort_resel
),
1707 }/*-------------------------< BAD_STATUS >-----------------------*/,{
1709 * Anything different from INTERMEDIATE
1710 * CONDITION MET should be a bad SCSI status,
1711 * given that GOOD status has already been tested.
1717 SCR_INT
^ IFFALSE (DATA (S_COND_MET
)),
1718 SIR_BAD_SCSI_STATUS
,
1721 }/*-------------------------< WSR_MA_HELPER >--------------------*/,{
1723 * Helper for the C code when WSR bit is set.
1724 * Perform the move of the residual byte.
1726 SCR_CHMOV_TBL
^ SCR_DATA_IN
,
1727 offsetof (struct sym_ccb
, phys
.wresid
),
1731 }/*-------------------------< ZERO >-----------------------------*/,{
1733 }/*-------------------------< SCRATCH >--------------------------*/,{
1734 SCR_DATA_ZERO
, /* MUST BE BEFORE SCRATCH1 */
1735 }/*-------------------------< SCRATCH1 >-------------------------*/,{
1737 }/*-------------------------< PREV_DONE >------------------------*/,{
1738 SCR_DATA_ZERO
, /* MUST BE BEFORE DONE_POS ! */
1739 }/*-------------------------< DONE_POS >-------------------------*/,{
1741 }/*-------------------------< NEXTJOB >--------------------------*/,{
1742 SCR_DATA_ZERO
, /* MUST BE BEFORE STARTPOS ! */
1743 }/*-------------------------< STARTPOS >-------------------------*/,{
1745 }/*-------------------------< TARGTBL >--------------------------*/,{
1747 }/*--------------------------<>----------------------------------*/
1750 static struct SYM_FWZ_SCR SYM_FWZ_SCR
= {
1751 /*-------------------------< SNOOPTEST >------------------------*/{
1753 * Read the variable.
1759 * Write the variable.
1765 * Read back the variable.
1770 }/*-------------------------< SNOOPEND >-------------------------*/,{
1776 }/*--------------------------<>----------------------------------*/