NetBSD Problem Report #31990

From yamt@mwd.biglobe.ne.jp  Thu Nov  3 13:22:57 2005
Return-Path: <yamt@mwd.biglobe.ne.jp>
Received: from yamt.dyndns.org (FLA1Abm205.kng.mesh.ad.jp [219.107.215.205])
	by narn.netbsd.org (Postfix) with ESMTP id 2695963B8E4
	for <gnats-bugs@gnats.NetBSD.org>; Thu,  3 Nov 2005 13:22:56 +0000 (UTC)
Message-Id: <1131024126.688232.12078.nullmailer@yamt.dyndns.org>
Date: Thu, 03 Nov 2005 22:22:06 +0900
From: yamt@mwd.biglobe.ne.jp
Reply-To: yamt@mwd.biglobe.ne.jp
To: gnats-bugs@netbsd.org
Subject: esiop leaves b_resid non-zero
X-Send-Pr-Version: 3.95

>Number:         31990
>Category:       kern
>Synopsis:       esiop leaves b_resid non-zero
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    bouyer
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Nov 03 13:23:00 +0000 2005
>Closed-Date:    Sat Nov 26 20:33:27 +0000 2005
>Last-Modified:  Wed Dec 14 03:25:04 +0000 2005
>Originator:     YAMAMOTO Takashi <yamt@mwd.biglobe.ne.jp>
>Release:        NetBSD 3.99.11
>Organization:

>Environment:
System: NetBSD 3.99.11
Architecture: alpha
Machine: alpha
>Description:
	the following is the first i/o request of
	"dd if=/dev/rsd0c of=/dev/null", after biodone() is called on it.

		db> sh buf 0xfffffc001dde6458
		  vp 0x0 lblkno 0xdeadbeefdeadbeef blkno 0x0 dev 0x802
		  error 0 flags 0x1c0210<BUSY,DONE,PHYS,RAW,READ>
		  bufsize 0x200 bcount 0x200 resid 0x200
		  data 0x120018000 saveaddr 0x0 dep 0x0
		  iodone 0xfffffc0000480420

	after putting some printf,
	esiop_intr seems to call esiop_scsicmd_end with offset == 0.

>How-To-Repeat:
>Fix:

>Release-Note:

>Audit-Trail:
From: Manuel Bouyer <bouyer@antioche.eu.org>
To: gnats-bugs@NetBSD.org
Cc: kern-bug-people@NetBSD.org, gnats-admin@NetBSD.org,
	netbsd-bugs@NetBSD.org
Subject: Re: kern/31990: esiop leaves b_resid non-zero
Date: Thu, 3 Nov 2005 23:32:28 +0100

 On Thu, Nov 03, 2005 at 01:23:01PM +0000, yamt@mwd.biglobe.ne.jp wrote:
 > >Number:         31990
 > >Category:       kern
 > >Synopsis:       esiop leaves b_resid non-zero
 > >Confidential:   no
 > >Severity:       serious
 > >Priority:       low
 > >Responsible:    kern-bug-people
 > >State:          open
 > >Class:          sw-bug
 > >Submitter-Id:   net
 > >Arrival-Date:   Thu Nov 03 13:23:00 +0000 2005
 > >Originator:     YAMAMOTO Takashi <yamt@mwd.biglobe.ne.jp>
 > >Release:        NetBSD 3.99.11
 > >Organization:
 > 
 > >Environment:
 > System: NetBSD 3.99.11
 > Architecture: alpha
 > Machine: alpha
 > >Description:
 > 	the following is the first i/o request of
 > 	"dd if=/dev/rsd0c of=/dev/null", after biodone() is called on it.
 > 
 > 		db> sh buf 0xfffffc001dde6458
 > 		  vp 0x0 lblkno 0xdeadbeefdeadbeef blkno 0x0 dev 0x802
 > 		  error 0 flags 0x1c0210<BUSY,DONE,PHYS,RAW,READ>
 > 		  bufsize 0x200 bcount 0x200 resid 0x200
 > 		  data 0x120018000 saveaddr 0x0 dep 0x0
 > 		  iodone 0xfffffc0000480420
 > 
 > 	after putting some printf,
 > 	esiop_intr seems to call esiop_scsicmd_end with offset == 0.

 I don't see a problem here. Calling esiop_scsicmd_end with offset == 0 is
 valid, if the command didn't complete properly. Can you give more detail on
 what you see wrong here ? Does the kernel print some message ?

 -- 
 Manuel Bouyer <bouyer@antioche.eu.org>
      NetBSD: 26 ans d'experience feront toujours la difference
 --

