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];
59 #ifdef SYM_CONF_TARGET_ROLE_SUPPORT
64 #if SYM_CONF_DMA_ADDRESSING_MODE == 2
65 u32 is_dmap_dirty
[ 4];
70 #ifdef SYM_CONF_IARB_SUPPORT
81 u32 datai_done_wsr
[ 20];
83 u32 datao_done_wss
[ 6];
88 #ifdef SYM_CONF_IARB_SUPPORT
97 u32 complete_error
[ 4];
100 u32 disconnect
[ 12];
101 #ifdef SYM_CONF_IARB_SUPPORT
106 #ifdef SYM_CONF_IARB_SUPPORT
111 #ifdef SYM_CONF_TARGET_ROLE_SUPPORT
116 u32 reselected
[ 22];
117 u32 resel_scntl4
[ 20];
119 #if SYM_CONF_MAX_TASK*4 > 512
121 #elif SYM_CONF_MAX_TASK*4 > 256
128 u32 resel_no_tag
[ 6];
129 u32 data_in
[SYM_CONF_MAX_SG
* 2];
131 u32 data_out
[SYM_CONF_MAX_SG
* 2];
134 u32 pm0_data_out
[ 6];
135 u32 pm0_data_end
[ 6];
137 u32 pm1_data_out
[ 6];
138 u32 pm1_data_end
[ 6];
142 * Script fragments which stay in main memory for all chips
143 * except for chips that support 8K on-chip RAM.
148 #ifdef SYM_CONF_TARGET_ROLE_SUPPORT
149 u32 sel_for_abort
[ 18];
151 u32 sel_for_abort
[ 16];
153 u32 sel_for_abort_1
[ 2];
154 u32 msg_in_etc
[ 12];
155 u32 msg_received
[ 4];
156 u32 msg_weird_seen
[ 4];
157 u32 msg_extended
[ 20];
168 u32 nego_bad_phase
[ 4];
170 u32 msg_out_done
[ 4];
172 u32 data_ovrun1
[ 22];
173 u32 data_ovrun2
[ 8];
174 u32 abort_resel
[ 16];
175 u32 resend_ident
[ 4];
176 u32 ident_break
[ 4];
177 u32 ident_break_atn
[ 4];
179 u32 resel_bad_lun
[ 4];
181 u32 bad_i_t_l_q
[ 4];
187 u32 pm_save_end
[ 4];
191 u32 pm_wsr_handle
[ 38];
192 u32 wsr_ma_helper
[ 4];
197 u32 pm0_data_addr
[ 1];
198 u32 pm1_data_addr
[ 1];
205 * Script fragments used at initialisations.
206 * Only runs out of main memory.
213 static struct SYM_FWA_SCR SYM_FWA_SCR
= {
214 /*--------------------------< START >----------------------------*/ {
217 * Will be patched with a NO_OP if LED
218 * not needed or not desired.
220 SCR_REG_REG (gpreg
, SCR_AND
, 0xfe),
225 SCR_FROM_REG (ctest2
),
228 * Stop here if the C code wants to perform
229 * some error recovery procedure manually.
230 * (Indicate this by setting SEM in ISTAT)
232 SCR_FROM_REG (istat
),
235 * Report to the C code the next position in
236 * the start queue the SCRIPTS will schedule.
237 * The C code must not change SCRATCHA.
239 SCR_LOAD_ABS (scratcha
, 4),
241 SCR_INT
^ IFTRUE (MASK (SEM
, SEM
)),
244 * Start the next job.
246 * @DSA = start point for this job.
247 * SCRATCHA = address of this job in the start queue.
249 * We will restore startpos with SCRATCHA if we fails the
250 * arbitration or if it is the idle job.
252 * The below GETJOB_BEGIN to GETJOB_END section of SCRIPTS
253 * is a critical path. If it is partially executed, it then
254 * may happen that the job address is not yet in the DSA
255 * and the next queue position points to the next JOB.
257 SCR_LOAD_ABS (dsa
, 4),
259 SCR_LOAD_REL (temp
, 4),
261 }/*-------------------------< GETJOB_BEGIN >---------------------*/,{
262 SCR_STORE_ABS (temp
, 4),
264 SCR_LOAD_REL (dsa
, 4),
266 }/*-------------------------< GETJOB_END >-----------------------*/,{
267 SCR_LOAD_REL (temp
, 4),
271 }/*-------------------------< SELECT >---------------------------*/,{
273 * DSA contains the address of a scheduled
276 * SCRATCHA contains the address of the start queue
277 * entry which points to the next job.
279 * Set Initiator mode.
281 * (Target mode is left as an exercise for the reader)
283 #ifdef SYM_CONF_TARGET_ROLE_SUPPORT
288 * And try to select this target.
290 SCR_SEL_TBL_ATN
^ offsetof (struct sym_dsb
, select
),
293 * Now there are 4 possibilities:
295 * (1) The chip loses arbitration.
296 * This is ok, because it will try again,
297 * when the bus becomes idle.
298 * (But beware of the timeout function!)
300 * (2) The chip is reselected.
301 * Then the script processor takes the jump
302 * to the RESELECT label.
304 * (3) The chip wins arbitration.
305 * Then it will execute SCRIPTS instruction until
306 * the next instruction that checks SCSI phase.
307 * Then will stop and wait for selection to be
308 * complete or selection time-out to occur.
310 * After having won arbitration, the SCRIPTS
311 * processor is able to execute instructions while
312 * the SCSI core is performing SCSI selection.
315 * Initialize the status registers
317 SCR_LOAD_REL (scr0
, 4),
318 offsetof (struct sym_ccb
, phys
.head
.status
),
320 * We may need help from CPU if the DMA segment
321 * registers aren't up-to-date for this IO.
322 * Patched with NOOP for chips that donnot
323 * support DAC addressing.
325 #if SYM_CONF_DMA_ADDRESSING_MODE == 2
326 }/*-------------------------< IS_DMAP_DIRTY >--------------------*/,{
327 SCR_FROM_REG (HX_REG
),
329 SCR_INT
^ IFTRUE (MASK (HX_DMAP_DIRTY
, HX_DMAP_DIRTY
)),
332 }/*-------------------------< WF_SEL_DONE >----------------------*/,{
333 SCR_INT
^ IFFALSE (WHEN (SCR_MSG_OUT
)),
334 SIR_SEL_ATN_NO_MSG_OUT
,
335 }/*-------------------------< SEL_DONE >-------------------------*/,{
337 * C1010-33 errata work-around.
338 * Due to a race, the SCSI core may not have
339 * loaded SCNTL3 on SEL_TBL instruction.
340 * We reload it once phase is stable.
341 * Patched with a NOOP for other chips.
343 SCR_LOAD_REL (scntl3
, 1),
344 offsetof(struct sym_dsb
, select
.sel_scntl3
),
345 }/*-------------------------< SEND_IDENT >-----------------------*/,{
347 * Selection complete.
348 * Send the IDENTIFY and possibly the TAG message
349 * and negotiation message if present.
351 SCR_MOVE_TBL
^ SCR_MSG_OUT
,
352 offsetof (struct sym_dsb
, smsg
),
353 }/*-------------------------< SELECT2 >--------------------------*/,{
354 #ifdef SYM_CONF_IARB_SUPPORT
356 * Set IMMEDIATE ARBITRATION if we have been given
357 * a hint to do so. (Some job to do after this one).
359 SCR_FROM_REG (HF_REG
),
361 SCR_JUMPR
^ IFFALSE (MASK (HF_HINT_IARB
, HF_HINT_IARB
)),
363 SCR_REG_REG (scntl1
, SCR_OR
, IARB
),
367 * Anticipate the COMMAND phase.
368 * This is the PHASE we expect at this point.
370 SCR_JUMP
^ IFFALSE (WHEN (SCR_COMMAND
)),
371 PADDR_A (sel_no_cmd
),
372 }/*-------------------------< COMMAND >--------------------------*/,{
374 * ... and send the command
376 SCR_MOVE_TBL
^ SCR_COMMAND
,
377 offsetof (struct sym_dsb
, cmd
),
378 }/*-------------------------< DISPATCH >-------------------------*/,{
380 * MSG_IN is the only phase that shall be
381 * entered at least once for each (re)selection.
382 * So we test it first.
384 SCR_JUMP
^ IFTRUE (WHEN (SCR_MSG_IN
)),
386 SCR_JUMP
^ IFTRUE (IF (SCR_DATA_OUT
)),
387 PADDR_A (datao_phase
),
388 SCR_JUMP
^ IFTRUE (IF (SCR_DATA_IN
)),
389 PADDR_A (datai_phase
),
390 SCR_JUMP
^ IFTRUE (IF (SCR_STATUS
)),
392 SCR_JUMP
^ IFTRUE (IF (SCR_COMMAND
)),
394 SCR_JUMP
^ IFTRUE (IF (SCR_MSG_OUT
)),
397 * Discard as many illegal phases as
398 * required and tell the C code about.
400 SCR_JUMPR
^ IFFALSE (WHEN (SCR_ILG_OUT
)),
402 SCR_MOVE_ABS (1) ^ SCR_ILG_OUT
,
404 SCR_JUMPR
^ IFTRUE (WHEN (SCR_ILG_OUT
)),
406 SCR_JUMPR
^ IFFALSE (WHEN (SCR_ILG_IN
)),
408 SCR_MOVE_ABS (1) ^ SCR_ILG_IN
,
410 SCR_JUMPR
^ IFTRUE (WHEN (SCR_ILG_IN
)),
416 }/*-------------------------< SEL_NO_CMD >-----------------------*/,{
418 * The target does not switch to command
419 * phase after IDENTIFY has been sent.
421 * If it stays in MSG OUT phase send it
422 * the IDENTIFY again.
424 SCR_JUMP
^ IFTRUE (WHEN (SCR_MSG_OUT
)),
425 PADDR_B (resend_ident
),
427 * If target does not switch to MSG IN phase
428 * and we sent a negotiation, assert the
429 * failure immediately.
431 SCR_JUMP
^ IFTRUE (WHEN (SCR_MSG_IN
)),
433 SCR_FROM_REG (HS_REG
),
435 SCR_INT
^ IFTRUE (DATA (HS_NEGOTIATE
)),
438 * Jump to dispatcher.
442 }/*-------------------------< INIT >-----------------------------*/,{
444 * Wait for the SCSI RESET signal to be
445 * inactive before restarting operations,
446 * since the chip may hang on SEL_ATN
447 * if SCSI RESET is active.
449 SCR_FROM_REG (sstat0
),
451 SCR_JUMPR
^ IFTRUE (MASK (IRST
, IRST
)),
455 }/*-------------------------< CLRACK >---------------------------*/,{
457 * Terminate possible pending message phase.
463 }/*-------------------------< DATAI_DONE >-----------------------*/,{
465 * Save current pointer to LASTP.
467 SCR_STORE_REL (temp
, 4),
468 offsetof (struct sym_ccb
, phys
.head
.lastp
),
470 * If the SWIDE is not full, jump to dispatcher.
471 * We anticipate a STATUS phase.
473 SCR_FROM_REG (scntl2
),
475 SCR_JUMP
^ IFTRUE (MASK (WSR
, WSR
)),
476 PADDR_A (datai_done_wsr
),
477 SCR_JUMP
^ IFTRUE (WHEN (SCR_STATUS
)),
481 }/*-------------------------< DATAI_DONE_WSR >-------------------*/,{
484 * Clear this condition.
486 SCR_REG_REG (scntl2
, SCR_OR
, WSR
),
489 * We are expecting an IGNORE RESIDUE message
490 * from the device, otherwise we are in data
491 * overrun condition. Check against MSG_IN phase.
493 SCR_INT
^ IFFALSE (WHEN (SCR_MSG_IN
)),
495 SCR_JUMP
^ IFFALSE (WHEN (SCR_MSG_IN
)),
498 * We are in MSG_IN phase,
499 * Read the first byte of the message.
500 * If it is not an IGNORE RESIDUE message,
501 * signal overrun and jump to message
504 SCR_MOVE_ABS (1) ^ SCR_MSG_IN
,
506 SCR_INT
^ IFFALSE (DATA (M_IGN_RESIDUE
)),
508 SCR_JUMP
^ IFFALSE (DATA (M_IGN_RESIDUE
)),
511 * We got the message we expected.
512 * Read the 2nd byte, and jump to dispatcher.
516 SCR_MOVE_ABS (1) ^ SCR_MSG_IN
,
522 }/*-------------------------< DATAO_DONE >-----------------------*/,{
524 * Save current pointer to LASTP.
526 SCR_STORE_REL (temp
, 4),
527 offsetof (struct sym_ccb
, phys
.head
.lastp
),
529 * If the SODL is not full jump to dispatcher.
530 * We anticipate a STATUS phase.
532 SCR_FROM_REG (scntl2
),
534 SCR_JUMP
^ IFTRUE (MASK (WSS
, WSS
)),
535 PADDR_A (datao_done_wss
),
536 SCR_JUMP
^ IFTRUE (WHEN (SCR_STATUS
)),
540 }/*-------------------------< DATAO_DONE_WSS >-------------------*/,{
542 * The SODL is full, clear this condition.
544 SCR_REG_REG (scntl2
, SCR_OR
, WSS
),
547 * And signal a DATA UNDERRUN condition
554 }/*-------------------------< DATAI_PHASE >----------------------*/,{
556 * Jump to current pointer.
558 SCR_LOAD_REL (temp
, 4),
559 offsetof (struct sym_ccb
, phys
.head
.lastp
),
562 }/*-------------------------< DATAO_PHASE >----------------------*/,{
564 * C1010-66 errata work-around.
565 * Extra clocks of data hold must be inserted
566 * in DATA OUT phase on 33 MHz PCI BUS.
567 * Patched with a NOOP for other chips.
569 SCR_REG_REG (scntl4
, SCR_OR
, (XCLKH_DT
|XCLKH_ST
)),
572 * Jump to current pointer.
574 SCR_LOAD_REL (temp
, 4),
575 offsetof (struct sym_ccb
, phys
.head
.lastp
),
578 }/*-------------------------< MSG_IN >---------------------------*/,{
580 * Get the first byte of the message.
582 * The script processor doesn't negate the
583 * ACK signal after this transfer.
585 SCR_MOVE_ABS (1) ^ SCR_MSG_IN
,
587 }/*-------------------------< MSG_IN2 >--------------------------*/,{
589 * Check first against 1 byte messages
590 * that we handle from SCRIPTS.
592 SCR_JUMP
^ IFTRUE (DATA (M_COMPLETE
)),
594 SCR_JUMP
^ IFTRUE (DATA (M_DISCONNECT
)),
595 PADDR_A (disconnect
),
596 SCR_JUMP
^ IFTRUE (DATA (M_SAVE_DP
)),
598 SCR_JUMP
^ IFTRUE (DATA (M_RESTORE_DP
)),
599 PADDR_A (restore_dp
),
601 * We handle all other messages from the
602 * C code, so no need to waste on-chip RAM
606 PADDR_B (msg_in_etc
),
607 }/*-------------------------< STATUS >---------------------------*/,{
611 SCR_MOVE_ABS (1) ^ SCR_STATUS
,
613 #ifdef SYM_CONF_IARB_SUPPORT
615 * If STATUS is not GOOD, clear IMMEDIATE ARBITRATION,
616 * since we may have to tamper the start queue from
619 SCR_JUMPR
^ IFTRUE (DATA (S_GOOD
)),
621 SCR_REG_REG (scntl1
, SCR_AND
, ~IARB
),
625 * save status to scsi_status.
630 SCR_LOAD_REG (HS_REG
, HS_COMPLETE
),
633 * Anticipate the MESSAGE PHASE for
634 * the TASK COMPLETE message.
636 SCR_JUMP
^ IFTRUE (WHEN (SCR_MSG_IN
)),
640 }/*-------------------------< COMPLETE >-------------------------*/,{
644 * When we terminate the cycle by clearing ACK,
645 * the target may disconnect immediately.
647 * We don't want to be told of an "unexpected disconnect",
648 * so we disable this feature.
650 SCR_REG_REG (scntl2
, SCR_AND
, 0x7f),
653 * Terminate cycle ...
655 SCR_CLR (SCR_ACK
|SCR_ATN
),
658 * ... and wait for the disconnect.
662 }/*-------------------------< COMPLETE2 >------------------------*/,{
666 SCR_STORE_REL (scr0
, 4),
667 offsetof (struct sym_ccb
, phys
.head
.status
),
669 * Some bridges may reorder DMA writes to memory.
670 * We donnot want the CPU to deal with completions
671 * without all the posted write having been flushed
672 * to memory. This DUMMY READ should flush posted
673 * buffers prior to the CPU having to deal with
676 SCR_LOAD_REL (scr0
, 4), /* DUMMY READ */
677 offsetof (struct sym_ccb
, phys
.head
.status
),
680 * If command resulted in not GOOD status,
681 * call the C code if needed.
683 SCR_FROM_REG (SS_REG
),
685 SCR_CALL
^ IFFALSE (DATA (S_GOOD
)),
686 PADDR_B (bad_status
),
688 * If we performed an auto-sense, call
689 * the C code to synchronyze task aborts
690 * with UNIT ATTENTION conditions.
692 SCR_FROM_REG (HF_REG
),
694 SCR_JUMP
^ IFFALSE (MASK (0 ,(HF_SENSE
|HF_EXT_ERR
))),
695 PADDR_A (complete_error
),
696 }/*-------------------------< DONE >-----------------------------*/,{
698 * Copy the DSA to the DONE QUEUE and
699 * signal completion to the host.
700 * If we are interrupted between DONE
701 * and DONE_END, we must reset, otherwise
702 * the completed CCB may be lost.
704 SCR_STORE_ABS (dsa
, 4),
706 SCR_LOAD_ABS (dsa
, 4),
708 SCR_LOAD_ABS (scratcha
, 4),
710 SCR_STORE_REL (scratcha
, 4),
713 * The instruction below reads the DONE QUEUE next
714 * free position from memory.
715 * In addition it ensures that all PCI posted writes
716 * are flushed and so the DSA value of the done
717 * CCB is visible by the CPU before INTFLY is raised.
719 SCR_LOAD_REL (scratcha
, 4),
723 SCR_STORE_ABS (scratcha
, 4),
725 }/*-------------------------< DONE_END >-------------------------*/,{
728 }/*-------------------------< COMPLETE_ERROR >-------------------*/,{
729 SCR_LOAD_ABS (scratcha
, 4),
733 }/*-------------------------< SAVE_DP >--------------------------*/,{
735 * Clear ACK immediately.
736 * No need to delay it.
741 * Keep track we received a SAVE DP, so
742 * we will switch to the other PM context
743 * on the next PM since the DP may point
744 * to the current PM context.
746 SCR_REG_REG (HF_REG
, SCR_OR
, HF_DP_SAVED
),
750 * Copy LASTP to SAVEP.
752 SCR_LOAD_REL (scratcha
, 4),
753 offsetof (struct sym_ccb
, phys
.head
.lastp
),
754 SCR_STORE_REL (scratcha
, 4),
755 offsetof (struct sym_ccb
, phys
.head
.savep
),
757 * Anticipate the MESSAGE PHASE for
758 * the DISCONNECT message.
760 SCR_JUMP
^ IFTRUE (WHEN (SCR_MSG_IN
)),
764 }/*-------------------------< RESTORE_DP >-----------------------*/,{
766 * Clear ACK immediately.
767 * No need to delay it.
772 * Copy SAVEP to LASTP.
774 SCR_LOAD_REL (scratcha
, 4),
775 offsetof (struct sym_ccb
, phys
.head
.savep
),
776 SCR_STORE_REL (scratcha
, 4),
777 offsetof (struct sym_ccb
, phys
.head
.lastp
),
780 }/*-------------------------< DISCONNECT >-----------------------*/,{
784 * disable the "unexpected disconnect" feature,
785 * and remove the ACK signal.
787 SCR_REG_REG (scntl2
, SCR_AND
, 0x7f),
789 SCR_CLR (SCR_ACK
|SCR_ATN
),
792 * Wait for the disconnect.
797 * Status is: DISCONNECTED.
799 SCR_LOAD_REG (HS_REG
, HS_DISCONNECT
),
804 SCR_STORE_REL (scr0
, 4),
805 offsetof (struct sym_ccb
, phys
.head
.status
),
808 }/*-------------------------< IDLE >-----------------------------*/,{
811 * Switch the LED off and wait for reselect.
812 * Will be patched with a NO_OP if LED
813 * not needed or not desired.
815 SCR_REG_REG (gpreg
, SCR_OR
, 0x01),
817 #ifdef SYM_CONF_IARB_SUPPORT
821 }/*-------------------------< UNGETJOB >-------------------------*/,{
822 #ifdef SYM_CONF_IARB_SUPPORT
824 * Set IMMEDIATE ARBITRATION, for the next time.
825 * This will give us better chance to win arbitration
826 * for the job we just wanted to do.
828 SCR_REG_REG (scntl1
, SCR_OR
, IARB
),
832 * We are not able to restart the SCRIPTS if we are
833 * interrupted and these instruction haven't been
834 * all executed. BTW, this is very unlikely to
835 * happen, but we check that from the C code.
837 SCR_LOAD_REG (dsa
, 0xff),
839 SCR_STORE_ABS (scratcha
, 4),
841 }/*-------------------------< RESELECT >-------------------------*/,{
842 #ifdef SYM_CONF_TARGET_ROLE_SUPPORT
844 * Make sure we are in initiator mode.
850 * Sleep waiting for a reselection.
854 }/*-------------------------< RESELECTED >-----------------------*/,{
857 * Will be patched with a NO_OP if LED
858 * not needed or not desired.
860 SCR_REG_REG (gpreg
, SCR_AND
, 0xfe),
863 * load the target id into the sdid
865 SCR_REG_SFBR (ssid
, SCR_AND
, 0x8F),
870 * Load the target control block address
872 SCR_LOAD_ABS (dsa
, 4),
874 SCR_SFBR_REG (dsa
, SCR_SHL
, 0),
876 SCR_REG_REG (dsa
, SCR_SHL
, 0),
878 SCR_REG_REG (dsa
, SCR_AND
, 0x3c),
880 SCR_LOAD_REL (dsa
, 4),
883 * We expect MESSAGE IN phase.
884 * If not, get help from the C code.
886 SCR_INT
^ IFFALSE (WHEN (SCR_MSG_IN
)),
889 * Load the legacy synchronous transfer registers.
891 SCR_LOAD_REL (scntl3
, 1),
892 offsetof(struct sym_tcb
, head
.wval
),
893 SCR_LOAD_REL (sxfer
, 1),
894 offsetof(struct sym_tcb
, head
.sval
),
895 }/*-------------------------< RESEL_SCNTL4 >---------------------*/,{
897 * The C1010 uses a new synchronous timing scheme.
898 * Will be patched with a NO_OP if not a C1010.
900 SCR_LOAD_REL (scntl4
, 1),
901 offsetof(struct sym_tcb
, head
.uval
),
903 * Get the IDENTIFY message.
905 SCR_MOVE_ABS (1) ^ SCR_MSG_IN
,
908 * If IDENTIFY LUN #0, use a faster path
909 * to find the LCB structure.
911 SCR_JUMP
^ IFTRUE (MASK (0x80, 0xbf)),
912 PADDR_A (resel_lun0
),
914 * If message isn't an IDENTIFY,
915 * tell the C code about.
917 SCR_INT
^ IFFALSE (MASK (0x80, 0x80)),
918 SIR_RESEL_NO_IDENTIFY
,
920 * It is an IDENTIFY message,
921 * Load the LUN control block address.
923 SCR_LOAD_REL (dsa
, 4),
924 offsetof(struct sym_tcb
, head
.luntbl_sa
),
925 SCR_SFBR_REG (dsa
, SCR_SHL
, 0),
927 SCR_REG_REG (dsa
, SCR_SHL
, 0),
929 SCR_REG_REG (dsa
, SCR_AND
, 0xfc),
931 SCR_LOAD_REL (dsa
, 4),
935 }/*-------------------------< RESEL_LUN0 >-----------------------*/,{
937 * LUN 0 special case (but usual one :))
939 SCR_LOAD_REL (dsa
, 4),
940 offsetof(struct sym_tcb
, head
.lun0_sa
),
942 * Jump indirectly to the reselect action for this LUN.
944 SCR_LOAD_REL (temp
, 4),
945 offsetof(struct sym_lcb
, head
.resel_sa
),
948 /* In normal situations, we jump to RESEL_TAG or RESEL_NO_TAG */
949 }/*-------------------------< RESEL_TAG >------------------------*/,{
951 * ACK the IDENTIFY previously received.
956 * It shall be a tagged command.
958 * The C code will deal with errors.
959 * Aggressive optimization, isn't it? :)
961 SCR_MOVE_ABS (2) ^ SCR_MSG_IN
,
964 * Load the pointer to the tagged task
965 * table for this LUN.
967 SCR_LOAD_REL (dsa
, 4),
968 offsetof(struct sym_lcb
, head
.itlq_tbl_sa
),
970 * The SIDL still contains the TAG value.
971 * Aggressive optimization, isn't it? :):)
973 SCR_REG_SFBR (sidl
, SCR_SHL
, 0),
975 #if SYM_CONF_MAX_TASK*4 > 512
976 SCR_JUMPR
^ IFFALSE (CARRYSET
),
978 SCR_REG_REG (dsa1
, SCR_OR
, 2),
980 SCR_REG_REG (sfbr
, SCR_SHL
, 0),
982 SCR_JUMPR
^ IFFALSE (CARRYSET
),
984 SCR_REG_REG (dsa1
, SCR_OR
, 1),
986 #elif SYM_CONF_MAX_TASK*4 > 256
987 SCR_JUMPR
^ IFFALSE (CARRYSET
),
989 SCR_REG_REG (dsa1
, SCR_OR
, 1),
993 * Retrieve the DSA of this task.
994 * JUMP indirectly to the restart point of the CCB.
996 SCR_SFBR_REG (dsa
, SCR_AND
, 0xfc),
998 SCR_LOAD_REL (dsa
, 4),
1000 SCR_LOAD_REL (temp
, 4),
1001 offsetof(struct sym_ccb
, phys
.head
.go
.restart
),
1004 /* In normal situations we branch to RESEL_DSA */
1005 }/*-------------------------< RESEL_DSA >------------------------*/,{
1007 * ACK the IDENTIFY or TAG previously received.
1011 }/*-------------------------< RESEL_DSA1 >-----------------------*/,{
1013 * Initialize the status registers
1015 SCR_LOAD_REL (scr0
, 4),
1016 offsetof (struct sym_ccb
, phys
.head
.status
),
1018 * Jump to dispatcher.
1022 }/*-------------------------< RESEL_NO_TAG >---------------------*/,{
1024 * Load the DSA with the unique ITL task.
1026 SCR_LOAD_REL (dsa
, 4),
1027 offsetof(struct sym_lcb
, head
.itl_task_sa
),
1029 * JUMP indirectly to the restart point of the CCB.
1031 SCR_LOAD_REL (temp
, 4),
1032 offsetof(struct sym_ccb
, phys
.head
.go
.restart
),
1035 /* In normal situations we branch to RESEL_DSA */
1036 }/*-------------------------< DATA_IN >--------------------------*/,{
1038 * Because the size depends on the
1039 * #define SYM_CONF_MAX_SG parameter,
1040 * it is filled in at runtime.
1042 * ##===========< i=0; i<SYM_CONF_MAX_SG >=========
1043 * || SCR_CHMOV_TBL ^ SCR_DATA_IN,
1044 * || offsetof (struct sym_dsb, data[ i]),
1045 * ##==========================================
1048 }/*-------------------------< DATA_IN2 >-------------------------*/,{
1050 PADDR_A (datai_done
),
1052 PADDR_B (data_ovrun
),
1053 }/*-------------------------< DATA_OUT >-------------------------*/,{
1055 * Because the size depends on the
1056 * #define SYM_CONF_MAX_SG parameter,
1057 * it is filled in at runtime.
1059 * ##===========< i=0; i<SYM_CONF_MAX_SG >=========
1060 * || SCR_CHMOV_TBL ^ SCR_DATA_OUT,
1061 * || offsetof (struct sym_dsb, data[ i]),
1062 * ##==========================================
1065 }/*-------------------------< DATA_OUT2 >------------------------*/,{
1067 PADDR_A (datao_done
),
1069 PADDR_B (data_ovrun
),
1070 }/*-------------------------< PM0_DATA >-------------------------*/,{
1072 * Read our host flags to SFBR, so we will be able
1073 * to check against the data direction we expect.
1075 SCR_FROM_REG (HF_REG
),
1078 * Check against actual DATA PHASE.
1080 SCR_JUMP
^ IFFALSE (WHEN (SCR_DATA_IN
)),
1081 PADDR_A (pm0_data_out
),
1083 * Actual phase is DATA IN.
1084 * Check against expected direction.
1086 SCR_JUMP
^ IFFALSE (MASK (HF_DATA_IN
, HF_DATA_IN
)),
1087 PADDR_B (data_ovrun
),
1089 * Keep track we are moving data from the
1090 * PM0 DATA mini-script.
1092 SCR_REG_REG (HF_REG
, SCR_OR
, HF_IN_PM0
),
1095 * Move the data to memory.
1097 SCR_CHMOV_TBL
^ SCR_DATA_IN
,
1098 offsetof (struct sym_ccb
, phys
.pm0
.sg
),
1100 PADDR_A (pm0_data_end
),
1101 }/*-------------------------< PM0_DATA_OUT >---------------------*/,{
1103 * Actual phase is DATA OUT.
1104 * Check against expected direction.
1106 SCR_JUMP
^ IFTRUE (MASK (HF_DATA_IN
, HF_DATA_IN
)),
1107 PADDR_B (data_ovrun
),
1109 * Keep track we are moving data from the
1110 * PM0 DATA mini-script.
1112 SCR_REG_REG (HF_REG
, SCR_OR
, HF_IN_PM0
),
1115 * Move the data from memory.
1117 SCR_CHMOV_TBL
^ SCR_DATA_OUT
,
1118 offsetof (struct sym_ccb
, phys
.pm0
.sg
),
1119 }/*-------------------------< PM0_DATA_END >---------------------*/,{
1121 * Clear the flag that told we were moving
1122 * data from the PM0 DATA mini-script.
1124 SCR_REG_REG (HF_REG
, SCR_AND
, (~HF_IN_PM0
)),
1127 * Return to the previous DATA script which
1128 * is guaranteed by design (if no bug) to be
1129 * the main DATA script for this transfer.
1131 SCR_LOAD_REL (temp
, 4),
1132 offsetof (struct sym_ccb
, phys
.pm0
.ret
),
1135 }/*-------------------------< PM1_DATA >-------------------------*/,{
1137 * Read our host flags to SFBR, so we will be able
1138 * to check against the data direction we expect.
1140 SCR_FROM_REG (HF_REG
),
1143 * Check against actual DATA PHASE.
1145 SCR_JUMP
^ IFFALSE (WHEN (SCR_DATA_IN
)),
1146 PADDR_A (pm1_data_out
),
1148 * Actual phase is DATA IN.
1149 * Check against expected direction.
1151 SCR_JUMP
^ IFFALSE (MASK (HF_DATA_IN
, HF_DATA_IN
)),
1152 PADDR_B (data_ovrun
),
1154 * Keep track we are moving data from the
1155 * PM1 DATA mini-script.
1157 SCR_REG_REG (HF_REG
, SCR_OR
, HF_IN_PM1
),
1160 * Move the data to memory.
1162 SCR_CHMOV_TBL
^ SCR_DATA_IN
,
1163 offsetof (struct sym_ccb
, phys
.pm1
.sg
),
1165 PADDR_A (pm1_data_end
),
1166 }/*-------------------------< PM1_DATA_OUT >---------------------*/,{
1168 * Actual phase is DATA OUT.
1169 * Check against expected direction.
1171 SCR_JUMP
^ IFTRUE (MASK (HF_DATA_IN
, HF_DATA_IN
)),
1172 PADDR_B (data_ovrun
),
1174 * Keep track we are moving data from the
1175 * PM1 DATA mini-script.
1177 SCR_REG_REG (HF_REG
, SCR_OR
, HF_IN_PM1
),
1180 * Move the data from memory.
1182 SCR_CHMOV_TBL
^ SCR_DATA_OUT
,
1183 offsetof (struct sym_ccb
, phys
.pm1
.sg
),
1184 }/*-------------------------< PM1_DATA_END >---------------------*/,{
1186 * Clear the flag that told we were moving
1187 * data from the PM1 DATA mini-script.
1189 SCR_REG_REG (HF_REG
, SCR_AND
, (~HF_IN_PM1
)),
1192 * Return to the previous DATA script which
1193 * is guaranteed by design (if no bug) to be
1194 * the main DATA script for this transfer.
1196 SCR_LOAD_REL (temp
, 4),
1197 offsetof (struct sym_ccb
, phys
.pm1
.ret
),
1200 }/*-------------------------<>-----------------------------------*/
1203 static struct SYM_FWB_SCR SYM_FWB_SCR
= {
1204 /*--------------------------< START64 >--------------------------*/ {
1206 * SCRIPT entry point for the 895A, 896 and 1010.
1207 * For now, there is no specific stuff for those
1208 * chips at this point, but this may come.
1212 }/*-------------------------< NO_DATA >--------------------------*/,{
1214 PADDR_B (data_ovrun
),
1215 }/*-------------------------< SEL_FOR_ABORT >--------------------*/,{
1217 * We are jumped here by the C code, if we have
1218 * some target to reset or some disconnected
1219 * job to abort. Since error recovery is a serious
1220 * busyness, we will really reset the SCSI BUS, if
1221 * case of a SCSI interrupt occurring in this path.
1223 #ifdef SYM_CONF_TARGET_ROLE_SUPPORT
1225 * Set initiator mode.
1231 * And try to select this target.
1233 SCR_SEL_TBL_ATN
^ offsetof (struct sym_hcb
, abrt_sel
),
1236 * Wait for the selection to complete or
1237 * the selection to time out.
1239 SCR_JUMPR
^ IFFALSE (WHEN (SCR_MSG_OUT
)),
1245 SIR_TARGET_SELECTED
,
1247 * The C code should let us continue here.
1248 * Send the 'kiss of death' message.
1249 * We expect an immediate disconnect once
1250 * the target has eaten the message.
1252 SCR_REG_REG (scntl2
, SCR_AND
, 0x7f),
1254 SCR_MOVE_TBL
^ SCR_MSG_OUT
,
1255 offsetof (struct sym_hcb
, abrt_tbl
),
1256 SCR_CLR (SCR_ACK
|SCR_ATN
),
1261 * Tell the C code that we are done.
1265 }/*-------------------------< SEL_FOR_ABORT_1 >------------------*/,{
1267 * Jump at scheduler.
1271 }/*-------------------------< MSG_IN_ETC >-----------------------*/,{
1273 * If it is an EXTENDED (variable size message)
1276 SCR_JUMP
^ IFTRUE (DATA (M_EXTENDED
)),
1277 PADDR_B (msg_extended
),
1279 * Let the C code handle any other
1282 SCR_JUMP
^ IFTRUE (MASK (0x00, 0xf0)),
1283 PADDR_B (msg_received
),
1284 SCR_JUMP
^ IFTRUE (MASK (0x10, 0xf0)),
1285 PADDR_B (msg_received
),
1287 * We donnot handle 2 bytes messages from SCRIPTS.
1288 * So, let the C code deal with these ones too.
1290 SCR_JUMP
^ IFFALSE (MASK (0x20, 0xf0)),
1291 PADDR_B (msg_weird_seen
),
1294 SCR_MOVE_ABS (1) ^ SCR_MSG_IN
,
1296 }/*-------------------------< MSG_RECEIVED >---------------------*/,{
1297 SCR_LOAD_REL (scratcha
, 4), /* DUMMY READ */
1301 }/*-------------------------< MSG_WEIRD_SEEN >-------------------*/,{
1302 SCR_LOAD_REL (scratcha
, 4), /* DUMMY READ */
1306 }/*-------------------------< MSG_EXTENDED >---------------------*/,{
1308 * Clear ACK and get the next byte
1309 * assumed to be the message length.
1313 SCR_MOVE_ABS (1) ^ SCR_MSG_IN
,
1316 * Try to catch some unlikely situations as 0 length
1317 * or too large the length.
1319 SCR_JUMP
^ IFTRUE (DATA (0)),
1320 PADDR_B (msg_weird_seen
),
1321 SCR_TO_REG (scratcha
),
1323 SCR_REG_REG (sfbr
, SCR_ADD
, (256-8)),
1325 SCR_JUMP
^ IFTRUE (CARRYSET
),
1326 PADDR_B (msg_weird_seen
),
1328 * We donnot handle extended messages from SCRIPTS.
1329 * Read the amount of data corresponding to the
1330 * message length and call the C code.
1332 SCR_STORE_REL (scratcha
, 1),
1333 offsetof (struct sym_dsb
, smsg_ext
.size
),
1336 SCR_MOVE_TBL
^ SCR_MSG_IN
,
1337 offsetof (struct sym_dsb
, smsg_ext
),
1339 PADDR_B (msg_received
),
1340 }/*-------------------------< MSG_BAD >--------------------------*/,{
1342 * unimplemented message - reject it.
1350 }/*-------------------------< MSG_WEIRD >------------------------*/,{
1352 * weird message received
1353 * ignore all MSG IN phases and reject it.
1359 }/*-------------------------< MSG_WEIRD1 >-----------------------*/,{
1362 SCR_JUMP
^ IFFALSE (WHEN (SCR_MSG_IN
)),
1364 SCR_MOVE_ABS (1) ^ SCR_MSG_IN
,
1367 PADDR_B (msg_weird1
),
1368 }/*-------------------------< WDTR_RESP >------------------------*/,{
1370 * let the target fetch our answer.
1376 SCR_JUMP
^ IFFALSE (WHEN (SCR_MSG_OUT
)),
1377 PADDR_B (nego_bad_phase
),
1378 }/*-------------------------< SEND_WDTR >------------------------*/,{
1380 * Send the M_X_WIDE_REQ
1382 SCR_MOVE_ABS (4) ^ SCR_MSG_OUT
,
1385 PADDR_B (msg_out_done
),
1386 }/*-------------------------< SDTR_RESP >------------------------*/,{
1388 * let the target fetch our answer.
1394 SCR_JUMP
^ IFFALSE (WHEN (SCR_MSG_OUT
)),
1395 PADDR_B (nego_bad_phase
),
1396 }/*-------------------------< SEND_SDTR >------------------------*/,{
1398 * Send the M_X_SYNC_REQ
1400 SCR_MOVE_ABS (5) ^ SCR_MSG_OUT
,
1403 PADDR_B (msg_out_done
),
1404 }/*-------------------------< PPR_RESP >-------------------------*/,{
1406 * let the target fetch our answer.
1412 SCR_JUMP
^ IFFALSE (WHEN (SCR_MSG_OUT
)),
1413 PADDR_B (nego_bad_phase
),
1414 }/*-------------------------< SEND_PPR >-------------------------*/,{
1416 * Send the M_X_PPR_REQ
1418 SCR_MOVE_ABS (8) ^ SCR_MSG_OUT
,
1421 PADDR_B (msg_out_done
),
1422 }/*-------------------------< NEGO_BAD_PHASE >-------------------*/,{
1427 }/*-------------------------< MSG_OUT >--------------------------*/,{
1429 * The target requests a message.
1430 * We donnot send messages that may
1431 * require the device to go to bus free.
1433 SCR_MOVE_ABS (1) ^ SCR_MSG_OUT
,
1436 * ... wait for the next phase
1437 * if it's a message out, send it again, ...
1439 SCR_JUMP
^ IFTRUE (WHEN (SCR_MSG_OUT
)),
1441 }/*-------------------------< MSG_OUT_DONE >---------------------*/,{
1443 * Let the C code be aware of the
1444 * sent message and clear the message.
1449 * ... and process the next phase
1453 }/*-------------------------< DATA_OVRUN >-----------------------*/,{
1455 * Use scratcha to count the extra bytes.
1457 SCR_LOAD_ABS (scratcha
, 4),
1459 }/*-------------------------< DATA_OVRUN1 >----------------------*/,{
1461 * The target may want to transfer too much data.
1463 * If phase is DATA OUT write 1 byte and count it.
1465 SCR_JUMPR
^ IFFALSE (WHEN (SCR_DATA_OUT
)),
1467 SCR_CHMOV_ABS (1) ^ SCR_DATA_OUT
,
1470 PADDR_B (data_ovrun2
),
1472 * If WSR is set, clear this condition, and
1475 SCR_FROM_REG (scntl2
),
1477 SCR_JUMPR
^ IFFALSE (MASK (WSR
, WSR
)),
1479 SCR_REG_REG (scntl2
, SCR_OR
, WSR
),
1482 PADDR_B (data_ovrun2
),
1484 * Finally check against DATA IN phase.
1485 * Signal data overrun to the C code
1486 * and jump to dispatcher if not so.
1487 * Read 1 byte otherwise and count it.
1489 SCR_JUMPR
^ IFTRUE (WHEN (SCR_DATA_IN
)),
1495 SCR_CHMOV_ABS (1) ^ SCR_DATA_IN
,
1497 }/*-------------------------< DATA_OVRUN2 >----------------------*/,{
1500 * This will allow to return a negative
1503 SCR_REG_REG (scratcha
, SCR_ADD
, 0x01),
1505 SCR_REG_REG (scratcha1
, SCR_ADDC
, 0),
1507 SCR_REG_REG (scratcha2
, SCR_ADDC
, 0),
1510 * .. and repeat as required.
1513 PADDR_B (data_ovrun1
),
1514 }/*-------------------------< ABORT_RESEL >----------------------*/,{
1520 * send the abort/abortag/reset message
1521 * we expect an immediate disconnect
1523 SCR_REG_REG (scntl2
, SCR_AND
, 0x7f),
1525 SCR_MOVE_ABS (1) ^ SCR_MSG_OUT
,
1527 SCR_CLR (SCR_ACK
|SCR_ATN
),
1535 }/*-------------------------< RESEND_IDENT >---------------------*/,{
1537 * The target stays in MSG OUT phase after having acked
1538 * Identify [+ Tag [+ Extended message ]]. Targets shall
1539 * behave this way on parity error.
1540 * We must send it again all the messages.
1542 SCR_SET (SCR_ATN
), /* Shall be asserted 2 deskew delays before the */
1543 0, /* 1rst ACK = 90 ns. Hope the chip isn't too fast */
1545 PADDR_A (send_ident
),
1546 }/*-------------------------< IDENT_BREAK >----------------------*/,{
1551 }/*-------------------------< IDENT_BREAK_ATN >------------------*/,{
1556 }/*-------------------------< SDATA_IN >-------------------------*/,{
1557 SCR_CHMOV_TBL
^ SCR_DATA_IN
,
1558 offsetof (struct sym_dsb
, sense
),
1560 PADDR_A (datai_done
),
1562 PADDR_B (data_ovrun
),
1563 }/*-------------------------< RESEL_BAD_LUN >--------------------*/,{
1565 * Message is an IDENTIFY, but lun is unknown.
1566 * Signal problem to C code for logging the event.
1567 * Send a M_ABORT to clear all pending tasks.
1572 PADDR_B (abort_resel
),
1573 }/*-------------------------< BAD_I_T_L >------------------------*/,{
1575 * We donnot have a task for that I_T_L.
1576 * Signal problem to C code for logging the event.
1577 * Send a M_ABORT message.
1580 SIR_RESEL_BAD_I_T_L
,
1582 PADDR_B (abort_resel
),
1583 }/*-------------------------< BAD_I_T_L_Q >----------------------*/,{
1585 * We donnot have a task that matches the tag.
1586 * Signal problem to C code for logging the event.
1587 * Send a M_ABORTTAG message.
1590 SIR_RESEL_BAD_I_T_L_Q
,
1592 PADDR_B (abort_resel
),
1593 }/*-------------------------< BAD_STATUS >-----------------------*/,{
1595 * Anything different from INTERMEDIATE
1596 * CONDITION MET should be a bad SCSI status,
1597 * given that GOOD status has already been tested.
1600 SCR_LOAD_ABS (scratcha
, 4),
1602 SCR_INT
^ IFFALSE (DATA (S_COND_MET
)),
1603 SIR_BAD_SCSI_STATUS
,
1606 }/*-------------------------< PM_HANDLE >------------------------*/,{
1608 * Phase mismatch handling.
1610 * Since we have to deal with 2 SCSI data pointers
1611 * (current and saved), we need at least 2 contexts.
1612 * Each context (pm0 and pm1) has a saved area, a
1613 * SAVE mini-script and a DATA phase mini-script.
1616 * Get the PM handling flags.
1618 SCR_FROM_REG (HF_REG
),
1621 * If no flags (1rst PM for example), avoid
1622 * all the below heavy flags testing.
1623 * This makes the normal case a bit faster.
1625 SCR_JUMP
^ IFTRUE (MASK (0, (HF_IN_PM0
| HF_IN_PM1
| HF_DP_SAVED
))),
1626 PADDR_B (pm_handle1
),
1628 * If we received a SAVE DP, switch to the
1629 * other PM context since the savep may point
1630 * to the current PM context.
1632 SCR_JUMPR
^ IFFALSE (MASK (HF_DP_SAVED
, HF_DP_SAVED
)),
1634 SCR_REG_REG (sfbr
, SCR_XOR
, HF_ACT_PM
),
1637 * If we have been interrupt in a PM DATA mini-script,
1638 * we take the return address from the corresponding
1640 * This ensure the return address always points to the
1641 * main DATA script for this transfer.
1643 SCR_JUMP
^ IFTRUE (MASK (0, (HF_IN_PM0
| HF_IN_PM1
))),
1644 PADDR_B (pm_handle1
),
1645 SCR_JUMPR
^ IFFALSE (MASK (HF_IN_PM0
, HF_IN_PM0
)),
1647 SCR_LOAD_REL (ia
, 4),
1648 offsetof(struct sym_ccb
, phys
.pm0
.ret
),
1651 SCR_LOAD_REL (ia
, 4),
1652 offsetof(struct sym_ccb
, phys
.pm1
.ret
),
1655 }/*-------------------------< PM_HANDLE1 >-----------------------*/,{
1658 * Update the return address so that it
1659 * will point after the interrupted MOVE.
1661 SCR_REG_REG (ia
, SCR_ADD
, 8),
1663 SCR_REG_REG (ia1
, SCR_ADDC
, 0),
1665 }/*-------------------------< PM_SAVE >--------------------------*/,{
1667 * Clear all the flags that told us if we were
1668 * interrupted in a PM DATA mini-script and/or
1669 * we received a SAVE DP.
1671 SCR_SFBR_REG (HF_REG
, SCR_AND
, (~(HF_IN_PM0
|HF_IN_PM1
|HF_DP_SAVED
))),
1674 * Choose the current PM context.
1676 SCR_JUMP
^ IFTRUE (MASK (HF_ACT_PM
, HF_ACT_PM
)),
1678 }/*-------------------------< PM0_SAVE >-------------------------*/,{
1679 SCR_STORE_REL (ia
, 4),
1680 offsetof(struct sym_ccb
, phys
.pm0
.ret
),
1682 * If WSR bit is set, either UA and RBC may
1683 * have to be changed whether the device wants
1684 * to ignore this residue or not.
1686 SCR_FROM_REG (scntl2
),
1688 SCR_CALL
^ IFTRUE (MASK (WSR
, WSR
)),
1689 PADDR_B (pm_wsr_handle
),
1691 * Save the remaining byte count, the updated
1692 * address and the return address.
1694 SCR_STORE_REL (rbc
, 4),
1695 offsetof(struct sym_ccb
, phys
.pm0
.sg
.size
),
1696 SCR_STORE_REL (ua
, 4),
1697 offsetof(struct sym_ccb
, phys
.pm0
.sg
.addr
),
1699 * Set the current pointer at the PM0 DATA mini-script.
1701 SCR_LOAD_ABS (ia
, 4),
1702 PADDR_B (pm0_data_addr
),
1703 }/*-------------------------< PM_SAVE_END >----------------------*/,{
1704 SCR_STORE_REL (ia
, 4),
1705 offsetof(struct sym_ccb
, phys
.head
.lastp
),
1708 }/*-------------------------< PM1_SAVE >-------------------------*/,{
1709 SCR_STORE_REL (ia
, 4),
1710 offsetof(struct sym_ccb
, phys
.pm1
.ret
),
1712 * If WSR bit is set, either UA and RBC may
1713 * have to be changed whether the device wants
1714 * to ignore this residue or not.
1716 SCR_FROM_REG (scntl2
),
1718 SCR_CALL
^ IFTRUE (MASK (WSR
, WSR
)),
1719 PADDR_B (pm_wsr_handle
),
1721 * Save the remaining byte count, the updated
1722 * address and the return address.
1724 SCR_STORE_REL (rbc
, 4),
1725 offsetof(struct sym_ccb
, phys
.pm1
.sg
.size
),
1726 SCR_STORE_REL (ua
, 4),
1727 offsetof(struct sym_ccb
, phys
.pm1
.sg
.addr
),
1729 * Set the current pointer at the PM1 DATA mini-script.
1731 SCR_LOAD_ABS (ia
, 4),
1732 PADDR_B (pm1_data_addr
),
1734 PADDR_B (pm_save_end
),
1735 }/*-------------------------< PM_WSR_HANDLE >--------------------*/,{
1737 * Phase mismatch handling from SCRIPT with WSR set.
1738 * Such a condition can occur if the chip wants to
1739 * execute a CHMOV(size > 1) when the WSR bit is
1740 * set and the target changes PHASE.
1742 * We must move the residual byte to memory.
1744 * UA contains bit 0..31 of the address to
1745 * move the residual byte.
1746 * Move it to the table indirect.
1748 SCR_STORE_REL (ua
, 4),
1749 offsetof (struct sym_ccb
, phys
.wresid
.addr
),
1751 * Increment UA (move address to next position).
1753 SCR_REG_REG (ua
, SCR_ADD
, 1),
1755 SCR_REG_REG (ua1
, SCR_ADDC
, 0),
1757 SCR_REG_REG (ua2
, SCR_ADDC
, 0),
1759 SCR_REG_REG (ua3
, SCR_ADDC
, 0),
1762 * Compute SCRATCHA as:
1763 * - size to transfer = 1 byte.
1764 * - bit 24..31 = high address bit [32...39].
1766 SCR_LOAD_ABS (scratcha
, 4),
1768 SCR_REG_REG (scratcha
, SCR_OR
, 1),
1770 SCR_FROM_REG (rbc3
),
1772 SCR_TO_REG (scratcha3
),
1775 * Move this value to the table indirect.
1777 SCR_STORE_REL (scratcha
, 4),
1778 offsetof (struct sym_ccb
, phys
.wresid
.size
),
1780 * Wait for a valid phase.
1781 * While testing with bogus QUANTUM drives, the C1010
1782 * sometimes raised a spurious phase mismatch with
1783 * WSR and the CHMOV(1) triggered another PM.
1784 * Waiting explicitly for the PHASE seemed to avoid
1785 * the nested phase mismatch. Btw, this didn't happen
1786 * using my IBM drives.
1788 SCR_JUMPR
^ IFFALSE (WHEN (SCR_DATA_IN
)),
1791 * Perform the move of the residual byte.
1793 SCR_CHMOV_TBL
^ SCR_DATA_IN
,
1794 offsetof (struct sym_ccb
, phys
.wresid
),
1796 * We can now handle the phase mismatch with UA fixed.
1797 * RBC[0..23]=0 is a special case that does not require
1798 * a PM context. The C code also checks against this.
1802 SCR_RETURN
^ IFFALSE (DATA (0)),
1804 SCR_FROM_REG (rbc1
),
1806 SCR_RETURN
^ IFFALSE (DATA (0)),
1808 SCR_FROM_REG (rbc2
),
1810 SCR_RETURN
^ IFFALSE (DATA (0)),
1814 * Not only we donnot need a PM context, but this would
1815 * lead to a bogus CHMOV(0). This condition means that
1816 * the residual was the last byte to move from this CHMOV.
1817 * So, we just have to move the current data script pointer
1818 * (i.e. TEMP) to the SCRIPTS address following the
1819 * interrupted CHMOV and jump to dispatcher.
1820 * IA contains the data pointer to save.
1823 PADDR_B (pm_save_end
),
1824 }/*-------------------------< WSR_MA_HELPER >--------------------*/,{
1826 * Helper for the C code when WSR bit is set.
1827 * Perform the move of the residual byte.
1829 SCR_CHMOV_TBL
^ SCR_DATA_IN
,
1830 offsetof (struct sym_ccb
, phys
.wresid
),
1834 }/*-------------------------< ZERO >-----------------------------*/,{
1836 }/*-------------------------< SCRATCH >--------------------------*/,{
1838 }/*-------------------------< PM0_DATA_ADDR >--------------------*/,{
1840 }/*-------------------------< PM1_DATA_ADDR >--------------------*/,{
1842 }/*-------------------------< DONE_POS >-------------------------*/,{
1844 }/*-------------------------< STARTPOS >-------------------------*/,{
1846 }/*-------------------------< TARGTBL >--------------------------*/,{
1848 }/*-------------------------<>-----------------------------------*/
1851 static struct SYM_FWZ_SCR SYM_FWZ_SCR
= {
1852 /*-------------------------< SNOOPTEST >------------------------*/{
1854 * Read the variable from memory.
1856 SCR_LOAD_REL (scratcha
, 4),
1857 offsetof(struct sym_hcb
, scratch
),
1859 * Write the variable to memory.
1861 SCR_STORE_REL (temp
, 4),
1862 offsetof(struct sym_hcb
, scratch
),
1864 * Read back the variable from memory.
1866 SCR_LOAD_REL (temp
, 4),
1867 offsetof(struct sym_hcb
, scratch
),
1868 }/*-------------------------< SNOOPEND >-------------------------*/,{
1874 }/*-------------------------<>-----------------------------------*/