patch-1.3.49 linux/drivers/scsi/53c7,8xx.h

Next file: linux/drivers/scsi/53c7,8xx.scr
Previous file: linux/drivers/scsi/53c7,8xx.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v1.3.48/linux/drivers/scsi/53c7,8xx.h linux/drivers/scsi/53c7,8xx.h
@@ -6,10 +6,10 @@
  *	Hannover, Germany
  *	hm@ix.de	
  *
- * Copyright 1993, Drew Eckhardt
+ * Copyright 1993, 1994, 1995 Drew Eckhardt
  *      Visionary Computing 
  *      (Unix and Linux consulting and custom programming)
- *      drew@Colorado.EDU
+ *      drew@PoohSticks.ORG
  *	+1 (303) 786-7975
  *
  * TolerANT and SCSI SCRIPTS are registered trademarks of NCR Corporation.
@@ -38,25 +38,13 @@
 
 #ifndef NCR53c7x0_H
 #define NCR53c7x0_H
-
-#ifdef __alpha__
-
-# define ncr_readb(a)		((unsigned int)readb((unsigned long)(a)))
-# define ncr_readw(a)		((unsigned int)readw((unsigned long)(a)))
-# define ncr_readl(a)		((unsigned int)readl((unsigned long)(a)))
-# define ncr_writeb(v,a)	(writeb((v), (unsigned long)(a)))
-# define ncr_writew(v,a)	(writew((v), (unsigned long)(a)))
-# define ncr_writel(v,a)	(writel((v), (unsigned long)(a)))
-
+#if !defined(LINUX_1_2) && !defined(LINUX_1_3)
+#include <linux/version.h>
+#if LINUX_VERSION_CODE > 65536 + 3 * 256
+#define LINUX_1_3
 #else
-
-# define ncr_readb(a)		(*(unsigned char*)(a))
-# define ncr_readw(a)		(*(unsigned short*)(a))
-# define ncr_readl(a)		(*(unsigned int*)(a))
-# define ncr_writeb(v,a)	(*(unsigned char*)(a) = (v))
-# define ncr_writew(v,a)	(*(unsigned short*)(a) = (v))
-# define ncr_writel(v,a)	(*(unsigned int*)(a) = (v))
-
+#define LINUX_1_2
+#endif
 #endif
 
 /* 
@@ -78,18 +66,68 @@
 #define NCR53c7xx_release NULL
 #endif
 
-#define NCR53c7xx {NULL, NULL, NULL, NULL,     \
-        "NCR53c{7,8}xx (rel 4)", NCR53c7xx_detect,                      \
-        NULL, /* info */ NULL, /* command, deprecated */ NULL,          \
-        NCR53c7xx_queue_command, NCR53c7xx_abort, NCR53c7xx_reset,      \
-        NULL /* slave attach */, scsicam_bios_param, /* can queue */ 1, \
-        /* id */ 7, 127 /* old SG_ALL */, /* cmd per lun */ 1 ,         \
-        /* present */ 0, /* unchecked isa dma */ 0, DISABLE_CLUSTERING} 
+#ifdef LINUX_1_2
+#define NCR53c7xx {NULL, NULL, "NCR53c{7,8}xx (rel 13)", NCR53c7xx_detect,\
+	NULL, /* info */ NULL, /* command, deprecated */ NULL, 		\
+	NCR53c7xx_queue_command, NCR53c7xx_abort, NCR53c7xx_reset,	\
+	NULL /* slave attach */, scsicam_bios_param, /* can queue */ 24, \
+	/* id */ 7, 127 /* old SG_ALL */, /* cmd per lun */ 3, 		\
+	/* present */ 0, /* unchecked isa dma */ 0, DISABLE_CLUSTERING} 
+#else
+#define NCR53c7xx {NULL, NULL, NULL, NULL, \
+        "NCR53c{7,8}xx (rel 13)", NCR53c7xx_detect,\
+        NULL, /* info */ NULL, /* command, deprecated */ NULL,		\
+	NCR53c7xx_queue_command, NCR53c7xx_abort, NCR53c7xx_reset,	\
+	NULL /* slave attach */, scsicam_bios_param, /* can queue */ 24, \
+	/* id */ 7, 127 /* old SG_ALL */, /* cmd per lun */ 3, 		\
+	/* present */ 0, /* unchecked isa dma */ 0, DISABLE_CLUSTERING} 
+#endif
+
 #endif /* defined(HOSTS_C) || defined(MODULE) */ 
 
 #ifndef HOSTS_C