From: YAMAMOTO Takashi <yamt@mwd.biglobe.ne.jp>
To: bouyer@antioche.eu.org
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
Date: Fri, 04 Nov 2005 09:06:54 +0900

 > > 		db> sh buf 0xfffffc001dde6458
 > > 		  vp 0x0 lblkno 0xdeadbeefdeadbeef blkno 0x0 dev 0x802
 > > 		  error 0 flags 0x1c0210<BUSY,DONE,PHYS,RAW,READ>
 > > 		  bufsize 0x200 bcount 0x200 resid 0x200
 > > 		  data 0x120018000 saveaddr 0x0 dep 0x0
 > > 		  iodone 0xfffffc0000480420
 > > 
 > > 	after putting some printf,
 > > 	esiop_intr seems to call esiop_scsicmd_end with offset == 0.
 > 
 > I don't see a problem here. Calling esiop_scsicmd_end with offset == 0 is
 > valid, if the command didn't complete properly. Can you give more detail on
 > what you see wrong here ?

 i expect an error, if the command didn't complete properly.

 > Does the kernel print some message ?

 nothing.

 YAMAMOTO Takashi

From: Manuel Bouyer <bouyer@antioche.eu.org>
To: 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
Date: Fri, 4 Nov 2005 14:12:20 +0100

 On Fri, Nov 04, 2005 at 09:06:54AM +0900, YAMAMOTO Takashi wrote:
 > > > 		db> sh buf 0xfffffc001dde6458
 > > > 		  vp 0x0 lblkno 0xdeadbeefdeadbeef blkno 0x0 dev 0x802
 > > > 		  error 0 flags 0x1c0210<BUSY,DONE,PHYS,RAW,READ>
 > > > 		  bufsize 0x200 bcount 0x200 resid 0x200
 > > > 		  data 0x120018000 saveaddr 0x0 dep 0x0
 > > > 		  iodone 0xfffffc0000480420
 > > > 
 > > > 	after putting some printf,
 > > > 	esiop_intr seems to call esiop_scsicmd_end with offset == 0.
 > > 
 > > I don't see a problem here. Calling esiop_scsicmd_end with offset == 0 is
 > > valid, if the command didn't complete properly. Can you give more detail on
 > > what you see wrong here ?
 > 
 > i expect an error, if the command didn't complete properly.

 It's possible that the drive did complete the command without transfering
 any data. In this case I would expect it to return a CHECK CONDITION status,
 but it seems it doesn't. I'll have to check the standards, but I think the
 target is required to return CHECK CONDITION in this case.

 Can you turn on the various DEBUG bits in esiop.c and see what the drive
 returns in this case ? First you could add a printf() in esiop_scsicmd_end()
 to see what xs->status is.

 -- 
 Manuel Bouyer <bouyer@antioche.eu.org>
      NetBSD: 26 ans d'experience feront toujours la difference
 --

Responsible-Changed-From-To: kern-bug-people->bouyer
Responsible-Changed-By: bouyer@netbsd.org
Responsible-Changed-When: Wed, 09 Nov 2005 19:00:49 +0000
Responsible-Changed-Why:
I sent a patch


State-Changed-From-To: open->feedback
State-Changed-By: bouyer@netbsd.org
State-Changed-When: Wed, 09 Nov 2005 19:00:49 +0000
State-Changed-Why:
I sent a patch


From: Manuel Bouyer <bouyer@antioche.eu.org>
To: gnats-bugs@NetBSD.org
Cc: kern-bug-people@NetBSD.org, gnats-admin@NetBSD.org,
	netbsd-bugs@NetBSD.org
