Subject: Re: kern/31990: esiop leaves b_resid non-zero (newfs troubles, etc ...)
To: None <bouyer@netbsd.org, gnats-admin@netbsd.org, netbsd-bugs@netbsd.org>
From: Manuel Bouyer <bouyer@antioche.eu.org>
List: netbsd-bugs
Date: 11/17/2005 17:42:01
The following reply was made to PR kern/31990; it has been noted by GNATS.

From: Manuel Bouyer <bouyer@antioche.eu.org>
To: Roy Bixler <rcbixler@nyx.net>, edwin <edwin@spacebugs.nl>,
	YAMAMOTO Takashi <yamt@mwd.biglobe.ne.jp>
Cc: gnats-bugs@NetBSD.org, kern-bug-people@NetBSD.org,
	gnats-admin@NetBSD.org, netbsd-bugs@NetBSD.org
Subject: Re: kern/31990: esiop leaves b_resid non-zero (newfs troubles, etc ...)
Date: Thu, 17 Nov 2005 18:41:01 +0100

 --OgqxwSJOaUobr8KG
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 
 Hi,
 my previous patch was still not right, I forgot a case where b_resid would
 not be properly updated. I reworked the code, and now the code path used
 to handle drives which don't issue a save data pointer after the last data
 transfers is also used, in some case, for drives which do.
 This means that I can test part of the code on my system, and it's more
 likely to work on yours :)
 
 Please test this new patch
 
 -- 
 Manuel Bouyer <bouyer@antioche.eu.org>
      NetBSD: 26 ans d'experience feront toujours la difference
 --
 
 --OgqxwSJOaUobr8KG
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: attachment; filename=diff-current
 
 Index: ic/esiop.c
 ===================================================================
 RCS file: /cvsroot/src/sys/dev/ic/esiop.c,v
 retrieving revision 1.33
 diff -u -r1.33 esiop.c
 --- ic/esiop.c	23 Mar 2005 21:23:15 -0000	1.33
 +++ ic/esiop.c	17 Nov 2005 17:23:29 -0000
 @@ -252,6 +252,14 @@
  			    sizeof(struct siop_common_xfer));
  		}
  		for (j = 0; j <
 +		    (sizeof(E_saved_offset_offset_Used) /
 +		     sizeof(E_saved_offset_offset_Used[0]));
 +		    j++) {
 +			bus_space_write_4(sc->sc_c.sc_ramt, sc->sc_c.sc_ramh,
 +			    E_saved_offset_offset_Used[j] * 4,
 +			    sizeof(struct siop_common_xfer) + 4);
 +		}
 +		for (j = 0; j <
  		    (sizeof(E_abs_msgin2_Used) / sizeof(E_abs_msgin2_Used[0]));
  		    j++) {
  			bus_space_write_4(sc->sc_c.sc_ramt, sc->sc_c.sc_ramh,
 @@ -290,6 +298,13 @@
  			    htole32(sizeof(struct siop_common_xfer));
  		}
  		for (j = 0; j <
 +		    (sizeof(E_saved_offset_offset_Used) /
 +		     sizeof(E_saved_offset_offset_Used[0]));
 +		    j++) {
 +			sc->sc_c.sc_script[E_saved_offset_offset_Used[j]] =
 +			    htole32(sizeof(struct siop_common_xfer) + 4);
 +		}
 +		for (j = 0; j <
  		    (sizeof(E_abs_msgin2_Used) / sizeof(E_abs_msgin2_Used[0]));
  		    j++) {
  			sc->sc_c.sc_script[E_abs_msgin2_Used[j]] =
 @@ -1071,6 +1086,9 @@
  			printf("disconnect offset %d\n", offset);
  #endif
  			siop_sdp(&esiop_cmd->cmd_c, offset);
 +			/* we start again with no offset */
 +			ESIOP_XFER(esiop_cmd, saved_offset) =
 +			    htole32(SIOP_NOOFFSET);
  			esiop_table_sync(esiop_cmd,
  			    BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
  			CALL_SCRIPT(Ent_script_sched);
 @@ -1125,6 +1143,17 @@
  		esiop_lun->active = NULL;
  	offset = bus_space_read_1(sc->sc_c.sc_rt, sc->sc_c.sc_rh,
  	    SIOP_SCRATCHA + 1);
 +	/*
 +	 * if we got a disconnect between the last data phase
 +	 * and the status phase, offset will be 0. In this
 +	 * case, cmd_tables->saved_offset will have the proper value 
 +	 * if it got updated by the controller
 +	 */
 +	if (offset == 0 &&
 +	    ESIOP_XFER(esiop_cmd, saved_offset) != htole32(SIOP_NOOFFSET))
 +		offset =
 +		    (le32toh(ESIOP_XFER(esiop_cmd, saved_offset)) >> 8) & 0xff;
 +
  	esiop_scsicmd_end(esiop_cmd, offset);
  	if (freetarget && esiop_target->target_c.status == TARST_PROBING)
  		esiop_del_dev(sc, target, lun);
 @@ -1213,7 +1242,7 @@
  	u_int32_t slot;
  	int needsync = 0;
  	int status;
 -	u_int32_t sem;
 +	u_int32_t sem, offset;
  
  	esiop_script_sync(sc, BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE);
  	sem = esiop_script_read(sc, sc->sc_semoffset);
 @@ -1294,10 +1323,15 @@
  		esiop_lun->tactive[tag] = NULL;
  	else
  		esiop_lun->active = NULL;
 -	/* scratcha was saved in tlq by script. fetch offset from it */
 -	esiop_scsicmd_end(esiop_cmd,
 -	    (le32toh(((struct esiop_xfer *)esiop_cmd->cmd_tables)->tlq) >> 8)
 -	    & 0xff);
 +	/*
 +	 * scratcha was eventually saved in saved_offset by script.
 +	 * fetch offset from it
 +	 */
 +	offset = 0;
 +	if (ESIOP_XFER(esiop_cmd, saved_offset) != htole32(SIOP_NOOFFSET))
 +		offset =
 +		    (le32toh(ESIOP_XFER(esiop_cmd, saved_offset)) >> 8) & 0xff;
 +	esiop_scsicmd_end(esiop_cmd, offset);
  	goto next;
  }
  
 @@ -1603,14 +1637,13 @@
  		else
  			esiop_cmd->cmd_c.tag = -1;
  		siop_setuptables(&esiop_cmd->cmd_c);
 -		((struct esiop_xfer *)esiop_cmd->cmd_tables)->tlq =
 -		    htole32(A_f_c_target | A_f_c_lun);
 -		((struct esiop_xfer *)esiop_cmd->cmd_tables)->tlq |=
 +		ESIOP_XFER(esiop_cmd, saved_offset) = htole32(SIOP_NOOFFSET);
 +		ESIOP_XFER(esiop_cmd, tlq) = htole32(A_f_c_target | A_f_c_lun);
 +		ESIOP_XFER(esiop_cmd, tlq) |=
  		    htole32((target << 8) | (lun << 16));
  		if (esiop_cmd->cmd_c.flags & CMDFL_TAG) {
 -			((struct esiop_xfer *)esiop_cmd->cmd_tables)->tlq |=
 -			    htole32(A_f_c_tag);
 -			((struct esiop_xfer *)esiop_cmd->cmd_tables)->tlq |=
 +			ESIOP_XFER(esiop_cmd, tlq) |= htole32(A_f_c_tag);
 +			ESIOP_XFER(esiop_cmd, tlq) |=
  			    htole32(esiop_cmd->cmd_c.tag << 24);
  		}
  
 @@ -1958,10 +1991,12 @@
  		TAILQ_INSERT_TAIL(&sc->free_list, &newcbd->cmds[i], next);
  		splx(s);
  #ifdef SIOP_DEBUG
 -		printf("tables[%d]: in=0x%x out=0x%x status=0x%x\n", i,
 +		printf("tables[%d]: in=0x%x out=0x%x status=0x%x "
 +		    "offset=0x%x\n", i,
  		    le32toh(newcbd->cmds[i].cmd_tables->t_msgin.addr),
  		    le32toh(newcbd->cmds[i].cmd_tables->t_msgout.addr),
 -		    le32toh(newcbd->cmds[i].cmd_tables->t_status.addr));
 +		    le32toh(newcbd->cmds[i].cmd_tables->t_status.addr,
 +		    le32toh(newcbd->cmds[i].cmd_tables->t_offset.addr));
  #endif
  	}
  	s = splbio();
 Index: ic/esiopvar.h
 ===================================================================
 RCS file: /cvsroot/src/sys/dev/ic/esiopvar.h,v
 retrieving revision 1.12
 diff -u -r1.12 esiopvar.h
 --- ic/esiopvar.h	27 Feb 2005 00:27:01 -0000	1.12
 +++ ic/esiopvar.h	17 Nov 2005 17:23:29 -0000
 @@ -53,9 +53,11 @@
  struct esiop_xfer {
  	struct siop_common_xfer siop_tables;
  	u_int32_t tlq; /* target/lun/tag loaded in scratchC by script */
 -		      /* will also containt scratcha at end of command */
 +	u_int32_t saved_offset;/* contains scratchA if script saved an offset */
  } __attribute__((__packed__));
  
 +#define ESIOP_XFER(cmd, m) (((struct esiop_xfer *)((cmd)->cmd_tables))->m)
 +
  /*
   * This describes a command handled by the SCSI controller
   * These are chained in either a free list or a active list
 Index: ic/siop.c
 ===================================================================
 RCS file: /cvsroot/src/sys/dev/ic/siop.c,v
 retrieving revision 1.78
 diff -u -r1.78 siop.c
 --- ic/siop.c	27 Feb 2005 00:27:02 -0000	1.78
 +++ ic/siop.c	17 Nov 2005 17:23:29 -0000
 @@ -103,6 +103,7 @@
  static int siop_stat_intr = 0;
  static int siop_stat_intr_shortxfer = 0;
  static int siop_stat_intr_sdp = 0;
 +static int siop_stat_intr_saveoffset = 0;
  static int siop_stat_intr_done = 0;
  static int siop_stat_intr_xferdisc = 0;
  static int siop_stat_intr_lunresel = 0;
 @@ -911,10 +912,22 @@
  			printf("disconnect offset %d\n", offset);
  #endif
  			siop_sdp(&siop_cmd->cmd_c, offset);
 +			/* we start again with no offset */
 +			siop_cmd->saved_offset = SIOP_NOOFFSET;
  			siop_table_sync(siop_cmd,
  			    BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
  			CALL_SCRIPT(Ent_script_sched);
  			return 1;
 +		case A_int_saveoffset:
 +			INCSTAT(siop_stat_intr_saveoffset);
 +			offset = bus_space_read_1(sc->sc_c.sc_rt,
 +			    sc->sc_c.sc_rh, SIOP_SCRATCHA + 1);
 +#ifdef SIOP_DEBUG_DR
 +			printf("saveoffset offset %d\n", offset);
 +#endif
 +			siop_cmd->saved_offset = offset;
 +			CALL_SCRIPT(Ent_script_sched);
 +			return 1;
  		case A_int_resfail:
  			printf("reselect failed\n");
  			CALL_SCRIPT(Ent_script_sched);
 @@ -939,6 +952,15 @@
  			/* update resid.  */
  			offset = bus_space_read_1(sc->sc_c.sc_rt,
  			    sc->sc_c.sc_rh, SIOP_SCRATCHA + 1);
 +			/*
 +			 * if we got a disconnect between the last data phase
 +			 * and the status phase, offset will be 0. In this
 +			 * case, siop_cmd->saved_offset will have the proper
 +			 * value if it got updated by the controller
 +			 */
 +			if (offset == 0 && 
 +			    siop_cmd->saved_offset != SIOP_NOOFFSET)
 +				offset = siop_cmd->saved_offset;
  			siop_update_resid(&siop_cmd->cmd_c, offset);
  			siop_cmd->cmd_c.status = CMDST_DONE;
  			goto end;
 @@ -1348,6 +1370,7 @@
  			siop_cmd->cmd_c.tag = 0;
  		}
  		siop_setuptables(&siop_cmd->cmd_c);
 +		siop_cmd->saved_offset = SIOP_NOOFFSET;
  		siop_table_sync(siop_cmd,
  		    BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
  		siop_start(sc, siop_cmd);
 @@ -1717,10 +1740,12 @@
  		TAILQ_INSERT_TAIL(&sc->free_list, &newcbd->cmds[i], next);
  		splx(s);
  #ifdef SIOP_DEBUG
 -		printf("tables[%d]: in=0x%x out=0x%x status=0x%x\n", i,
 +		printf("tables[%d]: in=0x%x out=0x%x status=0x%x "
 +		    "offset=0x%x\n", i,
  		    le32toh(newcbd->cmds[i].cmd_tables->t_msgin.addr),
  		    le32toh(newcbd->cmds[i].cmd_tables->t_msgout.addr),
 -		    le32toh(newcbd->cmds[i].cmd_tables->t_status.addr));
 +		    le32toh(newcbd->cmds[i].cmd_tables->t_status.addr),
 +		    le32toh(newcbd->cmds[i].cmd_tables->t_offset.addr));
  #endif
  	}
  	s = splbio();
 @@ -2002,6 +2027,7 @@
  	printf("siop_stat_intr_shortxfer %d\n", siop_stat_intr_shortxfer);
  	printf("siop_stat_intr_xferdisc %d\n", siop_stat_intr_xferdisc);
  	printf("siop_stat_intr_sdp %d\n", siop_stat_intr_sdp);
 +	printf("siop_stat_intr_saveoffset %d\n", siop_stat_intr_saveoffset);
  	printf("siop_stat_intr_done %d\n", siop_stat_intr_done);
  	printf("siop_stat_intr_lunresel %d\n", siop_stat_intr_lunresel);
  	printf("siop_stat_intr_qfull %d\n", siop_stat_intr_qfull);
 Index: ic/siopvar.h
 ===================================================================
 RCS file: /cvsroot/src/sys/dev/ic/siopvar.h,v
 retrieving revision 1.21
 diff -u -r1.21 siopvar.h
 --- ic/siopvar.h	27 Feb 2005 00:27:02 -0000	1.21
 +++ ic/siopvar.h	17 Nov 2005 17:23:29 -0000
 @@ -56,6 +56,7 @@
  	struct siop_common_cmd cmd_c;
  	struct siop_cbd *siop_cbdp; /* pointer to our siop_cbd */
  	int reselslot;
 +	u_int32_t saved_offset; /* offset in table after disc without sdp */
  };
  #define cmd_tables cmd_c.siop_tables
  
 Index: ic/siopvar_common.h
 ===================================================================
 RCS file: /cvsroot/src/sys/dev/ic/siopvar_common.h,v
 retrieving revision 1.32
 diff -u -r1.32 siopvar_common.h
 --- ic/siopvar_common.h	27 Feb 2005 00:27:02 -0000	1.32
 +++ ic/siopvar_common.h	17 Nov 2005 17:23:29 -0000
 @@ -56,7 +56,7 @@
  	u_int8_t msg_out[16];	/* 0 */
  	u_int8_t msg_in[16];	/* 16 */
  	u_int32_t status;	/* 32 */
 -	u_int32_t pad1;		/* 36 */
 +	u_int32_t pad1; 	/* 36 */
  	u_int32_t id;		/* 40 */
  	u_int32_t pad2;		/* 44 */
  	scr_table_t t_msgin;	/* 48 */
 @@ -72,6 +72,9 @@
  #define SCSI_SIOP_NOCHECK	0xfe	/* don't check the scsi status */
  #define SCSI_SIOP_NOSTATUS	0xff	/* device didn't report status */
  
 +/* offset is initialised to SIOP_NOOFFSET, used to check if it was updated */
 +#define SIOP_NOOFFSET 0xffffffff
 +
  /*
   * This describes a command handled by the SCSI controller
   */
 Index: microcode/siop/esiop.out
 ===================================================================
 RCS file: /cvsroot/src/sys/dev/microcode/siop/esiop.out,v
 retrieving revision 1.13
 diff -u -r1.13 esiop.out
 --- microcode/siop/esiop.out	17 May 2004 18:38:22 -0000	1.13
 +++ microcode/siop/esiop.out	17 Nov 2005 17:23:29 -0000
 @@ -1,7 +1,7 @@
 -/*	$NetBSD: esiop.out,v 1.13 2004/05/17 18:38:22 bouyer Exp $	*/
 +/*	$NetBSD: ncr53cxxx.c,v 1.14 2005/02/11 06:21:22 simonb Exp $	*/
  /*
   *	DO NOT EDIT - this file is automatically generated.
 - *	created from esiop.ss on Mon May 17 20:37:26 2004
 + *	created from esiop.ss on Thu Nov 17 17:54:10 2005
   */
  const u_int32_t esiop_script[] = {
  	0xe15c0004, 0x00000000,			/* 000 -   0 */
 @@ -13,7 +13,7 @@
  	0x78600000, 0x00000000,			/* 030 -  48 */
  	0x7869ff00, 0x00000000,			/* 038 -  56 */
  	0x80000000, 0x00000000,			/* 040 -  64 */
 -	0x54000000, 0x000002e8,			/* 048 -  72 */
 +	0x54000000, 0x000002f8,			/* 048 -  72 */
  	0x80000000, 0x00000000,			/* 050 -  80 */
  	0x740a0f00, 0x00000000,			/* 058 -  88 */
  	0x6a610000, 0x00000000,			/* 060 -  96 */
 @@ -46,12 +46,12 @@
  	0x87830000, 0x000000c8,			/* 138 - 312 */
  	0x0f000001, 0x00000000,			/* 140 - 320 */
  	0x60000040, 0x00000000,			/* 148 - 328 */
 -	0x80840020, 0x000003b8,			/* 150 - 336 */
 +	0x80840020, 0x000003c8,			/* 150 - 336 */
  	0x0f000001, 0x00000000,			/* 158 - 344 */
  	0x6a360000, 0x00000000,			/* 160 - 352 */
  	0x6a630000, 0x00000000,			/* 168 - 360 */
  	0x7a600400, 0x00000000,			/* 170 - 368 */
 -	0x88880000, 0x00000500,			/* 178 - 376 */
 +	0x88880000, 0x00000528,			/* 178 - 376 */
  	0x78370000, 0x00000000,			/* 180 - 384 */
  	0x60000400, 0x00000000,			/* 188 - 392 */
  	0x79360000, 0x00000000,			/* 190 - 400 */
 @@ -69,169 +69,174 @@
  	0x7f130000, 0x00000000,			/* 1f0 - 496 */
  	0xf1100004, 0x00000000,			/* 1f8 - 504 */
  	0x60000040, 0x00000000,			/* 200 - 512 */
 -	0x868b0000, 0x000002c8,			/* 208 - 520 */
 -	0x878b0000, 0x000002e8,			/* 210 - 528 */
 -	0x808b0000, 0x000003b8,			/* 218 - 536 */
 -	0x818b0000, 0x00000350,			/* 220 - 544 */
 -	0x828b0000, 0x00000320,			/* 228 - 552 */
 -	0x838b0000, 0x00000328,			/* 230 - 560 */
 +	0x868b0000, 0x000002d8,			/* 208 - 520 */
 +	0x878b0000, 0x000002f8,			/* 210 - 528 */
 +	0x808b0000, 0x000003e0,			/* 218 - 536 */
 +	0x818b0000, 0x00000378,			/* 220 - 544 */
 +	0x828b0000, 0x00000348,			/* 228 - 552 */
 +	0x838b0000, 0x00000350,			/* 230 - 560 */
  	0x98080000, 0x0000ffff,			/* 238 - 568 */
 -	0x88880000, 0x00000480,			/* 240 - 576 */
 -	0xf2340004, 0x00000000,			/* 248 - 584 */
 -	0x72690000, 0x00000000,			/* 250 - 592 */
 -	0x98040000, 0x0000ff00,			/* 258 - 600 */
 -	0x726c0000, 0x00000000,			/* 260 - 608 */
 -	0x6a100000, 0x00000000,			/* 268 - 616 */
 -	0x726d0000, 0x00000000,			/* 270 - 624 */
 -	0x6a110000, 0x00000000,			/* 278 - 632 */
 -	0x726e0000, 0x00000000,			/* 280 - 640 */
 -	0x6a120000, 0x00000000,			/* 288 - 648 */
 -	0x726f0000, 0x00000000,			/* 290 - 656 */
 -	0x6a130000, 0x00000000,			/* 298 - 664 */
 -	0xf1340001, 0x00000000,			/* 2a0 - 672 */
 -	0x72340000, 0x00000000,			/* 2a8 - 680 */
 -	0x80840000, 0xffffffe8,			/* 2b0 - 688 */
 -	0xf2600004, 0x00000000,			/* 2b8 - 696 */
 -	0x7e6c0400, 0x00000000,			/* 2c0 - 704 */
 -	0x7f6d0000, 0x00000000,			/* 2c8 - 712 */
 -	0x7f6e0000, 0x00000000,			/* 2d0 - 720 */
 -	0x7f6f0000, 0x00000000,			/* 2d8 - 728 */
 -	0x7e6a0100, 0x00000000,			/* 2e0 - 736 */
 -	0x726a0000, 0x00000000,			/* 2e8 - 744 */
 -	0x80840000, 0x00000028,			/* 2f0 - 752 */
 -	0x786cff00, 0x00000000,			/* 2f8 - 760 */
 -	0x786dff00, 0x00000000,			/* 300 - 768 */
 -	0x786eff00, 0x00000000,			/* 308 - 776 */
 -	0x786fff00, 0x00000000,			/* 310 - 784 */
 -	0x786a0000, 0x00000000,			/* 318 - 792 */
 -	0xe15c0004, 0x00000000,			/* 320 - 800 */
 -	0x7a5c0100, 0x00000000,			/* 328 - 808 */
 -	0xe25c0004, 0x00000000,			/* 330 - 816 */
 -	0x741a4000, 0x00000000,			/* 338 - 824 */
 -	0x72640000, 0x00000000,			/* 340 - 832 */
 -	0x6a100000, 0x00000000,			/* 348 - 840 */
 -	0x72650000, 0x00000000,			/* 350 - 848 */
 -	0x6a110000, 0x00000000,			/* 358 - 856 */
 -	0x72660000, 0x00000000,			/* 360 - 864 */
 -	0x6a120000, 0x00000000,			/* 368 - 872 */
 -	0x72670000, 0x00000000,			/* 370 - 880 */
 -	0x6a130000, 0x00000000,			/* 378 - 888 */
 -	0xf1100004, 0x00000000,			/* 380 - 896 */
 -	0x74100100, 0x00000000,			/* 388 - 904 */
 -	0x80840000, 0xfffffc68,			/* 390 - 912 */
 -	0x74100200, 0x00000000,			/* 398 - 920 */
 -	0x80840000, 0x00000018,			/* 3a0 - 928 */
 -	0xf1600004, 0x00000000,			/* 3a8 - 936 */
 -	0x47000028, 0xfffffc70,			/* 3b0 - 944 */
 -	0x9e030000, 0x0000ffff,			/* 3b8 - 952 */
 -	0x72640000, 0x00000000,			/* 3c0 - 960 */
 -	0x6a100000, 0x00000000,			/* 3c8 - 968 */
 -	0x72650000, 0x00000000,			/* 3d0 - 976 */
 -	0x6a110000, 0x00000000,			/* 3d8 - 984 */
 -	0x72660000, 0x00000000,			/* 3e0 - 992 */
 -	0x6a120000, 0x00000000,			/* 3e8 - 1000 */
 -	0x72670000, 0x00000000,			/* 3f0 - 1008 */
 -	0x6a130000, 0x00000000,			/* 3f8 - 1016 */
 -	0x7e680100, 0x00000000,			/* 400 - 1024 */
 -	0x7e640400, 0x00000000,			/* 408 - 1032 */
 -	0x7f650000, 0x00000000,			/* 410 - 1040 */
 -	0x7f660000, 0x00000000,			/* 418 - 1048 */
 -	0x7f670000, 0x00000000,			/* 420 - 1056 */
 -	0x72680000, 0x00000000,			/* 428 - 1064 */
 -	0x80840000, 0x00000028,			/* 430 - 1072 */
 -	0x7864ff00, 0x00000000,			/* 438 - 1080 */
 -	0x7865ff00, 0x00000000,			/* 440 - 1088 */
 -	0x7866ff00, 0x00000000,			/* 448 - 1096 */
 -	0x7867ff00, 0x00000000,			/* 450 - 1104 */
 -	0x78680000, 0x00000000,			/* 458 - 1112 */
 -	0xf15c0004, 0x00000000,			/* 460 - 1120 */
 -	0x7a5c0100, 0x00000000,			/* 468 - 1128 */
 -	0xf25c0004, 0x00000000,			/* 470 - 1136 */
 -	0x745c0200, 0x00000000,			/* 478 - 1144 */
 -	0x80840000, 0xfffffeb8,			/* 480 - 1152 */
 -	0x7c5cfc00, 0x00000000,			/* 488 - 1160 */
 -	0x88880000, 0x000001e8,			/* 490 - 1168 */
 -	0xe15c0004, 0x00000000,			/* 498 - 1176 */
 -	0x7a5c0200, 0x00000000,			/* 4a0 - 1184 */
 -	0xe25c0004, 0x00000000,			/* 4a8 - 1192 */
 -	0x80000000, 0x00000000,			/* 4b0 - 1200 */
 -	0x78350000, 0x00000000,			/* 4b8 - 1208 */
 -	0x7869ff00, 0x00000000,			/* 4c0 - 1216 */
 -	0x58000008, 0x00000000,			/* 4c8 - 1224 */
 -	0x60000040, 0x00000000,			/* 4d0 - 1232 */
 -	0x1e000048, 0x00000048,			/* 4d8 - 1240 */
 -	0x60000008, 0x00000000,			/* 4e0 - 1248 */
 -	0x80880000, 0xfffffd18,			/* 4e8 - 1256 */
 -	0x60000040, 0x00000000,			/* 4f0 - 1264 */
 -	0x7a601000, 0x00000000,			/* 4f8 - 1272 */
 -	0x60000008, 0x00000000,			/* 500 - 1280 */
 -	0x1f000030, 0x00000030,			/* 508 - 1288 */
 -	0x808c0000, 0xfffffd28,			/* 510 - 1296 */
 -	0x808c0002, 0xffffffd0,			/* 518 - 1304 */
 -	0x808c0001, 0x000001c8,			/* 520 - 1312 */
 -	0x98040004, 0x0000ff01,			/* 528 - 1320 */
 -	0x88880000, 0x00000190,			/* 530 - 1328 */
 -	0x74601000, 0x00000000,			/* 538 - 1336 */
 -	0x808c0000, 0xfffffdf8,			/* 540 - 1344 */
 -	0x98080000, 0x0000ff04,			/* 548 - 1352 */
 -	0x1a000050, 0x00000050,			/* 550 - 1360 */
 -	0x80880000, 0xfffffca8,			/* 558 - 1368 */
 -	0x1b000058, 0x00000058,			/* 560 - 1376 */
 -	0x6a690000, 0x00000000,			/* 568 - 1384 */
 -	0x80880000, 0xfffffc90,			/* 570 - 1392 */
 -	0x88880000, 0x000000b8,			/* 578 - 1400 */
 -	0x7a600800, 0x00000000,			/* 580 - 1408 */
 -	0x19000060, 0x00000060,			/* 588 - 1416 */
 -	0x7e350100, 0x00000000,			/* 590 - 1424 */
 -	0x7e100800, 0x00000000,			/* 598 - 1432 */
 -	0x7f110000, 0x00000000,			/* 5a0 - 1440 */
 -	0x7f120000, 0x00000000,			/* 5a8 - 1448 */
 -	0x7f130000, 0x00000000,			/* 5b0 - 1456 */
 -	0x818b0000, 0xffffffc8,			/* 5b8 - 1464 */
 -	0x88880000, 0x000000b8,			/* 5c0 - 1472 */
 -	0x7c60f700, 0x00000000,			/* 5c8 - 1480 */
 -	0x80880000, 0xfffffc30,			/* 5d0 - 1488 */
 -	0x88880000, 0x00000058,			/* 5d8 - 1496 */
 -	0x7a600800, 0x00000000,			/* 5e0 - 1504 */
 -	0x18000060, 0x00000060,			/* 5e8 - 1512 */
 -	0x7e350100, 0x00000000,			/* 5f0 - 1520 */
 -	0x7e100800, 0x00000000,			/* 5f8 - 1528 */
 -	0x7f110000, 0x00000000,			/* 600 - 1536 */
 -	0x7f120000, 0x00000000,			/* 608 - 1544 */
 -	0x7f130000, 0x00000000,			/* 610 - 1552 */
 -	0x808b0000, 0xffffffc8,			/* 618 - 1560 */
 -	0x88880000, 0x00000058,			/* 620 - 1568 */
 -	0x7c60f700, 0x00000000,			/* 628 - 1576 */
 -	0x80880000, 0xfffffbd0,			/* 630 - 1584 */
 -	0x72100000, 0x00000000,			/* 638 - 1592 */
 -	0x6a5c0000, 0x00000000,			/* 640 - 1600 */
 -	0x72110000, 0x00000000,			/* 648 - 1608 */
 -	0x6a5d0000, 0x00000000,			/* 650 - 1616 */
 -	0x72120000, 0x00000000,			/* 658 - 1624 */
 -	0x6a5e0000, 0x00000000,			/* 660 - 1632 */
 -	0x72130000, 0x00000000,			/* 668 - 1640 */
 -	0x6a5f0000, 0x00000000,			/* 670 - 1648 */
 -	0x90080000, 0x00000000,			/* 678 - 1656 */
 -	0x725c0000, 0x00000000,			/* 680 - 1664 */
 -	0x6a100000, 0x00000000,			/* 688 - 1672 */
 -	0x725d0000, 0x00000000,			/* 690 - 1680 */
 -	0x6a110000, 0x00000000,			/* 698 - 1688 */
 -	0x725e0000, 0x00000000,			/* 6a0 - 1696 */
 -	0x6a120000, 0x00000000,			/* 6a8 - 1704 */
 -	0x725f0000, 0x00000000,			/* 6b0 - 1712 */
 -	0x6a130000, 0x00000000,			/* 6b8 - 1720 */
 -	0x90080000, 0x00000000,			/* 6c0 - 1728 */
 -	0x7c027f00, 0x00000000,			/* 6c8 - 1736 */
 -	0x60000008, 0x00000000,			/* 6d0 - 1744 */
 -	0x60000040, 0x00000000,			/* 6d8 - 1752 */
 -	0x48000000, 0x00000000,			/* 6e0 - 1760 */
 +	0x88880000, 0x000004a8,			/* 240 - 576 */
 +	0x72350000, 0x00000000,			/* 248 - 584 */
 +	0x808c0000, 0x00000008,			/* 250 - 592 */
 +	0xf2340004, 0x00000000,			/* 258 - 600 */
 +	0x72690000, 0x00000000,			/* 260 - 608 */
 +	0x98040000, 0x0000ff00,			/* 268 - 616 */
 +	0x726c0000, 0x00000000,			/* 270 - 624 */
 +	0x6a100000, 0x00000000,			/* 278 - 632 */
 +	0x726d0000, 0x00000000,			/* 280 - 640 */
 +	0x6a110000, 0x00000000,			/* 288 - 648 */
 +	0x726e0000, 0x00000000,			/* 290 - 656 */
 +	0x6a120000, 0x00000000,			/* 298 - 664 */
 +	0x726f0000, 0x00000000,			/* 2a0 - 672 */
 +	0x6a130000, 0x00000000,			/* 2a8 - 680 */
 +	0xf1340001, 0x00000000,			/* 2b0 - 688 */
 +	0x72340000, 0x00000000,			/* 2b8 - 696 */
 +	0x80840000, 0xffffffe8,			/* 2c0 - 704 */
 +	0xf2600004, 0x00000000,			/* 2c8 - 712 */
 +	0x7e6c0400, 0x00000000,			/* 2d0 - 720 */
 +	0x7f6d0000, 0x00000000,			/* 2d8 - 728 */
 +	0x7f6e0000, 0x00000000,			/* 2e0 - 736 */
 +	0x7f6f0000, 0x00000000,			/* 2e8 - 744 */
 +	0x7e6a0100, 0x00000000,			/* 2f0 - 752 */
 +	0x726a0000, 0x00000000,			/* 2f8 - 760 */
 +	0x80840000, 0x00000028,			/* 300 - 768 */
 +	0x786cff00, 0x00000000,			/* 308 - 776 */
 +	0x786dff00, 0x00000000,			/* 310 - 784 */
 +	0x786eff00, 0x00000000,			/* 318 - 792 */
 +	0x786fff00, 0x00000000,			/* 320 - 800 */
 +	0x786a0000, 0x00000000,			/* 328 - 808 */
 +	0xe15c0004, 0x00000000,			/* 330 - 816 */
 +	0x7a5c0100, 0x00000000,			/* 338 - 824 */
 +	0xe25c0004, 0x00000000,			/* 340 - 832 */
 +	0x741a4000, 0x00000000,			/* 348 - 840 */
 +	0x72640000, 0x00000000,			/* 350 - 848 */
 +	0x6a100000, 0x00000000,			/* 358 - 856 */
 +	0x72650000, 0x00000000,			/* 360 - 864 */
 +	0x6a110000, 0x00000000,			/* 368 - 872 */
 +	0x72660000, 0x00000000,			/* 370 - 880 */
 +	0x6a120000, 0x00000000,			/* 378 - 888 */
 +	0x72670000, 0x00000000,			/* 380 - 896 */
 +	0x6a130000, 0x00000000,			/* 388 - 904 */
 +	0xf1100004, 0x00000000,			/* 390 - 912 */
 +	0x74100100, 0x00000000,			/* 398 - 920 */
 +	0x80840000, 0xfffffc58,			/* 3a0 - 928 */
 +	0x74100200, 0x00000000,			/* 3a8 - 936 */
 +	0x80840000, 0x00000018,			/* 3b0 - 944 */
 +	0xf1600004, 0x00000000,			/* 3b8 - 952 */
 +	0x47000028, 0xfffffc60,			/* 3c0 - 960 */
 +	0x9e030000, 0x0000ffff,			/* 3c8 - 968 */
 +	0x72640000, 0x00000000,			/* 3d0 - 976 */
 +	0x6a100000, 0x00000000,			/* 3d8 - 984 */
 +	0x72650000, 0x00000000,			/* 3e0 - 992 */
 +	0x6a110000, 0x00000000,			/* 3e8 - 1000 */
 +	0x72660000, 0x00000000,			/* 3f0 - 1008 */
 +	0x6a120000, 0x00000000,			/* 3f8 - 1016 */
 +	0x72670000, 0x00000000,			/* 400 - 1024 */
 +	0x6a130000, 0x00000000,			/* 408 - 1032 */
 +	0x7e680100, 0x00000000,			/* 410 - 1040 */
 +	0x7e640400, 0x00000000,			/* 418 - 1048 */
 +	0x7f650000, 0x00000000,			/* 420 - 1056 */
 +	0x7f660000, 0x00000000,			/* 428 - 1064 */
 +	0x7f670000, 0x00000000,			/* 430 - 1072 */
 +	0x72680000, 0x00000000,			/* 438 - 1080 */
 +	0x80840000, 0x00000028,			/* 440 - 1088 */
 +	0x7864ff00, 0x00000000,			/* 448 - 1096 */
 +	0x7865ff00, 0x00000000,			/* 450 - 1104 */
 +	0x7866ff00, 0x00000000,			/* 458 - 1112 */
 +	0x7867ff00, 0x00000000,			/* 460 - 1120 */
 +	0x78680000, 0x00000000,			/* 468 - 1128 */
 +	0xf15c0004, 0x00000000,			/* 470 - 1136 */
 +	0x7a5c0100, 0x00000000,			/* 478 - 1144 */
 +	0xf25c0004, 0x00000000,			/* 480 - 1152 */
 +	0x745c0200, 0x00000000,			/* 488 - 1160 */
 +	0x80840000, 0xfffffeb8,			/* 490 - 1168 */
 +	0x7c5cfc00, 0x00000000,			/* 498 - 1176 */
 +	0x88880000, 0x00000200,			/* 4a0 - 1184 */
 +	0xe15c0004, 0x00000000,			/* 4a8 - 1192 */
 +	0x7a5c0200, 0x00000000,			/* 4b0 - 1200 */
 +	0xe25c0004, 0x00000000,			/* 4b8 - 1208 */
 +	0x80000000, 0x00000000,			/* 4c0 - 1216 */
 +	0x78350000, 0x00000000,			/* 4c8 - 1224 */
 +	0x7869ff00, 0x00000000,			/* 4d0 - 1232 */
 +	0x58000008, 0x00000000,			/* 4d8 - 1240 */
 +	0x60000040, 0x00000000,			/* 4e0 - 1248 */
 +	0x1e000048, 0x00000048,			/* 4e8 - 1256 */
 +	0x60000008, 0x00000000,			/* 4f0 - 1264 */
 +	0x80880000, 0xfffffd08,			/* 4f8 - 1272 */
 +	0x60000040, 0x00000000,			/* 500 - 1280 */
 +	0x7a601000, 0x00000000,			/* 508 - 1288 */
 +	0x60000008, 0x00000000,			/* 510 - 1296 */
 +	0x1f000030, 0x00000030,			/* 518 - 1304 */
 +	0x808c0000, 0xfffffd18,			/* 520 - 1312 */
 +	0x808c0002, 0xffffffd0,			/* 528 - 1320 */
 +	0x808c0001, 0x000001e0,			/* 530 - 1328 */
 +	0x98040004, 0x0000ff01,			/* 538 - 1336 */
 +	0x88880000, 0x000001a8,			/* 540 - 1344 */
 +	0x74601000, 0x00000000,			/* 548 - 1352 */
 +	0x98040000, 0x0000ff04,			/* 550 - 1360 */
 +	0x72350000, 0x00000000,			/* 558 - 1368 */
 +	0x808c0000, 0xfffffde8,			/* 560 - 1376 */
 +	0xf2340004, 0x00000000,			/* 568 - 1384 */
 +	0x80880000, 0xfffffdd8,			/* 570 - 1392 */
 +	0x1a000050, 0x00000050,			/* 578 - 1400 */
 +	0x80880000, 0xfffffc80,			/* 580 - 1408 */
 +	0x1b000058, 0x00000058,			/* 588 - 1416 */
 +	0x6a690000, 0x00000000,			/* 590 - 1424 */
 +	0x80880000, 0xfffffc68,			/* 598 - 1432 */
 +	0x88880000, 0x000000b8,			/* 5a0 - 1440 */
 +	0x7a600800, 0x00000000,			/* 5a8 - 1448 */
 +	0x19000060, 0x00000060,			/* 5b0 - 1456 */
 +	0x7e350100, 0x00000000,			/* 5b8 - 1464 */
 +	0x7e100800, 0x00000000,			/* 5c0 - 1472 */
 +	0x7f110000, 0x00000000,			/* 5c8 - 1480 */
 +	0x7f120000, 0x00000000,			/* 5d0 - 1488 */
 +	0x7f130000, 0x00000000,			/* 5d8 - 1496 */
 +	0x818b0000, 0xffffffc8,			/* 5e0 - 1504 */
 +	0x88880000, 0x000000b8,			/* 5e8 - 1512 */
 +	0x7c60f700, 0x00000000,			/* 5f0 - 1520 */
 +	0x80880000, 0xfffffc08,			/* 5f8 - 1528 */
 +	0x88880000, 0x00000058,			/* 600 - 1536 */
 +	0x7a600800, 0x00000000,			/* 608 - 1544 */
 +	0x18000060, 0x00000060,			/* 610 - 1552 */
 +	0x7e350100, 0x00000000,			/* 618 - 1560 */
 +	0x7e100800, 0x00000000,			/* 620 - 1568 */
 +	0x7f110000, 0x00000000,			/* 628 - 1576 */
 +	0x7f120000, 0x00000000,			/* 630 - 1584 */
 +	0x7f130000, 0x00000000,			/* 638 - 1592 */
 +	0x808b0000, 0xffffffc8,			/* 640 - 1600 */
 +	0x88880000, 0x00000058,			/* 648 - 1608 */
 +	0x7c60f700, 0x00000000,			/* 650 - 1616 */
 +	0x80880000, 0xfffffba8,			/* 658 - 1624 */
 +	0x72100000, 0x00000000,			/* 660 - 1632 */
 +	0x6a5c0000, 0x00000000,			/* 668 - 1640 */
 +	0x72110000, 0x00000000,			/* 670 - 1648 */
 +	0x6a5d0000, 0x00000000,			/* 678 - 1656 */
 +	0x72120000, 0x00000000,			/* 680 - 1664 */
 +	0x6a5e0000, 0x00000000,			/* 688 - 1672 */
 +	0x72130000, 0x00000000,			/* 690 - 1680 */
 +	0x6a5f0000, 0x00000000,			/* 698 - 1688 */
 +	0x90080000, 0x00000000,			/* 6a0 - 1696 */
 +	0x725c0000, 0x00000000,			/* 6a8 - 1704 */
 +	0x6a100000, 0x00000000,			/* 6b0 - 1712 */
 +	0x725d0000, 0x00000000,			/* 6b8 - 1720 */
 +	0x6a110000, 0x00000000,			/* 6c0 - 1728 */
 +	0x725e0000, 0x00000000,			/* 6c8 - 1736 */
 +	0x6a120000, 0x00000000,			/* 6d0 - 1744 */
 +	0x725f0000, 0x00000000,			/* 6d8 - 1752 */
 +	0x6a130000, 0x00000000,			/* 6e0 - 1760 */
  	0x90080000, 0x00000000,			/* 6e8 - 1768 */
 -	0x60000040, 0x00000000,			/* 6f0 - 1776 */
 -	0x1f000038, 0x00000038,			/* 6f8 - 1784 */
 -	0x98080000, 0x0000ff02,			/* 700 - 1792 */
 -	0x60000040, 0x00000000,			/* 708 - 1800 */
 -	0x1f000040, 0x00000040,			/* 710 - 1808 */
 -	0x98080000, 0x0000ff03,			/* 718 - 1816 */
 +	0x7c027f00, 0x00000000,			/* 6f0 - 1776 */
 +	0x60000008, 0x00000000,			/* 6f8 - 1784 */
 +	0x60000040, 0x00000000,			/* 700 - 1792 */
 +	0x48000000, 0x00000000,			/* 708 - 1800 */
 +	0x90080000, 0x00000000,			/* 710 - 1808 */
 +	0x60000040, 0x00000000,			/* 718 - 1816 */
 +	0x1f000038, 0x00000038,			/* 720 - 1824 */
 +	0x98080000, 0x0000ff02,			/* 728 - 1832 */
 +	0x60000040, 0x00000000,			/* 730 - 1840 */
 +	0x1f000040, 0x00000040,			/* 738 - 1848 */
 +	0x98080000, 0x0000ff03,			/* 740 - 1856 */
  };
  
  const u_int32_t esiop_led_on[] = {
 @@ -274,29 +279,34 @@
  #define	A_cmd_slot_size	0x00000004
  #define	A_ndone_slots	0x00000100
  #define	A_ndone_slots_last	0x00000000
 -#define	Ent_cmdr0	0x00000438
 -#define	Ent_cmdr1	0x00000440
 -#define	Ent_cmdr2	0x00000448
 -#define	Ent_cmdr3	0x00000450
 -#define	Ent_doner0	0x000002f8
 -#define	Ent_doner1	0x00000300
 -#define	Ent_doner2	0x00000308
 -#define	Ent_doner3	0x00000310
 +#define	Ent_cmdr0	0x00000448
 +#define	Ent_cmdr1	0x00000450
 +#define	Ent_cmdr2	0x00000458
 +#define	Ent_cmdr3	0x00000460
 +#define	Ent_doner0	0x00000308
 +#define	Ent_doner1	0x00000310
 +#define	Ent_doner2	0x00000318
 +#define	Ent_doner3	0x00000320
  #define	Ent_reselect	0x00000028
 -#define	Ent_led_on1	0x000004b0
 +#define	Ent_led_on1	0x000004c0
  #define	Ent_led_on2	0x00000050
  #define	Ent_led_off	0x00000040
 -#define	Ent_status	0x00000560
 -#define	Ent_msgin	0x00000500
 +#define	Ent_status	0x00000588
 +#define	Ent_msgin	0x00000510
  #define	Ent_msgin_ack	0x00000200
 -#define	Ent_get_extmsgdata	0x00000708
 -#define	Ent_send_msgout	0x000004c8
 -#define	Ent_script_sched	0x00000340
 +#define	Ent_get_extmsgdata	0x00000730
 +#define	Ent_send_msgout	0x000004d8
 +#define	Ent_script_sched	0x00000350
  #define	Ent_load_targtable	0x000000a0
  #define	E_tlq_offset	0x00000000
  u_int32_t E_tlq_offset_Used[] = {
 -	0x00000093,
 -	0x000000eb,
 +	0x000000ef,
 +};
 +
 +#define	E_saved_offset_offset	0x00000000
 +u_int32_t E_saved_offset_offset_Used[] = {
 +	0x00000097,
 +	0x0000015b,
  };
  
  #define	E_abs_msgin2	0x00000000
 @@ -310,10 +320,10 @@
  u_int32_t E_abs_sem_Used[] = {
  	0x00000001,
  	0x00000009,
 -	0x000000c9,
  	0x000000cd,
 -	0x00000127,
 +	0x000000d1,
  	0x0000012b,
 +	0x0000012f,
  };
  
  #define	A_sem_done	0x00000001
 Index: microcode/siop/esiop.ss
 ===================================================================
 RCS file: /cvsroot/src/sys/dev/microcode/siop/esiop.ss,v
 retrieving revision 1.19
 diff -u -r1.19 esiop.ss
 --- microcode/siop/esiop.ss	27 Feb 2005 00:27:29 -0000	1.19
 +++ microcode/siop/esiop.ss	17 Nov 2005 17:23:29 -0000
 @@ -112,6 +112,7 @@
  ENTRY load_targtable;
  
  EXTERN tlq_offset;
 +EXTERN saved_offset_offset;
  EXTERN abs_msgin2;
  
  EXTERN abs_sem; a 32bits word used a semaphore between script and driver
 @@ -208,7 +209,11 @@
  
  handle_cmpl:
  	CALL REL(disconnect);
 -	STORE NOFLUSH SCRATCHA0, 4, from tlq_offset; save current offset
 +; update offset if we did some data transfer
 +	MOVE SCRATCHA1 TO SFBR;
 +	JUMP REL(handle_cmpl_noxfer), if 0x00;
 +	STORE NOFLUSH SCRATCHA0, 4, FROM saved_offset_offset;
 +handle_cmpl_noxfer:
  	MOVE SCRATCHE1 to SFBR;
  	INT int_done, IF NOT 0x00; if status is not "done", let host handle it
  	MOVE SCRATCHF0 to SFBR; load pointer in done ring
 @@ -344,9 +349,12 @@
  	CALL REL(disconnect)		; disconnect message
  ; if we didn't get sdp, no need to interrupt
  	MOVE SCRATCHC0 & f_c_sdp TO SFBR;
 +	INT int_disc, IF not 0x00;
 +; update offset if we did some data transfer
 +	MOVE SCRATCHA1 TO SFBR;
  	JUMP REL(script_sched), if 0x00;
 -; Ok, we need to save data pointers
 -	INT int_disc;
 +	STORE NOFLUSH SCRATCHA0, 4, FROM saved_offset_offset;
 +	JUMP REL(script_sched);
  
  cmdout:
          MOVE FROM t_cmd, WHEN CMD;
 Index: microcode/siop/siop.out
 ===================================================================
 RCS file: /cvsroot/src/sys/dev/microcode/siop/siop.out,v
 retrieving revision 1.15
 diff -u -r1.15 siop.out
 --- microcode/siop/siop.out	17 May 2004 18:38:02 -0000	1.15
 +++ microcode/siop/siop.out	17 Nov 2005 17:23:29 -0000
 @@ -1,19 +1,19 @@
 -/*	$NetBSD: siop.out,v 1.15 2004/05/17 18:38:02 bouyer Exp $	*/
 +/*	$NetBSD: ncr53cxxx.c,v 1.14 2005/02/11 06:21:22 simonb Exp $	*/
  /*
   *	DO NOT EDIT - this file is automatically generated.
 - *	created from siop.ss on Mon May 17 20:37:26 2004
 + *	created from siop.ss on Thu Nov 17 17:43:46 2005
   */
  const u_int32_t siop_script[] = {
  	0x78340000, 0x00000000,			/* 000 -   0 */
  	0x78350000, 0x00000000,			/* 008 -   8 */
  	0x72370000, 0x00000000,			/* 010 -  16 */
  	0x80840020, 0x00000318,			/* 018 -  24 */
 -	0x868b0000, 0x00000370,			/* 020 -  32 */
 +	0x868b0000, 0x00000380,			/* 020 -  32 */
  	0x878b0000, 0x000002f8,			/* 028 -  40 */
 -	0x808b0000, 0x000003f8,			/* 030 -  48 */
 -	0x818b0000, 0x00000390,			/* 038 -  56 */
 -	0x828b0000, 0x00000368,			/* 040 -  64 */
 -	0x838b0000, 0x00000370,			/* 048 -  72 */
 +	0x808b0000, 0x00000408,			/* 030 -  48 */
 +	0x818b0000, 0x000003a0,			/* 038 -  56 */
 +	0x828b0000, 0x00000378,			/* 040 -  64 */
 +	0x838b0000, 0x00000380,			/* 048 -  72 */
  	0x98080000, 0x0000ffff,			/* 050 -  80 */
  	0x741a4000, 0x00000000,			/* 058 -  88 */
  	0x980c0000, 0x0000ff83,			/* 060 -  96 */
 @@ -107,81 +107,83 @@
  	0x7a340100, 0x00000000,			/* 320 - 800 */
  	0x60000008, 0x00000000,			/* 328 - 808 */
  	0x1f000030, 0x00000030,			/* 330 - 816 */
 -	0x808c0000, 0x00000208,			/* 338 - 824 */
 +	0x808c0000, 0x00000218,			/* 338 - 824 */
  	0x808c0002, 0xffffffd0,			/* 340 - 832 */
 -	0x808c0001, 0x00000208,			/* 348 - 840 */
 +	0x808c0001, 0x00000218,			/* 348 - 840 */
  	0x98040004, 0x0000ff01,			/* 350 - 848 */
 -	0x88880000, 0x000001c0,			/* 358 - 856 */
 +	0x88880000, 0x000001d0,			/* 358 - 856 */
  	0x74340100, 0x00000000,			/* 360 - 864 */
 -	0x808c0000, 0xfffffd00,			/* 368 - 872 */
 -	0x98080000, 0x0000ff04,			/* 370 - 880 */
 -	0x60000040, 0x00000000,			/* 378 - 888 */
 -	0x80880000, 0xfffffc98,			/* 380 - 896 */
 -	0x58000008, 0x00000000,			/* 388 - 904 */
 -	0x60000040, 0x00000000,			/* 390 - 912 */
 -	0x1e000048, 0x00000048,			/* 398 - 920 */
 -	0x60000008, 0x00000000,			/* 3a0 - 928 */
 -	0x80880000, 0xfffffc70,			/* 3a8 - 936 */
 -	0x1a000050, 0x00000050,			/* 3b0 - 944 */
 +	0x98040000, 0x0000ff04,			/* 368 - 872 */
 +	0x72350000, 0x00000000,			/* 370 - 880 */
 +	0x808c0000, 0xfffffcf0,			/* 378 - 888 */
 +	0x98080000, 0x0000ff05,			/* 380 - 896 */
 +	0x60000040, 0x00000000,			/* 388 - 904 */
 +	0x80880000, 0xfffffc88,			/* 390 - 912 */
 +	0x58000008, 0x00000000,			/* 398 - 920 */
 +	0x60000040, 0x00000000,			/* 3a0 - 928 */
 +	0x1e000048, 0x00000048,			/* 3a8 - 936 */
 +	0x60000008, 0x00000000,			/* 3b0 - 944 */
  	0x80880000, 0xfffffc60,			/* 3b8 - 952 */
 -	0x1b000058, 0x00000058,			/* 3c0 - 960 */
 +	0x1a000050, 0x00000050,			/* 3c0 - 960 */
  	0x80880000, 0xfffffc50,			/* 3c8 - 968 */
 -	0x88880000, 0x000000b8,			/* 3d0 - 976 */
 -	0x7a340200, 0x00000000,			/* 3d8 - 984 */
 -	0x19000060, 0x00000060,			/* 3e0 - 992 */
 -	0x7e350100, 0x00000000,			/* 3e8 - 1000 */
 -	0x7e100800, 0x00000000,			/* 3f0 - 1008 */
 -	0x7f110000, 0x00000000,			/* 3f8 - 1016 */
 -	0x7f120000, 0x00000000,			/* 400 - 1024 */
 -	0x7f130000, 0x00000000,			/* 408 - 1032 */
 -	0x818b0000, 0xffffffc8,			/* 410 - 1040 */
 -	0x88880000, 0x000000b8,			/* 418 - 1048 */
 -	0x7c34fd00, 0x00000000,			/* 420 - 1056 */
 -	0x80880000, 0xfffffbf0,			/* 428 - 1064 */
 -	0x88880000, 0x00000058,			/* 430 - 1072 */
 -	0x7a340200, 0x00000000,			/* 438 - 1080 */
 -	0x18000060, 0x00000060,			/* 440 - 1088 */
 -	0x7e350100, 0x00000000,			/* 448 - 1096 */
 -	0x7e100800, 0x00000000,			/* 450 - 1104 */
 -	0x7f110000, 0x00000000,			/* 458 - 1112 */
 -	0x7f120000, 0x00000000,			/* 460 - 1120 */
 -	0x7f130000, 0x00000000,			/* 468 - 1128 */
 -	0x808b0000, 0xffffffc8,			/* 470 - 1136 */
 -	0x88880000, 0x00000058,			/* 478 - 1144 */
 -	0x7c34fd00, 0x00000000,			/* 480 - 1152 */
 -	0x80880000, 0xfffffb90,			/* 488 - 1160 */
 -	0x72100000, 0x00000000,			/* 490 - 1168 */
 -	0x6a5c0000, 0x00000000,			/* 498 - 1176 */
 -	0x72110000, 0x00000000,			/* 4a0 - 1184 */
 -	0x6a5d0000, 0x00000000,			/* 4a8 - 1192 */
 -	0x72120000, 0x00000000,			/* 4b0 - 1200 */
 -	0x6a5e0000, 0x00000000,			/* 4b8 - 1208 */
 -	0x72130000, 0x00000000,			/* 4c0 - 1216 */
 -	0x6a5f0000, 0x00000000,			/* 4c8 - 1224 */
 -	0x90080000, 0x00000000,			/* 4d0 - 1232 */
 -	0x725c0000, 0x00000000,			/* 4d8 - 1240 */
 -	0x6a100000, 0x00000000,			/* 4e0 - 1248 */
 -	0x725d0000, 0x00000000,			/* 4e8 - 1256 */
 -	0x6a110000, 0x00000000,			/* 4f0 - 1264 */
 -	0x725e0000, 0x00000000,			/* 4f8 - 1272 */
 -	0x6a120000, 0x00000000,			/* 500 - 1280 */
 -	0x725f0000, 0x00000000,			/* 508 - 1288 */
 -	0x6a130000, 0x00000000,			/* 510 - 1296 */
 -	0x90080000, 0x00000000,			/* 518 - 1304 */
 -	0x7c027f00, 0x00000000,			/* 520 - 1312 */
 -	0x60000008, 0x00000000,			/* 528 - 1320 */
 -	0x60000040, 0x00000000,			/* 530 - 1328 */
 -	0x48000000, 0x00000000,			/* 538 - 1336 */
 -	0x90080000, 0x00000000,			/* 540 - 1344 */
 -	0x88880000, 0xffffffd0,			/* 548 - 1352 */
 -	0x98080000, 0x0000ff00,			/* 550 - 1360 */
 -	0x60000040, 0x00000000,			/* 558 - 1368 */
 -	0x1f000038, 0x00000038,			/* 560 - 1376 */
 -	0x98080000, 0x0000ff02,			/* 568 - 1384 */
 -	0x60000040, 0x00000000,			/* 570 - 1392 */
 -	0x1f000040, 0x00000040,			/* 578 - 1400 */
 -	0x98080000, 0x0000ff03,			/* 580 - 1408 */
 -	0x80000000, 0x00000000,			/* 588 - 1416 */
 +	0x1b000058, 0x00000058,			/* 3d0 - 976 */
 +	0x80880000, 0xfffffc40,			/* 3d8 - 984 */
 +	0x88880000, 0x000000b8,			/* 3e0 - 992 */
 +	0x7a340200, 0x00000000,			/* 3e8 - 1000 */
 +	0x19000060, 0x00000060,			/* 3f0 - 1008 */
 +	0x7e350100, 0x00000000,			/* 3f8 - 1016 */
 +	0x7e100800, 0x00000000,			/* 400 - 1024 */
 +	0x7f110000, 0x00000000,			/* 408 - 1032 */
 +	0x7f120000, 0x00000000,			/* 410 - 1040 */
 +	0x7f130000, 0x00000000,			/* 418 - 1048 */
 +	0x818b0000, 0xffffffc8,			/* 420 - 1056 */
 +	0x88880000, 0x000000b8,			/* 428 - 1064 */
 +	0x7c34fd00, 0x00000000,			/* 430 - 1072 */
 +	0x80880000, 0xfffffbe0,			/* 438 - 1080 */
 +	0x88880000, 0x00000058,			/* 440 - 1088 */
 +	0x7a340200, 0x00000000,			/* 448 - 1096 */
 +	0x18000060, 0x00000060,			/* 450 - 1104 */
 +	0x7e350100, 0x00000000,			/* 458 - 1112 */
 +	0x7e100800, 0x00000000,			/* 460 - 1120 */
 +	0x7f110000, 0x00000000,			/* 468 - 1128 */
 +	0x7f120000, 0x00000000,			/* 470 - 1136 */
 +	0x7f130000, 0x00000000,			/* 478 - 1144 */
 +	0x808b0000, 0xffffffc8,			/* 480 - 1152 */
 +	0x88880000, 0x00000058,			/* 488 - 1160 */
 +	0x7c34fd00, 0x00000000,			/* 490 - 1168 */
 +	0x80880000, 0xfffffb80,			/* 498 - 1176 */
 +	0x72100000, 0x00000000,			/* 4a0 - 1184 */
 +	0x6a5c0000, 0x00000000,			/* 4a8 - 1192 */
 +	0x72110000, 0x00000000,			/* 4b0 - 1200 */
 +	0x6a5d0000, 0x00000000,			/* 4b8 - 1208 */
 +	0x72120000, 0x00000000,			/* 4c0 - 1216 */
 +	0x6a5e0000, 0x00000000,			/* 4c8 - 1224 */
 +	0x72130000, 0x00000000,			/* 4d0 - 1232 */
 +	0x6a5f0000, 0x00000000,			/* 4d8 - 1240 */
 +	0x90080000, 0x00000000,			/* 4e0 - 1248 */
 +	0x725c0000, 0x00000000,			/* 4e8 - 1256 */
 +	0x6a100000, 0x00000000,			/* 4f0 - 1264 */
 +	0x725d0000, 0x00000000,			/* 4f8 - 1272 */
 +	0x6a110000, 0x00000000,			/* 500 - 1280 */
 +	0x725e0000, 0x00000000,			/* 508 - 1288 */
 +	0x6a120000, 0x00000000,			/* 510 - 1296 */
 +	0x725f0000, 0x00000000,			/* 518 - 1304 */
 +	0x6a130000, 0x00000000,			/* 520 - 1312 */
 +	0x90080000, 0x00000000,			/* 528 - 1320 */
 +	0x7c027f00, 0x00000000,			/* 530 - 1328 */
 +	0x60000008, 0x00000000,			/* 538 - 1336 */
 +	0x60000040, 0x00000000,			/* 540 - 1344 */
 +	0x48000000, 0x00000000,			/* 548 - 1352 */
 +	0x90080000, 0x00000000,			/* 550 - 1360 */
 +	0x88880000, 0xffffffd0,			/* 558 - 1368 */
 +	0x98080000, 0x0000ff00,			/* 560 - 1376 */
 +	0x60000040, 0x00000000,			/* 568 - 1384 */
 +	0x1f000038, 0x00000038,			/* 570 - 1392 */
 +	0x98080000, 0x0000ff02,			/* 578 - 1400 */
 +	0x60000040, 0x00000000,			/* 580 - 1408 */
 +	0x1f000040, 0x00000040,			/* 588 - 1416 */
 +	0x98080000, 0x0000ff03,			/* 590 - 1424 */
 +	0x80000000, 0x00000000,			/* 598 - 1432 */
  };
  
  const u_int32_t lun_switch[] = {
 @@ -250,6 +252,7 @@
  #define	A_int_extmsgin	0x0000ff02
  #define	A_int_extmsgdata	0x0000ff03
  #define	A_int_disc	0x0000ff04
 +#define	A_int_saveoffset	0x0000ff05
  #define	A_int_reseltarg	0x0000ff80
  #define	A_int_resellun	0x0000ff81
  #define	A_int_reseltag	0x0000ff82
 @@ -259,24 +262,24 @@
  #define	A_flag_data	0x00000002
  #define	A_flag_data_mask	0x000000fd
  #define	Ent_waitphase	0x00000020
 -#define	Ent_send_msgout	0x00000388
 -#define	Ent_msgout	0x00000398
 +#define	Ent_send_msgout	0x00000398
 +#define	Ent_msgout	0x000003a8
  #define	Ent_msgin	0x00000328
  #define	Ent_handle_msgin	0x00000338
 -#define	Ent_msgin_ack	0x00000378
 -#define	Ent_dataout	0x00000430
 -#define	Ent_datain	0x000003d0
 -#define	Ent_cmdout	0x000003b0
 -#define	Ent_status	0x000003c0
 -#define	Ent_disconnect	0x00000520
 +#define	Ent_msgin_ack	0x00000388
 +#define	Ent_dataout	0x00000440
 +#define	Ent_datain	0x000003e0
 +#define	Ent_cmdout	0x000003c0
 +#define	Ent_status	0x000003d0
 +#define	Ent_disconnect	0x00000530
  #define	Ent_reselect	0x000001e0
  #define	Ent_reselected	0x00000000
 -#define	Ent_selected	0x00000378
 +#define	Ent_selected	0x00000388
  #define	Ent_script_sched	0x00000070
  #define	Ent_script_sched_slot0	0x000000a0
 -#define	Ent_get_extmsgdata	0x00000570
 +#define	Ent_get_extmsgdata	0x00000580
  #define	Ent_resel_targ0	0x00000238
 -#define	Ent_msgin_space	0x00000588
 +#define	Ent_msgin_space	0x00000598
  #define	Ent_lunsw_return	0x000002b8
  #define	Ent_led_on1	0x00000068
  #define	Ent_led_on2	0x00000220
 Index: microcode/siop/siop.ss
 ===================================================================
 RCS file: /cvsroot/src/sys/dev/microcode/siop/siop.ss,v
 retrieving revision 1.19
 diff -u -r1.19 siop.ss
 --- microcode/siop/siop.ss	27 Feb 2005 00:27:29 -0000	1.19
 +++ microcode/siop/siop.ss	17 Nov 2005 17:23:29 -0000
 @@ -47,6 +47,7 @@
  ABSOLUTE int_extmsgin	= 0xff02;
  ABSOLUTE int_extmsgdata	= 0xff03;
  ABSOLUTE int_disc	= 0xff04;
 +ABSOLUTE int_saveoffset	= 0xff05;
  ; interrupts that don't have a valid DSA
  ABSOLUTE int_reseltarg	= 0xff80;
  ABSOLUTE int_resellun	= 0xff81;
 @@ -262,9 +263,12 @@
  	CALL REL(disconnect)                  ; disconnect message;
  ; if we didn't get sdp, no need to interrupt
  	MOVE SCRATCHA0 & flag_sdp TO SFBR;
 +	INT int_disc, IF not 0x00;
 +; update offset if we did some data transfer
 +	MOVE SCRATCHA1 TO SFBR;
  	JUMP REL(script_sched), if 0x00;
 -; Ok, we need to save data pointers
 -	INT int_disc;
 +	INT int_saveoffset;
 +
  msgin_ack:
  selected:
  	CLEAR ACK;
 
 --OgqxwSJOaUobr8KG
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: attachment; filename=diff-2
 
 Index: ic/esiop.c
 ===================================================================
 RCS file: /cvsroot/src/sys/dev/ic/esiop.c,v
 retrieving revision 1.27.4.5
 diff -u -r1.27.4.5 esiop.c
 --- ic/esiop.c	16 May 2005 05:15:48 -0000	1.27.4.5
 +++ ic/esiop.c	17 Nov 2005 17:28:53 -0000
 @@ -253,6 +253,14 @@
  			    sizeof(struct siop_common_xfer));
  		}
  		for (j = 0; j <
 +		    (sizeof(E_saved_offset_offset_Used) /
 +		     sizeof(E_saved_offset_offset_Used[0]));
 +		    j++) {
 +			bus_space_write_4(sc->sc_c.sc_ramt, sc->sc_c.sc_ramh,
 +			    E_saved_offset_offset_Used[j] * 4,
 +			    sizeof(struct siop_common_xfer) + 4);
 +		}
 +		for (j = 0; j <
  		    (sizeof(E_abs_msgin2_Used) / sizeof(E_abs_msgin2_Used[0]));
  		    j++) {
  			bus_space_write_4(sc->sc_c.sc_ramt, sc->sc_c.sc_ramh,
 @@ -291,6 +299,13 @@
  			    htole32(sizeof(struct siop_common_xfer));
  		}
  		for (j = 0; j <
 +		    (sizeof(E_saved_offset_offset_Used) /
 +		     sizeof(E_saved_offset_offset_Used[0]));
 +		    j++) {
 +			sc->sc_c.sc_script[E_saved_offset_offset_Used[j]] =
 +			    htole32(sizeof(struct siop_common_xfer) + 4);
 +		}
 +		for (j = 0; j <
  		    (sizeof(E_abs_msgin2_Used) / sizeof(E_abs_msgin2_Used[0]));
  		    j++) {
  			sc->sc_c.sc_script[E_abs_msgin2_Used[j]] =
 @@ -1072,6 +1087,9 @@
  			printf("disconnect offset %d\n", offset);
  #endif
  			siop_sdp(&esiop_cmd->cmd_c, offset);
 +			/* we start again with no offset */
 +			ESIOP_XFER(esiop_cmd, saved_offset) =
 +			    htole32(SIOP_NOOFFSET);
  			esiop_table_sync(esiop_cmd,
  			    BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
  			CALL_SCRIPT(Ent_script_sched);
 @@ -1126,6 +1144,17 @@
  		esiop_lun->active = NULL;
  	offset = bus_space_read_1(sc->sc_c.sc_rt, sc->sc_c.sc_rh,
  	    SIOP_SCRATCHA + 1);
 +	/*
 +	 * if we got a disconnect between the last data phase
 +	 * and the status phase, offset will be 0. In this
 +	 * case, cmd_tables->saved_offset will have the proper value 
 +	 * if it got updated by the controller
 +	 */
 +	if (offset == 0 &&
 +	    ESIOP_XFER(esiop_cmd, saved_offset) != htole32(SIOP_NOOFFSET))
 +		offset =
 +		    (le32toh(ESIOP_XFER(esiop_cmd, saved_offset)) >> 8) & 0xff;
 +
  	esiop_scsicmd_end(esiop_cmd, offset);
  	if (freetarget && esiop_target->target_c.status == TARST_PROBING)
  		esiop_del_dev(sc, target, lun);
 @@ -1214,7 +1243,7 @@
  	u_int32_t slot;
  	int needsync = 0;
  	int status;
 -	u_int32_t sem;
 +	u_int32_t sem, offset;
  
  	esiop_script_sync(sc, BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE);
  	sem = esiop_script_read(sc, sc->sc_semoffset);
 @@ -1295,10 +1324,15 @@
  		esiop_lun->tactive[tag] = NULL;
  	else
  		esiop_lun->active = NULL;
 -	/* scratcha was saved in tlq by script. fetch offset from it */
 -	esiop_scsicmd_end(esiop_cmd,
 -	    (le32toh(((struct esiop_xfer *)esiop_cmd->cmd_tables)->tlq) >> 8)
 -	    & 0xff);
 +	/*
 +	 * scratcha was eventually saved in saved_offset by script.
 +	 * fetch offset from it
 +	 */
 +	offset = 0;
 +	if (ESIOP_XFER(esiop_cmd, saved_offset) != htole32(SIOP_NOOFFSET))
 +		offset =
 +		    (le32toh(ESIOP_XFER(esiop_cmd, saved_offset)) >> 8) & 0xff;
 +	esiop_scsicmd_end(esiop_cmd, offset);
  	goto next;
  }
  
 @@ -1604,14 +1638,13 @@
  		else
  			esiop_cmd->cmd_c.tag = -1;
  		siop_setuptables(&esiop_cmd->cmd_c);
 -		((struct esiop_xfer *)esiop_cmd->cmd_tables)->tlq =
 -		    htole32(A_f_c_target | A_f_c_lun);
 -		((struct esiop_xfer *)esiop_cmd->cmd_tables)->tlq |=
 +		ESIOP_XFER(esiop_cmd, saved_offset) = htole32(SIOP_NOOFFSET);
 +		ESIOP_XFER(esiop_cmd, tlq) = htole32(A_f_c_target | A_f_c_lun);
 +		ESIOP_XFER(esiop_cmd, tlq) |=
  		    htole32((target << 8) | (lun << 16));
  		if (esiop_cmd->cmd_c.flags & CMDFL_TAG) {
 -			((struct esiop_xfer *)esiop_cmd->cmd_tables)->tlq |=
 -			    htole32(A_f_c_tag);
 -			((struct esiop_xfer *)esiop_cmd->cmd_tables)->tlq |=
 +			ESIOP_XFER(esiop_cmd, tlq) |= htole32(A_f_c_tag);
 +			ESIOP_XFER(esiop_cmd, tlq) |=
  			    htole32(esiop_cmd->cmd_c.tag << 24);
  		}
  
 @@ -1959,10 +1992,12 @@
  		TAILQ_INSERT_TAIL(&sc->free_list, &newcbd->cmds[i], next);
  		splx(s);
  #ifdef SIOP_DEBUG
 -		printf("tables[%d]: in=0x%x out=0x%x status=0x%x\n", i,
 +		printf("tables[%d]: in=0x%x out=0x%x status=0x%x "
 +		    "offset=0x%x\n", i,
  		    le32toh(newcbd->cmds[i].cmd_tables->t_msgin.addr),
  		    le32toh(newcbd->cmds[i].cmd_tables->t_msgout.addr),
 -		    le32toh(newcbd->cmds[i].cmd_tables->t_status.addr));
 +		    le32toh(newcbd->cmds[i].cmd_tables->t_status.addr,
 +		    le32toh(newcbd->cmds[i].cmd_tables->t_offset.addr));
  #endif
  	}
  	s = splbio();
 Index: ic/esiopvar.h
 ===================================================================
 RCS file: /cvsroot/src/sys/dev/ic/esiopvar.h,v
 retrieving revision 1.8.4.1
 diff -u -r1.8.4.1 esiopvar.h
 --- ic/esiopvar.h	11 May 2005 03:19:58 -0000	1.8.4.1
 +++ ic/esiopvar.h	17 Nov 2005 17:28:53 -0000
 @@ -53,9 +53,11 @@
  struct esiop_xfer {
  	struct siop_common_xfer siop_tables;
  	u_int32_t tlq; /* target/lun/tag loaded in scratchC by script */
 -		      /* will also containt scratcha at end of command */
 +	u_int32_t saved_offset;/* contains scratchA if script saved an offset */
  } __attribute__((__packed__));
  
 +#define ESIOP_XFER(cmd, m) (((struct esiop_xfer *)((cmd)->cmd_tables))->m)
 +
  /*
   * This describes a command handled by the SCSI controller
   * These are chained in either a free list or a active list
 Index: ic/siop.c
 ===================================================================
 RCS file: /cvsroot/src/sys/dev/ic/siop.c,v
 retrieving revision 1.72.4.4
 diff -u -r1.72.4.4 siop.c
 --- ic/siop.c	11 May 2005 04:06:08 -0000	1.72.4.4
 +++ ic/siop.c	17 Nov 2005 17:28:53 -0000
 @@ -103,6 +103,7 @@
  static int siop_stat_intr = 0;
  static int siop_stat_intr_shortxfer = 0;
  static int siop_stat_intr_sdp = 0;
 +static int siop_stat_intr_saveoffset = 0;
  static int siop_stat_intr_done = 0;
  static int siop_stat_intr_xferdisc = 0;
  static int siop_stat_intr_lunresel = 0;
 @@ -911,10 +912,22 @@
  			printf("disconnect offset %d\n", offset);
  #endif
  			siop_sdp(&siop_cmd->cmd_c, offset);
 +			/* we start again with no offset */
 +			siop_cmd->saved_offset = SIOP_NOOFFSET;
  			siop_table_sync(siop_cmd,
  			    BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
  			CALL_SCRIPT(Ent_script_sched);
  			return 1;
 +		case A_int_saveoffset:
 +			INCSTAT(siop_stat_intr_saveoffset);
 +			offset = bus_space_read_1(sc->sc_c.sc_rt,
 +			    sc->sc_c.sc_rh, SIOP_SCRATCHA + 1);
 +#ifdef SIOP_DEBUG_DR
 +			printf("saveoffset offset %d\n", offset);
 +#endif
 +			siop_cmd->saved_offset = offset;
 +			CALL_SCRIPT(Ent_script_sched);
 +			return 1;
  		case A_int_resfail:
  			printf("reselect failed\n");
  			CALL_SCRIPT(Ent_script_sched);
 @@ -939,6 +952,15 @@
  			/* update resid.  */
  			offset = bus_space_read_1(sc->sc_c.sc_rt,
  			    sc->sc_c.sc_rh, SIOP_SCRATCHA + 1);
 +			/*
 +			 * if we got a disconnect between the last data phase
 +			 * and the status phase, offset will be 0. In this
 +			 * case, siop_cmd->saved_offset will have the proper
 +			 * value if it got updated by the controller
 +			 */
 +			if (offset == 0 && 
 +			    siop_cmd->saved_offset != SIOP_NOOFFSET)
 +				offset = siop_cmd->saved_offset;
  			siop_update_resid(&siop_cmd->cmd_c, offset);
  			siop_cmd->cmd_c.status = CMDST_DONE;
  			goto end;
 @@ -1348,6 +1370,7 @@
  			siop_cmd->cmd_c.tag = 0;
  		}
  		siop_setuptables(&siop_cmd->cmd_c);
 +		siop_cmd->saved_offset = SIOP_NOOFFSET;
  		siop_table_sync(siop_cmd,
  		    BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
  		siop_start(sc, siop_cmd);
 @@ -1717,10 +1740,12 @@
  		TAILQ_INSERT_TAIL(&sc->free_list, &newcbd->cmds[i], next);
  		splx(s);
  #ifdef SIOP_DEBUG
 -		printf("tables[%d]: in=0x%x out=0x%x status=0x%x\n", i,
 +		printf("tables[%d]: in=0x%x out=0x%x status=0x%x "
 +		    "offset=0x%x\n", i,
  		    le32toh(newcbd->cmds[i].cmd_tables->t_msgin.addr),
  		    le32toh(newcbd->cmds[i].cmd_tables->t_msgout.addr),
 -		    le32toh(newcbd->cmds[i].cmd_tables->t_status.addr));
 +		    le32toh(newcbd->cmds[i].cmd_tables->t_status.addr),
 +		    le32toh(newcbd->cmds[i].cmd_tables->t_offset.addr));
  #endif
  	}
  	s = splbio();
 @@ -2002,6 +2027,7 @@
  	printf("siop_stat_intr_shortxfer %d\n", siop_stat_intr_shortxfer);
  	printf("siop_stat_intr_xferdisc %d\n", siop_stat_intr_xferdisc);
  	printf("siop_stat_intr_sdp %d\n", siop_stat_intr_sdp);
 +	printf("siop_stat_intr_saveoffset %d\n", siop_stat_intr_saveoffset);
  	printf("siop_stat_intr_done %d\n", siop_stat_intr_done);
  	printf("siop_stat_intr_lunresel %d\n", siop_stat_intr_lunresel);
  	printf("siop_stat_intr_qfull %d\n", siop_stat_intr_qfull);
 Index: ic/siopvar.h
 ===================================================================
 RCS file: /cvsroot/src/sys/dev/ic/siopvar.h,v
 retrieving revision 1.19
 diff -u -r1.19 siopvar.h
 --- ic/siopvar.h	2 Nov 2003 11:07:46 -0000	1.19
 +++ ic/siopvar.h	17 Nov 2005 17:28:53 -0000
 @@ -56,6 +56,7 @@
  	struct siop_common_cmd cmd_c;
  	struct siop_cbd *siop_cbdp; /* pointer to our siop_cbd */
  	int reselslot;
 +	u_int32_t saved_offset; /* offset in table after disc without sdp */
  };
  #define cmd_tables cmd_c.siop_tables
  
 Index: ic/siopvar_common.h
 ===================================================================
 RCS file: /cvsroot/src/sys/dev/ic/siopvar_common.h,v
 retrieving revision 1.27.4.2
 diff -u -r1.27.4.2 siopvar_common.h
 --- ic/siopvar_common.h	11 May 2005 03:59:14 -0000	1.27.4.2
 +++ ic/siopvar_common.h	17 Nov 2005 17:28:53 -0000
 @@ -56,7 +56,7 @@
  	u_int8_t msg_out[16];	/* 0 */
  	u_int8_t msg_in[16];	/* 16 */
  	u_int32_t status;	/* 32 */
 -	u_int32_t pad1;		/* 36 */
 +	u_int32_t pad1; 	/* 36 */
  	u_int32_t id;		/* 40 */
  	u_int32_t pad2;		/* 44 */
  	scr_table_t t_msgin;	/* 48 */
 @@ -72,6 +72,9 @@
  #define SCSI_SIOP_NOCHECK	0xfe	/* don't check the scsi status */
  #define SCSI_SIOP_NOSTATUS	0xff	/* device didn't report status */
  
 +/* offset is initialised to SIOP_NOOFFSET, used to check if it was updated */
 +#define SIOP_NOOFFSET 0xffffffff
 +
  /*
   * This describes a command handled by the SCSI controller
   */
 Index: microcode/siop/esiop.out
 ===================================================================
 RCS file: /cvsroot/src/sys/dev/microcode/siop/esiop.out,v
 retrieving revision 1.11.4.2
 diff -u -r1.11.4.2 esiop.out
 --- microcode/siop/esiop.out	11 May 2005 03:50:26 -0000	1.11.4.2
 +++ microcode/siop/esiop.out	17 Nov 2005 17:28:53 -0000
 @@ -1,7 +1,7 @@
 -/*	$NetBSD: esiop.out,v 1.11.4.2 2005/05/11 03:50:26 snj Exp $	*/
 +/*	$NetBSD: ncr53cxxx.c,v 1.12.2.1 2004/05/20 09:41:26 tron Exp $	*/
  /*
   *	DO NOT EDIT - this file is automatically generated.
 - *	created from esiop.ss on Tue May 10 12:49:57 2005
 + *	created from esiop.ss on Thu Nov 17 18:28:34 2005
   */
  const u_int32_t esiop_script[] = {
  	0xe15c0004, 0x00000000,			/* 000 -   0 */
 @@ -13,7 +13,7 @@
  	0x78600000, 0x00000000,			/* 030 -  48 */
  	0x7869ff00, 0x00000000,			/* 038 -  56 */
  	0x80000000, 0x00000000,			/* 040 -  64 */
 -	0x54000000, 0x000002e8,			/* 048 -  72 */
 +	0x54000000, 0x000002f8,			/* 048 -  72 */
  	0x80000000, 0x00000000,			/* 050 -  80 */
  	0x740a0f00, 0x00000000,			/* 058 -  88 */
  	0x6a610000, 0x00000000,			/* 060 -  96 */
 @@ -46,12 +46,12 @@
  	0x87830000, 0x000000c8,			/* 138 - 312 */
  	0x0f000001, 0x00000000,			/* 140 - 320 */
  	0x60000040, 0x00000000,			/* 148 - 328 */
 -	0x80840020, 0x000003b8,			/* 150 - 336 */
 +	0x80840020, 0x000003c8,			/* 150 - 336 */
  	0x0f000001, 0x00000000,			/* 158 - 344 */
  	0x6a360000, 0x00000000,			/* 160 - 352 */
  	0x6a630000, 0x00000000,			/* 168 - 360 */
  	0x7a600400, 0x00000000,			/* 170 - 368 */
 -	0x88880000, 0x00000500,			/* 178 - 376 */
 +	0x88880000, 0x00000528,			/* 178 - 376 */
  	0x78370000, 0x00000000,			/* 180 - 384 */
  	0x60000400, 0x00000000,			/* 188 - 392 */
  	0x79360000, 0x00000000,			/* 190 - 400 */
 @@ -69,169 +69,174 @@
  	0x7f130000, 0x00000000,			/* 1f0 - 496 */
  	0xf1100004, 0x00000000,			/* 1f8 - 504 */
  	0x60000040, 0x00000000,			/* 200 - 512 */
 -	0x868b0000, 0x000002c8,			/* 208 - 520 */
 -	0x878b0000, 0x000002e8,			/* 210 - 528 */
 -	0x808b0000, 0x000003b8,			/* 218 - 536 */
 -	0x818b0000, 0x00000350,			/* 220 - 544 */
 -	0x828b0000, 0x00000320,			/* 228 - 552 */
 -	0x838b0000, 0x00000328,			/* 230 - 560 */
 +	0x868b0000, 0x000002d8,			/* 208 - 520 */
 +	0x878b0000, 0x000002f8,			/* 210 - 528 */
 +	0x808b0000, 0x000003e0,			/* 218 - 536 */
 +	0x818b0000, 0x00000378,			/* 220 - 544 */
 +	0x828b0000, 0x00000348,			/* 228 - 552 */
 +	0x838b0000, 0x00000350,			/* 230 - 560 */
  	0x98080000, 0x0000ffff,			/* 238 - 568 */
 -	0x88880000, 0x00000480,			/* 240 - 576 */
 -	0xf2340004, 0x00000000,			/* 248 - 584 */
 -	0x72690000, 0x00000000,			/* 250 - 592 */
 -	0x98040000, 0x0000ff00,			/* 258 - 600 */
 -	0x726c0000, 0x00000000,			/* 260 - 608 */
 -	0x6a100000, 0x00000000,			/* 268 - 616 */
 -	0x726d0000, 0x00000000,			/* 270 - 624 */
 -	0x6a110000, 0x00000000,			/* 278 - 632 */
 -	0x726e0000, 0x00000000,			/* 280 - 640 */
 -	0x6a120000, 0x00000000,			/* 288 - 648 */
 -	0x726f0000, 0x00000000,			/* 290 - 656 */
 -	0x6a130000, 0x00000000,			/* 298 - 664 */
 -	0xf1340001, 0x00000000,			/* 2a0 - 672 */
 -	0x72340000, 0x00000000,			/* 2a8 - 680 */
 -	0x80840000, 0xffffffe8,			/* 2b0 - 688 */
 -	0xf2600004, 0x00000000,			/* 2b8 - 696 */
 -	0x7e6c0400, 0x00000000,			/* 2c0 - 704 */
 -	0x7f6d0000, 0x00000000,			/* 2c8 - 712 */
 -	0x7f6e0000, 0x00000000,			/* 2d0 - 720 */
 -	0x7f6f0000, 0x00000000,			/* 2d8 - 728 */
 -	0x7e6a0100, 0x00000000,			/* 2e0 - 736 */
 -	0x726a0000, 0x00000000,			/* 2e8 - 744 */
 -	0x80840000, 0x00000028,			/* 2f0 - 752 */
 -	0x786cff00, 0x00000000,			/* 2f8 - 760 */
 -	0x786dff00, 0x00000000,			/* 300 - 768 */
 -	0x786eff00, 0x00000000,			/* 308 - 776 */
 -	0x786fff00, 0x00000000,			/* 310 - 784 */
 -	0x786a0000, 0x00000000,			/* 318 - 792 */
 -	0xe15c0004, 0x00000000,			/* 320 - 800 */
 -	0x7a5c0100, 0x00000000,			/* 328 - 808 */
 -	0xe25c0004, 0x00000000,			/* 330 - 816 */
 -	0x741a4000, 0x00000000,			/* 338 - 824 */
 -	0x72640000, 0x00000000,			/* 340 - 832 */
 -	0x6a100000, 0x00000000,			/* 348 - 840 */
 -	0x72650000, 0x00000000,			/* 350 - 848 */
 -	0x6a110000, 0x00000000,			/* 358 - 856 */
 -	0x72660000, 0x00000000,			/* 360 - 864 */
 -	0x6a120000, 0x00000000,			/* 368 - 872 */
 -	0x72670000, 0x00000000,			/* 370 - 880 */
 -	0x6a130000, 0x00000000,			/* 378 - 888 */
 -	0xf1100004, 0x00000000,			/* 380 - 896 */
 -	0x74100100, 0x00000000,			/* 388 - 904 */
 -	0x80840000, 0xfffffc68,			/* 390 - 912 */
 -	0x74100200, 0x00000000,			/* 398 - 920 */
 -	0x80840000, 0x00000018,			/* 3a0 - 928 */
 -	0xf1600004, 0x00000000,			/* 3a8 - 936 */
 -	0x47000028, 0xfffffc70,			/* 3b0 - 944 */
 -	0x9e030000, 0x0000ffff,			/* 3b8 - 952 */
 -	0x72640000, 0x00000000,			/* 3c0 - 960 */
 -	0x6a100000, 0x00000000,			/* 3c8 - 968 */
 -	0x72650000, 0x00000000,			/* 3d0 - 976 */
 -	0x6a110000, 0x00000000,			/* 3d8 - 984 */
 -	0x72660000, 0x00000000,			/* 3e0 - 992 */
 -	0x6a120000, 0x00000000,			/* 3e8 - 1000 */
 -	0x72670000, 0x00000000,			/* 3f0 - 1008 */
 -	0x6a130000, 0x00000000,			/* 3f8 - 1016 */
 -	0x7e680100, 0x00000000,			/* 400 - 1024 */
 -	0x7e640400, 0x00000000,			/* 408 - 1032 */
 -	0x7f650000, 0x00000000,			/* 410 - 1040 */
 -	0x7f660000, 0x00000000,			/* 418 - 1048 */
 -	0x7f670000, 0x00000000,			/* 420 - 1056 */
 -	0x72680000, 0x00000000,			/* 428 - 1064 */
 -	0x80840000, 0x00000028,			/* 430 - 1072 */
 -	0x7864ff00, 0x00000000,			/* 438 - 1080 */
 -	0x7865ff00, 0x00000000,			/* 440 - 1088 */
 -	0x7866ff00, 0x00000000,			/* 448 - 1096 */
 -	0x7867ff00, 0x00000000,			/* 450 - 1104 */
 -	0x78680000, 0x00000000,			/* 458 - 1112 */
 -	0xf15c0004, 0x00000000,			/* 460 - 1120 */
 -	0x7a5c0100, 0x00000000,			/* 468 - 1128 */
 -	0xf25c0004, 0x00000000,			/* 470 - 1136 */
 -	0x745c0200, 0x00000000,			/* 478 - 1144 */
 -	0x80840000, 0xfffffeb8,			/* 480 - 1152 */
 -	0x7c5cfc00, 0x00000000,			/* 488 - 1160 */
 -	0x88880000, 0x000001e8,			/* 490 - 1168 */
 -	0xe15c0004, 0x00000000,			/* 498 - 1176 */
 -	0x7a5c0200, 0x00000000,			/* 4a0 - 1184 */
 -	0xe25c0004, 0x00000000,			/* 4a8 - 1192 */
 -	0x80000000, 0x00000000,			/* 4b0 - 1200 */
 -	0x78350000, 0x00000000,			/* 4b8 - 1208 */
 -	0x7869ff00, 0x00000000,			/* 4c0 - 1216 */
 -	0x58000008, 0x00000000,			/* 4c8 - 1224 */
 -	0x60000040, 0x00000000,			/* 4d0 - 1232 */
 -	0x1e000048, 0x00000048,			/* 4d8 - 1240 */
 -	0x60000008, 0x00000000,			/* 4e0 - 1248 */
 -	0x80880000, 0xfffffd18,			/* 4e8 - 1256 */
 -	0x60000040, 0x00000000,			/* 4f0 - 1264 */
 -	0x7a601000, 0x00000000,			/* 4f8 - 1272 */
 -	0x60000008, 0x00000000,			/* 500 - 1280 */
 -	0x1f000030, 0x00000030,			/* 508 - 1288 */
 -	0x808c0000, 0xfffffd28,			/* 510 - 1296 */
 -	0x808c0002, 0xffffffd0,			/* 518 - 1304 */
 -	0x808c0001, 0x000001c8,			/* 520 - 1312 */
 -	0x98040004, 0x0000ff01,			/* 528 - 1320 */
 -	0x88880000, 0x00000190,			/* 530 - 1328 */
 -	0x74601000, 0x00000000,			/* 538 - 1336 */
 -	0x808c0000, 0xfffffdf8,			/* 540 - 1344 */
 -	0x98080000, 0x0000ff04,			/* 548 - 1352 */
 -	0x1a000050, 0x00000050,			/* 550 - 1360 */
 -	0x80880000, 0xfffffca8,			/* 558 - 1368 */
 -	0x1b000058, 0x00000058,			/* 560 - 1376 */
 -	0x6a690000, 0x00000000,			/* 568 - 1384 */
 -	0x80880000, 0xfffffc90,			/* 570 - 1392 */
 -	0x88880000, 0x000000b8,			/* 578 - 1400 */
 -	0x7a600800, 0x00000000,			/* 580 - 1408 */
 -	0x19000060, 0x00000060,			/* 588 - 1416 */
 -	0x7e350100, 0x00000000,			/* 590 - 1424 */
 -	0x7e100800, 0x00000000,			/* 598 - 1432 */
 -	0x7f110000, 0x00000000,			/* 5a0 - 1440 */
 -	0x7f120000, 0x00000000,			/* 5a8 - 1448 */
 -	0x7f130000, 0x00000000,			/* 5b0 - 1456 */
 -	0x818b0000, 0xffffffc8,			/* 5b8 - 1464 */
 -	0x88880000, 0x000000b8,			/* 5c0 - 1472 */
 -	0x7c60f700, 0x00000000,			/* 5c8 - 1480 */
 -	0x80880000, 0xfffffc30,			/* 5d0 - 1488 */
 -	0x88880000, 0x00000058,			/* 5d8 - 1496 */
 -	0x7a600800, 0x00000000,			/* 5e0 - 1504 */
 -	0x18000060, 0x00000060,			/* 5e8 - 1512 */
 -	0x7e350100, 0x00000000,			/* 5f0 - 1520 */
 -	0x7e100800, 0x00000000,			/* 5f8 - 1528 */
 -	0x7f110000, 0x00000000,			/* 600 - 1536 */
 -	0x7f120000, 0x00000000,			/* 608 - 1544 */
 -	0x7f130000, 0x00000000,			/* 610 - 1552 */
 -	0x808b0000, 0xffffffc8,			/* 618 - 1560 */
 -	0x88880000, 0x00000058,			/* 620 - 1568 */
 -	0x7c60f700, 0x00000000,			/* 628 - 1576 */
 -	0x80880000, 0xfffffbd0,			/* 630 - 1584 */
 -	0x72100000, 0x00000000,			/* 638 - 1592 */
 -	0x6a5c0000, 0x00000000,			/* 640 - 1600 */
 -	0x72110000, 0x00000000,			/* 648 - 1608 */
 -	0x6a5d0000, 0x00000000,			/* 650 - 1616 */
 -	0x72120000, 0x00000000,			/* 658 - 1624 */
 -	0x6a5e0000, 0x00000000,			/* 660 - 1632 */
 -	0x72130000, 0x00000000,			/* 668 - 1640 */
 -	0x6a5f0000, 0x00000000,			/* 670 - 1648 */
 -	0x90080000, 0x00000000,			/* 678 - 1656 */
 -	0x725c0000, 0x00000000,			/* 680 - 1664 */
 -	0x6a100000, 0x00000000,			/* 688 - 1672 */
 -	0x725d0000, 0x00000000,			/* 690 - 1680 */
 -	0x6a110000, 0x00000000,			/* 698 - 1688 */
 -	0x725e0000, 0x00000000,			/* 6a0 - 1696 */
 -	0x6a120000, 0x00000000,			/* 6a8 - 1704 */
 -	0x725f0000, 0x00000000,			/* 6b0 - 1712 */
 -	0x6a130000, 0x00000000,			/* 6b8 - 1720 */
 -	0x90080000, 0x00000000,			/* 6c0 - 1728 */
 -	0x7c027f00, 0x00000000,			/* 6c8 - 1736 */
 -	0x60000008, 0x00000000,			/* 6d0 - 1744 */
 -	0x60000040, 0x00000000,			/* 6d8 - 1752 */
 -	0x48000000, 0x00000000,			/* 6e0 - 1760 */
 +	0x88880000, 0x000004a8,			/* 240 - 576 */
 +	0x72350000, 0x00000000,			/* 248 - 584 */
 +	0x808c0000, 0x00000008,			/* 250 - 592 */
 +	0xf2340004, 0x00000000,			/* 258 - 600 */
 +	0x72690000, 0x00000000,			/* 260 - 608 */
 +	0x98040000, 0x0000ff00,			/* 268 - 616 */
 +	0x726c0000, 0x00000000,			/* 270 - 624 */
 +	0x6a100000, 0x00000000,			/* 278 - 632 */
 +	0x726d0000, 0x00000000,			/* 280 - 640 */
 +	0x6a110000, 0x00000000,			/* 288 - 648 */
 +	0x726e0000, 0x00000000,			/* 290 - 656 */
 +	0x6a120000, 0x00000000,			/* 298 - 664 */
 +	0x726f0000, 0x00000000,			/* 2a0 - 672 */
 +	0x6a130000, 0x00000000,			/* 2a8 - 680 */
 +	0xf1340001, 0x00000000,			/* 2b0 - 688 */
 +	0x72340000, 0x00000000,			/* 2b8 - 696 */
 +	0x80840000, 0xffffffe8,			/* 2c0 - 704 */
 +	0xf2600004, 0x00000000,			/* 2c8 - 712 */
 +	0x7e6c0400, 0x00000000,			/* 2d0 - 720 */
 +	0x7f6d0000, 0x00000000,			/* 2d8 - 728 */
 +	0x7f6e0000, 0x00000000,			/* 2e0 - 736 */
 +	0x7f6f0000, 0x00000000,			/* 2e8 - 744 */
 +	0x7e6a0100, 0x00000000,			/* 2f0 - 752 */
 +	0x726a0000, 0x00000000,			/* 2f8 - 760 */
 +	0x80840000, 0x00000028,			/* 300 - 768 */
 +	0x786cff00, 0x00000000,			/* 308 - 776 */
 +	0x786dff00, 0x00000000,			/* 310 - 784 */
 +	0x786eff00, 0x00000000,			/* 318 - 792 */
 +	0x786fff00, 0x00000000,			/* 320 - 800 */
 +	0x786a0000, 0x00000000,			/* 328 - 808 */
 +	0xe15c0004, 0x00000000,			/* 330 - 816 */
 +	0x7a5c0100, 0x00000000,			/* 338 - 824 */
 +	0xe25c0004, 0x00000000,			/* 340 - 832 */
 +	0x741a4000, 0x00000000,			/* 348 - 840 */
 +	0x72640000, 0x00000000,			/* 350 - 848 */
 +	0x6a100000, 0x00000000,			/* 358 - 856 */
 +	0x72650000, 0x00000000,			/* 360 - 864 */
 +	0x6a110000, 0x00000000,			/* 368 - 872 */
 +	0x72660000, 0x00000000,			/* 370 - 880 */
 +	0x6a120000, 0x00000000,			/* 378 - 888 */
 +	0x72670000, 0x00000000,			/* 380 - 896 */
 +	0x6a130000, 0x00000000,			/* 388 - 904 */
 +	0xf1100004, 0x00000000,			/* 390 - 912 */
 +	0x74100100, 0x00000000,			/* 398 - 920 */
 +	0x80840000, 0xfffffc58,			/* 3a0 - 928 */
 +	0x74100200, 0x00000000,			/* 3a8 - 936 */
 +	0x80840000, 0x00000018,			/* 3b0 - 944 */
 +	0xf1600004, 0x00000000,			/* 3b8 - 952 */
 +	0x47000028, 0xfffffc60,			/* 3c0 - 960 */
 +	0x9e030000, 0x0000ffff,			/* 3c8 - 968 */
 +	0x72640000, 0x00000000,			/* 3d0 - 976 */
 +	0x6a100000, 0x00000000,			/* 3d8 - 984 */
 +	0x72650000, 0x00000000,			/* 3e0 - 992 */
 +	0x6a110000, 0x00000000,			/* 3e8 - 1000 */
 +	0x72660000, 0x00000000,			/* 3f0 - 1008 */
 +	0x6a120000, 0x00000000,			/* 3f8 - 1016 */
 +	0x72670000, 0x00000000,			/* 400 - 1024 */
 +	0x6a130000, 0x00000000,			/* 408 - 1032 */
 +	0x7e680100, 0x00000000,			/* 410 - 1040 */
 +	0x7e640400, 0x00000000,			/* 418 - 1048 */
 +	0x7f650000, 0x00000000,			/* 420 - 1056 */
 +	0x7f660000, 0x00000000,			/* 428 - 1064 */
 +	0x7f670000, 0x00000000,			/* 430 - 1072 */
 +	0x72680000, 0x00000000,			/* 438 - 1080 */
 +	0x80840000, 0x00000028,			/* 440 - 1088 */
 +	0x7864ff00, 0x00000000,			/* 448 - 1096 */
 +	0x7865ff00, 0x00000000,			/* 450 - 1104 */
 +	0x7866ff00, 0x00000000,			/* 458 - 1112 */
 +	0x7867ff00, 0x00000000,			/* 460 - 1120 */
 +	0x78680000, 0x00000000,			/* 468 - 1128 */
 +	0xf15c0004, 0x00000000,			/* 470 - 1136 */
 +	0x7a5c0100, 0x00000000,			/* 478 - 1144 */
 +	0xf25c0004, 0x00000000,			/* 480 - 1152 */
 +	0x745c0200, 0x00000000,			/* 488 - 1160 */
 +	0x80840000, 0xfffffeb8,			/* 490 - 1168 */
 +	0x7c5cfc00, 0x00000000,			/* 498 - 1176 */
 +	0x88880000, 0x00000200,			/* 4a0 - 1184 */
 +	0xe15c0004, 0x00000000,			/* 4a8 - 1192 */
 +	0x7a5c0200, 0x00000000,			/* 4b0 - 1200 */
 +	0xe25c0004, 0x00000000,			/* 4b8 - 1208 */
 +	0x80000000, 0x00000000,			/* 4c0 - 1216 */
 +	0x78350000, 0x00000000,			/* 4c8 - 1224 */
 +	0x7869ff00, 0x00000000,			/* 4d0 - 1232 */
 +	0x58000008, 0x00000000,			/* 4d8 - 1240 */
 +	0x60000040, 0x00000000,			/* 4e0 - 1248 */
 +	0x1e000048, 0x00000048,			/* 4e8 - 1256 */
 +	0x60000008, 0x00000000,			/* 4f0 - 1264 */
 +	0x80880000, 0xfffffd08,			/* 4f8 - 1272 */
 +	0x60000040, 0x00000000,			/* 500 - 1280 */
 +	0x7a601000, 0x00000000,			/* 508 - 1288 */
 +	0x60000008, 0x00000000,			/* 510 - 1296 */
 +	0x1f000030, 0x00000030,			/* 518 - 1304 */
 +	0x808c0000, 0xfffffd18,			/* 520 - 1312 */
 +	0x808c0002, 0xffffffd0,			/* 528 - 1320 */
 +	0x808c0001, 0x000001e0,			/* 530 - 1328 */
 +	0x98040004, 0x0000ff01,			/* 538 - 1336 */
 +	0x88880000, 0x000001a8,			/* 540 - 1344 */
 +	0x74601000, 0x00000000,			/* 548 - 1352 */
 +	0x98040000, 0x0000ff04,			/* 550 - 1360 */
 +	0x72350000, 0x00000000,			/* 558 - 1368 */
 +	0x808c0000, 0xfffffde8,			/* 560 - 1376 */
 +	0xf2340004, 0x00000000,			/* 568 - 1384 */
 +	0x80880000, 0xfffffdd8,			/* 570 - 1392 */
 +	0x1a000050, 0x00000050,			/* 578 - 1400 */
 +	0x80880000, 0xfffffc80,			/* 580 - 1408 */
 +	0x1b000058, 0x00000058,			/* 588 - 1416 */
 +	0x6a690000, 0x00000000,			/* 590 - 1424 */
 +	0x80880000, 0xfffffc68,			/* 598 - 1432 */
 +	0x88880000, 0x000000b8,			/* 5a0 - 1440 */
 +	0x7a600800, 0x00000000,			/* 5a8 - 1448 */
 +	0x19000060, 0x00000060,			/* 5b0 - 1456 */
 +	0x7e350100, 0x00000000,			/* 5b8 - 1464 */
 +	0x7e100800, 0x00000000,			/* 5c0 - 1472 */
 +	0x7f110000, 0x00000000,			/* 5c8 - 1480 */
 +	0x7f120000, 0x00000000,			/* 5d0 - 1488 */
 +	0x7f130000, 0x00000000,			/* 5d8 - 1496 */
 +	0x818b0000, 0xffffffc8,			/* 5e0 - 1504 */
 +	0x88880000, 0x000000b8,			/* 5e8 - 1512 */
 +	0x7c60f700, 0x00000000,			/* 5f0 - 1520 */
 +	0x80880000, 0xfffffc08,			/* 5f8 - 1528 */
 +	0x88880000, 0x00000058,			/* 600 - 1536 */
 +	0x7a600800, 0x00000000,			/* 608 - 1544 */
 +	0x18000060, 0x00000060,			/* 610 - 1552 */
 +	0x7e350100, 0x00000000,			/* 618 - 1560 */
 +	0x7e100800, 0x00000000,			/* 620 - 1568 */
 +	0x7f110000, 0x00000000,			/* 628 - 1576 */
 +	0x7f120000, 0x00000000,			/* 630 - 1584 */
 +	0x7f130000, 0x00000000,			/* 638 - 1592 */
 +	0x808b0000, 0xffffffc8,			/* 640 - 1600 */
 +	0x88880000, 0x00000058,			/* 648 - 1608 */
 +	0x7c60f700, 0x00000000,			/* 650 - 1616 */
 +	0x80880000, 0xfffffba8,			/* 658 - 1624 */
 +	0x72100000, 0x00000000,			/* 660 - 1632 */
 +	0x6a5c0000, 0x00000000,			/* 668 - 1640 */
 +	0x72110000, 0x00000000,			/* 670 - 1648 */
 +	0x6a5d0000, 0x00000000,			/* 678 - 1656 */
 +	0x72120000, 0x00000000,			/* 680 - 1664 */
 +	0x6a5e0000, 0x00000000,			/* 688 - 1672 */
 +	0x72130000, 0x00000000,			/* 690 - 1680 */
 +	0x6a5f0000, 0x00000000,			/* 698 - 1688 */
 +	0x90080000, 0x00000000,			/* 6a0 - 1696 */
 +	0x725c0000, 0x00000000,			/* 6a8 - 1704 */
 +	0x6a100000, 0x00000000,			/* 6b0 - 1712 */
 +	0x725d0000, 0x00000000,			/* 6b8 - 1720 */
 +	0x6a110000, 0x00000000,			/* 6c0 - 1728 */
 +	0x725e0000, 0x00000000,			/* 6c8 - 1736 */
 +	0x6a120000, 0x00000000,			/* 6d0 - 1744 */
 +	0x725f0000, 0x00000000,			/* 6d8 - 1752 */
 +	0x6a130000, 0x00000000,			/* 6e0 - 1760 */
  	0x90080000, 0x00000000,			/* 6e8 - 1768 */
 -	0x60000040, 0x00000000,			/* 6f0 - 1776 */
 -	0x1f000038, 0x00000038,			/* 6f8 - 1784 */
 -	0x98080000, 0x0000ff02,			/* 700 - 1792 */
 -	0x60000040, 0x00000000,			/* 708 - 1800 */
 -	0x1f000040, 0x00000040,			/* 710 - 1808 */
 -	0x98080000, 0x0000ff03,			/* 718 - 1816 */
 +	0x7c027f00, 0x00000000,			/* 6f0 - 1776 */
 +	0x60000008, 0x00000000,			/* 6f8 - 1784 */
 +	0x60000040, 0x00000000,			/* 700 - 1792 */
 +	0x48000000, 0x00000000,			/* 708 - 1800 */
 +	0x90080000, 0x00000000,			/* 710 - 1808 */
 +	0x60000040, 0x00000000,			/* 718 - 1816 */
 +	0x1f000038, 0x00000038,			/* 720 - 1824 */
 +	0x98080000, 0x0000ff02,			/* 728 - 1832 */
 +	0x60000040, 0x00000000,			/* 730 - 1840 */
 +	0x1f000040, 0x00000040,			/* 738 - 1848 */
 +	0x98080000, 0x0000ff03,			/* 740 - 1856 */
  };
  
  const u_int32_t esiop_led_on[] = {
 @@ -274,29 +279,34 @@
  #define	A_cmd_slot_size	0x00000004
  #define	A_ndone_slots	0x00000100
  #define	A_ndone_slots_last	0x00000000
 -#define	Ent_cmdr0	0x00000438
 -#define	Ent_cmdr1	0x00000440
 -#define	Ent_cmdr2	0x00000448
 -#define	Ent_cmdr3	0x00000450
 -#define	Ent_doner0	0x000002f8
 -#define	Ent_doner1	0x00000300
 -#define	Ent_doner2	0x00000308
 -#define	Ent_doner3	0x00000310
 +#define	Ent_cmdr0	0x00000448
 +#define	Ent_cmdr1	0x00000450
 +#define	Ent_cmdr2	0x00000458
 +#define	Ent_cmdr3	0x00000460
 +#define	Ent_doner0	0x00000308
 +#define	Ent_doner1	0x00000310
 +#define	Ent_doner2	0x00000318
 +#define	Ent_doner3	0x00000320
  #define	Ent_reselect	0x00000028
 -#define	Ent_led_on1	0x000004b0
 +#define	Ent_led_on1	0x000004c0
  #define	Ent_led_on2	0x00000050
  #define	Ent_led_off	0x00000040
 -#define	Ent_status	0x00000560
 -#define	Ent_msgin	0x00000500
 +#define	Ent_status	0x00000588
 +#define	Ent_msgin	0x00000510
  #define	Ent_msgin_ack	0x00000200
 -#define	Ent_get_extmsgdata	0x00000708
 -#define	Ent_send_msgout	0x000004c8
 -#define	Ent_script_sched	0x00000340
 +#define	Ent_get_extmsgdata	0x00000730
 +#define	Ent_send_msgout	0x000004d8
 +#define	Ent_script_sched	0x00000350
  #define	Ent_load_targtable	0x000000a0
  #define	E_tlq_offset	0x00000000
  u_int32_t E_tlq_offset_Used[] = {
 -	0x00000093,
 -	0x000000eb,
 +	0x000000ef,
 +};
 +
 +#define	E_saved_offset_offset	0x00000000
 +u_int32_t E_saved_offset_offset_Used[] = {
 +	0x00000097,
 +	0x0000015b,
  };
  
  #define	E_abs_msgin2	0x00000000
 @@ -310,10 +320,10 @@
  u_int32_t E_abs_sem_Used[] = {
  	0x00000001,
  	0x00000009,
 -	0x000000c9,
  	0x000000cd,
 -	0x00000127,
 +	0x000000d1,
  	0x0000012b,
 +	0x0000012f,
  };
  
  #define	A_sem_done	0x00000001
 Index: microcode/siop/esiop.ss
 ===================================================================
 RCS file: /cvsroot/src/sys/dev/microcode/siop/esiop.ss,v
 retrieving revision 1.16.4.2
 diff -u -r1.16.4.2 esiop.ss
 --- microcode/siop/esiop.ss	11 May 2005 03:48:47 -0000	1.16.4.2
 +++ microcode/siop/esiop.ss	17 Nov 2005 17:28:53 -0000
 @@ -112,6 +112,7 @@
  ENTRY load_targtable;
  
  EXTERN tlq_offset;
 +EXTERN saved_offset_offset;
  EXTERN abs_msgin2;
  
  EXTERN abs_sem; a 32bits word used a semaphore between script and driver
 @@ -208,7 +209,11 @@
  
  handle_cmpl:
  	CALL REL(disconnect);
 -	STORE NOFLUSH SCRATCHA0, 4, from tlq_offset; save current offset
 +; update offset if we did some data transfer
 +	MOVE SCRATCHA1 TO SFBR;
 +	JUMP REL(handle_cmpl_noxfer), if 0x00;
 +	STORE NOFLUSH SCRATCHA0, 4, FROM saved_offset_offset;
 +handle_cmpl_noxfer:
  	MOVE SCRATCHE1 to SFBR;
  	INT int_done, IF NOT 0x00; if status is not "done", let host handle it
  	MOVE SCRATCHF0 to SFBR; load pointer in done ring
 @@ -344,9 +349,12 @@
  	CALL REL(disconnect)		; disconnect message
  ; if we didn't get sdp, no need to interrupt
  	MOVE SCRATCHC0 & f_c_sdp TO SFBR;
 +	INT int_disc, IF not 0x00;
 +; update offset if we did some data transfer
 +	MOVE SCRATCHA1 TO SFBR;
  	JUMP REL(script_sched), if 0x00;
 -; Ok, we need to save data pointers
 -	INT int_disc;
 +	STORE NOFLUSH SCRATCHA0, 4, FROM saved_offset_offset;
 +	JUMP REL(script_sched);
  
  cmdout:
          MOVE FROM t_cmd, WHEN CMD; 
 Index: microcode/siop/siop.out
 ===================================================================
 RCS file: /cvsroot/src/sys/dev/microcode/siop/siop.out,v
 retrieving revision 1.14.14.1
 diff -u -r1.14.14.1 siop.out
 --- microcode/siop/siop.out	11 May 2005 03:50:26 -0000	1.14.14.1
 +++ microcode/siop/siop.out	17 Nov 2005 17:28:53 -0000
 @@ -1,19 +1,19 @@
 -/*	$NetBSD: siop.out,v 1.14.14.1 2005/05/11 03:50:26 snj Exp $	*/
 +/*	$NetBSD: ncr53cxxx.c,v 1.12.2.1 2004/05/20 09:41:26 tron Exp $	*/
  /*
   *	DO NOT EDIT - this file is automatically generated.
 - *	created from siop.ss on Tue May 10 12:46:01 2005
 + *	created from siop.ss on Thu Nov 17 18:28:18 2005
   */
  const u_int32_t siop_script[] = {
  	0x78340000, 0x00000000,			/* 000 -   0 */
  	0x78350000, 0x00000000,			/* 008 -   8 */
  	0x72370000, 0x00000000,			/* 010 -  16 */
  	0x80840020, 0x00000318,			/* 018 -  24 */
 -	0x868b0000, 0x00000370,			/* 020 -  32 */
 +	0x868b0000, 0x00000380,			/* 020 -  32 */
  	0x878b0000, 0x000002f8,			/* 028 -  40 */
 -	0x808b0000, 0x000003f8,			/* 030 -  48 */
 -	0x818b0000, 0x00000390,			/* 038 -  56 */
 -	0x828b0000, 0x00000368,			/* 040 -  64 */
 -	0x838b0000, 0x00000370,			/* 048 -  72 */
 +	0x808b0000, 0x00000408,			/* 030 -  48 */
 +	0x818b0000, 0x000003a0,			/* 038 -  56 */
 +	0x828b0000, 0x00000378,			/* 040 -  64 */
 +	0x838b0000, 0x00000380,			/* 048 -  72 */
  	0x98080000, 0x0000ffff,			/* 050 -  80 */
  	0x741a4000, 0x00000000,			/* 058 -  88 */
  	0x980c0000, 0x0000ff83,			/* 060 -  96 */
 @@ -107,81 +107,83 @@
  	0x7a340100, 0x00000000,			/* 320 - 800 */
  	0x60000008, 0x00000000,			/* 328 - 808 */
  	0x1f000030, 0x00000030,			/* 330 - 816 */
 -	0x808c0000, 0x00000208,			/* 338 - 824 */
 +	0x808c0000, 0x00000218,			/* 338 - 824 */
  	0x808c0002, 0xffffffd0,			/* 340 - 832 */
 -	0x808c0001, 0x00000208,			/* 348 - 840 */
 +	0x808c0001, 0x00000218,			/* 348 - 840 */
  	0x98040004, 0x0000ff01,			/* 350 - 848 */
 -	0x88880000, 0x000001c0,			/* 358 - 856 */
 +	0x88880000, 0x000001d0,			/* 358 - 856 */
  	0x74340100, 0x00000000,			/* 360 - 864 */
 -	0x808c0000, 0xfffffd00,			/* 368 - 872 */
 -	0x98080000, 0x0000ff04,			/* 370 - 880 */
 -	0x60000040, 0x00000000,			/* 378 - 888 */
 -	0x80880000, 0xfffffc98,			/* 380 - 896 */
 -	0x58000008, 0x00000000,			/* 388 - 904 */
 -	0x60000040, 0x00000000,			/* 390 - 912 */
 -	0x1e000048, 0x00000048,			/* 398 - 920 */
 -	0x60000008, 0x00000000,			/* 3a0 - 928 */
 -	0x80880000, 0xfffffc70,			/* 3a8 - 936 */
 -	0x1a000050, 0x00000050,			/* 3b0 - 944 */
 +	0x98040000, 0x0000ff04,			/* 368 - 872 */
 +	0x72350000, 0x00000000,			/* 370 - 880 */
 +	0x808c0000, 0xfffffcf0,			/* 378 - 888 */
 +	0x98080000, 0x0000ff05,			/* 380 - 896 */
 +	0x60000040, 0x00000000,			/* 388 - 904 */
 +	0x80880000, 0xfffffc88,			/* 390 - 912 */
 +	0x58000008, 0x00000000,			/* 398 - 920 */
 +	0x60000040, 0x00000000,			/* 3a0 - 928 */
 +	0x1e000048, 0x00000048,			/* 3a8 - 936 */
 +	0x60000008, 0x00000000,			/* 3b0 - 944 */
  	0x80880000, 0xfffffc60,			/* 3b8 - 952 */
 -	0x1b000058, 0x00000058,			/* 3c0 - 960 */
 +	0x1a000050, 0x00000050,			/* 3c0 - 960 */
  	0x80880000, 0xfffffc50,			/* 3c8 - 968 */
 -	0x88880000, 0x000000b8,			/* 3d0 - 976 */
 -	0x7a340200, 0x00000000,			/* 3d8 - 984 */
 -	0x19000060, 0x00000060,			/* 3e0 - 992 */
 -	0x7e350100, 0x00000000,			/* 3e8 - 1000 */
 -	0x7e100800, 0x00000000,			/* 3f0 - 1008 */
 -	0x7f110000, 0x00000000,			/* 3f8 - 1016 */
 -	0x7f120000, 0x00000000,			/* 400 - 1024 */
 -	0x7f130000, 0x00000000,			/* 408 - 1032 */
 -	0x818b0000, 0xffffffc8,			/* 410 - 1040 */
 -	0x88880000, 0x000000b8,			/* 418 - 1048 */
 -	0x7c34fd00, 0x00000000,			/* 420 - 1056 */
 -	0x80880000, 0xfffffbf0,			/* 428 - 1064 */
 -	0x88880000, 0x00000058,			/* 430 - 1072 */
 -	0x7a340200, 0x00000000,			/* 438 - 1080 */
 -	0x18000060, 0x00000060,			/* 440 - 1088 */
 -	0x7e350100, 0x00000000,			/* 448 - 1096 */
 -	0x7e100800, 0x00000000,			/* 450 - 1104 */
 -	0x7f110000, 0x00000000,			/* 458 - 1112 */
 -	0x7f120000, 0x00000000,			/* 460 - 1120 */
 -	0x7f130000, 0x00000000,			/* 468 - 1128 */
 -	0x808b0000, 0xffffffc8,			/* 470 - 1136 */
 -	0x88880000, 0x00000058,			/* 478 - 1144 */
 -	0x7c34fd00, 0x00000000,			/* 480 - 1152 */
 -	0x80880000, 0xfffffb90,			/* 488 - 1160 */
 -	0x72100000, 0x00000000,			/* 490 - 1168 */
 -	0x6a5c0000, 0x00000000,			/* 498 - 1176 */
 -	0x72110000, 0x00000000,			/* 4a0 - 1184 */
 -	0x6a5d0000, 0x00000000,			/* 4a8 - 1192 */
 -	0x72120000, 0x00000000,			/* 4b0 - 1200 */
 -	0x6a5e0000, 0x00000000,			/* 4b8 - 1208 */
 -	0x72130000, 0x00000000,			/* 4c0 - 1216 */
 -	0x6a5f0000, 0x00000000,			/* 4c8 - 1224 */
 -	0x90080000, 0x00000000,			/* 4d0 - 1232 */
 -	0x725c0000, 0x00000000,			/* 4d8 - 1240 */
 -	0x6a100000, 0x00000000,			/* 4e0 - 1248 */
 -	0x725d0000, 0x00000000,			/* 4e8 - 1256 */
 -	0x6a110000, 0x00000000,			/* 4f0 - 1264 */
 -	0x725e0000, 0x00000000,			/* 4f8 - 1272 */
 -	0x6a120000, 0x00000000,			/* 500 - 1280 */
 -	0x725f0000, 0x00000000,			/* 508 - 1288 */
 -	0x6a130000, 0x00000000,			/* 510 - 1296 */
 -	0x90080000, 0x00000000,			/* 518 - 1304 */
 -	0x7c027f00, 0x00000000,			/* 520 - 1312 */
 -	0x60000008, 0x00000000,			/* 528 - 1320 */
 -	0x60000040, 0x00000000,			/* 530 - 1328 */
 -	0x48000000, 0x00000000,			/* 538 - 1336 */
 -	0x90080000, 0x00000000,			/* 540 - 1344 */
 -	0x88880000, 0xffffffd0,			/* 548 - 1352 */
 -	0x98080000, 0x0000ff00,			/* 550 - 1360 */
 -	0x60000040, 0x00000000,			/* 558 - 1368 */
 -	0x1f000038, 0x00000038,			/* 560 - 1376 */
 -	0x98080000, 0x0000ff02,			/* 568 - 1384 */
 -	0x60000040, 0x00000000,			/* 570 - 1392 */
 -	0x1f000040, 0x00000040,			/* 578 - 1400 */
 -	0x98080000, 0x0000ff03,			/* 580 - 1408 */
 -	0x80000000, 0x00000000,			/* 588 - 1416 */
 +	0x1b000058, 0x00000058,			/* 3d0 - 976 */
 +	0x80880000, 0xfffffc40,			/* 3d8 - 984 */
 +	0x88880000, 0x000000b8,			/* 3e0 - 992 */
 +	0x7a340200, 0x00000000,			/* 3e8 - 1000 */
 +	0x19000060, 0x00000060,			/* 3f0 - 1008 */
 +	0x7e350100, 0x00000000,			/* 3f8 - 1016 */
 +	0x7e100800, 0x00000000,			/* 400 - 1024 */
 +	0x7f110000, 0x00000000,			/* 408 - 1032 */
 +	0x7f120000, 0x00000000,			/* 410 - 1040 */
 +	0x7f130000, 0x00000000,			/* 418 - 1048 */
 +	0x818b0000, 0xffffffc8,			/* 420 - 1056 */
 +	0x88880000, 0x000000b8,			/* 428 - 1064 */
 +	0x7c34fd00, 0x00000000,			/* 430 - 1072 */
 +	0x80880000, 0xfffffbe0,			/* 438 - 1080 */
 +	0x88880000, 0x00000058,			/* 440 - 1088 */
 +	0x7a340200, 0x00000000,			/* 448 - 1096 */
 +	0x18000060, 0x00000060,			/* 450 - 1104 */
 +	0x7e350100, 0x00000000,			/* 458 - 1112 */
 +	0x7e100800, 0x00000000,			/* 460 - 1120 */
 +	0x7f110000, 0x00000000,			/* 468 - 1128 */
 +	0x7f120000, 0x00000000,			/* 470 - 1136 */
 +	0x7f130000, 0x00000000,			/* 478 - 1144 */
 +	0x808b0000, 0xffffffc8,			/* 480 - 1152 */
 +	0x88880000, 0x00000058,			/* 488 - 1160 */
 +	0x7c34fd00, 0x00000000,			/* 490 - 1168 */
 +	0x80880000, 0xfffffb80,			/* 498 - 1176 */
 +	0x72100000, 0x00000000,			/* 4a0 - 1184 */
 +	0x6a5c0000, 0x00000000,			/* 4a8 - 1192 */
 +	0x72110000, 0x00000000,			/* 4b0 - 1200 */
 +	0x6a5d0000, 0x00000000,			/* 4b8 - 1208 */
 +	0x72120000, 0x00000000,			/* 4c0 - 1216 */
 +	0x6a5e0000, 0x00000000,			/* 4c8 - 1224 */
 +	0x72130000, 0x00000000,			/* 4d0 - 1232 */
 +	0x6a5f0000, 0x00000000,			/* 4d8 - 1240 */
 +	0x90080000, 0x00000000,			/* 4e0 - 1248 */
 +	0x725c0000, 0x00000000,			/* 4e8 - 1256 */
 +	0x6a100000, 0x00000000,			/* 4f0 - 1264 */
 +	0x725d0000, 0x00000000,			/* 4f8 - 1272 */
 +	0x6a110000, 0x00000000,			/* 500 - 1280 */
 +	0x725e0000, 0x00000000,			/* 508 - 1288 */
 +	0x6a120000, 0x00000000,			/* 510 - 1296 */
 +	0x725f0000, 0x00000000,			/* 518 - 1304 */
 +	0x6a130000, 0x00000000,			/* 520 - 1312 */
 +	0x90080000, 0x00000000,			/* 528 - 1320 */
 +	0x7c027f00, 0x00000000,			/* 530 - 1328 */
 +	0x60000008, 0x00000000,			/* 538 - 1336 */
 +	0x60000040, 0x00000000,			/* 540 - 1344 */
 +	0x48000000, 0x00000000,			/* 548 - 1352 */
 +	0x90080000, 0x00000000,			/* 550 - 1360 */
 +	0x88880000, 0xffffffd0,			/* 558 - 1368 */
 +	0x98080000, 0x0000ff00,			/* 560 - 1376 */
 +	0x60000040, 0x00000000,			/* 568 - 1384 */
 +	0x1f000038, 0x00000038,			/* 570 - 1392 */
 +	0x98080000, 0x0000ff02,			/* 578 - 1400 */
 +	0x60000040, 0x00000000,			/* 580 - 1408 */
 +	0x1f000040, 0x00000040,			/* 588 - 1416 */
 +	0x98080000, 0x0000ff03,			/* 590 - 1424 */
 +	0x80000000, 0x00000000,			/* 598 - 1432 */
  };
  
  const u_int32_t lun_switch[] = {
 @@ -250,6 +252,7 @@
  #define	A_int_extmsgin	0x0000ff02
  #define	A_int_extmsgdata	0x0000ff03
  #define	A_int_disc	0x0000ff04
 +#define	A_int_saveoffset	0x0000ff05
  #define	A_int_reseltarg	0x0000ff80
  #define	A_int_resellun	0x0000ff81
  #define	A_int_reseltag	0x0000ff82
 @@ -259,24 +262,24 @@
  #define	A_flag_data	0x00000002
  #define	A_flag_data_mask	0x000000fd
  #define	Ent_waitphase	0x00000020
 -#define	Ent_send_msgout	0x00000388
 -#define	Ent_msgout	0x00000398
 +#define	Ent_send_msgout	0x00000398
 +#define	Ent_msgout	0x000003a8
  #define	Ent_msgin	0x00000328
  #define	Ent_handle_msgin	0x00000338
 -#define	Ent_msgin_ack	0x00000378
 -#define	Ent_dataout	0x00000430
 -#define	Ent_datain	0x000003d0
 -#define	Ent_cmdout	0x000003b0
 -#define	Ent_status	0x000003c0
 -#define	Ent_disconnect	0x00000520
 +#define	Ent_msgin_ack	0x00000388
 +#define	Ent_dataout	0x00000440
 +#define	Ent_datain	0x000003e0
 +#define	Ent_cmdout	0x000003c0
 +#define	Ent_status	0x000003d0
 +#define	Ent_disconnect	0x00000530
  #define	Ent_reselect	0x000001e0
  #define	Ent_reselected	0x00000000
 -#define	Ent_selected	0x00000378
 +#define	Ent_selected	0x00000388
  #define	Ent_script_sched	0x00000070
  #define	Ent_script_sched_slot0	0x000000a0
 -#define	Ent_get_extmsgdata	0x00000570
 +#define	Ent_get_extmsgdata	0x00000580
  #define	Ent_resel_targ0	0x00000238
 -#define	Ent_msgin_space	0x00000588
 +#define	Ent_msgin_space	0x00000598
  #define	Ent_lunsw_return	0x000002b8
  #define	Ent_led_on1	0x00000068
  #define	Ent_led_on2	0x00000220
 Index: microcode/siop/siop.ss
 ===================================================================
 RCS file: /cvsroot/src/sys/dev/microcode/siop/siop.ss,v
 retrieving revision 1.17.10.1
 diff -u -r1.17.10.1 siop.ss
 --- microcode/siop/siop.ss	11 May 2005 03:48:47 -0000	1.17.10.1
 +++ microcode/siop/siop.ss	17 Nov 2005 17:28:53 -0000
 @@ -47,6 +47,7 @@
  ABSOLUTE int_extmsgin	= 0xff02;
  ABSOLUTE int_extmsgdata	= 0xff03;
  ABSOLUTE int_disc	= 0xff04;
 +ABSOLUTE int_saveoffset	= 0xff05;
  ; interrupts that don't have a valid DSA
  ABSOLUTE int_reseltarg	= 0xff80;
  ABSOLUTE int_resellun	= 0xff81;
 @@ -262,9 +263,12 @@
  	CALL REL(disconnect)                  ; disconnect message;
  ; if we didn't get sdp, no need to interrupt
  	MOVE SCRATCHA0 & flag_sdp TO SFBR;
 +	INT int_disc, IF not 0x00;
 +; update offset if we did some data transfer
 +	MOVE SCRATCHA1 TO SFBR;
  	JUMP REL(script_sched), if 0x00; 
 -; Ok, we need to save data pointers
 -	INT int_disc;
 +	INT int_saveoffset;
 +
  msgin_ack:
  selected:
  	CLEAR ACK;
 
 --OgqxwSJOaUobr8KG--