-/* Register addresses, ordered numerically */
+#ifdef LINUX_1_2
+/*
+ * Change virtual addresses to physical addresses and vv.
+ * These are trivial on the 1:1 Linux/i386 mapping (but if we ever
+ * make the kernel segment mapped at 0, we need to do translation
+ * on the i386 as well)
+ */
+extern inline unsigned long virt_to_phys(volatile void * address)
+{       
+	return (unsigned long) address;
+}       
+
+extern inline void * phys_to_virt(unsigned long address)
+{
+	return (void *) address;      
+}
 
+/*
+ * IO bus memory addresses are also 1:1 with the physical address
+ */
+#define virt_to_bus virt_to_phys
+#define bus_to_virt phys_to_virt
+
+/*
+ * readX/writeX() are used to access memory mapped devices. On some
+ * architectures the memory mapped IO stuff needs to be accessed
+ * differently. On the x86 architecture, we just read/write the
+ * memory location directly.
+ */
+#define readb(addr) (*(volatile unsigned char *) (addr))
+#define readw(addr) (*(volatile unsigned short *) (addr))
+#define readl(addr) (*(volatile unsigned int *) (addr))
+
+#define writeb(b,addr) ((*(volatile unsigned char *) (addr)) = (b))
+#define writew(b,addr) ((*(volatile unsigned short *) (addr)) = (b))
+#define writel(b,addr) ((*(volatile unsigned int *) (addr)) = (b))
+
+#define mb()
+
+#endif /* def LINUX_1_2 */
+
+/* Register addresses, ordered numerically */
 
 /* SCSI control 0 rw, default = 0xc0 */ 
 #define SCNTL0_REG 		0x00	
@@ -113,7 +151,7 @@
 #define SCNTL1_DHP_800		0x20	/* Disable halt on parity error or ATN
 					   target mode only */
 #define SCNTL1_CON		0x10	/* Connected */
-#define SCNTL1_RST		0x08	/*  SCSI RST/ */
+#define SCNTL1_RST		0x08	/* SCSI RST/ */
 #define SCNTL1_AESP		0x04	/* Force bad parity */
 #define SCNTL1_SND_700		0x02	/* Start SCSI send */
 #define SCNTL1_IARB_800		0x02	/* Immediate Arbitration, start
@@ -198,15 +236,16 @@
 #define SXFER_TP1		0x20
 #define SXFER_TP0		0x10	/* lsb */
 #define SXFER_TP_MASK		0x70
-#define SXFER_TP_SHIFT		4
+/* FIXME : SXFER_TP_SHIFT == 5 is right for '8xx chips */
+#define SXFER_TP_SHIFT		5
 #define SXFER_TP_4		0x00	/* Divisors */
-#define SXFER_TP_5		0x10
-#define SXFER_TP_6		0x20
-#define SXFER_TP_7		0x30
-#define SXFER_TP_8		0x40
-#define SXFER_TP_9		0x50
-#define SXFER_TP_10		0x60
-#define SXFER_TP_11		0x70
+#define SXFER_TP_5		0x10<<1
+#define SXFER_TP_6		0x20<<1
+#define SXFER_TP_7		0x30<<1
+#define SXFER_TP_8		0x40<<1
+#define SXFER_TP_9		0x50<<1
+#define SXFER_TP_10		0x60<<1
+#define SXFER_TP_11		0x70<<1
 
 #define SXFER_MO3		0x08	/* Max offset msb */
 #define SXFER_MO2		0x04
@@ -334,6 +373,7 @@
 #define DSTAT_800_IID		0x01	/* Same thing, different name */
 
 
+/* NCR53c800 moves this stuff into SIST0 */
 #define SSTAT0_REG		0x0d	/* SCSI status 0 ro */
 #define SIST0_REG_800		0x42	
 #define SSTAT0_MA		0x80	/* ini : phase mismatch,
@@ -349,6 +389,8 @@
 #define SSTAT0_RST		0x02	/* SCSI RST/ received */
 #define SSTAT0_PAR		0x01	/* Parity error */
 