Subject: Re: kern/31990: esiop leaves b_resid non-zero
Date: Wed, 9 Nov 2005 19:59:56 +0100

 --RnlQjJ0d97Da+TV1
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline

 OK, I think I understand the problem, but I can't reproduce it. It's
 probably dependant on the hard drive.

 I think that what happens here is that the drive disconnects after the
 last transfert, before the status phase and without a save data pointer
 message (I'm not sure why a drive would do this for a read, though).
 When the drive reconnects to send the status, the offset stored in
 SCRATCHA1 is reset to 0, so the driver thinks that no transfers occured.

 The attached patch should fix this, can you try it ?

 -- 
 Manuel Bouyer <bouyer@antioche.eu.org>
      NetBSD: 26 ans d'experience feront toujours la difference
 --

 --RnlQjJ0d97Da+TV1
 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	9 Nov 2005 17:52:37 -0000
 @@ -1125,6 +1125,16 @@
  		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->offset will have the proper value 
 +	 * if it got updated by the controller
 +	 */
 +	if (offset == 0 &&
 +	    esiop_cmd->cmd_tables->offset != htole32(SIOP_NOOFFSET))
 +		offset = le32toh(esiop_cmd->cmd_tables->offset);
 +
  	esiop_scsicmd_end(esiop_cmd, offset);
  	if (freetarget && esiop_target->target_c.status == TARST_PROBING)
  		esiop_del_dev(sc, target, lun);
 @@ -1953,15 +1963,20 @@
  		xfer->siop_tables.t_status.count= htole32(1);
  		xfer->siop_tables.t_status.addr = htole32(dsa +
  			offsetof(struct siop_common_xfer, status));
 +		xfer->siop_tables.t_offset.count= htole32(1);
 +		xfer->siop_tables.t_offset.addr = htole32(dsa +
 +			offsetof(struct siop_common_xfer, offset));

  		s = splbio();
  		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/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	9 Nov 2005 17:52:37 -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;
 @@ -915,6 +916,16 @@
  			    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->cmd_tables->status = htole32(offset);
 +			CALL_SCRIPT(Ent_script_sched);
 +			return 1;
  		case A_int_resfail:
  			printf("reselect failed\n");
  			CALL_SCRIPT(Ent_script_sched);
 @@ -939,6 +950,16 @@
  			/* 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, cmd_tables->offset will have the proper value
 +			 * if it got updated by the controller
 +			 */
 +			if (offset == 0 && 
 +			    siop_cmd->cmd_tables->offset !=
 +			    htole32(SIOP_NOOFFSET))
 +				offset = le32toh(siop_cmd->cmd_tables->offset);
  			siop_update_resid(&siop_cmd->cmd_c, offset);
  			siop_cmd->cmd_c.status = CMDST_DONE;
  			goto end;
 @@ -1686,6 +1707,9 @@
  		xfer->siop_tables.t_status.count= htole32(1);
  		xfer->siop_tables.t_status.addr = htole32(dsa +
  				offsetof(struct siop_common_xfer, status));
 +		xfer->siop_tables.t_offset.count= htole32(1);
 +		xfer->siop_tables.t_offset.addr = htole32(dsa +
 +				offsetof(struct siop_common_xfer, offset));
  		/* The select/reselect script */
  		scr = &xfer->resel[0];
  		for (j = 0; j < sizeof(load_dsa) / sizeof(load_dsa[0]); j++)
 @@ -1717,10 +1741,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 +2028,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/siop_common.c
 ===================================================================
 RCS file: /cvsroot/src/sys/dev/ic/siop_common.c,v
 retrieving revision 1.37
 diff -u -r1.37 siop_common.c
 --- ic/siop_common.c	27 Feb 2005 00:27:02 -0000	1.37
 +++ ic/siop_common.c	9 Nov 2005 17:52:37 -0000
 @@ -315,6 +315,8 @@
  	}
  	siop_cmd->siop_tables->status =
  	    htole32(SCSI_SIOP_NOSTATUS); /* set invalid status */
 +	siop_cmd->siop_tables->offset =
 +	    htole32(SIOP_NOOFFSET); /* set invalid offset */

  	siop_cmd->siop_tables->cmd.count =
  	    htole32(siop_cmd->dmamap_cmd->dm_segs[0].ds_len);
 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	9 Nov 2005 17:52:37 -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 offset;	/* 36 */
  	u_int32_t id;		/* 40 */
  	u_int32_t pad2;		/* 44 */
  	scr_table_t t_msgin;	/* 48 */
 @@ -65,13 +65,17 @@
  	scr_table_t t_msgout;	/* 72 */
  	scr_table_t cmd;	/* 80 */
  	scr_table_t t_status;	/* 88 */
 -	scr_table_t data[SIOP_NSG]; /* 96 */
 +	scr_table_t t_offset;	/* 96 */
 +	scr_table_t data[SIOP_NSG]; /* 104 */
  } __packed;

  /* status can hold the SCSI_* status values, and 2 additional values: */
  #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 0xff
 +
  /*
   * 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	9 Nov 2005 17:52:37 -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 Wed Nov  9 17:21:34 2005
   */
  const u_int32_t esiop_script[] = {
  	0xe15c0004, 0x00000000,			/* 000 -   0 */
 @@ -51,7 +51,7 @@
  	0x6a360000, 0x00000000,			/* 160 - 352 */
  	0x6a630000, 0x00000000,			/* 168 - 360 */
  	0x7a600400, 0x00000000,			/* 170 - 368 */
 -	0x88880000, 0x00000500,			/* 178 - 376 */
 +	0x88880000, 0x00000518,			/* 178 - 376 */
  	0x78370000, 0x00000000,			/* 180 - 384 */
  	0x60000400, 0x00000000,			/* 188 - 392 */
  	0x79360000, 0x00000000,			/* 190 - 400 */
 @@ -71,12 +71,12 @@
  	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 */
 +	0x808b0000, 0x000003d0,			/* 218 - 536 */
 +	0x818b0000, 0x00000368,			/* 220 - 544 */
 +	0x828b0000, 0x00000338,			/* 228 - 552 */
 +	0x838b0000, 0x00000340,			/* 230 - 560 */
  	0x98080000, 0x0000ffff,			/* 238 - 568 */
 -	0x88880000, 0x00000480,			/* 240 - 576 */
 +	0x88880000, 0x00000498,			/* 240 - 576 */
  	0xf2340004, 0x00000000,			/* 248 - 584 */
  	0x72690000, 0x00000000,			/* 250 - 592 */
  	0x98040000, 0x0000ff00,			/* 258 - 600 */
 @@ -150,7 +150,7 @@
  	0x745c0200, 0x00000000,			/* 478 - 1144 */
  	0x80840000, 0xfffffeb8,			/* 480 - 1152 */
  	0x7c5cfc00, 0x00000000,			/* 488 - 1160 */
 -	0x88880000, 0x000001e8,			/* 490 - 1168 */
 +	0x88880000, 0x00000200,			/* 490 - 1168 */
  	0xe15c0004, 0x00000000,			/* 498 - 1176 */
  	0x7a5c0200, 0x00000000,			/* 4a0 - 1184 */
  	0xe25c0004, 0x00000000,			/* 4a8 - 1192 */
 @@ -168,70 +168,73 @@
  	0x1f000030, 0x00000030,			/* 508 - 1288 */
  	0x808c0000, 0xfffffd28,			/* 510 - 1296 */
  	0x808c0002, 0xffffffd0,			/* 518 - 1304 */
 -	0x808c0001, 0x000001c8,			/* 520 - 1312 */
 +	0x808c0001, 0x000001e0,			/* 520 - 1312 */
  	0x98040004, 0x0000ff01,			/* 528 - 1320 */
 -	0x88880000, 0x00000190,			/* 530 - 1328 */
 +	0x88880000, 0x000001a8,			/* 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 */
 +	0x98040000, 0x0000ff04,			/* 540 - 1344 */
 +	0x72350000, 0x00000000,			/* 548 - 1352 */
 +	0x808c0000, 0xfffffde8,			/* 550 - 1360 */
 +	0xf2350001, 0x00000060,			/* 558 - 1368 */
 +	0x80880000, 0xfffffdd8,			/* 560 - 1376 */
 +	0x1a000050, 0x00000050,			/* 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 */
 -	0x90080000, 0x00000000,			/* 6e8 - 1768 */
 +	0x1b000058, 0x00000058,			/* 578 - 1400 */
 +	0x6a690000, 0x00000000,			/* 580 - 1408 */
 +	0x80880000, 0xfffffc78,			/* 588 - 1416 */
 +	0x88880000, 0x000000b8,			/* 590 - 1424 */
 +	0x7a600800, 0x00000000,			/* 598 - 1432 */
 +	0x19000068, 0x00000068,			/* 5a0 - 1440 */
 +	0x7e350100, 0x00000000,			/* 5a8 - 1448 */
 +	0x7e100800, 0x00000000,			/* 5b0 - 1456 */
 +	0x7f110000, 0x00000000,			/* 5b8 - 1464 */
 +	0x7f120000, 0x00000000,			/* 5c0 - 1472 */
 +	0x7f130000, 0x00000000,			/* 5c8 - 1480 */
 +	0x818b0000, 0xffffffc8,			/* 5d0 - 1488 */
 +	0x88880000, 0x000000b8,			/* 5d8 - 1496 */
 +	0x7c60f700, 0x00000000,			/* 5e0 - 1504 */
 +	0x80880000, 0xfffffc18,			/* 5e8 - 1512 */
 +	0x88880000, 0x00000058,			/* 5f0 - 1520 */
 +	0x7a600800, 0x00000000,			/* 5f8 - 1528 */
 +	0x18000068, 0x00000068,			/* 600 - 1536 */
 +	0x7e350100, 0x00000000,			/* 608 - 1544 */
 +	0x7e100800, 0x00000000,			/* 610 - 1552 */
 +	0x7f110000, 0x00000000,			/* 618 - 1560 */
 +	0x7f120000, 0x00000000,			/* 620 - 1568 */
 +	0x7f130000, 0x00000000,			/* 628 - 1576 */
 +	0x808b0000, 0xffffffc8,			/* 630 - 1584 */
 +	0x88880000, 0x00000058,			/* 638 - 1592 */
 +	0x7c60f700, 0x00000000,			/* 640 - 1600 */
 +	0x80880000, 0xfffffbb8,			/* 648 - 1608 */
 +	0x72100000, 0x00000000,			/* 650 - 1616 */
 +	0x6a5c0000, 0x00000000,			/* 658 - 1624 */
 +	0x72110000, 0x00000000,			/* 660 - 1632 */
 +	0x6a5d0000, 0x00000000,			/* 668 - 1640 */
 +	0x72120000, 0x00000000,			/* 670 - 1648 */
 +	0x6a5e0000, 0x00000000,			/* 678 - 1656 */
 +	0x72130000, 0x00000000,			/* 680 - 1664 */
 +	0x6a5f0000, 0x00000000,			/* 688 - 1672 */
 +	0x90080000, 0x00000000,			/* 690 - 1680 */
 +	0x725c0000, 0x00000000,			/* 698 - 1688 */
 +	0x6a100000, 0x00000000,			/* 6a0 - 1696 */
 +	0x725d0000, 0x00000000,			/* 6a8 - 1704 */
 +	0x6a110000, 0x00000000,			/* 6b0 - 1712 */
 +	0x725e0000, 0x00000000,			/* 6b8 - 1720 */
 +	0x6a120000, 0x00000000,			/* 6c0 - 1728 */
 +	0x725f0000, 0x00000000,			/* 6c8 - 1736 */
 +	0x6a130000, 0x00000000,			/* 6d0 - 1744 */
 +	0x90080000, 0x00000000,			/* 6d8 - 1752 */
 +	0x7c027f00, 0x00000000,			/* 6e0 - 1760 */
 +	0x60000008, 0x00000000,			/* 6e8 - 1768 */
  	0x60000040, 0x00000000,			/* 6f0 - 1776 */
 -	0x1f000038, 0x00000038,			/* 6f8 - 1784 */
 -	0x98080000, 0x0000ff02,			/* 700 - 1792 */
 +	0x48000000, 0x00000000,			/* 6f8 - 1784 */
 +	0x90080000, 0x00000000,			/* 700 - 1792 */
  	0x60000040, 0x00000000,			/* 708 - 1800 */
 -	0x1f000040, 0x00000040,			/* 710 - 1808 */
 -	0x98080000, 0x0000ff03,			/* 718 - 1816 */
 +	0x1f000038, 0x00000038,			/* 710 - 1808 */
 +	0x98080000, 0x0000ff02,			/* 718 - 1816 */
 +	0x60000040, 0x00000000,			/* 720 - 1824 */
 +	0x1f000040, 0x00000040,			/* 728 - 1832 */
 +	0x98080000, 0x0000ff03,			/* 730 - 1840 */
  };

  const u_int32_t esiop_led_on[] = {
 @@ -249,7 +252,8 @@
  #define	A_t_msg_out	0x00000048
  #define	A_t_cmd	0x00000050
  #define	A_t_status	0x00000058
 -#define	A_t_data	0x00000060
 +#define	A_t_offset	0x00000060
 +#define	A_t_data	0x00000068
  #define	A_target_id	0x00000000
  #define	A_target_luntbl	0x00000008
  #define	A_target_luntbl_tag	0x0000000c
 @@ -286,10 +290,10 @@
  #define	Ent_led_on1	0x000004b0
  #define	Ent_led_on2	0x00000050
  #define	Ent_led_off	0x00000040
 -#define	Ent_status	0x00000560
 +#define	Ent_status	0x00000578
  #define	Ent_msgin	0x00000500
  #define	Ent_msgin_ack	0x00000200
 -#define	Ent_get_extmsgdata	0x00000708
 +#define	Ent_get_extmsgdata	0x00000720
  #define	Ent_send_msgout	0x000004c8
  #define	Ent_script_sched	0x00000340
  #define	Ent_load_targtable	0x000000a0
 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	9 Nov 2005 17:52:37 -0000
 @@ -40,7 +40,8 @@
  ABSOLUTE t_msg_out = 72;
  ABSOLUTE t_cmd = 80;
  ABSOLUTE t_status = 88;
 -ABSOLUTE t_data = 96;
 +ABSOLUTE t_offset = 96;
 +ABSOLUTE t_data = 104;

  ; offsets in the per-target lun table
  ABSOLUTE target_id = 0x0;
 @@ -344,9 +345,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 SCRATCHA1, 1, FROM t_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	9 Nov 2005 17:52:37 -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 Wed Nov  9 17:21:34 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 */
 +	0x19000068, 0x00000068,			/* 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 */
 +	0x18000068, 0x00000068,			/* 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[] = {
 @@ -244,12 +246,14 @@
  #define	A_t_msg_out	0x00000048
  #define	A_t_cmd	0x00000050
  #define	A_t_status	0x00000058
 -#define	A_t_data	0x00000060
 +#define	A_t_offset	0x00000060
 +#define	A_t_data	0x00000068
  #define	A_int_done	0x0000ff00
  #define	A_int_msgin	0x0000ff01
  #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 +263,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	9 Nov 2005 17:52:37 -0000
 @@ -38,7 +38,8 @@
  ABSOLUTE t_msg_out = 72;
  ABSOLUTE t_cmd = 80;
  ABSOLUTE t_status = 88;
 -ABSOLUTE t_data = 96;
 +ABSOLUTE t_offset = 96;
 +ABSOLUTE t_data = 104;

  ;; interrupt codes
  ; interrupts that need a valid DSA
 @@ -47,6 +48,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 +264,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;

 --RnlQjJ0d97Da+TV1--

From: YAMAMOTO Takashi <yamt@mwd.biglobe.ne.jp>
To: bouyer@antioche.eu.org
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
Date: Wed, 16 Nov 2005 17:17:59 +0900

 > The attached patch should fix this, can you try it ?

 i tried "dd if=/dev/rsd0c of=/dev/null" with your patch
 and got EIO after the following messages on console.
 is this an expected behaviour?

 YAMAMOTO Takashi


 esiop0: DMA IRQ: Illegal instruction DMA fifo empty, DSP=0x560 DSA=0x40237464: T/L/Q=1/0/0 last msg_in=0x4 status=0xff
 esiop0: scsi bus reset
 sd0(esiop0:0:1:0): command with tag id 0 reset
 sd0: async, 8-bit transfers, tagged queueing
 sd0: sync (50.00ns offset 15), 16-bit (40.000MB/s) transfers, tagged queueing
 esiop0: DMA IRQ: Illegal instruction DMA fifo empty, DSP=0x560 DSA=0x40237680: T/L/Q=1/0/0 last msg_in=0x4 status=0xff
 esiop0: scsi bus reset
 sd0(esiop0:0:1:0): command with tag id 0 reset
 sd0: async, 8-bit transfers, tagged queueing
 sd0: sync (50.00ns offset 15), 16-bit (40.000MB/s) transfers, tagged queueing
 esiop0: DMA IRQ: Illegal instruction DMA fifo empty, DSP=0x560 DSA=0x4023789c: T/L/Q=1/0/0 last msg_in=0x4 status=0xff
 esiop0: scsi bus reset
 sd0(esiop0:0:1:0): command with tag id 0 reset
 sd0: async, 8-bit transfers, tagged queueing
 sd0: sync (50.00ns offset 15), 16-bit (40.000MB/s) transfers, tagged queueing
 esiop0: DMA IRQ: Illegal instruction DMA fifo empty, DSP=0x560 DSA=0x40237ab8: T/L/Q=1/0/0 last msg_in=0x4 status=0xff
 esiop0: scsi bus reset
 sd0(esiop0:0:1:0): command with tag id 0 reset
 sd0: async, 8-bit transfers, tagged queueing
 sd0: sync (50.00ns offset 15), 16-bit (40.000MB/s) transfers, tagged queueing
 esiop0: DMA IRQ: Illegal instruction DMA fifo empty, DSP=0x560 DSA=0x40237cd4: T/L/Q=1/0/0 last msg_in=0x4 status=0xff
 esiop0: scsi bus reset
 sd0(esiop0:0:1:0): command with tag id 0 reset
 sd0: async, 8-bit transfers, tagged queueing
 sd0: disk label read error
 sd0: sync (50.00ns offset 15), 16-bit (40.000MB/s) transfers, tagged queueing
 esiop0: DMA IRQ: Illegal instruction DMA fifo empty, DSP=0x560 DSA=0x40237ef0: T/L/Q=1/0/0 last msg_in=0x4 status=0xff
 esiop0: scsi bus reset
 sd0(esiop0:0:1:0): command with tag id 0 reset
 sd0: async, 8-bit transfers, tagged queueing
 sd0: sync (50.00ns offset 15), 16-bit (40.000MB/s) transfers, tagged queueing
 esiop0: DMA IRQ: Illegal instruction DMA fifo empty, DSP=0x560 DSA=0x40236168: T/L/Q=1/0/0 last msg_in=0x4 status=0xff
 esiop0: scsi bus reset
 sd0(esiop0:0:1:0): command with tag id 0 reset
 sd0: async, 8-bit transfers, tagged queueing
 sd0: sync (50.00ns offset 15), 16-bit (40.000MB/s) transfers, tagged queueing
 esiop0: DMA IRQ: Illegal instruction DMA fifo empty, DSP=0x560 DSA=0x40236384: T/L/Q=1/0/0 last msg_in=0x4 status=0xff
 esiop0: scsi bus reset
 sd0(esiop0:0:1:0): command with tag id 0 reset
 sd0: async, 8-bit transfers, tagged queueing
 sd0: sync (50.00ns offset 15), 16-bit (40.000MB/s) transfers, tagged queueing
 esiop0: DMA IRQ: Illegal instruction DMA fifo empty, DSP=0x560 DSA=0x402365a0: T/L/Q=1/0/0 last msg_in=0x4 status=0xff
 esiop0: scsi bus reset
 sd0(esiop0:0:1:0): command with tag id 0 reset
 sd0: async, 8-bit transfers, tagged queueing
 sd0: sync (50.00ns offset 15), 16-bit (40.000MB/s) transfers, tagged queueing
 esiop0: DMA IRQ: Illegal instruction DMA fifo empty, DSP=0x560 DSA=0x402367bc: T/L/Q=1/0/0 last msg_in=0x4 status=0xff
 esiop0: scsi bus reset
 sd0(esiop0:0:1:0): command with tag id 0 reset
 sd0: async, 8-bit transfers, tagged queueing

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--

From: YAMAMOTO Takashi <yamt@mwd.biglobe.ne.jp>
To: bouyer@antioche.eu.org
Cc: rcbixler@nyx.net, edwin@spacebugs.nl, 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: Fri, 18 Nov 2005 12:34:51 +0900

 > 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

 my disk seems to start working with this patch.

 YAMAMOTO Takashi

State-Changed-From-To: feedback->closed
State-Changed-By: bouyer@netbsd.org
State-Changed-When: Sat, 26 Nov 2005 20:33:27 +0000
State-Changed-Why:
Fixed in current, pulled up to netbsd-3, requests for netbsd-2 and netbsd-1-6
have been sent.


From: James Chacon <jmc@netbsd.org>
To: gnats-bugs@netbsd.org
Cc: 
Subject: PR/31990 CVS commit: [netbsd-1-6] src/sys/dev
Date: Wed, 14 Dec 2005 03:20:35 +0000 (UTC)

 Module Name:	src
 Committed By:	jmc
 Date:		Wed Dec 14 03:20:35 UTC 2005

 Modified Files:
 	src/sys/dev/ic [netbsd-1-6]: esiop.c esiopvar.h siop.c siopvar.h
 	    siopvar_common.h
 	src/sys/dev/microcode/siop [netbsd-1-6]: esiop.ss siop.ss

 Log Message:
 Pullup via patch (requested in ticket #5957 by bouyer)
   Some drives disconnect after the last data phase without a save data pointer
   message. In such case we would not update resid with the proper value
   (eventually resid would not be updated at all if there was only one data
   phase). To fix this, have the script save the offset in the data tables at
   disconnect time if there was a transfer, and use this to compute the resid
   if the current offset is 0. PR#31990


 To generate a diff of this commit:
 cvs rdiff -r1.16.2.6 -r1.16.2.7 src/sys/dev/ic/esiop.c
 cvs rdiff -r1.7.4.1 -r1.7.4.2 src/sys/dev/ic/esiopvar.h
 cvs rdiff -r1.62.2.5 -r1.62.2.6 src/sys/dev/ic/siop.c
 cvs rdiff -r1.18 -r1.18.4.1 src/sys/dev/ic/siopvar.h
 cvs rdiff -r1.21.4.3 -r1.21.4.4 src/sys/dev/ic/siopvar_common.h
 cvs rdiff -r1.13.4.3 -r1.13.4.4 src/sys/dev/microcode/siop/esiop.ss
 cvs rdiff -r1.15.4.1 -r1.15.4.2 src/sys/dev/microcode/siop/siop.ss

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: James Chacon <jmc@netbsd.org>
To: gnats-bugs@netbsd.org
Cc: 
Subject: PR/31990 CVS commit: [netbsd-1-6] src/sys/dev/microcode/siop
Date: Wed, 14 Dec 2005 03:21:51 +0000 (UTC)

 Module Name:	src
 Committed By:	jmc
 Date:		Wed Dec 14 03:21:51 UTC 2005

 Modified Files:
 	src/sys/dev/microcode/siop [netbsd-1-6]: esiop.out siop.out

 Log Message:
 Regen (requested in ticket #5957 by bouyer)
   Some drives disconnect after the last data phase without a save data pointer
   message. In such case we would not update resid with the proper value
   (eventually resid would not be updated at all if there was only one data
   phase). To fix this, have the script save the offset in the data tables at
   disconnect time if there was a transfer, and use this to compute the resid
   if the current offset is 0. PR#31990


 To generate a diff of this commit:
 cvs rdiff -r1.10.4.3 -r1.10.4.4 src/sys/dev/microcode/siop/esiop.out
 cvs rdiff -r1.14.4.2 -r1.14.4.3 src/sys/dev/microcode/siop/siop.out

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.