+/* And uses SSTAT0 for what was SSTAT1 */
+
 #define SSTAT1_REG		0x0e	/* SCSI status 1 ro */
 #define SSTAT1_ILF		0x80	/* SIDL full */
 #define SSTAT1_ORF		0x40	/* SODR full */
@@ -365,6 +407,7 @@
 #define SSTAT2_FF1		0x20	
 #define SSTAT2_FF0		0x10
 #define SSTAT2_FF_MASK		0xf0
+#define SSTAT2_FF_SHIFT		4
 
 /* 
  * Latched signals, latched on the leading edge of REQ/ for initiators,
@@ -374,6 +417,13 @@
 #define SSTAT2_MSG		0x04	/* MSG */
 #define SSTAT2_CD		0x02	/* C/D */
 #define SSTAT2_IO		0x01	/* I/O */
+#define SSTAT2_PHASE_CMDOUT	SSTAT2_CD
+#define SSTAT2_PHASE_DATAIN	SSTAT2_IO
+#define SSTAT2_PHASE_DATAOUT	0
+#define SSTAT2_PHASE_MSGIN	(SSTAT2_CD|SSTAT2_IO|SSTAT2_MSG)
+#define SSTAT2_PHASE_MSGOUT	(SSTAT2_CD|SSTAT2_MSG)
+#define SSTAT2_PHASE_STATIN	(SSTAT2_CD|SSTAT2_IO)
+#define SSTAT2_PHASE_MASK	(SSTAT2_CD|SSTAT2_IO|SSTAT2_MSG)
 
 
 /* NCR53c700-66 only */
@@ -867,7 +917,8 @@
 #define STIME1_REG_800		0x49
 #define STIME1_800_GEN_MASK	0x0f	/* General purpose timer */
 
-#define RESPID_REG_800		0x4a	/* Response ID, bit fielded */
+#define RESPID_REG_800		0x4a	/* Response ID, bit fielded.  8
+					   bits on narrow chips, 16 on WIDE */
 
 #define STEST0_REG_800		0x4c	
 #define STEST0_800_SLT		0x08	/* Selection response logic test */
@@ -895,10 +946,6 @@
 #define STEST3_800_CSF		0x02	/* Clear SCSI FIFO */
 #define STEST3_800_STW		0x01	/* SCSI FIFO test write */
 
-
-
-
-
 #define OPTION_PARITY 		0x1	/* Enable parity checking */
 #define OPTION_TAGGED_QUEUE	0x2	/* Enable SCSI-II tagged queuing */
 #define OPTION_700		0x8	/* Always run NCR53c700 scripts */
@@ -919,14 +966,12 @@
 #define OPTION_MEMORY_MAPPED	0x800	/* NCR registers have valid 
 					   memory mapping */
 #define OPTION_IO_MAPPED	0x1000  /* NCR registers have valid
-					   I/O mapping */
-#define OPTION_DEBUG_PROBE_ONLY	0x2000	/* Probe only, don't even init */
-#define OPTION_DEBUG_TESTS_ONLY	0x4000	/* Probe, init, run selected tests */
-
+					     I/O mapping */
+#define OPTION_DEBUG_PROBE_ONLY	0x2000  /* Probe only, don't even init */
+#define OPTION_DEBUG_TESTS_ONLY	0x4000  /* Probe, init, run selected tests */
 #define OPTION_DEBUG_TEST0	0x08000 /* Run test 0 */
 #define OPTION_DEBUG_TEST1	0x10000 /* Run test 1 */
 #define OPTION_DEBUG_TEST2	0x20000 /* Run test 2 */
-
 #define OPTION_DEBUG_DUMP	0x40000 /* Dump commands */
 #define OPTION_DEBUG_TARGET_LIMIT 0x80000 /* Only talk to target+luns specified */
 #define OPTION_DEBUG_NCOMMANDS_LIMIT 0x100000 /* Limit the number of commands */
@@ -934,17 +979,41 @@
 #define OPTION_DEBUG_FIXUP 0x400000 /* print fixup values */
 #define OPTION_DEBUG_DSA 0x800000
 #define OPTION_DEBUG_CORRUPTION	0x1000000	/* Detect script corruption */
-
+#define OPTION_DEBUG_SDTR       0x2000000	/* Debug SDTR problem */
+#define OPTION_DEBUG_MISMATCH 	0x4000000 	/* Debug phase mismatches */
+#define OPTION_DISCONNECT	0x8000000	/* Allow disconect */
+#define OPTION_DEBUG_DISCONNECT 0x10000000	
+#define OPTION_ALWAYS_SYNCHRONOUS 0x20000000	/* Negotiate sync. transfers
+						   on power up */
+#define OPTION_SCSI_MALLOC	0x40000000	/* Use scsi_malloc instead of
+						   kmalloc() to allocate NCR
+						   command structures after 
+						   boot */
+#define OPTION_DEBUG_QUEUES	0x80000000	
+#define OPTION_DEBUG_ALLOCATION 0x100000000LL
+#define OPTION_DEBUG_SYNCHRONOUS 0x200000000LL	/* Sanity check SXFER and 
+						   SCNTL3 registers */
+#define OPTION_NO_ASYNC	0x400000000LL		/* Don't automagically send
+						   SDTR for async transfers when
+						   we haven't been told to do
+						   a synchronous transfer. */
+#define OPTION_NO_PRINT_RACE 0x800000000LL	/* Don't print message when
+						   the reselect/WAIT DISCONNECT
+						   race condition hits */
 #if !defined(PERM_OPTIONS)
 #define PERM_OPTIONS 0
 #endif
 				
 struct NCR53c7x0_synchronous {
     u32 select_indirect;		/* Value used for indirect selection */
-    u32 script[6];			/* Size ?? Script used when target is 
+    u32 script[8];			/* Size ?? Script used when target is 
 						reselected */
-    unsigned renegotiate:1;		/* Force renegotiation on next   
-					   select */
+    unsigned char synchronous_want[5];	/* Per target desired SDTR */
+/* 
+ * Set_synchronous programs these, select_indirect and current settings after
+ * int_debug_should show a match.
+ */
+    unsigned char sxfer_sanity, scntl3_sanity;
 };
 
 #define CMD_FLAG_SDTR 		1	/* Initiating synchronous 
@@ -952,15 +1021,70 @@
 #define CMD_FLAG_WDTR		2	/* Initiating wide transfer
 					   negotiation */
 #define CMD_FLAG_DID_SDTR	4	/* did SDTR */
+#define CMD_FLAG_DID_WDTR	8	/* did WDTR */
 
 struct NCR53c7x0_table_indirect {
     u32 count;
     void *address;
 };
 
+enum ncr_event { 
+    EVENT_NONE = 0,
+/* 
+ * Order is IMPORTANT, since these must correspond to the event interrupts
+ * in 53c7,8xx.scr 
+ */
+
+    EVENT_ISSUE_QUEUE = 0x5000000,	/* Command was added to issue queue */
+    EVENT_START_QUEUE,			/* Command moved to start queue */
+    EVENT_SELECT,			/* Command completed selection */
+    EVENT_DISCONNECT,			/* Command disconnected */
+    EVENT_RESELECT,			/* Command reselected */
+    EVENT_COMPLETE,		        /* Command completed */
+    EVENT_IDLE,
+    EVENT_SELECT_FAILED,
+    EVENT_BEFORE_SELECT,
+    EVENT_RESELECT_FAILED
+};
+
+struct NCR53c7x0_event {
+    enum ncr_event event;	/* What type of event */
+    unsigned char target;
+    unsigned char lun;
+    struct timeval time;	
+    u32 *dsa;			/* What's in the DSA register now (virt) */
+/* 
+ * A few things from that SCSI pid so we know what happened after 
+ * the Scsi_Cmnd structure in question may have disappeared.
+ */
+    unsigned long pid;		/* The SCSI PID which caused this 
+				   event */
+    unsigned char cmnd[12];
+};
+
+/*
+ * Things in the NCR53c7x0_cmd structure are split into two parts :
+ *
+ * 1.  A fixed portion, for things which are not accessed directly by static NCR
+ *	code (ie, are referenced only by the Linux side of the driver,
+ *	or only by dynamically genreated code).  
+ *
+ * 2.  The DSA portion, for things which are accessed directly by static NCR
+ *	code.
+ *
+ * This is a little ugly, but it 
+ * 1.  Avoids conflicts between the NCR code's picture of the structure, and 
+ * 	Linux code's idea of what it looks like.
+ *
+ * 2.  Minimizes the pain in the Linux side of the code needed 
+ * 	to calculate real dsa locations for things, etc.
+ * 
+ */
+
 struct NCR53c7x0_cmd {
-    void *real;				/* Real, unaligned address */
-    void (* free)(void *);		/* Command to deallocate; NULL
+    void *real;				/* Real, unaligned address for
+					   free function */
+    void (* free)(void *, int);		/* Command to deallocate; NULL
 					   for structures allocated with
 					   scsi_register, etc. */
     Scsi_Cmnd *cmd;			/* Associated Scsi_Cmnd 
@@ -971,7 +1095,15 @@
     int size;				/* scsi_malloc'd size of this 
 					   structure */
 
-    int flags;
+    int flags;				/* CMD_* flags */
+
+/*
+ * SDTR and WIDE messages are an either/or affair
+ * in this message, since we will go into message out and send
+ * _the whole mess_ without dropping out of message out to 
+ * let the target go into message in after sending the first 
+ * message.
+ */
 
     unsigned char select[11];		/* Select message, includes
 					   IDENTIFY
@@ -980,26 +1112,54 @@
 					 */
 
 
-    volatile struct NCR53c7x0_cmd *next, *prev;	
-					/* Linux maintained lists.  Note that
-					   hostdata->free is a singly linked
-					   list; the rest are doubly linked */
+    volatile struct NCR53c7x0_cmd *next; /* Linux maintained lists (free,
+					    running, eventually finished */
     					 
 
-    long dsa_size; /* Size of DSA structure */
-
     u32 *data_transfer_start;		/* Start of data transfer routines */
     u32 *data_transfer_end;		/* Address after end of data transfer o
     	    	    	    	    	   routines */
+/* 
+ * The following three fields were moved from the DSA propper to here
+ * since only dynamically generated NCR code refers to them, meaning
+ * we don't need dsa_* absolutes, and it is simpler to let the 
+ * host code refer to them directly.
+ */
 
-    u32 residual[8];			/* Residual data transfer
-					   shadow of data_transfer code.
+/* 
+ * HARD CODED : residual and saved_residual need to agree with the sizes
+ * used in NCR53c7,8xx.scr.  
+ * 
+ * FIXME: we want to consider the case where we have odd-length 
+ *	scatter/gather buffers and a WIDE transfer, in which case 
+ *	we'll need to use the CHAIN MOVE instruction.  Ick.
+ */
+    u32 residual[6];			/* Residual data transfer which
+					   allows pointer code to work
+					   right.
+
+    	    	    	    	    	    [0-1] : Conditional call to 
+    	    	    	    	    	    	appropriate other transfer 
+    	    	    	    	    	    	routine.
+    	    	    	    	    	    [2-3] : Residual block transfer
+    	    	    	    	    	    	instruction.
+    	    	    	    	    	    [4-5] : Jump to instruction
+    	    	    	    	    	    	after splice.
+					 */
+    u32 saved_residual[6]; 		/* Copy of old residual, so we 
+					   can get another partial 
+					   transfer and still recover 
+    	    	    	    	    	 */
+    	    	
+    u32 saved_data_pointer;		/* Saved data pointer */
+
+    u32 dsa_next_addr;		        /* _Address_ of dsa_next field  
+					   in this dsa for RISCy 
+					   style constant. */
+
+    u32 dsa_addr;			/* Address of dsa; RISCy style
+					   constant */
 
-					   Has instruction with modified
-					   DBC field followed by jump to 
-					   CALL routine following command.
-					 */
-	     
     u32 dsa[0];				/* Variable length (depending
 					   on host type, number of scatter /
 					   gather buffers, etc).  */
@@ -1025,10 +1185,10 @@
  * Indicates that the NCR was being aborted.
  */
 #define STATE_ABORTING	3
-/* 
- * Indicates that the NCR was successfully aborted. */
+/* Indicates that the NCR was successfully aborted. */
 #define STATE_ABORTED 4
-    
+/* Indicates that the NCR has been disabled due to a fatal error */
+#define STATE_DISABLED 5
 
 /* 
  * Where knowledge of SCSI SCRIPT(tm) specified values are needed 
@@ -1054,15 +1214,9 @@
 					   bit is being used to enable
 					   termination, etc. */
 
-    int chip;				/* set to chip type */
-	/*
-  	 * NCR53c700 = 700
-	 * NCR53c700-66 = 70066
-	 * NCR53c710 = 710
-	 * NCR53c720 = 720 
-	 * NCR53c810 = 810
-	 */
-
+    int chip;				/* set to chip type; 700-66 is
+					   700-66, rest are last three
+					   digits of part number */
     /*
      * PCI bus, device, function, only for NCR53c8x0 chips.
      * pci_valid indicates that the PCI configuration information
@@ -1110,7 +1264,7 @@
 
     int (* dstat_sir_intr)(struct Scsi_Host *host, struct NCR53c7x0_cmd *cmd);
 
-    long dsa_size; /* Size of DSA structure */
+    int dsa_len; /* Size of DSA structure */
 
     /*
      * Location of DSA fields for the SCSI SCRIPT corresponding to this 
@@ -1131,9 +1285,10 @@
     s32 dsa_msgout_other;
     s32 dsa_write_sync;
     s32 dsa_write_resume;
-    s32 dsa_jump_resume;
     s32 dsa_check_reselect;
     s32 dsa_status;
+    s32 dsa_saved_pointer;
+    s32 dsa_jump_dest;
 
     /* 
      * Important entry points that generic fixup code needs
@@ -1141,14 +1296,17 @@
      */
 
     s32 E_accept_message;
+    s32 E_command_complete;		
+    s32 E_data_transfer;
     s32 E_dsa_code_template;
     s32 E_dsa_code_template_end;
-    s32 E_command_complete;		
+    s32 E_end_data_transfer;
     s32 E_msg_in;
     s32 E_initiator_abort;
     s32 E_other_transfer;
+    s32 E_other_in;
+    s32 E_other_out;
     s32 E_target_abort;
-    s32 E_schedule;			
     s32 E_debug_break;	
     s32 E_reject_message;
     s32 E_respond_message;
@@ -1159,13 +1317,15 @@
     s32 E_test_2;
     s32 E_test_3;
     s32 E_dsa_zero;
-    s32 E_dsa_jump_resume;
+    s32 E_cmdout_cmdout;
+    s32 E_wait_reselect;
+    s32 E_dsa_code_begin;
 
-    int options;			/* Bitfielded set of options enabled */
+    long long options;			/* Bitfielded set of options enabled */
     volatile u32 test_completed;	/* Test completed */
     int test_running;			/* Test currently running */
-    int test_source;
-    volatile int test_dest;
+    s32 test_source;
+    volatile s32 test_dest;
 
     volatile int state;			/* state of driver, only used for 
 					   OPTION_700 */
@@ -1186,6 +1346,7 @@
 					 */
 
     volatile int intrs;			/* Number of interrupts */
+    volatile int resets;		/* Number of SCSI resets */
     unsigned char saved_dmode;	
     unsigned char saved_ctest4;
     unsigned char saved_ctest7;
@@ -1213,7 +1374,7 @@
 					   information for if 
 					   OPTION_DEBUG_DUMP is set */ 
 
-    unsigned char debug_lun_limit[8];	/* If OPTION_DEBUG_TARGET_LIMIT
+    unsigned char debug_lun_limit[16];	/* If OPTION_DEBUG_TARGET_LIMIT
 					   set, puke if commands are sent
 					   to other target/lun combinations */
 
@@ -1225,22 +1386,20 @@
     volatile unsigned idle:1;			/* set to 1 if idle */
 
     /* 
-     * Table of synchronous transfer parameters set on a per-target
+     * Table of synchronous+wide transfer parameters set on a per-target
      * basis.
-     * 
-     * XXX - do we need to increase this to 16 for the WIDE-SCSI
-     * flavors of the board?
      */
     
-    volatile struct NCR53c7x0_synchronous sync[8];
+    volatile struct NCR53c7x0_synchronous sync[16];
 
-    volatile struct NCR53c7x0_cmd *issue_queue;
+    volatile Scsi_Cmnd *issue_queue;
 						/* waiting to be issued by
 						   Linux driver */
     volatile struct NCR53c7x0_cmd *running_list;	
 						/* commands running, maintained
 						   by Linux driver */
-    volatile struct NCR53c7x0_cmd *current_cmd;	/* currently connected 
+
+    volatile struct NCR53c7x0_cmd *current;	/* currently connected 
 						   nexus, ONLY valid for
 						   NCR53c700/NCR53c700-66
 						 */
@@ -1256,10 +1415,11 @@
 						   */
     volatile int num_cmds;			/* Number of commands 
 						   allocated */
-    volatile unsigned char cmd_allocated[8];	/* Have we allocated commands
+    volatile int extra_allocate;
+    volatile unsigned char cmd_allocated[16];	/* Have we allocated commands
 						   for this target yet?  If not,
 						   do so ASAP */
-    volatile unsigned char busy[8][8];     	/* number of commands 
+    volatile unsigned char busy[16][8];     	/* number of commands 
 						   executing on each target
     	    	    	    	    	    	 */
     /* 
@@ -1272,20 +1432,32 @@
 						
 
     /* Shared variables between SCRIPT and host driver */
-    volatile u32 issue_dsa_head;
-						/* commands waiting to be 
-						   issued, insertions are 
-						   done by Linux driver,
-						   deletions are done by
-						   NCR */
-    u32 *issue_dsa_tail;			/* issue queue tail pointer;
-						   used by Linux driver only */
+    volatile u32 *schedule;			/* Array of JUMPs to dsa_begin
+						   routines of various DSAs.  
+						   When not in use, replace
+						   with jump to next slot */
+
+
     volatile unsigned char msg_buf[16];		/* buffer for messages
 						   other than the command
 						   complete message */
-    volatile u32 reconnect_dsa_head;
-						/* disconnected commands,
-						   maintained by NCR */
+
+    /* Per-target default synchronous and WIDE messages */
+    volatile unsigned char synchronous_want[16][5];
+    volatile unsigned char wide_want[16][4];
+
+    /* Bit fielded set of targets we want to speak synchronously with */ 
+    volatile u16 initiate_sdtr;	
+    /* Bit fielded set of targets we want to speak wide with */
+    volatile u16 initiate_wdtr;
+    /* Bit fielded list of targets we've talked to. */
+    volatile u16 talked_to;
+    /* Array of bit-fielded lun lists that we need to request_sense */
+    volatile unsigned char request_sense[16];
+
+    u32 addr_reconnect_dsa_head;		/* RISCy style constant,
+						   address of following */
+    volatile u32 reconnect_dsa_head;	
     /* Data identifying nexus we are trying to match during reselection */
     volatile unsigned char reselected_identify; /* IDENTIFY message */
     volatile unsigned char reselected_tag;	/* second byte of queue tag 
@@ -1294,10 +1466,21 @@
 
     s32 NCR53c7xx_zero;
     s32 NCR53c7xx_sink;
+    u32 NOP_insn;
     char NCR53c7xx_msg_reject;
     char NCR53c7xx_msg_abort;
     char NCR53c7xx_msg_nop;
 
+    volatile int event_size, event_index;
+    volatile struct NCR53c7x0_event *events;
+
+    /* If we need to generate code to kill off the currently connected 
+       command, this is where we do it. Should have a BMI instruction
+       to source or sink the current data, followed by a JUMP
+       to abort_connected */
+
+    u32 *abort_script;
+
     int script_count;				/* Size of script in words */
     u32 script[0];				/* Relocated SCSI script */
 
@@ -1327,37 +1510,38 @@
 
 #define NCR53c7x0_read8(address) 					\
     (NCR53c7x0_memory_mapped ? 						\
-	ncr_readb(NCR53c7x0_address_memory + (address))  :		\
+	(unsigned int)readb(NCR53c7x0_address_memory + (address)) :	\
 	inb(NCR53c7x0_address_io + (address)))
 
 #define NCR53c7x0_read16(address) 					\
     (NCR53c7x0_memory_mapped ? 						\
-	ncr_readw(NCR53c7x0_address_memory + (address))  :		\
+	(unsigned int)readw(NCR53c7x0_address_memory + (address)) :	\
 	inw(NCR53c7x0_address_io + (address)))
 
 #define NCR53c7x0_read32(address) 					\
     (NCR53c7x0_memory_mapped ? 						\
-	ncr_readl(NCR53c7x0_address_memory + (address))  :		\
+	(unsigned int) readl(NCR53c7x0_address_memory + (address)) : 	\
 	inl(NCR53c7x0_address_io + (address)))
 
 #define NCR53c7x0_write8(address,value) 				\
     (NCR53c7x0_memory_mapped ? 						\
-	ncr_writeb((value), NCR53c7x0_address_memory + (address)) :	\
+     ({writeb((value), NCR53c7x0_address_memory + (address)); mb();}) :	\
 	outb((value), NCR53c7x0_address_io + (address)))
 
 #define NCR53c7x0_write16(address,value) 				\
     (NCR53c7x0_memory_mapped ? 						\
-	ncr_writew((value), NCR53c7x0_address_memory + (address)) :	\
+     ({writew((value), NCR53c7x0_address_memory + (address)); mb();}) :	\
 	outw((value), NCR53c7x0_address_io + (address)))
 
 #define NCR53c7x0_write32(address,value) 				\
     (NCR53c7x0_memory_mapped ? 						\
-	ncr_writel((value), NCR53c7x0_address_memory + (address)) :	\
+     ({writel((value), NCR53c7x0_address_memory + (address)); mb();}) :	\
 	outl((value), NCR53c7x0_address_io + (address)))
 
+/* Patch arbitrary 32 bit words in the script */
 #define patch_abs_32(script, offset, symbol, value)			\
     	for (i = 0; i < (sizeof (A_##symbol##_used) / sizeof 		\
-    	    (u32)); ++i) {						\
+    	    (u32)); ++i) {					\
 	    (script)[A_##symbol##_used[i] - (offset)] += (value);	\
 	    if (hostdata->options & OPTION_DEBUG_FIXUP) 		\
 	      printk("scsi%d : %s reference %d at 0x%x in %s is now 0x%x\n",\
@@ -1366,26 +1550,39 @@
 		(offset)]);						\
     	}
 
+/* Patch read/write instruction immediate field */
 #define patch_abs_rwri_data(script, offset, symbol, value)		\
     	for (i = 0; i < (sizeof (A_##symbol##_used) / sizeof 		\
-    	    (u32)); ++i)						\
+    	    (u32)); ++i)					\
     	    (script)[A_##symbol##_used[i] - (offset)] =			\
 	    	((script)[A_##symbol##_used[i] - (offset)] & 		\
 	    	~DBC_RWRI_IMMEDIATE_MASK) | 				\
     	    	(((value) << DBC_RWRI_IMMEDIATE_SHIFT) &		\
 		 DBC_RWRI_IMMEDIATE_MASK)
 
+/* Patch transfer control instruction data field */
+#define patch_abs_tci_data(script, offset, symbol, value)	        \
+    	for (i = 0; i < (sizeof (A_##symbol##_used) / sizeof 		\
+    	    (u32)); ++i)					\
+    	    (script)[A_##symbol##_used[i] - (offset)] =			\
+	    	((script)[A_##symbol##_used[i] - (offset)] & 		\
+	    	~DBC_TCI_DATA_MASK) | 					\
+    	    	(((value) << DBC_TCI_DATA_SHIFT) &			\
+		 DBC_TCI_DATA_MASK)
+
+/* Patch field in dsa structure (assignment should be +=?) */
 #define patch_dsa_32(dsa, symbol, word, value)				\
 	{								\
 	(dsa)[(hostdata->##symbol - hostdata->dsa_start) / sizeof(u32)	\
-		+ (word)] = (value);					\
+	    + (word)] = (value);					\
 	if (hostdata->options & OPTION_DEBUG_DSA)			\
 	    printk("scsi : dsa %s symbol %s(%d) word %d now 0x%x\n",	\
-		#dsa, #symbol, hostdata->##symbol,	 		\
-		(word), (u32)(value));				\
+		#dsa, #symbol, hostdata->##symbol, 			\
+		(word), (u32) (value));					\
 	}
-    
 
+/* Paranoid people could use panic() here. */
+#define FATAL(host) shutdown((host));
 
 #endif /* NCR53c7x0_C */
 #endif /* NCR53c7x0_H */

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov with Sam's (original) version
of this