All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@oss.qualcomm.com>
To: qemu-devel@nongnu.org
Cc: "Helge Deller" <deller@gmx.de>,
	"Richard Henderson" <richard.henderson@linaro.org>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Mark Cave-Ayland" <mark.cave-ayland@ilande.co.uk>,
	"Fam Zheng" <fam@euphon.net>,
	"Keith Monahan" <keith@techtravels.org>,
	"BALATON Zoltan" <balaton@eik.bme.hu>,
	"Philippe Mathieu-Daudé" <philmd@oss.qualcomm.com>
Subject: [RFC PATCH-for-11.2??? v4 07/14] hw/scsi/ncr53c710: Rewrite the 53C710 SCRIPTS engine
Date: Fri, 20 Nov 2026 18:12:27 +0100	[thread overview]
Message-ID: <20261120171235.61325-8-philmd@oss.qualcomm.com> (raw)
In-Reply-To: <20261120171235.61325-1-philmd@oss.qualcomm.com>

From: Keith Monahan <keith@techtravels.org>

Rewrite the NCR 53C710 model with a SCRIPTS engine derived from QEMU's
LSI53C895A model (hw/scsi/lsi53c895a.c), an actively maintained sibling
in the same NCR/LSI SCRIPTS family, adapted to the 53C710: its register
map, single byte (DSTAT/SSTAT0) interrupt model, big endian SCRIPTS and
table indirect fetch (the part sits on the big endian PA-RISC LASI bus),
and 24 bit DMA counts.  Behaviour follows the NCR 53C710 Data Manual
(Jun 1992) and Programmer's Guide (Oct 1990).

The LASI glue (hw/scsi/lasi_ncr710.c) is the only instantiated device
and embeds one NCR710State by value.  It gains the free_request
SCSIBusInfo callback and request queue init the new core needs, renames
the reselection timer to scripts_timer, and drops the old model's dead
scaffolding (the unused SCNR define, the DPRINTF macros, and unused or
shadowing register macros).

Disconnect and reselect, adapted from lsi53c895a, let a driver overlap
tagged commands: a disconnecting command's request moves onto a per
device queue and is reselected once its data is ready and the engine is
parked at Wait Reselect.  Reselection follows the 53C700 family rather
than the 8xx parts: gated on the (re)selection interrupt enable
(SIEN.SEL) alone, one hot SDID, an SFBR id bitmask in 700 compatibility
mode, and IDENTIFY (plus SIMPLE QUEUE TAG when tagged) replayed on
reconnect.  A disconnect is fabricated only for a tagged command under a
driver that parks on Wait Reselect with SIEN.SEL clear, which today
means HP-UX; untagged transfers and reselection interrupt drivers (e.g.
Linux 53c700) keep the existing connected completion path.

SDTR/WDTR/PPR negotiation is declined with MESSAGE REJECT.

Completion deferral, the synchronous drain, the HP-UX MESSAGE REJECT
quirk, the reentrancy guard and the soft reset request cancel are added
by the following patches, as is the migration version bump: this patch
does not preserve the migration stream of the model it replaces.

Derived from hw/scsi/lsi53c895a.c (Copyright (c) 2006 CodeSourcery,
written by Paul Brook), which is LGPL; this derived work is distributed
under GPL-2.0-or-later, as the LGPL permits.  Replaces the 53C710 model
written for Google Summer of Code 2025 by Soumyajyotii Ssarkar, itself
based on earlier NCR 53C710 work by Helge Deller and by Toni Wilen (for
UAE).

Signed-off-by: Keith Monahan <keith@techtravels.org>
Signed-off-by: Helge Deller <deller@gmx.de>
AI-used-for: Patch series decomposition (commit splitting and ordering)
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
---
 hw/scsi/lasi_ncr710.h |   28 +-
 hw/scsi/ncr53c710.h   |  263 ++--
 hw/scsi/lasi_ncr710.c |  108 +-
 hw/scsi/ncr53c710.c   | 2843 ++++++++++++++---------------------------
 hw/scsi/trace-events  |   42 +-
 5 files changed, 1131 insertions(+), 2153 deletions(-)

diff --git a/hw/scsi/lasi_ncr710.h b/hw/scsi/lasi_ncr710.h
index 450fb7e1c3dc..5168f6171568 100644
--- a/hw/scsi/lasi_ncr710.h
+++ b/hw/scsi/lasi_ncr710.h
@@ -1,12 +1,9 @@
 /*
- * LASI Wrapper for NCR710 SCSI Controller
+ * LASI wrapper for the NCR 53C710 SCSI controller
  *
  * Copyright (c) 2025 Soumyajyotii Ssarkar <soumyajyotisarkar23@gmail.com>
- * This driver was developed during the Google Summer of Code 2025 program.
- * Mentored by Helge Deller <deller@gmx.de>
- *
- * NCR710 SCSI Controller implementation
- * Based on the NCR53C710 Technical Manual Version 3.2, December 2000
+ * Developed during Google Summer of Code 2025, mentored by
+ * Helge Deller <deller@gmx.de>.
  *
  * SPDX-License-Identifier: GPL-2.0-or-later
  */
@@ -22,29 +19,10 @@
 #define TYPE_LASI_NCR710 "lasi-ncr710"
 OBJECT_DECLARE_SIMPLE_TYPE(LasiNCR710State, LASI_NCR710)
 
-#define LASI_SCSI_RESET         0x000   /* SCSI Reset Register */
-#define LASI_SCSI_NCR710_BASE   0x100   /* NCR710 Base Register Offset */
-
-#define PARISC_DEVICE_ID_OFF    0x00    /* HW type, HVERSION, SVERSION */
-#define PARISC_DEVICE_CONFIG_OFF 0x04   /* Configuration data */
-
-#define PHASE_MASK              7
-#define PHASE_DO                0
-
-#define NCR710_SCNTL1_RST       0x08    /* SCSI Reset */
-#define NCR710_ISTAT_RST        0x40    /* Device Reset */
-#define NCR710_ISTAT_ABRT       0x80    /* Script Abort */
-#define NCR710_ISTAT_CON        0x08    /* ISTAT_Connected */
-#define NCR710_DSTAT_DFE        0x80    /* DMA FIFO Empty */
-#define NCR710_CTEST2_DACK      0x01    /* DMA Acknowledge */
-
 typedef struct LasiNCR710State {
     SysBusDevice parent_obj;
     MemoryRegion mmio;
     qemu_irq lasi_irq;       /* IRQ line to LASI controller */
-    uint32_t hw_type;        /* Hardware type (HPHW_*) */
-    uint32_t sversion;       /* Software version */
-    uint32_t hversion;       /* Hardware version */
     NCR710State ncr710;
 } LasiNCR710State;
 
diff --git a/hw/scsi/ncr53c710.h b/hw/scsi/ncr53c710.h
index 7dd0fe5f7589..82202940caa6 100644
--- a/hw/scsi/ncr53c710.h
+++ b/hw/scsi/ncr53c710.h
@@ -1,13 +1,11 @@
 /*
- * QEMU NCR710 SCSI Controller
+ * QEMU NCR 53C710 SCSI I/O Processor emulation
  *
- * Copyright (c) 2025 Soumyajyotii Ssarkar <soumyajyotisarkar23@gmail.com>
+ * Copyright (c) 2026 Keith Monahan <keith@techtravels.org>
  *
- * NCR710 SCSI Controller implementation
- * Based on the NCR53C710 Technical Manual Version 3.2, December 2000
- *
- * Developed from the hackish implementation of NCR53C710 by Helge Deller
- * which was interim based on the hackish implementation by Toni Wilen for UAE
+ * Interface to the 53C710 model (ncr53c710.c).  The only instantiated device is
+ * the LASI wrapper in lasi_ncr710.c, which embeds one NCR710State by value and
+ * drives it through the functions declared here.
  *
  * SPDX-License-Identifier: GPL-2.0-or-later
  */
@@ -15,148 +13,98 @@
 #ifndef HW_NCR53C710_H
 #define HW_NCR53C710_H
 
-#include "hw/core/sysbus.h"
+#include "qemu/queue.h"
 #include "hw/scsi/scsi.h"
-#include "qemu/fifo8.h"
-#include "qom/object.h"
 #include "system/memory.h"
-#include "hw/core/irq.h"
 #include "qemu/timer.h"
+#include "migration/vmstate.h"
+#include "lsi_scsi.h"
 
-#define TYPE_NCR710_SCSI "ncr710-scsi"
-#define TYPE_SYSBUS_NCR710_SCSI "sysbus-ncr710-scsi"
-
-#define SYSBUS_NCR710_SCSI(obj) \
-    OBJECT_CHECK(SysBusNCR710State, (obj), TYPE_SYSBUS_NCR710_SCSI)
-
-#define ENABLE_DEBUG 0
-#if ENABLE_DEBUG
-#define DBG(x)          x
-#define NCR710_DPRINTF(fmt, ...) \
-    fprintf(stderr, "QEMU: " fmt, ## __VA_ARGS__)
-#define BADF(fmt, ...) \
-    fprintf(stderr, "QEMU: error: " fmt, ## __VA_ARGS__)
-#else
-#define DBG(x)         do { } while (0)
-#define NCR710_DPRINTF(fmt, ...) do { } while (0)
-#define BADF(fmt, ...) do { } while (0)
-#endif
-
-/* NCR710 - Little Endian register Ordering */
-#define NCR710_SCNTL0_REG       0x00    /* SCSI Control Zero */
-#define NCR710_SCNTL1_REG       0x01    /* SCSI Control One */
-#define NCR710_SDID_REG         0x02    /* SCSI Destination ID */
-#define NCR710_SIEN_REG         0x03    /* SCSI Interrupt Enable */
-#define NCR710_SCID_REG         0x04    /* SCSI Chip ID */
-#define NCR710_SXFER_REG        0x05    /* SCSI Transfer */
-#define NCR710_SODL_REG         0x06    /* SCSI Output Data Latch */
-#define NCR710_SOCL_REG         0x07    /* SCSI Output Control Latch */
-#define NCR710_SFBR_REG         0x08    /* SCSI First Byte Received */
-#define NCR710_SIDL_REG         0x09    /* SCSI Input Data Latch */
-#define NCR710_SBDL_REG         0x0A    /* SCSI Bus Data Lines */
-#define NCR710_SBCL_REG         0x0B    /* SCSI Bus Control Lines */
-#define NCR710_DSTAT_REG        0x0C    /* DMA Status */
-#define NCR710_SSTAT0_REG       0x0D    /* SCSI Status Zero */
-#define NCR710_SSTAT1_REG       0x0E    /* SCSI Status One */
-#define NCR710_SSTAT2_REG       0x0F    /* SCSI Status Two */
-#define NCR710_DSA_REG          0x10    /* Data Structure Address */
-#define NCR710_CTEST0_REG       0x14    /* Chip Test Zero */
-#define NCR710_CTEST1_REG       0x15    /* Chip Test One */
-#define NCR710_CTEST2_REG       0x16    /* Chip Test Two */
-#define NCR710_CTEST3_REG       0x17    /* Chip Test Three */
-#define NCR710_CTEST4_REG       0x18    /* Chip Test Four */
-#define NCR710_CTEST5_REG       0x19    /* Chip Test Five */
-#define NCR710_CTEST6_REG       0x1A    /* Chip Test Six */
-#define NCR710_CTEST7_REG       0x1B    /* Chip Test Seven */
-#define NCR710_TEMP_REG         0x1C    /* Temporary Stack */
-#define NCR710_DFIFO_REG        0x20    /* DMA FIFO */
-#define NCR710_ISTAT_REG        0x21    /* Interrupt Status */
-#define NCR710_CTEST8_REG       0x22    /* Chip Test Eight */
-#define NCR710_LCRC_REG         0x23    /* Longitudinal Parity */
-#define NCR710_DBC_REG          0x24    /* DMA Byte Counter (24-bit, LE) */
-#define NCR710_DCMD_REG         0x27    /* DMA Command */
-#define NCR710_DNAD_REG         0x28    /* DMA Next Data Address (32-bit, LE) */
-#define NCR710_DSP_REG          0x2C    /* DMA SCRIPTS Pointer (32-bit, LE) */
-#define NCR710_DSPS_REG         0x30    /* DMA SCRIPTS Pointer Save */
-#define NCR710_SCRATCH_REG      0x34    /* Scratch (32-bit, LE) */
-#define NCR710_DMODE_REG        0x38    /* DMA Mode */
-#define NCR710_DIEN_REG         0x39    /* DMA Interrupt Enable */
-#define NCR710_DWT_REG          0x3A    /* DMA Watchdog Timer */
-#define NCR710_DCNTL_REG        0x3B    /* DMA Control */
-#define NCR710_ADDER_REG        0x3C    /* Adder Sum Output (32-bit, LE) */
+/* Register offsets (little endian addressing; the chip is internally LE). */
+#define NCR710_SCNTL0   0x00
+#define NCR710_SCNTL1   0x01
+#define NCR710_SDID     0x02
+#define NCR710_SIEN     0x03
+#define NCR710_SCID     0x04
+#define NCR710_SXFER    0x05
+#define NCR710_SODL     0x06
+#define NCR710_SOCL     0x07
+#define NCR710_SFBR     0x08
+#define NCR710_SIDL     0x09
+#define NCR710_SBDL     0x0a
+#define NCR710_SBCL     0x0b
+#define NCR710_DSTAT    0x0c
+#define NCR710_SSTAT0   0x0d
+#define NCR710_SSTAT1   0x0e
+#define NCR710_SSTAT2   0x0f
+#define NCR710_DSA      0x10
+#define NCR710_CTEST0   0x14
+#define NCR710_CTEST1   0x15
+#define NCR710_CTEST2   0x16
+#define NCR710_CTEST3   0x17
+#define NCR710_CTEST4   0x18
+#define NCR710_CTEST5   0x19
+#define NCR710_CTEST6   0x1a
+#define NCR710_CTEST7   0x1b
+#define NCR710_TEMP     0x1c
+#define NCR710_DFIFO    0x20
+#define NCR710_ISTAT    0x21
+#define NCR710_CTEST8   0x22
+#define NCR710_LCRC     0x23
+#define NCR710_DBC      0x24
+#define NCR710_DCMD     0x27
+#define NCR710_DNAD     0x28
+#define NCR710_DSP      0x2c
+#define NCR710_DSPS     0x30
+#define NCR710_SCRATCH  0x34
+#define NCR710_DMODE    0x38
+#define NCR710_DIEN     0x39
+#define NCR710_DWT      0x3a
+#define NCR710_DCNTL    0x3b
+#define NCR710_ADDER    0x3c
 
 /* DMODE bit 4: Function Code 1 (FC1), kept by an ISTAT.RST soft reset. */
 #define NCR710_DMODE_FC1  0x10
 /* DCNTL bit 5: Enable Acknowledge (EA), kept by an ISTAT.RST soft reset. */
 #define NCR710_DCNTL_EA   0x20
 
-#define NCR710_REG_SIZE         0x100
-
-#define NCR710_BUF_SIZE         4096
-#define NCR710_HOST_ID          7
-#define NCR710_MAX_MSGIN_LEN    8
-#define NCR710_SCSI_FIFO_SIZE   8
-
-typedef enum {
-    NCR710_WAIT_NONE = 0,
-    NCR710_WAIT_RESELECT = 1,
-    NCR710_WAIT_DMA = 2,
-    NCR710_WAIT_RESERVED = 3
-} NCR710WaitState;
-
-typedef enum {
-    NCR710_CMD_PENDING = 0,
-    NCR710_CMD_DATA_READY = 1,
-    NCR710_CMD_COMPLETE = 2
-} NCR710CommandState;
-
-typedef enum {
-    NCR710_MSG_ACTION_NONE = 0,
-    NCR710_MSG_ACTION_DISCONNECT = 1,
-    NCR710_MSG_ACTION_DATA_OUT = 2,
-    NCR710_MSG_ACTION_DATA_IN = 3
-} NCR710MessageAction;
-
-typedef struct NCR710State NCR710State;
-typedef struct NCR710Request NCR710Request;
-
-/*
- * SCSI FIFO structure - 8 transfers deep, 1 byte per transfer
- * (9-bit wide with parity)
- */
-typedef struct {
-    uint8_t data[NCR710_SCSI_FIFO_SIZE];
-    uint8_t parity[NCR710_SCSI_FIFO_SIZE];
-    int head;
-    int count;
-} NCR710_SCSI_FIFO;
-
-struct NCR710Request {
-    SCSIRequest *req;
-    uint32_t tag;
-    uint32_t dma_len;
-    uint32_t pending;
-    uint8_t status;
-    bool active;
-    uint8_t *dma_buf;
-    bool out;
-    uint32_t resume_offset;
-    uint32_t saved_dnad;
-};
-
-struct NCR710State {
-    SysBusDevice parent_obj;
-    MemoryRegion mmio;
-    qemu_irq irq;
+/* The chip revision reported in CTEST8[7:4]. */
+#define NCR710_CHIP_REVISION 0x2
 
+typedef struct NCR710State {
+    /* Wiring filled in by the LASI wrapper before ncr710_soft_reset(). */
     SCSIBus bus;
     AddressSpace *as;
+    qemu_irq irq;
+    /*
+     * SCRIPTS yield/resume timer, mirroring lsi53c895a's scripts_timer.  The
+     * wrapper creates it.
+     */
+    QEMUTimer *scripts_timer;
 
-    /* Registers */
+    /* SCRIPTS engine working state (not directly register mapped). */
+    int carry;
+    int status;
+    int msg_action;
+    int msg_len;
+    uint8_t msg[LSI_MAX_MSGIN_LEN];
+    int waiting;
+    int current_lun;
+    uint32_t select_tag;
+    int command_complete;
+    bool script_running;
+    lsi_request *current;
+    /* Disconnected tagged commands awaiting reselection. */
+    QTAILQ_HEAD(, lsi_request) queue;
+
+    /*
+     * Registers (53C710 layout).  Several (e.g. sodl/sidl/sbdl/lcrc/ctest*) are
+     * readback/scratch only, with no modelled side effects.
+     */
     uint8_t scntl0;
     uint8_t scntl1;
     uint8_t sdid;
-    uint8_t sien0;
+    uint8_t sien;
     uint8_t scid;
     uint8_t sxfer;
     uint8_t sodl;
@@ -171,14 +119,10 @@ struct NCR710State {
     uint8_t sstat2;
     uint32_t dsa;
     uint8_t ctest0;
-    uint8_t ctest1;
-    uint8_t ctest2;
     uint8_t ctest3;
     uint8_t ctest4;
     uint8_t ctest5;
-    uint8_t ctest6;
     uint8_t ctest7;
-    uint8_t ctest8;
     uint32_t temp;
     uint8_t dfifo;
     uint8_t istat;
@@ -194,58 +138,21 @@ struct NCR710State {
     uint8_t dwt;
     uint8_t dcntl;
     uint32_t adder;
-
-    NCR710_SCSI_FIFO scsi_fifo;
-
-    NCR710Request *current;
-    uint8_t status;
-    uint8_t msg[NCR710_MAX_MSGIN_LEN];
-    uint8_t msg_len;
-    uint8_t msg_action;         /* NCR710MessageAction values */
-    int carry;
-    bool script_active;
-    int32_t waiting;            /* NCR710WaitState values */
-    uint8_t command_complete;   /* NCR710CommandState values */
-
-    QEMUTimer *reselection_retry_timer;
-    uint32_t saved_dsps;
-
-    uint32_t select_tag;
-    uint8_t current_lun;
-    uint8_t reselection_id;
-    bool wait_reselect;
-};
-
-typedef struct SysBusNCR710State {
-    SysBusDevice parent_obj;
-    MemoryRegion mmio;
-    MemoryRegion iomem;
-    qemu_irq irq;
-    NCR710State ncr710;
-} SysBusNCR710State;
+} NCR710State;
 
 static inline NCR710State *ncr710_from_scsi_bus(SCSIBus *bus)
 {
     return container_of(bus, NCR710State, bus);
 }
 
-static inline SysBusNCR710State *sysbus_from_ncr710(NCR710State *s)
-{
-    return container_of(s, SysBusNCR710State, ncr710);
-}
-
-DeviceState *ncr53c710_init(MemoryRegion *address_space, hwaddr addr,
-                             qemu_irq irq);
-DeviceState *ncr710_device_create_sysbus(hwaddr addr, qemu_irq irq);
-void ncr710_reg_write(void *opaque, hwaddr addr, uint64_t val, unsigned size);
-uint64_t ncr710_reg_read(void *opaque, hwaddr addr, unsigned size);
+/* Interface used by the LASI wrapper (lasi_ncr710.c). */
+uint64_t ncr710_reg_read(NCR710State *s, hwaddr addr, unsigned size);
+void ncr710_reg_write(NCR710State *s, hwaddr addr, uint64_t val, unsigned size);
 void ncr710_soft_reset(NCR710State *s);
 void ncr710_request_cancelled(SCSIRequest *req);
 void ncr710_command_complete(SCSIRequest *req, size_t resid);
 void ncr710_transfer_data(SCSIRequest *req, uint32_t len);
-void ncr710_execute_script(NCR710State *s);
-void ncr710_set_phase(NCR710State *s, int phase);
-void ncr710_reselection_retry_callback(void *opaque);
+void ncr710_scripts_timer_callback(void *opaque);
 extern const VMStateDescription vmstate_ncr710;
 
 #endif /* HW_NCR53C710_H */
diff --git a/hw/scsi/lasi_ncr710.c b/hw/scsi/lasi_ncr710.c
index 27d8b5c74935..cbb04017ce9c 100644
--- a/hw/scsi/lasi_ncr710.c
+++ b/hw/scsi/lasi_ncr710.c
@@ -1,12 +1,12 @@
 /*
- * LASI Wrapper for NCR710 SCSI Controller
+ * LASI wrapper for the NCR 53C710 SCSI controller
  *
  * Copyright (c) 2025 Soumyajyotii Ssarkar <soumyajyotisarkar23@gmail.com>
- * This driver was developed during the Google Summer of Code 2025 program.
- * Mentored by Helge Deller <deller@gmx.de>
+ * Developed during Google Summer of Code 2025, mentored by
+ * Helge Deller <deller@gmx.de>.
  *
- * NCR710 SCSI Controller implementation
- * Based on the NCR53C710 Technical Manual Version 3.2, December 2000
+ * LASI module glue mapping the 53C710 core in ncr53c710.c onto the HP 715
+ * (-M 715) LASI bus.
  *
  * SPDX-License-Identifier: GPL-2.0-or-later
  */
@@ -24,7 +24,6 @@
 #include "system/dma.h"
 
 #define LASI_710_SVERSION    0x00082
-#define SCNR                 0xBEEFBABE
 #define LASI_710_HVERSION    0x3D
 #define HPHW_FIO             5        /* Fixed I/O module */
 
@@ -34,8 +33,6 @@ static uint64_t lasi_ncr710_reg_read(void *opaque, hwaddr addr,
     LasiNCR710State *s = LASI_NCR710(opaque);
     uint64_t val = 0;
 
-    trace_lasi_ncr710_reg_read(addr, 0, size);
-
     if (addr == 0x00) {  /* Device ID */
         val = (HPHW_FIO << 24) | LASI_710_SVERSION;
         trace_lasi_ncr710_reg_read_id(HPHW_FIO, LASI_710_SVERSION, val);
@@ -51,22 +48,22 @@ static uint64_t lasi_ncr710_reg_read(void *opaque, hwaddr addr,
     if (addr >= 0x100) {
         hwaddr ncr_addr = addr - 0x100;
         if (size == 1) {
+            /*
+             * Single byte access: flip the byte lane (PA-RISC big endian
+             * access -> the chip's little endian register order).
+             */
             ncr_addr ^= 3;
-            NCR710_DPRINTF("Reading value to LASI WRAPPER == 0x%lx%s, "
-                           "val=0x%lx, size=%u\n",
-                           addr - 0x100, size == 1 ? " (XORed)" : "",
-                           val, size);
             val = ncr710_reg_read(&s->ncr710, ncr_addr, size);
         } else {
+            /*
+             * Multibyte access: gather little endian, no lane flip, so
+             * the 24/32 bit registers assemble correctly.
+             */
             val = 0;
             for (unsigned i = 0; i < size; i++) {
                 uint8_t byte_val = ncr710_reg_read(&s->ncr710, ncr_addr + i, 1);
                 val |= ((uint64_t)byte_val) << (i * 8);
-                NCR710_DPRINTF("  Read byte %u from NCR addr 0x%lx: "
-                               "0x%02x\n", i, ncr_addr + i, byte_val);
             }
-            NCR710_DPRINTF("  Reconstructed %u-byte value: 0x%lx\n",
-                           size, val);
         }
 
         trace_lasi_ncr710_reg_forward_read(addr, val);
@@ -84,7 +81,11 @@ static void lasi_ncr710_reg_write(void *opaque, hwaddr addr,
 
     trace_lasi_ncr710_reg_write(addr, val, size);
 
-    if (addr <= 0x0F) {
+    /*
+     * 0x00..0x0f is the read only LASI module header (ID/SVERSION/HVERSION);
+     * writes to it are ignored.
+     */
+    if (addr <= 0x0f) {
         return;
     }
 
@@ -93,16 +94,10 @@ static void lasi_ncr710_reg_write(void *opaque, hwaddr addr,
 
         if (size == 1) {
             ncr_addr ^= 3;
-            NCR710_DPRINTF("Writing value to LASI WRAPPER == 0x%lx%s, "
-                           "val=0x%lx, size=%u\n",
-                           addr - 0x100, size == 1 ? " (XORed)" : "",
-                           val, size);
             ncr710_reg_write(&s->ncr710, ncr_addr, val, size);
         } else {
             for (unsigned i = 0; i < size; i++) {
                 uint8_t byte_val = (val >> (i * 8)) & 0xff;
-                 NCR710_DPRINTF("  Writing byte %u to NCR addr 0x%lx: 0x%02x\n",
-                       i, ncr_addr + i, byte_val);
                 ncr710_reg_write(&s->ncr710, ncr_addr + i, byte_val, 1);
             }
         }
@@ -113,10 +108,7 @@ static void lasi_ncr710_reg_write(void *opaque, hwaddr addr,
     }
 }
 
-/*
- * req_cancelled, command_complete, transfer_data forwards
- * commands to its core counterparts.
- */
+/* SCSIBusInfo callbacks: trace, then forward to the ncr53c710 core. */
 static void lasi_ncr710_request_cancelled(SCSIRequest *req)
 {
     trace_lasi_ncr710_request_cancelled(req);
@@ -129,20 +121,27 @@ static void lasi_ncr710_command_complete(SCSIRequest *req, size_t resid)
     ncr710_command_complete(req, resid);
 }
 
- static void lasi_ncr710_transfer_data(SCSIRequest *req, uint32_t len)
+static void lasi_ncr710_transfer_data(SCSIRequest *req, uint32_t len)
 {
     trace_lasi_ncr710_transfer_data(len);
     ncr710_transfer_data(req, len);
 }
 
+static void lasi_ncr710_free_request(SCSIBus *bus, void *priv)
+{
+    g_free(priv);
+}
+
 static const struct SCSIBusInfo lasi_ncr710_scsi_info = {
     .tcq = true,
+    /* 8-bit bus: targets and LUNs 0-7 (scsi-bus.c maxima are inclusive). */
     .max_target = 7,
     .max_lun = 7,
 
     .transfer_data = lasi_ncr710_transfer_data,
     .complete = lasi_ncr710_command_complete,
     .cancel = lasi_ncr710_request_cancelled,
+    .free_request = lasi_ncr710_free_request,
 };
 
 static const MemoryRegionOps lasi_ncr710_mmio_ops = {
@@ -160,9 +159,6 @@ static const VMStateDescription vmstate_lasi_ncr710 = {
     .version_id = 1,
     .minimum_version_id = 1,
     .fields = (const VMStateField[]) {
-        VMSTATE_UINT32(hw_type, LasiNCR710State),
-        VMSTATE_UINT32(sversion, LasiNCR710State),
-        VMSTATE_UINT32(hversion, LasiNCR710State),
         VMSTATE_STRUCT(ncr710, LasiNCR710State, 1, vmstate_ncr710, NCR710State),
         VMSTATE_END_OF_LIST()
     }
@@ -179,10 +175,11 @@ static void lasi_ncr710_realize(DeviceState *dev, Error **errp)
                   &lasi_ncr710_scsi_info);
     s->ncr710.as = &address_space_memory;
     s->ncr710.irq = s->lasi_irq;
+    QTAILQ_INIT(&s->ncr710.queue);
 
-    s->ncr710.reselection_retry_timer =
+    s->ncr710.scripts_timer =
         timer_new_ns(QEMU_CLOCK_VIRTUAL,
-                     ncr710_reselection_retry_callback,
+                     ncr710_scripts_timer_callback,
                      &s->ncr710);
 
     ncr710_soft_reset(&s->ncr710);
@@ -191,40 +188,26 @@ static void lasi_ncr710_realize(DeviceState *dev, Error **errp)
     s->ncr710.dmode = 0;
 
     trace_lasi_ncr710_timers_initialized(
-        (uint64_t)s->ncr710.reselection_retry_timer);
+        (uint64_t)s->ncr710.scripts_timer);
 
-    /* Initialize memory region */
     memory_region_init_io(&s->mmio, OBJECT(dev), &lasi_ncr710_mmio_ops, s,
                           "lasi-ncr710", 0x200);
     sysbus_init_mmio(sbd, &s->mmio);
 }
 
+static void lasi_ncr710_unrealize(DeviceState *dev)
+{
+    LasiNCR710State *s = LASI_NCR710(dev);
+
+    timer_free(s->ncr710.scripts_timer);
+    s->ncr710.scripts_timer = NULL;
+}
+
 void lasi_ncr710_handle_legacy_cmdline(DeviceState *lasi_dev)
 {
     LasiNCR710State *s = LASI_NCR710(lasi_dev);
-    SCSIBus *bus = &s->ncr710.bus;
-    int found_drives = 0;
 
-    if (!bus) {
-        return;
-    }
-
-    for (int unit = 0; unit <= 7; unit++) {
-        DriveInfo *dinfo = drive_get(IF_SCSI, bus->busnr, unit);
-        if (dinfo) {
-            trace_lasi_ncr710_legacy_drive_found(bus->busnr, unit);
-            found_drives++;
-        }
-    }
-
-    trace_lasi_ncr710_handle_legacy_cmdline(bus->busnr, found_drives);
-
-    scsi_bus_legacy_handle_cmdline(bus);
-    BusChild *kid;
-    QTAILQ_FOREACH(kid, &bus->qbus.children, sibling) {
-        trace_lasi_ncr710_scsi_device_created(
-            object_get_typename(OBJECT(kid->child)));
-    }
+    scsi_bus_legacy_handle_cmdline(&s->ncr710.bus);
 }
 
 DeviceState *lasi_ncr710_init(MemoryRegion *addr_space, hwaddr hpa,
@@ -254,20 +237,12 @@ static void lasi_ncr710_reset(DeviceState *dev)
     s->ncr710.dmode = 0;
 }
 
-static void lasi_ncr710_instance_init(Object *obj)
-{
-    LasiNCR710State *s = LASI_NCR710(obj);
-
-    s->hw_type = HPHW_FIO;
-    s->sversion = LASI_710_SVERSION;
-    s->hversion = LASI_710_HVERSION;
-}
-
 static void lasi_ncr710_class_init(ObjectClass *klass, const void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
 
     dc->realize = lasi_ncr710_realize;
+    dc->unrealize = lasi_ncr710_unrealize;
     set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
     dc->fw_name = "scsi";
     dc->desc = "HP-PARISC LASI NCR710 SCSI adapter";
@@ -280,7 +255,6 @@ static const TypeInfo lasi_ncr710_info = {
     .name          = TYPE_LASI_NCR710,
     .parent        = TYPE_SYS_BUS_DEVICE,
     .instance_size = sizeof(LasiNCR710State),
-    .instance_init = lasi_ncr710_instance_init,
     .class_init    = lasi_ncr710_class_init,
 };
 
diff --git a/hw/scsi/ncr53c710.c b/hw/scsi/ncr53c710.c
index 55153418e409..305958b92f4a 100644
--- a/hw/scsi/ncr53c710.c
+++ b/hw/scsi/ncr53c710.c
@@ -1,1497 +1,958 @@
 /*
- * QEMU NCR710 SCSI Controller
+ * QEMU NCR 53C710 SCSI I/O Processor emulation
  *
- * Copyright (c) 2025 Soumyajyotii Ssarkar <soumyajyotisarkar23@gmail.com>
- * This driver was developed during the Google Summer of Code 2025 program.
+ * Copyright (c) 2026 Keith Monahan <keith@techtravels.org>
+ * Copyright (c) 2006 CodeSourcery (lsi53c895a.c, written by Paul Brook)
  *
- * NCR710 SCSI Controller implementation
- * Based on the NCR53C710 Technical Manual Version 3.2, December 2000
+ * The SCRIPTS engine is derived from QEMU's LSI53C895A model and adapted to
+ * the 53C710's register map, single byte interrupt model, big endian SCRIPTS
+ * fetch and 24 bit DMA, per the NCR 53C710 Data Manual and Programmer's Guide.
  *
- * Developed from an implementation of NCR53C710 by Helge Deller
- * which was interim based on the implementation by Toni Wilen for UAE.
+ * Replaces the 53C710 model written for Google Summer of Code 2025 by
+ * Soumyajyotii Ssarkar <soumyajyotisarkar23@gmail.com>, itself based on
+ * earlier NCR 53C710 work by Helge Deller and by Toni Wilen (for UAE).
  *
  * SPDX-License-Identifier: GPL-2.0-or-later
- *
- * Contents:
- * 1. Register Definitions
- * 2. Register name functions
- * 3. Parity functions
- * 4. SCSI FIFO Structures
- * 5. Scripts Misc functions
- * 6. DMA functions
- * 7. Scripts functions
- * 8. Read and Write functions
- * 9. QEMU Device model functions
- *
  */
 
 #include "qemu/osdep.h"
-#include "qapi/error.h"
-#include "qemu/timer.h"
-#include "hw/core/irq.h"
-#include "hw/core/sysbus.h"
-#include "hw/scsi/scsi.h"
-#include "hw/scsi/ncr53c710.h"
-#include "migration/vmstate.h"
-#include "system/dma.h"
+#include "qemu/bitops.h"
 #include "qemu/log.h"
-#include "qemu/module.h"
+#include "qemu/main-loop.h"
+#include "hw/core/irq.h"
+#include "hw/scsi/ncr53c710.h"
+#include "system/block-backend.h"
 #include "trace.h"
-#include "qom/object.h"
 
-#define NCR710_MAX_DEVS 7
+/* SCNTL0 (0x00) */
+#define LSI_SCNTL0_EPG       0x04
 
-/* SCNTL0 (0x00) - SCSI Control Register 0 */
-#define NCR710_SCNTL0_TRG    0x01
-#define NCR710_SCNTL0_AAP    0x02
-#define NCR710_SCNTL0_EPG    0x04
-#define NCR710_SCNTL0_EPC    0x08
-#define NCR710_SCNTL0_WATN   0x10
-#define NCR710_SCNTL0_START  0x20
-#define NCR710_SCNTL0_ARB0   0x40
-#define NCR710_SCNTL0_ARB1   0x80
+/* SCNTL1 (0x01) */
+#define LSI_SCNTL1_ESR       0x20
 
-/* SCNTL1 (0x01) - SCSI Control Register 1 */
-#define NCR710_SCNTL1_RES0   0x01
-#define NCR710_SCNTL1_RES1   0x02
-#define NCR710_SCNTL1_AESP   0x04
-#define NCR710_SCNTL1_RST    0x08
-#define NCR710_SCNTL1_CON    0x10
-#define NCR710_SCNTL1_ESR    0x20
-#define NCR710_SCNTL1_ADB    0x40
-#define NCR710_SCNTL1_EXC    0x80
+/* SSTAT0 (0x0d) and SIEN (0x03) share this bit layout. */
+#define LSI_STAT0_PAR        0x01
+#define LSI_STAT0_RST        0x02
+#define LSI_STAT0_UDC        0x04
+#define LSI_STAT0_SGE        0x08
+#define LSI_STAT0_SEL        0x10
+#define LSI_STAT0_STO        0x20
+#define LSI_STAT0_FCMP       0x40
+#define LSI_STAT0_MA         0x80
 
-/* ISTAT (0x21) - Interrupt Status Register */
-#define NCR710_ISTAT_DIP    0x01
-#define NCR710_ISTAT_SIP    0x02
-#define NCR710_ISTAT_CON    0x08
-#define NCR710_ISTAT_SIGP   0x20
-#define NCR710_ISTAT_RST    0x40
-#define NCR710_ISTAT_ABRT   0x80
+/* DSTAT (0x0c) and DIEN (0x39) share this bit layout. */
+#define LSI_DSTAT_WTD        0x02
 
-/* SSTAT0 (0x0D) - SCSI Status Register 0 */
-#define NCR710_SSTAT0_PAR    0x01
-#define NCR710_SSTAT0_RST    0x02
-#define NCR710_SSTAT0_UDC    0x04
-#define NCR710_SSTAT0_SGE    0x08
-#define NCR710_SSTAT0_SEL    0x10
-#define NCR710_SSTAT0_STO    0x20
-#define NCR710_SSTAT0_FCMP   0x40
-#define NCR710_SSTAT0_MA     0x80
+/* SBCL (0x0b): low 3 bits mirror the SCSI phase, upper bits are bus signals. */
+#define LSI_SBCL_SEL         0x10
 
-/* SSTAT1 (0x0E) - SCSI Status Register 1 */
-#define NCR710_SSTAT1_ORF    0x02
-#define NCR710_SSTAT1_ILF    0x04
+/* DCNTL (0x3b) */
+#define LSI_DCNTL_FA         0x02
+#define LSI_DCNTL_LLM        0x08
+#define LSI_DCNTL_EA         0x20
 
-/* SSTAT2 (0x0F) - SCSI Status Register 2 */
-#define NCR710_SSTAT2_FF0    0x01
-#define NCR710_SSTAT2_FF1    0x02
-#define NCR710_SSTAT2_FF2    0x04
-#define NCR710_SSTAT2_FF3    0x08
+#define LSI_BUF_SIZE     4096
 
-/* SOCL (0x07) / SBCL (0x0B) - SCSI Output/Bus Control Lines */
-#define NCR710_SOCL_IO       0x01
-#define NCR710_SOCL_CD       0x02
-#define NCR710_SOCL_MSG      0x04
-#define NCR710_SOCL_ATN      0x08
-#define NCR710_SOCL_SEL      0x10
-#define NCR710_SOCL_BSY      0x20
-#define NCR710_SOCL_ACK      0x40
-#define NCR710_SOCL_REQ      0x80
+static const char *const lsi_reg_names[64] = {
+    "SCNTL0", "SCNTL1", "SDID", "SIEN", "SCID", "SXFER", "SODL", "SOCL",
+    "SFBR", "SIDL", "SBDL", "SBCL", "DSTAT", "SSTAT0", "SSTAT1", "SSTAT2",
+    "DSA0", "DSA1", "DSA2", "DSA3", "CTEST0", "CTEST1", "CTEST2", "CTEST3",
+    "CTEST4", "CTEST5", "CTEST6", "CTEST7", "TEMP0", "TEMP1", "TEMP2", "TEMP3",
+    "DFIFO", "ISTAT", "CTEST8", "LCRC", "DBC0", "DBC1", "DBC2", "DCMD",
+    "DNAD0", "DNAD1", "DNAD2", "DNAD3", "DSP0", "DSP1", "DSP2", "DSP3",
+    "DSPS0", "DSPS1", "DSPS2", "DSPS3", "SCRATCH0", "SCRATCH1", "SCRATCH2",
+    "SCRATCH3", "DMODE", "DIEN", "DWT", "DCNTL", "ADDER0", "ADDER1", "ADDER2",
+    "ADDER3",
+};
 
-/* SBCL bits same as SOCL */
-#define NCR710_SBCL_IO       0x01
-#define NCR710_SBCL_CD       0x02
-#define NCR710_SBCL_MSG      0x04
-#define NCR710_SBCL_ATN      0x08
-#define NCR710_SBCL_SEL      0x10
-#define NCR710_SBCL_BSY      0x20
-#define NCR710_SBCL_ACK      0x40
-#define NCR710_SBCL_REQ      0x80
-
-/* DSTAT (0x0C) - DMA Status Register */
-#define NCR710_DSTAT_IID     0x01
-#define NCR710_DSTAT_SIR     0x04
-#define NCR710_DSTAT_SSI     0x08
-#define NCR710_DSTAT_ABRT    0x10
-#define NCR710_DSTAT_BF      0x20
-#define NCR710_DSTAT_MDPE    0x40
-#define NCR710_DSTAT_DFE     0x80
-
-/* DCNTL (0x3B) - DMA Control Register */
-#define NCR710_DCNTL_COM     0x01
-#define NCR710_DCNTL_IRQD    0x02
-#define NCR710_DCNTL_STD     0x04
-#define NCR710_DCNTL_IRQM    0x08
-#define NCR710_DCNTL_SSM     0x10
-#define NCR710_DCNTL_PFEN    0x20
-#define NCR710_DCNTL_PFF     0x40
-
-/* DMODE (0x38) - DMA Mode Register */
-#define NCR710_DMODE_MAN     0x01
-#define NCR710_DMODE_BOF     0x02
-#define NCR710_DMODE_ERMP    0x04
-#define NCR710_DMODE_ERL     0x08
-#define NCR710_DMODE_DIOM    0x10
-#define NCR710_DMODE_SIOM    0x20
-#define NCR710_DMODE_BL_MASK 0xC0
-#define NCR710_DMODE_BL_1    0x00
-#define NCR710_DMODE_BL_2    0x40
-#define NCR710_DMODE_BL_4    0x80
-#define NCR710_DMODE_BL_8    0xC0
-
-/* CTEST2 (0x16) - Chip Test Register 2 */
-#define NCR710_CTEST2_DACK   0x01
-#define NCR710_CTEST2_DREQ   0x02
-#define NCR710_CTEST2_TEOP   0x04
-#define NCR710_CTEST2_PCICIE 0x08
-#define NCR710_CTEST2_CM     0x10
-#define NCR710_CTEST2_CIO    0x20
-#define NCR710_CTEST2_SIGP   0x40
-#define NCR710_CTEST2_DDIR   0x80
-
-/* CTEST5 (0x19) - Chip Test Register 5 */
-#define NCR710_CTEST5_BL2    0x04
-#define NCR710_CTEST5_DDIR   0x08
-#define NCR710_CTEST5_MASR   0x10
-#define NCR710_CTEST5_DFSN   0x20
-#define NCR710_CTEST5_BBCK   0x40
-#define NCR710_CTEST5_ADCK   0x80
-
-/* SCID (0x04) - SCSI Chip ID Register */
-#define NCR710_SCID_RRE      0x60
-#define NCR710_SCID_ID_MASK  0x07
-
-#define NCR710_HOST_ID       7
-
-/* NCR53C710 has 8-byte SCSI FIFO */
-#define NCR710_MAX_MSGIN_LEN 8
-#define NCR710_BUF_SIZE         4096
-
-/* Standard SCSI Message Byte Constants */
-#define SCSI_MSG_ABORT                      0x06
-#define SCSI_MSG_BUS_DEVICE_RESET           0x0c
-#define SCSI_MSG_COMMAND_COMPLETE           0x00
-#define SCSI_MSG_DISCONNECT                 0x04
-#define SCSI_MSG_EXTENDED_MESSAGE           0x01
-#define SCSI_MSG_IDENTIFY                   0x80
-#define SCSI_MSG_IGNORE_WIDE_RESIDUE        0x23
-#define SCSI_MSG_MESSAGE_PARITY_ERROR       0x09
-#define SCSI_MSG_MESSAGE_REJECT             0x07
-#define SCSI_MSG_NO_OPERATION               0x08
-#define SCSI_MSG_RELEASE_RECOVERY           0x10
-#define SCSI_MSG_RESTORE_POINTERS           0x03
-#define SCSI_MSG_SAVE_DATA_POINTER          0x02
-#define SCSI_MSG_SYNCHRONOUS_DATA_TRANSFER  0x01
-#define SCSI_MSG_WIDE_DATA_TRANSFER         0x03
-
-/* Script interrupt codes */
-#define A_GOOD_STATUS_AFTER_STATUS          0x401
-#define A_DISCONNECT_AFTER_CMD              0x380
-#define A_DISCONNECT_AFTER_DATA             0x580
-#define A_DISCONNECT_DURING_DATA            0x780
-#define A_RESELECTION_IDENTIFIED            0x1003
-#define A_UNEXPECTED_PHASE                  0x20
-#define A_FATAL                             0x2000
-#define A_DEBUG_INTERRUPT                   0x3000
-
-/* SCSI Script execution states */
-#define SCRIPT_STATE_IDLE                  0
-#define SCRIPT_STATE_SELECTING             1
-#define SCRIPT_STATE_COMMAND               2
-#define SCRIPT_STATE_DATA                  3
-#define SCRIPT_STATE_STATUS                4
-#define SCRIPT_STATE_MESSAGE               5
-#define SCRIPT_STATE_DISCONNECTED          6
-
-#define AFTER_SELECTION         0x100
-#define BEFORE_CMD              0x200
-#define AFTER_CMD               0x300
-#define AFTER_STATUS            0x400
-#define AFTER_DATA_IN           0x500
-#define AFTER_DATA_OUT          0x600
-#define DURING_DATA_IN          0x700
-
-#define NOT_MSG_OUT             0x10
-#define UNEXPECTED_PHASE        0x20
-#define NOT_MSG_IN              0x30
-#define UNEXPECTED_MSG          0x40
-#define MSG_IN                  0x50
-#define SDTR_MSG_R              0x60
-#define REJECT_MSG_R            0x70
-#define DISCONNECT              0x80
-#define MSG_OUT                 0x90
-#define WDTR_MSG_R              0xA0
-
-#define GOOD_STATUS             0x1
-
-#define NOT_MSG_OUT_AFTER_SELECTION         0x110
-#define UNEXPECTED_PHASE_BEFORE_CMD         0x220
-#define UNEXPECTED_PHASE_AFTER_CMD          0x320
-#define NOT_MSG_IN_AFTER_STATUS             0x430
-#define GOOD_STATUS_AFTER_STATUS            0x401
-#define UNEXPECTED_PHASE_AFTER_DATA_IN      0x520
-#define UNEXPECTED_PHASE_AFTER_DATA_OUT     0x620
-#define UNEXPECTED_MSG_BEFORE_CMD           0x240
-#define MSG_IN_BEFORE_CMD                   0x250
-#define MSG_IN_AFTER_CMD                    0x350
-#define SDTR_MSG_BEFORE_CMD                 0x260
-#define REJECT_MSG_BEFORE_CMD               0x270
-#define DISCONNECT_AFTER_CMD                0x380
-#define SDTR_MSG_AFTER_CMD                  0x360
-#define WDTR_MSG_AFTER_CMD                  0x3A0
-#define MSG_IN_AFTER_STATUS                 0x440
-#define DISCONNECT_AFTER_DATA               0x580
-#define MSG_IN_AFTER_DATA_IN                0x550
-#define MSG_IN_AFTER_DATA_OUT               0x650
-#define MSG_OUT_AFTER_DATA_IN               0x590
-#define DATA_IN_AFTER_DATA_IN               0x5a0
-#define MSG_IN_DURING_DATA_IN               0x750
-#define DISCONNECT_DURING_DATA              0x780
-
-#define RESELECTED_DURING_SELECTION      0x1000
-#define COMPLETED_SELECTION_AS_TARGET    0x1001
-#define RESELECTION_IDENTIFIED           0x1003
-
-#define FATAL                            0x2000
-#define FATAL_UNEXPECTED_RESELECTION_MSG 0x2000
-#define FATAL_SEND_MSG                   0x2001
-#define FATAL_NOT_MSG_IN_AFTER_SELECTION 0x2002
-#define FATAL_ILLEGAL_MSG_LENGTH         0x2003
-
-#define DEBUG_INTERRUPT     0x3000
-#define DEBUG_INTERRUPT1    0x3001
-#define DEBUG_INTERRUPT2    0x3002
-#define DEBUG_INTERRUPT3    0x3003
-#define DEBUG_INTERRUPT4    0x3004
-#define DEBUG_INTERRUPT5    0x3005
-#define DEBUG_INTERRUPT6    0x3006
-
-#define COMMAND_COMPLETE_MSG      0x00
-#define EXTENDED_MSG              0x01
-#define SDTR_MSG                  0x01
-#define SAVE_DATA_PTRS_MSG        0x02
-#define RESTORE_DATA_PTRS_MSG     0x03
-#define WDTR_MSG                  0x03
-#define DISCONNECT_MSG            0x04
-#define REJECT_MSG                0x07
-#define PARITY_ERROR_MSG          0x09
-#define SIMPLE_TAG_MSG            0x20
-#define IDENTIFY_MSG              0x80
-#define IDENTIFY_MSG_MASK         0x7F
-#define TWO_BYTE_MSG              0x20
-#define TWO_BYTE_MSG_MASK         0x0F
-
-/* SCSI phases */
-#define PHASE_DO   0  /* Data out phase */
-#define PHASE_DI   1  /* Data in phase */
-#define PHASE_CO   2  /* Command phase */
-#define PHASE_SI   3  /* Status phase */
-#define PHASE_ST   3  /* Status phase (alias) */
-#define PHASE_MO   6  /* Message out phase */
-#define PHASE_MI   7  /* Message in phase */
-#define PHASE_MASK 7  /* Mask for phase bits */
-
-#define NCR710_TAG_VALID     (1 << 16)
-
-static void ncr710_scsi_fifo_init(NCR710_SCSI_FIFO *fifo);
-static const char *ncr710_reg_name(int offset);
-static void ncr710_script_scsi_interrupt(NCR710State *s, int stat0);
-static void ncr710_update_irq(NCR710State *s);
-static void ncr710_script_dma_interrupt(NCR710State *s, int stat);
-static void ncr710_request_free(NCR710State *s, NCR710Request *p);
-static inline void ncr710_dma_read(NCR710State *s, uint32_t addr,
-                                   void *buf, uint32_t len);
-static inline void ncr710_dma_write(NCR710State *s, uint32_t addr,
-                                    const void *buf, uint32_t len);
-static uint8_t ncr710_reg_readb(NCR710State *s, int offset);
-static void ncr710_reg_writeb(NCR710State *s, int offset, uint8_t val);
-
-
-static inline int ncr710_irq_on_rsl(NCR710State *s)
+static const char *lsi_reg_name(int offset)
 {
-    return (s->sien0 & NCR710_SSTAT0_SEL) != 0;
+    return (offset >= 0 && offset < 64) ? lsi_reg_names[offset] : "???";
 }
 
-static void ncr710_clear_pending_irq(NCR710State *s)
+static uint8_t lsi_reg_readb(NCR710State *s, int offset);
+static void lsi_reg_writeb(NCR710State *s, int offset, uint8_t val);
+static void lsi_execute_script(NCR710State *s);
+static void lsi_set_phase(NCR710State *s, int phase);
+
+/*
+ * On the 53C700 family the Select/Reselect destination ID and SDID are a one
+ * hot bitmask, unlike the 53C8xx's binary target number.
+ */
+static int lsi_id_from_bits(unsigned bits)
 {
-    if (s->current) {
-        if (s->current->req) {
-            s->current->req->hba_private = NULL;
+    int i;
+
+    bits &= 0xff;
+    for (i = 0; i < 8; i++) {
+        if (bits & (1u << i)) {
+            return i;
         }
-        ncr710_request_free(s, s->current);
-        s->current = NULL;
     }
+    qemu_log_mask(LOG_GUEST_ERROR,
+                  "ncr710: empty destination ID bitmask; defaulting to ID 0\n");
+    return 0;
 }
 
 void ncr710_soft_reset(NCR710State *s)
 {
     trace_ncr710_reset();
+
     s->carry = 0;
-    s->msg_action = NCR710_MSG_ACTION_NONE;
+    s->msg_action = LSI_MSG_ACTION_COMMAND;
     s->msg_len = 0;
-    s->waiting = NCR710_WAIT_NONE;
-    s->wait_reselect = false;
-    s->reselection_id = 0;
-    s->dsa = 0;
-    s->dnad = 0;
-    s->dbc = 0;
-    s->temp = 0;
-    s->scratch = 0;
-    s->istat &= 0x40;
-    s->dcmd = 0x40;
-    s->dstat = NCR710_DSTAT_DFE;
-    s->dien = 0x04;
-    s->sien0 = 0;
-    s->ctest2 = NCR710_CTEST2_DACK;
-    s->ctest3 = 0;
-    s->ctest4 = 0;
-    s->ctest5 = 0;
-    s->dsp = 0;
-    s->dsps = 0;
-    s->dmode &= NCR710_DMODE_FC1;
-    s->dcntl &= NCR710_DCNTL_EA;
-    s->scntl0 = 0xc0;
+    s->waiting = LSI_NOWAIT;
+    s->current_lun = 0;
+    s->select_tag = 0;
+    s->command_complete = 0;
+    s->script_running = false;
+
+    s->scntl0 = 0xc0;       /* full arbitration */
     s->scntl1 = 0;
+    s->sdid = 0;
+    s->sien = 0;
+    s->scid = 0;
+    s->sxfer = 0;
+    s->sodl = 0;
+    s->socl = 0;
+    s->sfbr = 0;
+    s->sidl = 0;
+    s->sbdl = 0;
+    s->sbcl = 0;
+    s->dstat = 0;           /* DFE is OR'd in on read */
     s->sstat0 = 0;
     s->sstat1 = 0;
     s->sstat2 = 0;
-    s->scid = 0x80;
-    s->sxfer = 0;
-    s->socl = 0;
-    s->sdid = 0;
-    s->sbcl = 0;
-    s->sidl = 0;
-    s->sfbr = 0;
-    qemu_set_irq(s->irq, 0);
-    if (s->current && s->current->req) {
-        /* Drops hba_private via ncr710_request_cancelled() */
-        scsi_req_cancel(s->current->req);
-    }
-    ncr710_clear_pending_irq(s);
-    ncr710_scsi_fifo_init(&s->scsi_fifo);
-}
+    s->dsa = 0;
+    s->ctest0 = 0;
+    s->ctest3 = 0;
+    s->ctest4 = 0;
+    s->ctest5 = 0;
+    s->ctest7 = 0;
+    s->temp = 0;
+    s->dfifo = 0;
+    s->istat = 0;
+    s->lcrc = 0;
+    s->dbc = 0;
+    s->dcmd = 0;
+    s->dnad = 0;
+    s->dsp = 0;
+    s->dsps = 0;
+    s->scratch = 0;
+    s->dmode &= NCR710_DMODE_FC1;
+    s->dien = 0;
+    s->dwt = 0;
+    s->dcntl &= NCR710_DCNTL_EA;
+    s->adder = 0;
 
-static const char *ncr710_reg_name(int offset)
-{
-    switch (offset) {
-    case NCR710_SCNTL0_REG:      return "SCNTL0";
-    case NCR710_SCNTL1_REG:      return "SCNTL1";
-    case NCR710_SDID_REG:        return "SDID";
-    case NCR710_SIEN_REG:        return "SIEN";
-    case NCR710_SCID_REG:        return "SCID";
-    case NCR710_SXFER_REG:       return "SXFER";
-    case NCR710_SODL_REG:        return "SODL";
-    case NCR710_SOCL_REG:        return "SOCL";
-    case NCR710_SFBR_REG:        return "SFBR";
-    case NCR710_SIDL_REG:        return "SIDL";
-    case NCR710_SBDL_REG:        return "SBDL";
-    case NCR710_SBCL_REG:        return "SBCL";
-    case NCR710_DSTAT_REG:       return "DSTAT";
-    case NCR710_SSTAT0_REG:      return "SSTAT0";
-    case NCR710_SSTAT1_REG:      return "SSTAT1";
-    case NCR710_SSTAT2_REG:      return "SSTAT2";
-    case NCR710_DSA_REG:         return "DSA";
-    case NCR710_DSA_REG + 1:     return "DSA+1";
-    case NCR710_DSA_REG + 2:     return "DSA+2";
-    case NCR710_DSA_REG + 3:     return "DSA+3";
-    case NCR710_CTEST0_REG:      return "CTEST0";
-    case NCR710_CTEST1_REG:      return "CTEST1";
-    case NCR710_CTEST2_REG:      return "CTEST2";
-    case NCR710_CTEST3_REG:      return "CTEST3";
-    case NCR710_CTEST4_REG:      return "CTEST4";
-    case NCR710_CTEST5_REG:      return "CTEST5";
-    case NCR710_CTEST6_REG:      return "CTEST6";
-    case NCR710_CTEST7_REG:      return "CTEST7";
-    case NCR710_TEMP_REG:        return "TEMP";
-    case NCR710_TEMP_REG + 1:    return "TEMP+1";
-    case NCR710_TEMP_REG + 2:    return "TEMP+2";
-    case NCR710_TEMP_REG + 3:    return "TEMP+3";
-    case NCR710_DFIFO_REG:       return "DFIFO";
-    case NCR710_ISTAT_REG:       return "ISTAT";
-    case NCR710_CTEST8_REG:      return "CTEST8";
-    case NCR710_LCRC_REG:        return "LCRC";
-    case NCR710_DBC_REG:         return "DBC";
-    case NCR710_DBC_REG + 1:     return "DBC+1";
-    case NCR710_DBC_REG + 2:     return "DBC+2";
-    case NCR710_DCMD_REG:        return "DCMD";
-    case NCR710_DNAD_REG:        return "DNAD";
-    case NCR710_DNAD_REG + 1:    return "DNAD+1";
-    case NCR710_DNAD_REG + 2:    return "DNAD+2";
-    case NCR710_DNAD_REG + 3:    return "DNAD+3";
-    case NCR710_DSP_REG:         return "DSP";
-    case NCR710_DSP_REG + 1:     return "DSP+1";
-    case NCR710_DSP_REG + 2:     return "DSP+2";
-    case NCR710_DSP_REG + 3:     return "DSP+3";
-    case NCR710_DSPS_REG:        return "DSPS";
-    case NCR710_DSPS_REG + 1:    return "DSPS+1";
-    case NCR710_DSPS_REG + 2:    return "DSPS+2";
-    case NCR710_DSPS_REG + 3:    return "DSPS+3";
-    case NCR710_SCRATCH_REG:     return "SCRATCH";
-    case NCR710_SCRATCH_REG + 1: return "SCRATCH+1";
-    case NCR710_SCRATCH_REG + 2: return "SCRATCH+2";
-    case NCR710_SCRATCH_REG + 3: return "SCRATCH+3";
-    case NCR710_DMODE_REG:       return "DMODE";
-    case NCR710_DIEN_REG:        return "DIEN";
-    case NCR710_DWT_REG:         return "DWT";
-    case NCR710_DCNTL_REG:       return "DCNTL";
-    case NCR710_ADDER_REG:       return "ADDER";
-    case NCR710_ADDER_REG + 1:   return "ADDER+1";
-    case NCR710_ADDER_REG + 2:   return "ADDER+2";
-    case NCR710_ADDER_REG + 3:   return "ADDER+3";
-    default:                     return "UNKNOWN";
+    if (s->scripts_timer) {
+        timer_del(s->scripts_timer);
     }
 }
 
-static uint8_t ncr710_generate_scsi_parity(NCR710State *s, uint8_t data)
+static inline void lsi_mem_read(NCR710State *s, uint32_t addr,
+                                void *buf, uint32_t len)
 {
-    uint8_t parity = parity8(data);
-
-    if (s->scntl1 & NCR710_SCNTL1_AESP) {
-        parity = !parity;
-    }
-
-    return parity;
+    address_space_read(s->as, addr, MEMTXATTRS_UNSPECIFIED, buf, len);
 }
 
-static bool ncr710_check_scsi_parity(NCR710State *s, uint8_t data,
-                                     uint8_t parity)
+static inline void lsi_mem_write(NCR710State *s, uint32_t addr,
+                                 const void *buf, uint32_t len)
 {
-    if (!(s->scntl0 & NCR710_SCNTL0_EPC)) {
-        return true;
-    }
-
-    uint8_t expected_parity = ncr710_generate_scsi_parity(s, data);
-    return parity == expected_parity;
+    address_space_write(s->as, addr, MEMTXATTRS_UNSPECIFIED, buf, len);
 }
 
-static void ncr710_handle_parity_error(NCR710State *s)
-{
-    s->sstat0 |= NCR710_SSTAT0_PAR;
-
-    /* If parity error ATN is enabled, assert ATN */
-    if (s->scntl0 & NCR710_SCNTL0_AAP) {
-        s->socl |= NCR710_SOCL_ATN;
-    }
-
-    ncr710_script_scsi_interrupt(s, NCR710_SSTAT0_PAR);
-}
-
-/*
- * NCR710 SCSI FIFO IMPLEMENTATION
- *
- * Hardware Specifications (NCR53C710 datasheet):
- * - Width: 9 bits (8 data bits + 1 parity bit)
- * - Depth: 8 bytes
- * - Type: Circular buffer
- *
- * Implementation:
- * - Enqueue: Add byte at tail position ((head + count) % 8)
- * - Dequeue: Remove byte from head position, advance head
- * - Status: Empty (count=0), Full (count=8)
- *
- * FIFO Operations:
- * - ncr710_scsi_fifo_init()    - Reset FIFO to empty state
- * - ncr710_scsi_fifo_enqueue() - Add byte with parity to tail
- * - ncr710_scsi_fifo_dequeue() - Remove byte with parity from head
- * - ncr710_scsi_fifo_empty()   - Check if FIFO is empty
- * - ncr710_scsi_fifo_full()    - Check if FIFO is full
- */
-
-static void ncr710_scsi_fifo_init(NCR710_SCSI_FIFO *fifo)
-{
-    memset(fifo->data, 0, NCR710_SCSI_FIFO_SIZE);
-    memset(fifo->parity, 0, NCR710_SCSI_FIFO_SIZE);
-    fifo->head = 0;
-    fifo->count = 0;
-}
-
-static inline bool ncr710_scsi_fifo_empty(NCR710_SCSI_FIFO *fifo)
-{
-    return fifo->count == 0;
-}
-
-static inline bool ncr710_scsi_fifo_full(NCR710_SCSI_FIFO *fifo)
-{
-    return fifo->count == NCR710_SCSI_FIFO_SIZE;
-}
-
-static inline int ncr710_scsi_fifo_enqueue(NCR710_SCSI_FIFO *fifo,
-                                           uint8_t data, uint8_t parity)
-{
-    if (ncr710_scsi_fifo_full(fifo)) {
-        return -1; /* FIFO full - 8 transfers deep */
-    }
-
-    /* Add data at the tail (head + count) */
-    int tail_pos = (fifo->head + fifo->count) % NCR710_SCSI_FIFO_SIZE;
-    fifo->data[tail_pos] = data;
-    fifo->parity[tail_pos] = parity;
-    fifo->count++;
-
-    return 0;
-}
-
-static inline uint8_t ncr710_scsi_fifo_dequeue(NCR710_SCSI_FIFO *fifo,
-                                                uint8_t *parity)
-{
-    uint8_t data;
-
-    if (ncr710_scsi_fifo_empty(fifo)) {
-        *parity = 0;
-        return 0; /* FIFO empty */
-    }
-
-    /* Taking data from the head position */
-    data = fifo->data[fifo->head];
-    *parity = fifo->parity[fifo->head];
-    fifo->head = (fifo->head + 1) % NCR710_SCSI_FIFO_SIZE;
-    fifo->count--;
-
-    return data;
-}
-
-static inline uint32_t ncr710_read_dword(NCR710State *s, uint32_t addr)
+/* SCRIPTS and table indirect structures are built by the big endian CPU. */
+static inline uint32_t lsi_read_dword(NCR710State *s, uint32_t addr)
 {
     uint32_t buf;
-    address_space_read(s->as, addr, MEMTXATTRS_UNSPECIFIED,
-                       (uint8_t *)&buf, 4);
-    /*
-     * The NCR710 datasheet saying "operates internally in LE mode"
-     * refers to its internal register organization,
-     * not how it reads SCRIPTS from host memory.
-     */
-    buf = be32_to_cpu(buf);
-    NCR710_DPRINTF("Read dword %08x from %08x\n", buf, addr);
-    return buf;
+
+    address_space_read(s->as, addr, MEMTXATTRS_UNSPECIFIED, &buf, 4);
+    return be32_to_cpu(buf);
 }
 
-static inline void ncr710_dma_read(NCR710State *s, uint32_t addr,
-                                   void *buf, uint32_t len)
+static void lsi_stop_script(NCR710State *s)
 {
-    address_space_read(s->as, addr, MEMTXATTRS_UNSPECIFIED,
-                       buf, len);
-    NCR710_DPRINTF("Read %d bytes from %08x: ", len, addr);
-    for (int i = 0; i < len && i < 16; i++) {
-        NCR710_DPRINTF("%02x ", ((uint8_t *)buf)[i]);
-    }
-    NCR710_DPRINTF("\n");
+    s->script_running = false;
 }
 
-static inline void ncr710_dma_write(NCR710State *s, uint32_t addr,
-                                    const void *buf, uint32_t len)
-{
-    address_space_write(s->as, addr, MEMTXATTRS_UNSPECIFIED,
-                        buf, len);
-    NCR710_DPRINTF("Wrote %d bytes to %08x\n", len, addr);
-}
-
-static void ncr710_stop_script(NCR710State *s)
-{
-    s->script_active = 0;
-    s->scntl1 &= ~NCR710_SCNTL1_CON;
-    s->istat &= ~NCR710_ISTAT_CON;
-}
-
-static void ncr710_update_irq(NCR710State *s)
+static void lsi_update_irq(NCR710State *s)
 {
     int level = 0;
 
-    if (s->dstat & ~NCR710_DSTAT_DFE) {
+    if (s->dstat) {
         if (s->dstat & s->dien) {
             level = 1;
         }
-        s->istat |= NCR710_ISTAT_DIP;
+        s->istat |= LSI_ISTAT0_DIP;
     } else {
-        s->istat &= ~NCR710_ISTAT_DIP;
+        s->istat &= ~LSI_ISTAT0_DIP;
     }
 
     if (s->sstat0) {
-        if ((s->sstat0 & s->sien0)) {
+        if (s->sstat0 & s->sien) {
             level = 1;
         }
-        s->istat |= NCR710_ISTAT_SIP;
+        s->istat |= LSI_ISTAT0_SIP;
     } else {
-        s->istat &= ~NCR710_ISTAT_SIP;
+        s->istat &= ~LSI_ISTAT0_SIP;
     }
 
+    trace_ncr710_update_irq(level, s->istat, s->sstat0, s->dstat);
     qemu_set_irq(s->irq, level);
 }
 
-static void ncr710_script_scsi_interrupt(NCR710State *s, int stat0)
+/* Raise a SCSI interrupt and stop SCRIPTS on a fatal/unmasked condition. */
+static void lsi_script_scsi_interrupt(NCR710State *s, int stat0)
 {
-    uint32_t mask0;
+    uint8_t mask;
 
     trace_ncr710_script_scsi_interrupt(stat0, s->sstat0);
     s->sstat0 |= stat0;
-    mask0 = stat0 & s->sien0;
-    if (mask0) {
-        ncr710_stop_script(s);
-        s->istat |= NCR710_ISTAT_SIP;
-        ncr710_update_irq(s);
+    /*
+     * FCMP and SEL are nonfatal (only stop when enabled in SIEN); STO never
+     * stops here (execution continues until the next SCSI bus instruction).
+     */
+    mask = s->sien | (uint8_t)~(LSI_STAT0_FCMP | LSI_STAT0_SEL);
+    mask &= ~LSI_STAT0_STO;
+    if (s->sstat0 & mask) {
+        lsi_stop_script(s);
     }
+    lsi_update_irq(s);
 }
 
-static void ncr710_script_dma_interrupt(NCR710State *s, int stat)
+/* Raise a DMA interrupt and stop SCRIPTS (all DMA interrupts are fatal). */
+static void lsi_script_dma_interrupt(NCR710State *s, int stat)
 {
     trace_ncr710_script_dma_interrupt(stat, s->dstat);
-    if (stat == NCR710_DSTAT_SIR && (s->dstat & NCR710_DSTAT_DFE)) {
-        s->dstat &= ~NCR710_DSTAT_DFE;
-    }
-
     s->dstat |= stat;
-    s->istat |= NCR710_ISTAT_DIP;
-    ncr710_update_irq(s);
-    ncr710_stop_script(s);
+    lsi_update_irq(s);
+    lsi_stop_script(s);
 }
 
-inline void ncr710_set_phase(NCR710State *s, int phase)
+static void lsi_set_phase(NCR710State *s, int phase)
 {
+    trace_ncr710_set_phase(phase);
+    s->sbcl = (s->sbcl & ~PHASE_MASK) | phase | LSI_SBCL_REQ;
     s->sstat2 = (s->sstat2 & ~PHASE_MASK) | phase;
-    s->ctest0 &= ~1;
-    if (phase == PHASE_DI) {
-        s->ctest0 |= 1;
-    }
-    s->sbcl &= ~NCR710_SBCL_REQ;
 }
 
-static void ncr710_disconnect(NCR710State *s)
+/* 53C710 has no phase mismatch jump feature; a bad phase always interrupts. */
+static int lsi_bad_phase(NCR710State *s, int new_phase)
+{
+    lsi_script_scsi_interrupt(s, LSI_STAT0_MA);
+    lsi_stop_script(s);
+    lsi_set_phase(s, new_phase);
+    return 1;
+}
+
+static void lsi_resume_script(NCR710State *s)
+{
+    trace_ncr710_resume_script(s->waiting);
+    if (s->waiting != LSI_DMA_SCRIPTS) {
+        s->waiting = LSI_NOWAIT;
+        lsi_execute_script(s);
+    } else {
+        s->waiting = LSI_NOWAIT;
+    }
+}
+
+static void lsi_disconnect(NCR710State *s)
 {
     trace_ncr710_disconnect(s->waiting);
-    if (s->waiting == NCR710_WAIT_NONE) {
-        s->scntl1 &= ~NCR710_SCNTL1_CON;
-        s->istat &= ~NCR710_ISTAT_CON;
-    }
+    s->scntl1 &= ~LSI_SCNTL1_CON;
     s->sstat2 &= ~PHASE_MASK;
+    s->sbcl = 0;
 }
 
-static void ncr710_bad_selection(NCR710State *s, uint32_t id)
+static void lsi_bad_selection(NCR710State *s, uint32_t id)
 {
     trace_ncr710_bad_selection(id);
-    s->dstat = 0;
-    s->dsps = 0;
-    ncr710_script_scsi_interrupt(s, NCR710_SSTAT0_STO);
-    ncr710_disconnect(s);
+    lsi_script_scsi_interrupt(s, LSI_STAT0_STO);
+    lsi_disconnect(s);
 }
 
-static void ncr710_clear_selection_timeout(NCR710State *s)
-{
-    if (s->sstat0 & NCR710_SSTAT0_STO) {
-        s->sstat0 &= ~NCR710_SSTAT0_STO;
-        ncr710_clear_pending_irq(s);
-        if (s->sstat0 == 0) {
-            s->istat &= ~NCR710_ISTAT_SIP;
-        }
-        ncr710_update_irq(s);
-    }
-}
-
-static void ncr710_do_dma(NCR710State *s, int out)
+static void lsi_do_dma(NCR710State *s, int out)
 {
     uint32_t count;
     uint32_t addr;
-    SCSIDevice *dev;
-    assert(s->current);
-    if (!s->current->dma_len) {
-        /* We wait until data is available.  */
+    SCSIRequest *req;
+    lsi_request *p;
+
+    if (!s->current || !s->current->dma_len) {
+        /* Wait until data is available. */
+        trace_ncr710_do_dma_unavailable();
         return;
     }
 
-    dev = s->current->req->dev;
-    assert(dev);
+    p = s->current;
+    req = scsi_req_ref(s->current->req);
 
     count = s->dbc;
-    if (count > s->current->dma_len) {
-        count = s->current->dma_len;
+    if (count > p->dma_len) {
+        count = p->dma_len;
     }
 
     addr = s->dnad;
-
+    trace_ncr710_do_dma(addr, count);
     s->dnad += count;
     s->dbc -= count;
-    if (s->current->dma_buf == NULL) {
-        s->current->dma_buf = scsi_req_get_buf(s->current->req);
+    if (p->dma_buf == NULL) {
+        p->dma_buf = scsi_req_get_buf(req);
     }
-    /* ??? Set SFBR to first data byte.  */
     if (out) {
-        ncr710_dma_read(s, addr, s->current->dma_buf, count);
+        lsi_mem_read(s, addr, p->dma_buf, count);
     } else {
-        ncr710_dma_write(s, addr, s->current->dma_buf, count);
+        lsi_mem_write(s, addr, p->dma_buf, count);
     }
-    s->current->dma_len -= count;
-    if (s->current->dma_len == 0) {
-        s->current->dma_buf = NULL;
-        s->current->pending = 0;
-        s->waiting = NCR710_WAIT_DMA;
-        scsi_req_continue(s->current->req);
+    if (p->orphan) {
+        scsi_req_unref(req);
         return;
+    }
+    scsi_req_unref(req);
+
+    p->dma_len -= count;
+    if (p->dma_len == 0) {
+        p->dma_buf = NULL;
+        scsi_req_continue(req);
     } else {
-        s->current->dma_buf += count;
-        s->waiting = NCR710_WAIT_NONE;
-        ncr710_execute_script(s);
+        p->dma_buf += count;
+        lsi_resume_script(s);
     }
 }
 
-static void ncr710_add_msg_byte(NCR710State *s, uint8_t data)
+static void lsi_add_msg_byte(NCR710State *s, uint8_t data)
 {
-    if (s->msg_len >= NCR710_MAX_MSGIN_LEN) {
-        BADF("MSG IN data too long\n");
+    if (s->msg_len >= LSI_MAX_MSGIN_LEN) {
+        qemu_log_mask(LOG_GUEST_ERROR, "ncr710: MSG IN overflow\n");
     } else {
         s->msg[s->msg_len++] = data;
     }
 }
 
-static void ncr710_request_free(NCR710State *s, NCR710Request *p)
+/*
+ * Reselection-interrupt mode on the 53C700 family is enabled by SIEN.SEL alone,
+ * with no separate SCID.RRE bit.  With it clear, the driver instead parks the
+ * SCRIPTS engine on a Wait Reselect instruction.
+ */
+static inline int lsi_irq_on_rsl(NCR710State *s)
 {
-    if (!p) {
+    return (s->sien & LSI_STAT0_SEL) != 0;
+}
+
+/* First disconnected request whose data the SCSI layer has made ready. */
+static lsi_request *lsi_get_pending_req(NCR710State *s)
+{
+    lsi_request *p;
+
+    QTAILQ_FOREACH(p, &s->queue, next) {
+        if (p->pending) {
+            return p;
+        }
+    }
+    return NULL;
+}
+
+/* Move the in-flight command to the disconnected queue (target disconnect). */
+static void lsi_queue_command(NCR710State *s)
+{
+    lsi_request *p = s->current;
+
+    trace_ncr710_queue_command(p->tag);
+    assert(s->current != NULL);
+    assert(s->current->dma_len == 0);
+    QTAILQ_INSERT_TAIL(&s->queue, s->current, next);
+    s->current = NULL;
+    p->pending = 0;
+    p->out = (s->sstat2 & PHASE_MASK) == PHASE_DO;
+}
+
+/* Reselect a disconnected command to resume its data transfer. */
+static void lsi_reselect(NCR710State *s, lsi_request *p)
+{
+    int id;
+
+    assert(s->current == NULL);
+    QTAILQ_REMOVE(&s->queue, p, next);
+    s->current = p;
+
+    id = (p->tag >> 8) & 0xf;
+    s->sdid = 1 << id;                   /* one-hot target id (53C700 family) */
+    /* 53C700 compatibility: SFBR holds the reselecting id bitmask. */
+    if (!(s->dcntl & LSI_DCNTL_COM)) {
+        s->sfbr = 1 << (id & 0x7);
+    }
+    trace_ncr710_reselect(id);
+    s->scntl1 |= LSI_SCNTL1_CON;
+    lsi_set_phase(s, PHASE_MI);
+    s->msg_action = p->out ? LSI_MSG_ACTION_DOUT : LSI_MSG_ACTION_DIN;
+    s->current->dma_len = p->pending;
+    lsi_add_msg_byte(s, 0x80);        /* IDENTIFY (reselection) */
+    if (s->current->tag & LSI_TAG_VALID) {
+        lsi_add_msg_byte(s, 0x20);    /* SIMPLE QUEUE TAG */
+        lsi_add_msg_byte(s, p->tag & 0xff);
+    }
+    if (lsi_irq_on_rsl(s)) {
+        lsi_script_scsi_interrupt(s, LSI_STAT0_SEL);
+    }
+}
+
+/*
+ * Record that the SCSI layer has data ready for a queued command.  Returns 0 if
+ * the device was reselected (the engine can continue), nonzero if the transfer
+ * is deferred until the engine next parks at Wait Reselect.
+ */
+static int lsi_queue_req(NCR710State *s, SCSIRequest *req, uint32_t len)
+{
+    lsi_request *p = req->hba_private;
+
+    p->pending = len;
+    if (s->waiting == LSI_WAIT_RESELECT ||
+        (lsi_irq_on_rsl(s) && !(s->scntl1 & LSI_SCNTL1_CON) &&
+         !(s->istat & (LSI_ISTAT0_SIP | LSI_ISTAT0_DIP)))) {
+        lsi_reselect(s, p);
+        return 0;
+    }
+    trace_ncr710_queue_req(p->tag);
+    return 1;
+}
+
+/* SCRIPTS Wait Reselect: reconnect a ready queued command, else park. */
+static void lsi_wait_reselect(NCR710State *s)
+{
+    lsi_request *p;
+
+    if (s->current) {
         return;
     }
-    if (p->req && p->req->hba_private == p) {
-        p->req->hba_private = NULL;
+    p = lsi_get_pending_req(s);
+    if (p) {
+        lsi_reselect(s, p);
     }
+    if (s->current == NULL) {
+        s->waiting = LSI_WAIT_RESELECT;
+    }
+}
+
+static void lsi_request_orphan(NCR710State *s, lsi_request *p)
+{
+    p->orphan = true;
     if (p == s->current) {
         s->current = NULL;
+    } else {
+        QTAILQ_REMOVE(&s->queue, p, next);
     }
-    g_free(p);
+    scsi_req_unref(p->req);
 }
 
 void ncr710_request_cancelled(SCSIRequest *req)
 {
     NCR710State *s = ncr710_from_scsi_bus(req->bus);
-    NCR710Request *p = (NCR710Request *)req->hba_private;
-    if (p) {
-        req->hba_private = NULL;
-        p->req = NULL;
-        ncr710_request_free(s, p);
-    }
-    scsi_req_unref(req);
-}
+    lsi_request *p = req->hba_private;
 
-static int ncr710_queue_req(NCR710State *s, SCSIRequest *req, uint32_t len)
-{
-    NCR710Request *p = (NCR710Request *)req->hba_private;
-
-    if (!p) {
-        return -1;
-    }
-    p->pending = len;
-    if ((s->waiting == NCR710_WAIT_RESELECT &&
-        !(s->istat & (NCR710_ISTAT_SIP | NCR710_ISTAT_DIP))) ||
-        (ncr710_irq_on_rsl(s) && !(s->scntl1 & NCR710_SCNTL1_CON) &&
-        !(s->istat & (NCR710_ISTAT_SIP | NCR710_ISTAT_DIP)))) {
-        s->current = p;
-        return 0;
-    } else {
-        s->current = p;
-        return 1;
-    }
+    lsi_request_orphan(s, p);
 }
 
 void ncr710_command_complete(SCSIRequest *req, size_t resid)
 {
     NCR710State *s = ncr710_from_scsi_bus(req->bus);
-    NCR710Request *p = (NCR710Request *)req->hba_private;
+    int stop = 0;
 
     trace_ncr710_command_complete(req->tag, req->status);
-
-    s->lcrc = 0;
     s->status = req->status;
-    s->command_complete = NCR710_CMD_COMPLETE;
-
-    if (p) {
-        p->pending = 0;
-    }
-
-    ncr710_set_phase(s, PHASE_ST);
-
-    if (p) {
-        req->hba_private = NULL;
-        if (p == s->current) {
-            p->req = NULL;
-        } else {
-            ncr710_request_free(s, p);
+    s->command_complete = 2;
+    if (s->waiting && s->dbc != 0) {
+        /* Raise phase mismatch for short transfers. */
+        stop = lsi_bad_phase(s, PHASE_ST);
+        if (stop) {
+            s->waiting = LSI_NOWAIT;
         }
-        scsi_req_unref(req);
+    } else {
+        lsi_set_phase(s, PHASE_ST);
     }
 
-    if (s->waiting == NCR710_WAIT_RESELECT || s->waiting == NCR710_WAIT_DMA) {
-        s->waiting = NCR710_WAIT_NONE;
-        ncr710_execute_script(s);
+    if (req->hba_private == s->current) {
+        lsi_request_orphan(s, s->current);
+    }
+    if (!stop) {
+        lsi_resume_script(s);
     }
 }
 
 void ncr710_transfer_data(SCSIRequest *req, uint32_t len)
 {
     NCR710State *s = ncr710_from_scsi_bus(req->bus);
+    lsi_request *p = req->hba_private;
+    int out;
 
-    assert(req->hba_private);
+    assert(!p->orphan);
 
-    if (s->waiting == NCR710_WAIT_DMA) {
-        NCR710Request *p = (NCR710Request *)req->hba_private;
-        if (p) {
-            p->dma_len = len;
-        }
-        s->dsp -= 8;
-        s->waiting = NCR710_WAIT_NONE;
-        ncr710_execute_script(s);
-        return;
-    }
-
-    if (s->wait_reselect) {
-        s->current = (NCR710Request *)req->hba_private;
-        s->current->dma_len = len;
-        s->waiting = NCR710_WAIT_RESELECT;
-    }
-
-    if (req->hba_private != s->current ||
-        (ncr710_irq_on_rsl(s) && !(s->scntl1 & NCR710_SCNTL1_CON)) ||
-        s->waiting == NCR710_WAIT_RESELECT) {
-        int queue_result = ncr710_queue_req(s, req, len);
-        if (queue_result != 0) {
+    /*
+     * A disconnected command, or one whose data arrives while the engine is
+     * parked at Wait Reselect, must reselect before its data can be moved.
+     */
+    if (s->waiting == LSI_WAIT_RESELECT || p != s->current ||
+        (lsi_irq_on_rsl(s) && !(s->scntl1 & LSI_SCNTL1_CON))) {
+        if (lsi_queue_req(s, req, len)) {
             return;
         }
     }
 
-    /* Host adapter (re)connected */
-    s->command_complete = NCR710_CMD_DATA_READY;
-    if (!s->current) {
-        return;
-    }
+    out = (s->sstat2 & PHASE_MASK) == PHASE_DO;
+
+    trace_ncr710_transfer_data(req->tag, len);
     s->current->dma_len = len;
-
+    s->command_complete = 1;
     if (s->waiting) {
-        s->scntl1 |= NCR710_SCNTL1_CON;
-        s->istat |= NCR710_ISTAT_CON;
-        s->sbcl = NCR710_SBCL_IO | NCR710_SBCL_CD | NCR710_SBCL_MSG |
-                  NCR710_SBCL_BSY | NCR710_SBCL_SEL | NCR710_SBCL_REQ;
-        uint8_t host_id = (s->scid & 0x07);
-
-        /* Special case: both target and host are ID 0 */
-        if (req->dev->id == 0 && host_id == 0) {
-            s->sfbr = 0x00;
+        if (s->waiting == LSI_WAIT_RESELECT || s->dbc == 0) {
+            lsi_resume_script(s);
         } else {
-            s->sfbr = (req->dev->id == 0 ? 0 : (1 << req->dev->id)) |
-                      (host_id == 0 ? 0 : (1 << host_id));
+            lsi_do_dma(s, out);
         }
-
-        ncr710_set_phase(s, PHASE_MI);
-
-        if (s->current) {
-            uint8_t identify_msg = 0x80 | (req->lun & 0x07);
-            ncr710_add_msg_byte(s, identify_msg);
-
-            if (s->current->tag) {
-                ncr710_add_msg_byte(s, 0x20);  /* SIMPLE_TAG_MSG */
-                ncr710_add_msg_byte(s, s->current->tag & 0xff);
-            }
-        }
-
-        s->sstat0 |= NCR710_SSTAT0_SEL;
-        s->istat |= NCR710_ISTAT_SIP;
-        s->dsps = RESELECTED_DURING_SELECTION;
-        s->waiting = NCR710_WAIT_NONE;
-        ncr710_update_irq(s);
-        return;
-    }
-    if (!s->script_active && !s->waiting) {
-        ncr710_execute_script(s);
     }
 }
 
-static int idbitstonum(uint8_t id)
-{
-    return 7 - clz8(id);
-}
-
-static void ncr710_do_command(NCR710State *s)
+static void lsi_do_command(NCR710State *s)
 {
     SCSIDevice *dev;
-    uint8_t buf[16];
+    uint8_t buf[16] = {0};
     uint32_t id;
     int n;
-    int bytes_read;
+
     if (s->dbc > 16) {
         s->dbc = 16;
     }
-
-    /*
-     * Reading command data directly from memory
-     * NOTE: SCSI commands can be up to 16 bytes
-     * (e.g., READ_CAPACITY_10 is 10 bytes) but the NCR710 SCSI FIFO is
-     * only 8 bytes deep. For command phase, we bypass the FIFO and read
-     * directly from memory since commands don't need FIFO buffering.
-     */
-    bytes_read = MIN(s->dbc, sizeof(buf));
-    ncr710_dma_read(s, s->dnad, buf, bytes_read);
-
-    s->dnad += bytes_read;
-    s->dbc -= bytes_read;
+    lsi_mem_read(s, s->dnad, buf, s->dbc);
     s->sfbr = buf[0];
+    s->command_complete = 0;
+    trace_ncr710_do_command(s->dbc, buf[0],
+                            (buf[2] << 24) | (buf[3] << 16) |
+                            (buf[4] << 8) | buf[5],
+                            (buf[7] << 8) | buf[8]);
 
-    s->command_complete = NCR710_CMD_PENDING;
-    id = (s->select_tag >> 8) & 0xff;
-    s->lcrc = id;
-
-    dev = scsi_device_find(&s->bus, 0, idbitstonum(id), s->current_lun);
-
+    id = (s->select_tag >> 8) & 0xf;
+    dev = scsi_device_find(&s->bus, 0, id, s->current_lun);
     if (!dev) {
-        ncr710_bad_selection(s, id);
+        lsi_bad_selection(s, id);
         return;
     }
 
-    if (s->current) {
-        ncr710_request_free(s, s->current);
-        s->current = NULL;
-    }
-
-    s->current = g_new0(NCR710Request, 1);
+    assert(s->current == NULL);
+    s->current = g_new0(lsi_request, 1);
     s->current->tag = s->select_tag;
-    s->current->resume_offset = 0;
-
     s->current->req = scsi_req_new(dev, s->current->tag, s->current_lun, buf,
-                                   bytes_read, s->current);
+                                   s->dbc, s->current);
+
     n = scsi_req_enqueue(s->current->req);
     if (n) {
         if (n > 0) {
-            ncr710_set_phase(s, PHASE_DI);
+            lsi_set_phase(s, PHASE_DI);
         } else if (n < 0) {
-            ncr710_set_phase(s, PHASE_DO);
+            lsi_set_phase(s, PHASE_DO);
         }
         scsi_req_continue(s->current->req);
     }
-
     if (!s->command_complete) {
-        if (!n) {
-            ncr710_set_phase(s, PHASE_SI);
+        if (n) {
+            if ((s->current->tag & LSI_TAG_VALID) &&
+                !lsi_irq_on_rsl(s)) {
+                /*
+                 * Tagged command whose data is not yet ready, issued by a
+                 * driver that parks the SCRIPTS engine on a Wait Reselect
+                 * instruction (SIEN.SEL clear).  Disconnect and queue it so the
+                 * bus is free for further tagged commands.  Untagged transfers
+                 * and reselection-interrupt drivers stay connected.
+                 */
+                lsi_add_msg_byte(s, 2);   /* SAVE DATA POINTER */
+                lsi_add_msg_byte(s, 4);   /* DISCONNECT */
+                lsi_set_phase(s, PHASE_MI);
+                s->msg_action = LSI_MSG_ACTION_DISCONNECT;
+                lsi_queue_command(s);
+            }
         } else {
-            NCR710_DPRINTF("Data transfer phase\n");
+            /*
+             * Async no data command.  Park with dbc = 0 so the engine stops in
+             * COMMAND without a data phase.
+             */
+            s->dbc = 0;
+            s->waiting = LSI_DMA_IN_PROGRESS;
         }
     }
 }
 
-static void ncr710_do_status(NCR710State *s)
+static void lsi_do_status(NCR710State *s)
 {
-    uint8_t status = s->status;
-    uint8_t parity = 0;
+    uint8_t status;
 
+    trace_ncr710_do_status(s->dbc, s->status);
     if (s->dbc != 1) {
-        BADF("Bad Status move\n");
+        qemu_log_mask(LOG_GUEST_ERROR,
+                      "ncr710: STATUS move requested %u bytes (expected 1)\n",
+                      s->dbc);
     }
     s->dbc = 1;
+    status = s->status;
     s->sfbr = status;
-
-    /* Generate parity if enabled and enqueue status byte */
-    if (s->scntl0 & NCR710_SCNTL0_EPG) {
-        parity = ncr710_generate_scsi_parity(s, status);
-    }
-    ncr710_scsi_fifo_enqueue(&s->scsi_fifo, status, parity);
-
-    /* Dequeue status byte and write to memory */
-    status = ncr710_scsi_fifo_dequeue(&s->scsi_fifo, &parity);
-    if (s->scntl0 & NCR710_SCNTL0_EPC) {
-        if (!ncr710_check_scsi_parity(s, status, parity)) {
-            ncr710_handle_parity_error(s);
-        }
-    }
-    ncr710_dma_write(s, s->dnad, &status, 1);
-
-    s->dnad += 1;
-    s->dbc  -= 1;
-
-    ncr710_set_phase(s, PHASE_MI);
-    s->msg_action = NCR710_MSG_ACTION_DISCONNECT;
-    ncr710_add_msg_byte(s, 0); /* COMMAND COMPLETE */
-    s->command_complete = NCR710_CMD_COMPLETE;
+    lsi_mem_write(s, s->dnad, &status, 1);
+    lsi_set_phase(s, PHASE_MI);
+    s->msg_action = LSI_MSG_ACTION_DISCONNECT;
+    lsi_add_msg_byte(s, 0);            /* COMMAND COMPLETE */
 }
 
-static void ncr710_do_msgin(NCR710State *s)
+static void lsi_do_msgin(NCR710State *s)
 {
-    int len;
+    uint8_t len;
+
+    trace_ncr710_do_msgin(s->dbc, s->msg_len);
+    if (s->msg_len == 0) {
+        /*
+         * MOVE WHEN MSG IN with no message queued: transfer nothing (SFBR
+         * keeps its last byte).  After a declined negotiation MESSAGE REJECT
+         * (msg_action COMMAND) the target switches to COMMAND.
+         */
+        if (s->msg_action == LSI_MSG_ACTION_COMMAND) {
+            lsi_set_phase(s, PHASE_CMD);
+        }
+        return;
+    }
+    s->sfbr = s->msg[0];
     len = s->msg_len;
+    assert(len <= LSI_MAX_MSGIN_LEN);
     if (len > s->dbc) {
         len = s->dbc;
     }
-    s->sfbr = s->msg[0];
 
-    for (int i = 0; i < len; i++) {
-        uint8_t parity = 0;
-        if (s->scntl0 & NCR710_SCNTL0_EPG) {
-            parity = ncr710_generate_scsi_parity(s, s->msg[i]);
-        }
-        ncr710_scsi_fifo_enqueue(&s->scsi_fifo, s->msg[i], parity);
-    }
-
-    uint8_t buf[NCR710_MAX_MSGIN_LEN];
-    for (int i = 0; i < len; i++) {
-        uint8_t parity;
-        buf[i] = ncr710_scsi_fifo_dequeue(&s->scsi_fifo, &parity);
-        if (s->scntl0 & NCR710_SCNTL0_EPC) {
-            if (!ncr710_check_scsi_parity(s, buf[i], parity)) {
-                ncr710_handle_parity_error(s);
-            }
+    if (len) {
+        lsi_mem_write(s, s->dnad, s->msg, len);
+        /* Drivers rely on the last byte being in SIDL. */
+        s->sidl = s->msg[len - 1];
+        s->msg_len -= len;
+        if (s->msg_len) {
+            memmove(s->msg, s->msg + len, s->msg_len);
         }
     }
-    ncr710_dma_write(s, s->dnad, buf, len);
 
-    s->dnad += len;
-    s->dbc  -= len;
-    s->sidl = s->msg[len - 1];
-    s->msg_len -= len;
-    if (s->msg_len) {
-        memmove(s->msg, s->msg + len, s->msg_len);
-        return;
-    }
-    switch (s->msg_action) {
-    case NCR710_MSG_ACTION_NONE:
-        ncr710_set_phase(s, PHASE_CO);
-        break;
-    case NCR710_MSG_ACTION_DISCONNECT:
-        s->sstat2 &= ~PHASE_MASK;
-        break;
-    case NCR710_MSG_ACTION_DATA_OUT:
-        ncr710_set_phase(s, PHASE_DO);
-        break;
-    case NCR710_MSG_ACTION_DATA_IN:
-        ncr710_set_phase(s, PHASE_DI);
-        break;
-    default:
-        abort();
+    if (!s->msg_len) {
+        switch (s->msg_action) {
+        case LSI_MSG_ACTION_COMMAND:
+            /* Stay in MSG IN until the next block move requests COMMAND. */
+            break;
+        case LSI_MSG_ACTION_DISCONNECT:
+            lsi_disconnect(s);
+            break;
+        case LSI_MSG_ACTION_DOUT:
+            lsi_set_phase(s, PHASE_DO);
+            break;
+        case LSI_MSG_ACTION_DIN:
+            lsi_set_phase(s, PHASE_DI);
+            break;
+        default:
+            abort();
+        }
     }
 }
 
-static void ncr710_do_msgout(NCR710State *s)
+static uint8_t lsi_get_msgbyte(NCR710State *s)
 {
-    NCR710Request *current_req = s->current;
+    uint8_t data;
 
-    while (s->dbc > 0) {
-        int to_move = MIN((int)s->dbc, NCR710_SCSI_FIFO_SIZE);
-        uint8_t temp_buf[NCR710_SCSI_FIFO_SIZE];
-        ncr710_dma_read(s, s->dnad, temp_buf, to_move);
-        int filled = 0;
-        for (int j = 0; j < to_move &&
-                 !ncr710_scsi_fifo_full(&s->scsi_fifo); j++) {
-            uint8_t parity = 0;
-            if (s->scntl0 & NCR710_SCNTL0_EPG) {
-                parity = ncr710_generate_scsi_parity(s, temp_buf[j]);
-            }
-            if (ncr710_scsi_fifo_enqueue(&s->scsi_fifo, temp_buf[j],
-                                         parity) == 0) {
-                filled++;
-            } else {
-                break;
-            }
-        }
+    lsi_mem_read(s, s->dnad, &data, 1);
+    s->dnad++;
+    s->dbc--;
+    return data;
+}
 
-        if (filled <= 0) {
+static void lsi_skip_msgbytes(NCR710State *s, unsigned int n)
+{
+    s->dnad += n;
+    s->dbc -= n;
+}
+
+static void lsi_do_msgout(NCR710State *s)
+{
+    uint8_t msg;
+
+    trace_ncr710_do_msgout(s->dbc);
+    while (s->dbc) {
+        msg = lsi_get_msgbyte(s);
+        s->sfbr = msg;
+
+        switch (msg) {
+        case 0x04:
+            lsi_disconnect(s);
             break;
-        }
-        uint8_t buf[NCR710_SCSI_FIFO_SIZE];
-        int bytes = 0;
-        for (int j = 0; j < filled &&
-                 !ncr710_scsi_fifo_empty(&s->scsi_fifo); j++) {
-            uint8_t parity;
-            buf[bytes] = ncr710_scsi_fifo_dequeue(&s->scsi_fifo, &parity);
-            if (s->scntl0 & NCR710_SCNTL0_EPC) {
-                if (!ncr710_check_scsi_parity(s, buf[bytes], parity)) {
-                    ncr710_handle_parity_error(s);
-                }
-            }
-            bytes++;
-        }
-
-        s->dnad += bytes;
-        s->dbc  -= bytes;
-        int i = 0;
-        while (i < bytes) {
-            uint8_t msg = buf[i++];
-            s->sfbr = msg;
-
+        case 0x08:                       /* NOP */
+            lsi_set_phase(s, PHASE_CMD);
+            break;
+        case 0x01:                       /* Extended message */
+            lsi_get_msgbyte(s);       /* skip the length byte */
+            msg = lsi_get_msgbyte(s);
             switch (msg) {
-            case SCSI_MSG_COMMAND_COMPLETE:
-                /* 0x00 - NOP / padding byte / Command Complete */
-                /* Just gonna ignore padding bytes, continue processing */
-                break;
-
-            case SCSI_MSG_DISCONNECT: /* 0x04 - Disconnect */
-                ncr710_disconnect(s);
-                break;
-
-            case SCSI_MSG_MESSAGE_REJECT: /* 0x07 - Message Reject */
-                /* Target is rejecting our last message */
-                ncr710_set_phase(s, PHASE_CO);
-                break;
-
-            case SCSI_MSG_NO_OPERATION: /* 0x08 - NOP */
-                ncr710_set_phase(s, PHASE_CO);
-                break;
-
-            case SCSI_MSG_SAVE_DATA_POINTER: /* 0x02 - Save Data Pointer */
-                /* Save current data pointer for later restore */
-                break;
-
-            case SCSI_MSG_RESTORE_POINTERS: /* 0x03 - Restore Pointers */
-                /* Restore previously saved data pointer */
-                break;
-
-            case SCSI_MSG_EXTENDED_MESSAGE: { /* 0x01 - Extended message */
-                if (i >= bytes) {
-                    /* Not enough data; let next chunk continue parsing */
-                    i--; /* rewind one to reparse later */
-                    goto out_chunk;
-                }
-                i++; /* skip ext_len */
-
-                if (i >= bytes) {
-                    i -= 2; /* rewind msg + ext_len for next chunk */
-                    goto out_chunk;
-                }
-                uint8_t ext_code = buf[i++];
-
-                switch (ext_code) {
-                case 1: /* SDTR (ignore body) */
-                    /* Body has 2 bytes, may span chunks: skip what we have */
-                    {
-                        int skip = MIN(2, bytes - i);
-                        i += skip;
-                        /*
-                         * If not all skipped this chunk, rest will arrive
-                         * in next loop
-                         */
-                    }
-                    break;
-                case 3: /* WDTR (ignore body) */
-                    if (i < bytes) {
-                        i++; /* skip one param byte if present this chunk */
-                    }
-                    break;
-                default:
-                    goto bad;
-                }
-                break;
-            }
-
-            case 0x20: /* SIMPLE queue tag */
-            case 0x21: /* HEAD of queue tag */
-            case 0x22: /* ORDERED queue tag */
-                if (i < bytes) {
-                    uint8_t tag = buf[i++];
-                    s->select_tag = (s->select_tag & 0xFF00) | tag |
-                                    NCR710_TAG_VALID;
-                    NCR710_DPRINTF("Tagged command: tag=0x%02x, "
-                                   "type=0x%02x\n", tag, msg);
-                } else {
-                    /*
-                     * Tag byte not in this chunk; rewind and reparse
-                     * next loop
-                     */
-                    i--;
-                    goto out_chunk;
-                }
-                break;
-
-            case 0x0d: /* ABORT TAG */
-                if (current_req) {
-                    scsi_req_cancel(current_req->req);
-                }
-                ncr710_disconnect(s);
-                break;
-
-            case SCSI_MSG_ABORT: /* 0x06 - ABORT */
-            case 0x0e: /* CLEAR QUEUE */
-            case SCSI_MSG_BUS_DEVICE_RESET: /* 0x0c - BUS DEVICE RESET */
-                if (s->current) {
-                    scsi_req_cancel(s->current->req);
-                }
-                ncr710_disconnect(s);
-                break;
-
+            case 1:                      /* SDTR */
+                lsi_skip_msgbytes(s, 2);
+                goto reject;
+            case 3:                      /* WDTR */
+                lsi_skip_msgbytes(s, 1);
+                goto reject;
+            case 4:                      /* PPR */
+                lsi_skip_msgbytes(s, 5);
+                goto reject;
             default:
-                if (msg & SCSI_MSG_IDENTIFY) {
-                    uint8_t lun = msg & 0x07;
-                    s->current_lun = lun;
-                    ncr710_set_phase(s, PHASE_CO);
-                    break;
-                }
-
-                /* Unknown message - reject it */
                 goto bad;
             }
+            break;
+        case 0x20:                       /* SIMPLE queue tag */
+            s->select_tag &= ~0xff;
+            s->select_tag |= lsi_get_msgbyte(s) | LSI_TAG_VALID;
+            break;
+        case 0x21:                       /* HEAD of queue tag */
+        case 0x22:                       /* ORDERED queue tag */
+            s->select_tag &= ~0xff;
+            s->select_tag |= lsi_get_msgbyte(s) | LSI_TAG_VALID;
+            break;
+        case 0x0d:                       /* ABORT TAG */
+        case 0x06:                       /* ABORT */
+        case 0x0e:                       /* CLEAR QUEUE */
+        case 0x0c:                       /* BUS DEVICE RESET */
+            if (s->current && s->current->req) {
+                scsi_req_cancel(s->current->req);
+            }
+            lsi_disconnect(s);
+            break;
+        default:
+            if ((msg & 0x80) == 0) {
+                goto bad;
+            }
+            s->current_lun = msg & 7;    /* IDENTIFY */
+            lsi_set_phase(s, PHASE_CMD);
+            break;
         }
-
-out_chunk:
-        continue;
     }
-
     return;
-
+reject:
+    /* Decline SDTR/WDTR/PPR negotiation with a single MESSAGE REJECT. */
+    lsi_set_phase(s, PHASE_MI);
+    lsi_add_msg_byte(s, 7);           /* MESSAGE REJECT */
+    s->msg_action = LSI_MSG_ACTION_COMMAND;
+    return;
 bad:
-    BADF("Unimplemented/Invalid message 0x%02x\n", s->sfbr);
-    ncr710_set_phase(s, PHASE_MI);
-    ncr710_add_msg_byte(s, 7);
-    s->msg_action = NCR710_MSG_ACTION_NONE;
+    qemu_log_mask(LOG_UNIMP, "ncr710: unimplemented message 0x%02x\n", msg);
+    lsi_set_phase(s, PHASE_MI);
+    lsi_add_msg_byte(s, 7);           /* MESSAGE REJECT */
+    s->msg_action = LSI_MSG_ACTION_COMMAND;
 }
 
-static void ncr710_memcpy(NCR710State *s, uint32_t dest, uint32_t src,
-                          int count)
+static void lsi_memcpy(NCR710State *s, uint32_t dest, uint32_t src, int count)
 {
-    uint8_t buf[NCR710_BUF_SIZE];
+    QEMU_UNINITIALIZED uint8_t buf[LSI_BUF_SIZE];
+    int n;
 
     while (count) {
-        int chunk = MIN(count, NCR710_BUF_SIZE);
-        /* Read from source */
-        ncr710_dma_read(s, src, buf, chunk);
-
-        /* Write to destination */
-        ncr710_dma_write(s, dest, buf, chunk);
-
-        src += chunk;
-        dest += chunk;
-        count -= chunk;
+        n = (count > LSI_BUF_SIZE) ? LSI_BUF_SIZE : count;
+        lsi_mem_read(s, src, buf, n);
+        lsi_mem_write(s, dest, buf, n);
+        src += n;
+        dest += n;
+        count -= n;
     }
 }
 
-static void ncr710_wait_reselect(NCR710State *s)
+static void lsi_scripts_timer_start(NCR710State *s)
 {
-    s->wait_reselect = true;
-    s->waiting = NCR710_WAIT_RESELECT;
-    s->script_active = false;
-
-    s->scntl1 &= ~NCR710_SCNTL1_CON;
-    s->istat &= ~NCR710_ISTAT_CON;
+    /* The wrapper allocates this timer on the nanosecond clock. */
+    timer_mod(s->scripts_timer,
+              qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + 500000);
 }
 
-void ncr710_reselection_retry_callback(void *opaque)
+void ncr710_scripts_timer_callback(void *opaque)
 {
     NCR710State *s = opaque;
 
-    if (!s->current || s->current->pending == 0) {
-        return;
-    }
-
-    if (s->waiting != NCR710_WAIT_RESELECT) {
-        return;
-    }
-
-    if (s->istat & (NCR710_ISTAT_SIP | NCR710_ISTAT_DIP)) {
-        timer_mod(s->reselection_retry_timer,
-                  qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + 1000);
-        return;
-    }
-
-    NCR710Request *p = s->current;
-    uint32_t len = p->pending;
-    p->pending = 0;
-
-    SCSIRequest *req = p->req;
-    s->command_complete = NCR710_CMD_PENDING;
-    p->dma_len = len;
-
-    s->scntl1 |= NCR710_SCNTL1_CON;
-    s->istat |= NCR710_ISTAT_CON;
-    s->sbcl = NCR710_SBCL_IO | NCR710_SBCL_CD | NCR710_SBCL_MSG |
-              NCR710_SBCL_BSY | NCR710_SBCL_SEL | NCR710_SBCL_REQ;
-
-    uint8_t host_id = (s->scid & 0x07);
-    if (req->dev->id == 0 && host_id == 0) {
-        s->sfbr = 0x00;
-    } else {
-        s->sfbr = (req->dev->id == 0 ? 0 : (1 << req->dev->id)) |
-                  (host_id == 0 ? 0 : (1 << host_id));
-    }
-
-    ncr710_set_phase(s, PHASE_MI);
-
-    uint8_t identify_msg = 0x80 | (req->lun & 0x07);
-    ncr710_add_msg_byte(s, identify_msg);
-
-    if (p->tag) {
-        ncr710_add_msg_byte(s, 0x20);  /* SIMPLE_TAG_MSG */
-        ncr710_add_msg_byte(s, p->tag & 0xff);
-    }
-
-    s->dsp = p->resume_offset - 8;
-
-    s->dsps = RESELECTED_DURING_SELECTION;
-    s->sstat0 |= NCR710_SSTAT0_SEL;
-    s->istat |= NCR710_ISTAT_SIP;
-    ncr710_update_irq(s);
-    s->waiting = NCR710_WAIT_NONE;
+    s->waiting = LSI_NOWAIT;
+    lsi_execute_script(s);
 }
 
-void ncr710_execute_script(NCR710State *s)
+static void lsi_execute_script(NCR710State *s)
 {
     uint32_t insn;
     uint32_t addr;
     int opcode;
-    s->script_active = 1;
+    int insn_processed = 0;
 
+    if (s->waiting == LSI_WAIT_SCRIPTS) {
+        timer_del(s->scripts_timer);
+        s->waiting = LSI_NOWAIT;
+    }
+
+    s->script_running = true;
 again:
-    insn = ncr710_read_dword(s, s->dsp);
+    /* Yield to the CPU after LSI_MAX_INSN instructions. */
+    if (++insn_processed > LSI_MAX_INSN) {
+        trace_ncr710_script_yield(insn_processed);
+        s->waiting = LSI_WAIT_SCRIPTS;
+        lsi_scripts_timer_start(s);
+        return;
+    }
+
+    insn = lsi_read_dword(s, s->dsp);
     if (!insn) {
-        /*
-         * If we receive an empty opcode increment the DSP by 4 bytes
-         * and execute the next opcode at that location
-         */
+        /* Skip an empty (NULL) opcode 4 bytes at a time. */
         s->dsp += 4;
         goto again;
     }
-    addr = ncr710_read_dword(s, s->dsp + 4);
+    addr = lsi_read_dword(s, s->dsp + 4);
+    trace_ncr710_execute_script(s->dsp, insn, addr);
     s->dsps = addr;
     s->dcmd = insn >> 24;
     s->dsp += 8;
+
     switch (insn >> 30) {
-    case 0: /* Block move.  */
-        if (s->sstat0 & NCR710_SSTAT0_STO) {
-            NCR710_DPRINTF("Delayed select timeout\n");
-            ncr710_stop_script(s);
-            ncr710_update_irq(s);
+    case 0: /* Block move */
+        if (s->sstat0 & LSI_STAT0_STO) {
+            lsi_stop_script(s);
             break;
         }
         s->dbc = insn & 0xffffff;
         if (insn & (1 << 29)) {
-            /* Indirect addressing.  */
-            addr = ncr710_read_dword(s, addr);
+            /* Indirect addressing. */
+            addr = lsi_read_dword(s, addr);
         } else if (insn & (1 << 28)) {
+            /* Table indirect addressing (32 bit). */
             uint32_t buf[2];
-            int32_t offset;
-            /* Table indirect addressing.  */
+            int32_t offset = sextract32(addr, 0, 24);
 
-            /* 32-bit Table indirect */
-            offset = sextract32(addr, 0, 24);
-            ncr710_dma_read(s, s->dsa + offset, buf, 8);
-            /* byte count is stored in bits 0:23 only */
+            lsi_mem_read(s, s->dsa + offset, buf, 8);
             s->dbc = be32_to_cpu(buf[0]) & 0xffffff;
             addr = be32_to_cpu(buf[1]);
         }
-        /* Check phase match for block move instructions */
         if ((s->sstat2 & PHASE_MASK) != ((insn >> 24) & 7)) {
-            uint8_t current_phase = s->sstat2 & PHASE_MASK;
-
-            ncr710_set_phase(s, current_phase);
-            s->sbcl |= NCR710_SBCL_REQ;
-            ncr710_script_scsi_interrupt(s, NCR710_SSTAT0_MA);
-            ncr710_stop_script(s);
-            break;
+            /*
+             * The target controls the phase.  The one legitimate lazy
+             * transition is MSG IN -> COMMAND after a declined negotiation
+             * MESSAGE REJECT.  Any other requested phase is a mismatch.
+             */
+            if ((s->sstat2 & PHASE_MASK) == PHASE_MI && s->msg_len == 0 &&
+                s->msg_action == LSI_MSG_ACTION_COMMAND &&
+                ((insn >> 24) & 7) == PHASE_CMD) {
+                lsi_set_phase(s, PHASE_CMD);
+            } else {
+                trace_ncr710_block_move_badphase(s->sstat2 & PHASE_MASK,
+                                                 (insn >> 24) & 7);
+                lsi_script_scsi_interrupt(s, LSI_STAT0_MA);
+                break;
+            }
         }
-
         s->dnad = addr;
-        switch (s->sstat2 & 0x7) {
+        switch (s->sstat2 & PHASE_MASK) {
         case PHASE_DO:
-            s->waiting = NCR710_WAIT_DMA;
-            ncr710_do_dma(s, 1);
+            s->waiting = LSI_DMA_SCRIPTS;
+            lsi_do_dma(s, 1);
+            if (s->waiting) {
+                s->waiting = LSI_DMA_IN_PROGRESS;
+            }
             break;
         case PHASE_DI:
-            s->waiting = NCR710_WAIT_DMA;
-            ncr710_do_dma(s, 0);
+            s->waiting = LSI_DMA_SCRIPTS;
+            lsi_do_dma(s, 0);
+            if (s->waiting) {
+                s->waiting = LSI_DMA_IN_PROGRESS;
+            }
             break;
-        case PHASE_CO:
-            ncr710_do_command(s);
+        case PHASE_CMD:
+            lsi_do_command(s);
             break;
-        case PHASE_SI:
-            ncr710_do_status(s);
+        case PHASE_ST:
+            lsi_do_status(s);
             break;
         case PHASE_MO:
-            ncr710_do_msgout(s);
+            lsi_do_msgout(s);
             break;
         case PHASE_MI:
-            ncr710_do_msgin(s);
+            lsi_do_msgin(s);
             break;
         default:
-            BADF("Unimplemented phase %d\n", s->sstat2 & PHASE_MASK);
+            qemu_log_mask(LOG_UNIMP, "ncr710: unimplemented phase %d\n",
+                          s->sstat2 & PHASE_MASK);
         }
-        s->ctest5 = (s->ctest5 & 0xfc) | ((s->dbc >> 8) & 3);
+        s->dfifo = s->dbc & 0x7f;
         break;
 
-    case 1: /* IO or Read/Write instruction.  */
+    case 1: /* I/O or Read/Write register */
         opcode = (insn >> 27) & 7;
         if (opcode < 5) {
             uint32_t id;
+            unsigned id_bits;
 
             if (insn & (1 << 25)) {
-                id = ncr710_read_dword(s, s->dsa + sextract32(insn, 0, 24));
+                id_bits = lsi_read_dword(s, s->dsa + sextract32(insn, 0, 24));
             } else {
-                id = insn;
+                id_bits = insn;
             }
-            id = (id >> 16) & 0xff;
+            /* Destination ID is a one hot bitmask in bits 23:16. */
+            id_bits = (id_bits >> 16) & 0xff;
+            id = lsi_id_from_bits(id_bits);
             if (insn & (1 << 26)) {
                 addr = s->dsp + sextract32(addr, 0, 24);
             }
             s->dnad = addr;
             switch (opcode) {
             case 0: /* Select */
-                s->sdid = id;
-                if (s->scntl1 & NCR710_SCNTL1_CON) {
-                    if (!(insn & (1 << 24))) {
-                        s->dsp = s->dnad;
-                        break;
-                    }
-                }
-                bool device_exists = false;
-                if (insn & (1 << 24)) {
-                    /* ATN set - scan all LUNs for this target */
-                    for (int lun = 0; lun < 8; lun++) {
-                        SCSIDevice *dev = scsi_device_find(&s->bus, 0,
-                                                           idbitstonum(id),
-                                                           lun);
-                        if (dev) {
-                            device_exists = true;
-                            break;
-                        }
-                    }
-                } else {
-                    /* No ATN - check only LUN 0 */
-                    SCSIDevice *dev = scsi_device_find(&s->bus, 0,
-                                                       idbitstonum(id), 0);
-                    device_exists = dev != NULL;
-                }
-                if (!device_exists) {
-                    ncr710_bad_selection(s, id);
-                    if (!(insn & (1 << 24)) && addr != 0) {
-                        s->dsp = addr;
-                    }
+                trace_ncr710_select(id, !!(insn & (1 << 24)));
+                s->sdid = id_bits;
+                if (s->scntl1 & LSI_SCNTL1_CON) {
+                    s->dsp = s->dnad;
                     break;
-                } else {
-                    /*
-                     * ??? Linux drivers compain when this is set. Maybe
-                     * it only applies in low-level mode (unimplemented).
-                     * ncr710_script_scsi_interrupt(s, NCR710_SIST0_CMP, 0);
-                     */
-                    s->select_tag = id << 8;
-                    s->scntl1 |= NCR710_SCNTL1_CON;
-
-                    if (insn & (1 << 24)) {
-                        s->socl |= NCR710_SOCL_ATN;
-                        ncr710_set_phase(s, PHASE_MO);
-                    } else {
-                        ncr710_set_phase(s, PHASE_CO);
-                    }
                 }
+                s->sstat1 |= 0x04;       /* Won arbitration */
+                if (!scsi_device_find(&s->bus, 0, id, 0)) {
+                    lsi_bad_selection(s, id);
+                    break;
+                }
+                s->select_tag = id << 8;
+                s->scntl1 |= LSI_SCNTL1_CON;
+                s->sbcl |= LSI_SBCL_BSY;
+                if (insn & (1 << 24)) {
+                    /* Select with ATN/: the first phase is MESSAGE OUT. */
+                    s->socl |= LSI_SOCL_ATN;
+                    s->sbcl |= LSI_SBCL_ATN;
+                    lsi_set_phase(s, PHASE_MO);
+                } else {
+                    /* No ATN/: target goes straight to COMMAND phase. */
+                    lsi_set_phase(s, PHASE_CMD);
+                }
+                s->waiting = LSI_NOWAIT;
                 break;
-            case 1: /* Disconnect */
-
-                if (s->command_complete != NCR710_CMD_PENDING) {
-                    s->scntl1 &= ~NCR710_SCNTL1_CON;
-                    s->istat &= ~NCR710_ISTAT_CON;
-                    s->waiting = NCR710_WAIT_NONE;
-                } else {
-                    if (s->current) {
-                        s->current->resume_offset = s->dsp;
-                    }
-
-                    s->waiting = NCR710_WAIT_RESELECT;
-                    ncr710_stop_script(s);
-                    NCR710_DPRINTF("SCRIPTS paused at WAIT DISCONNECT\n");
-                }
+            case 1: /* Wait Disconnect */
+                trace_ncr710_wait_disconnect();
+                s->scntl1 &= ~LSI_SCNTL1_CON;
                 break;
             case 2: /* Wait Reselect */
-                if (!ncr710_irq_on_rsl(s)) {
-                    ncr710_wait_reselect(s);
+                /*
+                 * Two things release a Wait Reselect: SIGP (jump to the
+                 * dispatch address latched in DNAD), or a disconnected command
+                 * becoming ready to reselect.
+                 */
+                if (s->istat & LSI_ISTAT0_SIGP) {
+                    /*
+                     * The SIGP divert is a one-shot: clear the latch so a
+                     * later Wait Reselect does not re-fire on a stale SIGP.
+                     * An active SIGP at reselection also disables target-mode
+                     * auto-switching.
+                     */
+                    s->istat &= ~LSI_ISTAT0_SIGP;
+                    s->dsp = s->dnad;
+                } else if (!lsi_irq_on_rsl(s)) {
+                    lsi_wait_reselect(s);
                 }
                 break;
             case 3: /* Set */
                 if (insn & (1 << 3)) {
-                    s->socl |= NCR710_SOCL_ATN;
-                    ncr710_set_phase(s, PHASE_MO);
+                    s->socl |= LSI_SOCL_ATN;
+                    s->sbcl |= LSI_SBCL_ATN;
+                    lsi_set_phase(s, PHASE_MO);
+                }
+                if (insn & (1 << 6)) {
+                    s->sbcl |= LSI_SBCL_ACK;
                 }
                 if (insn & (1 << 10)) {
                     s->carry = 1;
@@ -1499,7 +960,11 @@ again:
                 break;
             case 4: /* Clear */
                 if (insn & (1 << 3)) {
-                    s->socl &= ~NCR710_SOCL_ATN;
+                    s->socl &= ~LSI_SOCL_ATN;
+                    s->sbcl &= ~LSI_SBCL_ATN;
+                }
+                if (insn & (1 << 6)) {
+                    s->sbcl &= ~LSI_SBCL_ACK;
                 }
                 if (insn & (1 << 10)) {
                     s->carry = 0;
@@ -1507,31 +972,31 @@ again:
                 break;
             }
         } else {
-            uint8_t op0;
-            uint8_t op1;
-            uint8_t data8;
-            int reg;
-            int xoperator;
+            /*
+             * Read/Write register.  The 895a ALU operator encoding is a
+             * backward compatible superset of the 710's, so this decode is
+             * shared with lsi53c895a.
+             */
+            uint8_t op0 = 0;
+            uint8_t op1 = 0;
+            uint8_t data8 = (insn >> 8) & 0xff;
+            int reg = ((insn >> 16) & 0x7f) | (insn & 0x80);
+            int operator = (insn >> 24) & 7;
 
-            reg = ((insn >> 16) & 0x7f) | (insn & 0x80);
-            data8 = (insn >> 8) & 0xff;
-            opcode = (insn >> 27) & 7;
-            xoperator = (insn >> 24) & 7;
-            op0 = op1 = 0;
             switch (opcode) {
             case 5: /* From SFBR */
                 op0 = s->sfbr;
                 op1 = data8;
                 break;
             case 6: /* To SFBR */
-                if (xoperator) {
-                    op0 = ncr710_reg_readb(s, reg);
+                if (operator) {
+                    op0 = lsi_reg_readb(s, reg);
                 }
                 op1 = data8;
                 break;
-            case 7: /* Read-modify-write */
-                if (xoperator) {
-                    op0 = ncr710_reg_readb(s, reg);
+            case 7: /* Read modify write */
+                if (operator) {
+                    op0 = lsi_reg_readb(s, reg);
                 }
                 if (insn & (1 << 23)) {
                     op1 = s->sfbr;
@@ -1541,11 +1006,11 @@ again:
                 break;
             }
 
-            switch (xoperator) {
+            switch (operator) {
             case 0: /* move */
                 op0 = op1;
                 break;
-            case 1: /* Shift left */
+            case 1: /* shift left */
                 op1 = op0 >> 7;
                 op0 = (op0 << 1) | s->carry;
                 s->carry = op1;
@@ -1559,7 +1024,7 @@ again:
             case 4: /* AND */
                 op0 &= op1;
                 break;
-            case 5: /* SHR */
+            case 5: /* shift right */
                 op1 = op0 & 1;
                 op0 = (op0 >> 1) | (s->carry << 7);
                 s->carry = op1;
@@ -1580,8 +1045,8 @@ again:
 
             switch (opcode) {
             case 5: /* From SFBR */
-            case 7: /* Read-modify-write */
-                ncr710_reg_writeb(s, reg, op0);
+            case 7: /* Read modify write */
+                lsi_reg_writeb(s, reg, op0);
                 break;
             case 6: /* To SFBR */
                 s->sfbr = op0;
@@ -1590,13 +1055,17 @@ again:
         }
         break;
 
-    case 2: /* Transfer Control.  */
+    case 2: /* Transfer Control */
         {
             int cond;
             int jmp;
 
-
-            if (s->sstat0 & NCR710_SSTAT0_STO) {
+            if ((insn & 0x002e0000) == 0) {
+                /* NOP */
+                break;
+            }
+            if (s->sstat0 & LSI_STAT0_STO) {
+                lsi_stop_script(s);
                 break;
             }
             cond = jmp = (insn & (1 << 19)) != 0;
@@ -1607,711 +1076,470 @@ again:
                 cond = (s->sstat2 & PHASE_MASK) == ((insn >> 24) & 7);
             }
             if (cond == jmp && (insn & (1 << 18))) {
-                uint8_t mask;
-
-                mask = (~insn >> 8) & 0xff;
+                uint8_t mask = (~insn >> 8) & 0xff;
                 cond = (s->sfbr & mask) == (insn & mask);
             }
             if (cond == jmp) {
                 if (insn & (1 << 23)) {
-                    /* Relative address.  */
+                    /* Relative address. */
                     addr = s->dsp + sextract32(addr, 0, 24);
                 }
                 switch ((insn >> 27) & 7) {
                 case 0: /* Jump */
+                    trace_ncr710_tc_jump(addr);
+                    s->adder = addr;
                     s->dsp = addr;
                     break;
                 case 1: /* Call */
+                    trace_ncr710_tc_call(addr);
                     s->temp = s->dsp;
                     s->dsp = addr;
                     break;
                 case 2: /* Return */
-                    if (s->temp == 0) {
-                        ncr710_script_dma_interrupt(s, NCR710_DSTAT_IID);
-                        break;
-                    }
+                    trace_ncr710_tc_return(s->temp);
                     s->dsp = s->temp;
                     break;
                 case 3: /* Interrupt */
-                    if ((insn & (1 << 20)) != 0) {
-                        ncr710_update_irq(s);
-                    } else {
-                        if (s->dsps == GOOD_STATUS_AFTER_STATUS) {
-                            NCR710_DPRINTF("Script completion: Processing "
-                                           "GOOD_STATUS_AFTER_STATUS\n");
-                            NCR710_DPRINTF("Script completion: Command state "
-                                           "preserved for driver processing\n");
-                            ncr710_script_dma_interrupt(s,
-                                                        NCR710_DSTAT_SIR);
-                            s->command_complete = NCR710_CMD_PENDING;
-                        } else {
-                            ncr710_script_dma_interrupt(s, NCR710_DSTAT_SIR);
-                        }
-                    }
+                    trace_ncr710_interrupt_insn(s->dsps);
+                    lsi_script_dma_interrupt(s, LSI_DSTAT_SIR);
                     break;
                 default:
-                    ncr710_script_dma_interrupt(s, NCR710_DSTAT_IID);
+                    trace_ncr710_illegal_insn(insn);
+                    lsi_script_dma_interrupt(s, LSI_DSTAT_IID);
                     break;
                 }
             }
         }
         break;
 
-    case 3:
+    case 3: /* Memory Move (Load/Store is illegal on the 710) */
         if ((insn & (1 << 29)) == 0) {
-            /* Memory move.  */
             uint32_t dest;
-            /*
-             * ??? The docs imply the destination address is loaded into
-             * the TEMP register.  However the Linux drivers rely on
-             * the value being preserved.
-             */
-            dest = ncr710_read_dword(s, s->dsp);
+
+            dest = lsi_read_dword(s, s->dsp);
             s->dsp += 4;
-            ncr710_memcpy(s, dest, addr, insn & 0xffffff);
+            trace_ncr710_memmove(dest, addr, insn & 0xffffff);
+            lsi_memcpy(s, dest, addr, insn & 0xffffff);
         } else {
-            uint8_t data[8];
-            int reg;
-            int n;
-            int i;
-            bool dsa_relative = (insn & (1 << 28)) != 0;
-            bool is_load = (insn & (1 << 24)) != 0;
-
-            if (dsa_relative) {
-                addr = s->dsa + sextract32(addr, 0, 24);
-            }
-
-            n = (insn & 7);
-            if (n == 0) {
-                n = 8;  /* 0 means 8 bytes */
-            }
-
-            reg = (insn >> 16) & 0xff;
-
-            if (is_load) {
-                ncr710_dma_read(s, addr, data, n);
-                for (i = 0; i < n; i++) {
-                    ncr710_reg_writeb(s, reg + i, data[i]);
-                }
-            } else {
-                for (i = 0; i < n; i++) {
-                    data[i] = ncr710_reg_readb(s, reg + i);
-                }
-                ncr710_dma_write(s, addr, data, n);
-            }
+            trace_ncr710_illegal_insn(insn);
+            lsi_script_dma_interrupt(s, LSI_DSTAT_IID);
         }
+        break;
     }
 
-    if (s->script_active && s->waiting == NCR710_WAIT_NONE) {
-        if (s->dcntl & NCR710_DCNTL_SSM) {
-            ncr710_script_dma_interrupt(s, NCR710_DSTAT_SSI);
-            return;
+    if (s->script_running && s->waiting == LSI_NOWAIT) {
+        if (s->dcntl & LSI_DCNTL_SSM) {
+            lsi_script_dma_interrupt(s, LSI_DSTAT_SSI);
         } else {
             goto again;
         }
-    } else if (s->waiting == NCR710_WAIT_RESELECT) {
-        return;
-    } else if (s->waiting == NCR710_WAIT_DMA ||
-               s->waiting == NCR710_WAIT_RESERVED) {
-        if (s->command_complete == NCR710_CMD_COMPLETE) {
-            s->waiting = NCR710_WAIT_NONE;
-            goto again;
-        }
-        return;
     }
 }
 
-static uint8_t ncr710_reg_readb(NCR710State *s, int offset)
+static uint8_t lsi_reg_readb(NCR710State *s, int offset)
 {
-    uint8_t ret = 0;
-
-#define CASE_GET_REG24(name, addr) \
-    case addr: \
-        ret = s->name & 0xff; \
-        break; \
-    case addr + 1: \
-        ret = (s->name >> 8) & 0xff; \
-        break; \
-    case addr + 2: \
-        ret = (s->name >> 16) & 0xff; \
-        break;
-
-#define CASE_GET_REG32(name, addr) \
-    case addr: \
-        ret = s->name & 0xff; \
-        break; \
-    case addr + 1: \
-        ret = (s->name >> 8) & 0xff; \
-        break; \
-    case addr + 2: \
-        ret = (s->name >> 16) & 0xff; \
-        break; \
-    case addr + 3: \
-        ret = (s->name >> 24) & 0xff; \
-        break;
+    uint8_t ret;
 
     switch (offset) {
-    case NCR710_SCNTL0_REG: /* SCNTL0 */
+    case NCR710_SCNTL0:
         ret = s->scntl0;
         break;
-    case NCR710_SCNTL1_REG: /* SCNTL1 */
+    case NCR710_SCNTL1:
         ret = s->scntl1;
         break;
-    case NCR710_SDID_REG: /* SDID */
+    case NCR710_SDID:
         ret = s->sdid;
         break;
-    case NCR710_SIEN_REG: /* SIEN */
-        ret = s->sien0;
+    case NCR710_SIEN:
+        ret = s->sien;
         break;
-    case NCR710_SCID_REG:
+    case NCR710_SCID:
         ret = s->scid;
-        if ((ret & 0x7F) == 0) {
-            ret = 0x80 | NCR710_HOST_ID;
-        } else {
-            ret |= 0x80;
-        }
         break;
-    case NCR710_SXFER_REG: /* SXFER */
+    case NCR710_SXFER:
         ret = s->sxfer;
         break;
-    case NCR710_SODL_REG: /* SODL */
+    case NCR710_SODL:
         ret = s->sodl;
         break;
-    case NCR710_SOCL_REG: /* SOCL */
+    case NCR710_SOCL:
         ret = s->socl;
         break;
-    case NCR710_SFBR_REG: /* SFBR */
+    case NCR710_SFBR:
         ret = s->sfbr;
         break;
-    case NCR710_SIDL_REG: /* SIDL */
+    case NCR710_SIDL:
         ret = s->sidl;
         break;
-    case NCR710_SBDL_REG: /* SBDL */
-        ret = s->sbdl;
-        break;
-    case NCR710_SBCL_REG: /* SBCL */
-        ret = 0;
-        if (s->scntl1 & NCR710_SCNTL1_CON) {
-            ret = s->sstat2 & PHASE_MASK;
-            ret |= s->sbcl;
-            if (s->socl & NCR710_SOCL_ATN) {
-                ret |= NCR710_SBCL_ATN;
-            }
+    case NCR710_SBDL:
+        /* Some drivers peek at the data bus during MSG IN. */
+        if ((s->sstat2 & PHASE_MASK) == PHASE_MI && s->msg_len > 0) {
+            ret = s->msg[0];
+        } else {
+            ret = 0;
         }
         break;
-    case NCR710_DSTAT_REG: /* DSTAT */
-        ret = s->dstat;
-
-        /*
-         * Not freeing s->current here:: driver needs it for completion
-         * processing. It will be freed when the next command starts.
-         */
-        if (s->dstat & NCR710_DSTAT_SIR) {
-            /* SIR bit set */
-        }
-        s->dstat = 0;  /* Clear all DMA interrupt status bits */
-        s->dstat |= NCR710_DSTAT_DFE;
-        ncr710_update_irq(s);
-
-        if (s->waiting == NCR710_WAIT_RESELECT && s->current &&
-            s->current->pending > 0) {
-            timer_mod(s->reselection_retry_timer,
-                      qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL));
-        }
-
-        if (!s->script_active && s->current && s->current->pending > 0 &&
-            s->command_complete == NCR710_CMD_COMPLETE) {
-            s->current->pending = 0;
-            s->waiting = NCR710_WAIT_NONE;
-            ncr710_execute_script(s);
-        }
-
-        if (s->waiting && s->current && s->current->pending > 0 &&
-            s->command_complete == NCR710_CMD_COMPLETE) {
-            s->current->pending = 0;
-            s->waiting = NCR710_WAIT_NONE;
-            ncr710_execute_script(s);
-        }
-
-        return ret;
-    case NCR710_SSTAT0_REG: /* SSTAT0 */
+    case NCR710_SBCL:
+        ret = s->sbcl;
+        break;
+    case NCR710_DSTAT:
+        ret = s->dstat | LSI_DSTAT_DFE;
+        s->dstat = 0;
+        lsi_update_irq(s);
+        break;
+    case NCR710_SSTAT0:
         ret = s->sstat0;
-        if (s->sstat0 != 0) {
-            s->sstat0 = 0;
-            s->istat &= ~NCR710_ISTAT_SIP;
-            ncr710_update_irq(s);
-            if (s->sbcl != 0) {
-                s->sbcl = 0;
-            }
-        }
+        s->sstat0 = 0;
+        lsi_update_irq(s);
         break;
-    case NCR710_SSTAT1_REG: /* SSTAT1 */
-        ret = s->sstat0;
+    case NCR710_SSTAT1:
+        ret = s->sstat1;
         break;
-    case NCR710_SSTAT2_REG: /* SSTAT2 */
+    case NCR710_SSTAT2:
         ret = s->sstat2;
         break;
-        CASE_GET_REG32(dsa, NCR710_DSA_REG)
+    case NCR710_DSA ... NCR710_DSA + 3:
+        ret = extract32(s->dsa, 8 * (offset - NCR710_DSA), 8);
         break;
-    case NCR710_CTEST0_REG: /* CTEST0 */
+    case NCR710_CTEST0:
         ret = s->ctest0;
         break;
-    case NCR710_CTEST1_REG: /* CTEST1 */
-        ret = s->ctest1;
+    case NCR710_CTEST1:
+        ret = 0xf0;              /* DMA FIFO empty */
         break;
-    case NCR710_CTEST2_REG: /* CTEST2 */
-        ret = s->ctest2;
-        s->ctest2 |= 0x04;
-        break;
-    case NCR710_CTEST3_REG: /* CTEST3 */
-        ret = s->ctest3;
-        if (!ncr710_scsi_fifo_empty(&s->scsi_fifo)) {
-            uint8_t parity;
-            ret = ncr710_scsi_fifo_dequeue(&s->scsi_fifo, &parity);
-            if (parity) {
-                s->ctest2 |= 0x10;
-            } else {
-                s->ctest2 &= ~0x10;
-            }
+    case NCR710_CTEST2:
+        ret = LSI_CTEST2_DACK;
+        if (s->istat & LSI_ISTAT0_SIGP) {
+            s->istat &= ~LSI_ISTAT0_SIGP;
+            ret |= LSI_CTEST2_SIGP;
         }
         break;
-    case NCR710_CTEST4_REG: /* CTEST4 */
+    case NCR710_CTEST3:
+        ret = s->ctest3;
+        break;
+    case NCR710_CTEST4:
         ret = s->ctest4;
         break;
-    case NCR710_CTEST5_REG: /* CTEST5 */
+    case NCR710_CTEST5:
         ret = s->ctest5;
         break;
-    case NCR710_CTEST6_REG: /* CTEST6 */
-        ret = s->ctest6;
+    case NCR710_CTEST6:
+        ret = 0;
         break;
-    case NCR710_CTEST7_REG: /* CTEST7 */
+    case NCR710_CTEST7:
         ret = s->ctest7;
         break;
-        CASE_GET_REG32(temp, NCR710_TEMP_REG)
-    case NCR710_DFIFO_REG: /* DFIFO */
+    case NCR710_TEMP ... NCR710_TEMP + 3:
+        ret = extract32(s->temp, 8 * (offset - NCR710_TEMP), 8);
+        break;
+    case NCR710_DFIFO:
         ret = s->dfifo;
-        s->dfifo = 0;  /* DMA FIFO count is always 0 */
         break;
-    case NCR710_ISTAT_REG: /* ISTAT */
-        ret = s->istat;
+    case NCR710_ISTAT:
+        ret = s->istat & ~LSI_ISTAT0_CON;
+        if (s->scntl1 & LSI_SCNTL1_CON) {
+            ret |= LSI_ISTAT0_CON;
+        }
         break;
-    case NCR710_CTEST8_REG: /* CTEST8 */
-        ret = s->istat;
+    case NCR710_CTEST8:
+        ret = NCR710_CHIP_REVISION << 4;
         break;
-    case NCR710_LCRC_REG: /* LCRC */
+    case NCR710_LCRC:
         ret = s->lcrc;
         break;
-        CASE_GET_REG24(dbc, NCR710_DBC_REG)
-    case NCR710_DCMD_REG: /* DCMD */
+    case NCR710_DBC ... NCR710_DBC + 2:
+        ret = extract32(s->dbc, 8 * (offset - NCR710_DBC), 8);
+        break;
+    case NCR710_DCMD:
         ret = s->dcmd;
         break;
-        CASE_GET_REG32(dnad, NCR710_DNAD_REG)
-    case NCR710_DSP_REG:
-        ret = s->dsp & 0xff;
+    case NCR710_DNAD ... NCR710_DNAD + 3:
+        ret = extract32(s->dnad, 8 * (offset - NCR710_DNAD), 8);
         break;
-    case NCR710_DSP_REG + 1:
-        ret = (s->dsp >> 8) & 0xff;
+    case NCR710_DSP ... NCR710_DSP + 3:
+        ret = extract32(s->dsp, 8 * (offset - NCR710_DSP), 8);
         break;
-    case NCR710_DSP_REG + 2:
-        ret = (s->dsp >> 16) & 0xff;
+    case NCR710_DSPS ... NCR710_DSPS + 3:
+        ret = extract32(s->dsps, 8 * (offset - NCR710_DSPS), 8);
         break;
-    case NCR710_DSP_REG + 3:
-        ret = (s->dsp >> 24) & 0xff;
-        if (s->dsps == GOOD_STATUS_AFTER_STATUS &&
-            (s->dstat & NCR710_DSTAT_SIR)) {
-            s->dstat &= ~NCR710_DSTAT_SIR;
-            ncr710_update_irq(s);
-        }
+    case NCR710_SCRATCH ... NCR710_SCRATCH + 3:
+        ret = extract32(s->scratch, 8 * (offset - NCR710_SCRATCH), 8);
         break;
-    case NCR710_DSPS_REG:
-        ret = s->dsps & 0xff;
-        break;
-    case NCR710_DSPS_REG + 1:
-        ret = (s->dsps >> 8) & 0xff;
-        break;
-    case NCR710_DSPS_REG + 2:
-        ret = (s->dsps >> 16) & 0xff;
-        break;
-    case NCR710_DSPS_REG + 3:
-        ret = (s->dsps >> 24) & 0xff;
-        if (!(s->dstat & NCR710_DSTAT_SIR) && s->dsps != 0) {
-            s->dsps = 0;
-        }
-        break;
-        CASE_GET_REG32(scratch, NCR710_SCRATCH_REG)
-        break;
-    case NCR710_DMODE_REG: /* DMODE */
+    case NCR710_DMODE:
         ret = s->dmode;
         break;
-    case NCR710_DIEN_REG: /* DIEN */
+    case NCR710_DIEN:
         ret = s->dien;
         break;
-    case NCR710_DWT_REG: /* DWT */
+    case NCR710_DWT:
         ret = s->dwt;
         break;
-    case NCR710_DCNTL_REG: /* DCNTL */
+    case NCR710_DCNTL:
         ret = s->dcntl;
-        return ret;
-        CASE_GET_REG32(adder, NCR710_ADDER_REG)
+        break;
+    case NCR710_ADDER ... NCR710_ADDER + 3:
+        ret = extract32(s->adder, 8 * (offset - NCR710_ADDER), 8);
         break;
     default:
-        ret = 0;
+        qemu_log_mask(LOG_GUEST_ERROR,
+                      "ncr710: invalid read from reg %s 0x%x\n",
+                      lsi_reg_name(offset), offset);
+        ret = 0xff;
         break;
     }
 
-#undef CASE_GET_REG24
-#undef CASE_GET_REG32
+    trace_ncr710_reg_read(lsi_reg_name(offset), offset, ret);
     return ret;
 }
 
-static void ncr710_reg_writeb(NCR710State *s, int offset, uint8_t val)
+static void lsi_reg_writeb(NCR710State *s, int offset, uint8_t val)
 {
-    uint8_t old_val;
-
-#define CASE_SET_REG24(name, addr) \
-    case addr: \
-        s->name &= 0xffffff00; \
-        s->name |= val; \
-        break; \
-    case addr + 1: \
-        s->name &= 0xffff00ff; \
-        s->name |= val << 8; \
-        break; \
-    case addr + 2: \
-        s->name &= 0xff00ffff; \
-        s->name |= val << 16; \
-        break;
-
-#define CASE_SET_REG32(name, addr) \
-    case addr: \
-        s->name &= 0xffffff00; \
-        s->name |= val; \
-        break; \
-    case addr + 1: \
-        s->name &= 0xffff00ff; \
-        s->name |= val << 8; \
-        break; \
-    case addr + 2: \
-        s->name &= 0xff00ffff; \
-        s->name |= val << 16; \
-        break; \
-    case addr + 3: \
-        s->name &= 0x00ffffff; \
-        s->name |= val << 24; \
-        break;
-
-    trace_ncr710_reg_write(ncr710_reg_name(offset), offset, val);
+    trace_ncr710_reg_write(lsi_reg_name(offset), offset, val);
 
     switch (offset) {
-    case NCR710_SCNTL0_REG: /* SCNTL0 */
-        old_val = s->scntl0;
+    case NCR710_SCNTL0:
         s->scntl0 = val;
-        break;
-
-    case NCR710_SCNTL1_REG: /* SCNTL1 */
-        old_val = s->scntl1;
-        s->scntl1 = val;
-
-
-        /* Handle Assert Even SCSI Parity (AESP) bit changes */
-        if ((val & NCR710_SCNTL1_AESP) != (old_val & NCR710_SCNTL1_AESP)) {
-            trace_ncr710_parity_sense_changed((val & NCR710_SCNTL1_AESP)
-                                               != 0 ? "even" : "odd");
+        if (val & LSI_SCNTL0_START) {
+            qemu_log_mask(LOG_UNIMP, "ncr710: START not implemented\n");
         }
-
-        if (val & NCR710_SCNTL1_RST) {
-            if (!(s->sstat0 & NCR710_SSTAT0_RST)) {
-                s->sstat0 |= NCR710_SSTAT0_RST;
-                ncr710_script_scsi_interrupt(s, NCR710_SSTAT0_RST);
-            }
-            if (!(old_val & NCR710_SCNTL1_RST)) {
-                NCR710_DPRINTF("NCR710: SCNTL1: SCSI bus reset "
-                               "initiated\n");
-                ncr710_soft_reset(s);
+        break;
+    case NCR710_SCNTL1:
+        s->scntl1 = val;
+        if (val & LSI_SCNTL1_RST) {
+            if (!(s->sstat0 & LSI_STAT0_RST)) {
+                bus_cold_reset(BUS(&s->bus));
+                s->sstat0 |= LSI_STAT0_RST;
+                lsi_script_scsi_interrupt(s, LSI_STAT0_RST);
             }
         } else {
-            s->sstat0 &= ~NCR710_SSTAT0_RST;
+            s->sstat0 &= ~LSI_STAT0_RST;
         }
         break;
-
-    case NCR710_SDID_REG: /* SDID */
-        s->sdid = val & 0x0F; /* Only lower 4 bits are valid */
+    case NCR710_SDID:
+        s->sdid = val;
         break;
-
-    case NCR710_SIEN_REG: /* SIEN */
-        s->sien0 = val;
-        NCR710_DPRINTF("SIEN: interrupt mask=0x%02x\n", val);
-        ncr710_update_irq(s);
+    case NCR710_SIEN:
+        s->sien = val;
+        lsi_update_irq(s);
         break;
-
-    case NCR710_SCID_REG: /* SCID */
+    case NCR710_SCID:
         s->scid = val;
         break;
-
-    case NCR710_SXFER_REG: /* SXFER */
+    case NCR710_SXFER:
         s->sxfer = val;
         break;
-
-    case NCR710_SODL_REG: /* SODL */
+    case NCR710_SODL:
         s->sodl = val;
-        s->sstat1 |= NCR710_SSTAT1_ORF; /* SCSI Output Register Full */
         break;
-
-    case NCR710_SOCL_REG: /* SOCL */
+    case NCR710_SOCL:
         s->socl = val;
         break;
-
-    case NCR710_SFBR_REG: /* SFBR */
+    case NCR710_SFBR:
+        /* CPU may not write SFBR, but SCRIPTS register moves do. */
         s->sfbr = val;
         break;
-
-    case NCR710_SIDL_REG: /* SIDL */
-    case NCR710_SBDL_REG: /* SBDL */
+    case NCR710_SIDL:
+    case NCR710_SBDL:
+        /* Read only. */
         break;
-
-    case NCR710_SBCL_REG: /* SBCL */
+    case NCR710_SBCL:
         s->sbcl = val;
-        ncr710_set_phase(s, val & PHASE_MASK);
         break;
-
-    case NCR710_DSTAT_REG:
-    case NCR710_SSTAT0_REG:
-    case NCR710_SSTAT1_REG:
-    case NCR710_SSTAT2_REG:
-        /* Linux writes to these readonly registers on startup */
-        return;
-
-    case NCR710_DSA_REG:
-        s->dsa &= 0xffffff00;
-        s->dsa |= val;
+    case NCR710_DSTAT:
+    case NCR710_SSTAT0:
+    case NCR710_SSTAT1:
+    case NCR710_SSTAT2:
+        /* Read only status registers. */
         break;
-    case NCR710_DSA_REG + 1:
-        s->dsa &= 0xffff00ff;
-        s->dsa |= val << 8;
+    case NCR710_DSA ... NCR710_DSA + 3:
+        s->dsa = deposit32(s->dsa, 8 * (offset - NCR710_DSA), 8, val);
         break;
-    case NCR710_DSA_REG + 2:
-        s->dsa &= 0xff00ffff;
-        s->dsa |= val << 16;
-        break;
-    case NCR710_DSA_REG + 3:
-        s->dsa &= 0x00ffffff;
-        s->dsa |= val << 24;
-        break;
-
-    case NCR710_CTEST0_REG: /* CTEST0 */
+    case NCR710_CTEST0:
         s->ctest0 = val;
         break;
-
-    case NCR710_CTEST1_REG: /* CTEST1, read-only */
-        s->ctest1 = val;
+    case NCR710_CTEST1:
+    case NCR710_CTEST2:
+        /* Read only. */
         break;
-
-    case NCR710_CTEST2_REG: /* CTEST2, read-only */
-        s->ctest2 = val;
-        break;
-
-    case NCR710_CTEST3_REG: /* CTEST3 */
+    case NCR710_CTEST3:
         s->ctest3 = val;
         break;
-
-    case NCR710_CTEST4_REG: /* CTEST4 */
+    case NCR710_CTEST4:
         s->ctest4 = val;
         break;
-
-    case NCR710_CTEST5_REG: /* CTEST5 */
+    case NCR710_CTEST5:
         s->ctest5 = val;
         break;
-
-    case NCR710_CTEST6_REG: /* CTEST6 */
-        s->ctest6 = val;
+    case NCR710_CTEST6:
         break;
-
-    case NCR710_CTEST7_REG: /* CTEST7 */
+    case NCR710_CTEST7:
         s->ctest7 = val;
         break;
-
-    CASE_SET_REG32(temp, NCR710_TEMP_REG)
-
-    case NCR710_DFIFO_REG: /* DFIFO, read-only */
+    case NCR710_TEMP ... NCR710_TEMP + 3:
+        s->temp = deposit32(s->temp, 8 * (offset - NCR710_TEMP), 8, val);
         break;
-
-    case NCR710_ISTAT_REG: /* ISTAT */
-        old_val = s->istat;
-
-        if ((old_val & NCR710_ISTAT_DIP) && !(val & NCR710_ISTAT_DIP)) {
-            /* Clear script interrupt data after Linux processes it */
-            s->dstat = 0;
-            s->dsps = 0;
+    case NCR710_DFIFO:
+        s->dfifo = val;
+        break;
+    case NCR710_ISTAT:
+        s->istat = (s->istat & ~(LSI_ISTAT0_ABRT | LSI_ISTAT0_SRST |
+                                 LSI_ISTAT0_SIGP)) |
+                   (val & (LSI_ISTAT0_ABRT | LSI_ISTAT0_SRST |
+                           LSI_ISTAT0_SIGP));
+        if (val & LSI_ISTAT0_SRST) {
+            ncr710_soft_reset(s);
+            return;
         }
-
-        if ((old_val & NCR710_ISTAT_SIP) && !(val & NCR710_ISTAT_SIP)) {
-            s->sstat0 = 0;
+        if (val & LSI_ISTAT0_ABRT) {
+            lsi_script_dma_interrupt(s, LSI_DSTAT_ABRT);
         }
-
-        s->istat = (val & ~(NCR710_ISTAT_DIP | NCR710_ISTAT_SIP)) |
-                  (s->istat & (NCR710_ISTAT_DIP | NCR710_ISTAT_SIP));
-        ncr710_update_irq(s);
-
-        if (val & NCR710_ISTAT_ABRT) {
-            ncr710_script_dma_interrupt(s, NCR710_DSTAT_ABRT);
+        if (s->waiting == LSI_WAIT_RESELECT && (val & LSI_ISTAT0_SIGP)) {
+            /*
+             * SIGP wake of a parked Wait Reselect.  Run the engine
+             * synchronously: this SELECT must take priority over any
+             * disconnected command pending reselection.  The guest takes any
+             * IRQ raised here after this store returns.
+             */
+            trace_ncr710_awoken();
+            s->waiting = LSI_NOWAIT;
+            s->dsp = s->dnad;
+            lsi_execute_script(s);
         }
         break;
-
-    case NCR710_CTEST8_REG: /* CTEST8 */
-        if (val & 0x08) {
-            s->dstat |= NCR710_DSTAT_DFE;
-        }
-        if (val & 0x04) {
-            ncr710_scsi_fifo_init(&s->scsi_fifo);
-            s->dstat |= NCR710_DSTAT_DFE;
-            s->ctest1 = 0xFF;
-        } else if (s->ctest8 & 0x04) {
-            s->ctest1 = 0x00;
-        }
-        s->ctest8 = val;
+    case NCR710_CTEST8:
+        /*
+         * Revision is read only; FLF/CLF FIFO ops do nothing (the FIFO is
+         * modelled as always empty).
+         */
         break;
-    case NCR710_LCRC_REG: /* LCRC */
-        s->lcrc = val;
+    case NCR710_LCRC:
+        /* Writing clears the longitudinal parity accumulator. */
+        s->lcrc = 0;
         break;
-
-    CASE_SET_REG24(dbc, NCR710_DBC_REG)
-
-    case NCR710_DCMD_REG: /* DCMD */
+    case NCR710_DBC ... NCR710_DBC + 2:
+        s->dbc = deposit32(s->dbc, 8 * (offset - NCR710_DBC), 8, val);
+        break;
+    case NCR710_DCMD:
         s->dcmd = val;
         break;
-
-    CASE_SET_REG32(dnad, NCR710_DNAD_REG)
-    case 0x2c: /* DSP[0:7] */
-        s->dsp &= 0xffffff00;
-        s->dsp |= val;
+    case NCR710_DNAD ... NCR710_DNAD + 3:
+        s->dnad = deposit32(s->dnad, 8 * (offset - NCR710_DNAD), 8, val);
         break;
-    case 0x2d: /* DSP[8:15] */
-        s->dsp &= 0xffff00ff;
-        s->dsp |= val << 8;
+    case NCR710_DSP:
+        s->dsp = (s->dsp & 0xffffff00) | val;
         break;
-    case 0x2e: /* DSP[16:23] */
-        s->dsp &= 0xff00ffff;
-        s->dsp |= val << 16;
+    case NCR710_DSP + 1:
+        s->dsp = (s->dsp & 0xffff00ff) | (val << 8);
         break;
-    case 0x2f: /* DSP[24:31] */
-        s->dsp &= 0x00ffffff;
-        s->dsp |= val << 24;
-        s->waiting = NCR710_WAIT_NONE;
-        s->script_active = 1;
-        s->istat |= NCR710_ISTAT_CON;
-        ncr710_clear_selection_timeout(s);
-        ncr710_execute_script(s);
+    case NCR710_DSP + 2:
+        s->dsp = (s->dsp & 0xff00ffff) | (val << 16);
         break;
-    CASE_SET_REG32(dsps, NCR710_DSPS_REG)
-    CASE_SET_REG32(scratch, NCR710_SCRATCH_REG)
-        break;
-
-    case NCR710_DMODE_REG: /* DMODE */
-        s->dmode = val;
-        break;
-
-    case NCR710_DIEN_REG: /* DIEN */
-        s->dien = val;
-        NCR710_DPRINTF("DIEN: interrupt enable=0x%02x\n", val);
-        ncr710_update_irq(s);
-        break;
-
-    case NCR710_DWT_REG: /* DWT */
-        s->dwt = val;
-        break;
-
-    case NCR710_DCNTL_REG: /* DCNTL */
-        s->dcntl = val & ~(NCR710_DCNTL_PFF);
-        if (val & NCR710_DCNTL_STD) {
-            s->waiting = NCR710_WAIT_NONE;
-            ncr710_execute_script(s);
-            s->dcntl &= ~NCR710_DCNTL_STD;
+    case NCR710_DSP + 3:
+        s->dsp = (s->dsp & 0x00ffffff) | (val << 24);
+        /* Writing the high byte starts SCRIPTS unless in manual start mode. */
+        if (!(s->dmode & LSI_DMODE_MAN) && !s->script_running) {
+            lsi_execute_script(s);
         }
         break;
-
-    CASE_SET_REG32(adder, NCR710_ADDER_REG)
+    case NCR710_DSPS ... NCR710_DSPS + 3:
+        s->dsps = deposit32(s->dsps, 8 * (offset - NCR710_DSPS), 8, val);
+        break;
+    case NCR710_SCRATCH ... NCR710_SCRATCH + 3:
+        s->scratch = deposit32(s->scratch, 8 * (offset - NCR710_SCRATCH),
+                               8, val);
+        break;
+    case NCR710_DMODE:
+        s->dmode = val;
+        break;
+    case NCR710_DIEN:
+        s->dien = val;
+        lsi_update_irq(s);
+        break;
+    case NCR710_DWT:
+        s->dwt = val;
+        break;
+    case NCR710_DCNTL:
+        s->dcntl = val & ~LSI_DCNTL_STD;
+        if ((val & LSI_DCNTL_STD) && !s->script_running) {
+            lsi_execute_script(s);
+        }
         break;
-
     default:
+        qemu_log_mask(LOG_GUEST_ERROR,
+                      "ncr710: invalid write to reg %s 0x%x (0x%02x)\n",
+                      lsi_reg_name(offset), offset, val);
         break;
     }
-
-#undef CASE_SET_REG24
-#undef CASE_SET_REG32
 }
 
-/* Memory region wrapper for NCR710 registers */
-uint64_t ncr710_reg_read(void *opaque, hwaddr addr, unsigned size)
+
+uint64_t ncr710_reg_read(NCR710State *s, hwaddr addr, unsigned size)
+{
+    /* The LASI wrapper decomposes multibyte accesses into single bytes. */
+    return lsi_reg_readb(s, addr & 0xff);
+}
+
+void ncr710_reg_write(NCR710State *s, hwaddr addr, uint64_t val, unsigned size)
+{
+    lsi_reg_writeb(s, addr & 0xff, val & 0xff);
+}
+
+static int lsi_pre_save(void *opaque)
 {
     NCR710State *s = opaque;
-    uint8_t offset = addr & 0xff;
-    uint8_t val = ncr710_reg_readb(s, offset);
-    trace_ncr710_reg_read(ncr710_reg_name(offset), offset, val);
-    return val;
-}
 
-void ncr710_reg_write(void *opaque, hwaddr addr, uint64_t val, unsigned size)
-{
-    NCR710State *s = opaque;
-    uint8_t offset = addr & 0xff;
-    uint8_t val8 = val & 0xff;
-    trace_ncr710_reg_write(ncr710_reg_name(offset), offset, val8);
-    ncr710_reg_writeb(s, offset, val8);
-}
-
-/* Device reset */
-static void ncr710_device_reset(DeviceState *dev)
-{
-    SysBusNCR710State *sysbus_dev = SYSBUS_NCR710_SCSI(dev);
-    NCR710State *s = &sysbus_dev->ncr710;
-
-    ncr710_soft_reset(s);
-    /* A device reset clears EA and FC1; only ISTAT.RST keeps them. */
-    s->dcntl = 0;
-    s->dmode = 0;
-}
-
-static const struct SCSIBusInfo ncr710_scsi_info = {
-    .tcq = true,
-    .max_target = 8,
-    .max_lun = 8,  /* Full LUN support */
-
-    .transfer_data = ncr710_transfer_data,
-    .complete = ncr710_command_complete,
-    .cancel = ncr710_request_cancelled,
-};
-
-static const MemoryRegionOps ncr710_mmio_ops = {
-    .read = ncr710_reg_read,
-    .write = ncr710_reg_write,
-    .endianness = DEVICE_LITTLE_ENDIAN,
-    .valid = {
-        .min_access_size = 1,
-        .max_access_size = 4,
-    },
-};
-
-static const VMStateDescription vmstate_ncr710_scsi_fifo = {
-    .name = "ncr710_scsi_fifo",
-    .version_id = 1,
-    .minimum_version_id = 1,
-    .fields = (VMStateField[]) {
-        VMSTATE_UINT8_ARRAY(data, NCR710_SCSI_FIFO, NCR710_SCSI_FIFO_SIZE),
-        VMSTATE_UINT8_ARRAY(parity, NCR710_SCSI_FIFO, NCR710_SCSI_FIFO_SIZE),
-        VMSTATE_INT32(count, NCR710_SCSI_FIFO),
-        VMSTATE_END_OF_LIST()
+    if (s->current) {
+        assert(s->current->dma_buf == NULL);
+        assert(s->current->dma_len == 0);
     }
-};
+    return 0;
+}
+
+static int lsi_post_load(void *opaque, int version_id)
+{
+    NCR710State *s = opaque;
+
+    if (s->msg_len < 0 || s->msg_len > LSI_MAX_MSGIN_LEN) {
+        return -EINVAL;
+    }
+    if (s->msg_action < LSI_MSG_ACTION_COMMAND ||
+        s->msg_action > LSI_MSG_ACTION_DIN) {
+        return -EINVAL;
+    }
+    if (s->waiting < LSI_NOWAIT || s->waiting > LSI_WAIT_SCRIPTS) {
+        return -EINVAL;
+    }
+    if (s->current_lun < 0 || s->current_lun > 7) {
+        return -EINVAL;
+    }
+    if (s->waiting == LSI_WAIT_SCRIPTS) {
+        lsi_scripts_timer_start(s);
+    }
+    return 0;
+}
 
 const VMStateDescription vmstate_ncr710 = {
     .name = "ncr710",
     .version_id = 1,
     .minimum_version_id = 1,
-    .fields = (VMStateField[]) {
+    .pre_save = lsi_pre_save,
+    .post_load = lsi_post_load,
+    .fields = (const VMStateField[]) {
+        VMSTATE_INT32(carry, NCR710State),
+        VMSTATE_INT32(status, NCR710State),
+        VMSTATE_INT32(msg_action, NCR710State),
+        VMSTATE_INT32(msg_len, NCR710State),
+        VMSTATE_BUFFER(msg, NCR710State),
+        VMSTATE_INT32(waiting, NCR710State),
+        VMSTATE_INT32(current_lun, NCR710State),
+        VMSTATE_UINT32(select_tag, NCR710State),
+        VMSTATE_INT32(command_complete, NCR710State),
+        VMSTATE_BOOL(script_running, NCR710State),
+
         VMSTATE_UINT8(scntl0, NCR710State),
         VMSTATE_UINT8(scntl1, NCR710State),
         VMSTATE_UINT8(sdid, NCR710State),
-        VMSTATE_UINT8(sien0, NCR710State),
+        VMSTATE_UINT8(sien, NCR710State),
         VMSTATE_UINT8(scid, NCR710State),
         VMSTATE_UINT8(sxfer, NCR710State),
         VMSTATE_UINT8(sodl, NCR710State),
@@ -2324,156 +1552,27 @@ const VMStateDescription vmstate_ncr710 = {
         VMSTATE_UINT8(sstat0, NCR710State),
         VMSTATE_UINT8(sstat1, NCR710State),
         VMSTATE_UINT8(sstat2, NCR710State),
+        VMSTATE_UINT32(dsa, NCR710State),
         VMSTATE_UINT8(ctest0, NCR710State),
-        VMSTATE_UINT8(ctest1, NCR710State),
-        VMSTATE_UINT8(ctest2, NCR710State),
         VMSTATE_UINT8(ctest3, NCR710State),
         VMSTATE_UINT8(ctest4, NCR710State),
         VMSTATE_UINT8(ctest5, NCR710State),
-        VMSTATE_UINT8(ctest6, NCR710State),
         VMSTATE_UINT8(ctest7, NCR710State),
-        VMSTATE_UINT8(ctest8, NCR710State),
         VMSTATE_UINT32(temp, NCR710State),
         VMSTATE_UINT8(dfifo, NCR710State),
         VMSTATE_UINT8(istat, NCR710State),
         VMSTATE_UINT8(lcrc, NCR710State),
-        VMSTATE_UINT8(dcmd, NCR710State),
-        VMSTATE_UINT8(dmode, NCR710State),
-        VMSTATE_UINT8(dien, NCR710State),
-        VMSTATE_UINT8(dwt, NCR710State),
-        VMSTATE_UINT8(dcntl, NCR710State),
-        VMSTATE_UINT32(dsa, NCR710State),
         VMSTATE_UINT32(dbc, NCR710State),
+        VMSTATE_UINT8(dcmd, NCR710State),
         VMSTATE_UINT32(dnad, NCR710State),
         VMSTATE_UINT32(dsp, NCR710State),
         VMSTATE_UINT32(dsps, NCR710State),
         VMSTATE_UINT32(scratch, NCR710State),
+        VMSTATE_UINT8(dmode, NCR710State),
+        VMSTATE_UINT8(dien, NCR710State),
+        VMSTATE_UINT8(dwt, NCR710State),
+        VMSTATE_UINT8(dcntl, NCR710State),
         VMSTATE_UINT32(adder, NCR710State),
-        VMSTATE_STRUCT(scsi_fifo, NCR710State, 1,
-            vmstate_ncr710_scsi_fifo, NCR710_SCSI_FIFO),
-        VMSTATE_UINT8(status, NCR710State),
-        VMSTATE_UINT8_ARRAY(msg, NCR710State,
-            NCR710_MAX_MSGIN_LEN),
-        VMSTATE_UINT8(msg_len, NCR710State),
-        VMSTATE_UINT8(msg_action, NCR710State),
-        VMSTATE_INT32(carry, NCR710State),
-        VMSTATE_BOOL(script_active, NCR710State),
-        VMSTATE_INT32(waiting, NCR710State),
-        VMSTATE_UINT8(command_complete, NCR710State),
-        VMSTATE_UINT32(select_tag, NCR710State),
-        VMSTATE_UINT8(current_lun, NCR710State),
         VMSTATE_END_OF_LIST()
     }
 };
-
-static const VMStateDescription vmstate_sysbus_ncr710 = {
-    .name = "sysbus_ncr710",
-    .version_id = 1,
-    .minimum_version_id = 1,
-    .fields = (VMStateField[]) {
-        VMSTATE_STRUCT(ncr710, SysBusNCR710State, 1, vmstate_ncr710,
-                       NCR710State),
-        VMSTATE_END_OF_LIST()
-    }
-};
-
-DeviceState *ncr710_device_create_sysbus(hwaddr addr, qemu_irq irq)
-{
-    DeviceState *dev;
-    SysBusDevice *sysbus;
-
-    dev = qdev_new(TYPE_SYSBUS_NCR710_SCSI);
-    sysbus = SYS_BUS_DEVICE(dev);
-
-    qdev_realize_and_unref(dev, NULL, &error_abort);
-    sysbus_mmio_map(sysbus, 0, addr);
-    sysbus_connect_irq(sysbus, 0, irq);
-    return dev;
-}
-
-DeviceState *ncr53c710_init(MemoryRegion *address_space, hwaddr addr,
-                             qemu_irq irq)
-{
-    DeviceState *dev;
-    SysBusDevice *sysbus;
-    SysBusNCR710State *s;
-
-    /* trace_ncr710_device_init(addr); */
-
-    dev = qdev_new(TYPE_SYSBUS_NCR710_SCSI);
-    sysbus = SYS_BUS_DEVICE(dev);
-
-    qdev_realize_and_unref(dev, NULL, &error_abort);
-    sysbus_mmio_map(sysbus, 0, addr);
-    sysbus_connect_irq(sysbus, 0, irq);
-
-    s = SYSBUS_NCR710_SCSI(dev);
-    if (!s->ncr710.as) {
-        s->ncr710.as = &address_space_memory;
-    }
-
-    return dev;
-}
-
-static void sysbus_ncr710_realize(DeviceState *dev, Error **errp)
-{
-    SysBusNCR710State *s = SYSBUS_NCR710_SCSI(dev);
-
-    trace_ncr710_device_realize();
-    scsi_bus_init(&s->ncr710.bus, sizeof(s->ncr710.bus), dev,
-                  &ncr710_scsi_info);
-    s->ncr710.as = &address_space_memory;
-
-    ncr710_scsi_fifo_init(&s->ncr710.scsi_fifo);
-    s->ncr710.dcntl &= ~NCR710_DCNTL_COM;
-    s->ncr710.scid = 0x80 | NCR710_HOST_ID;
-
-    s->ncr710.reselection_retry_timer =
-        timer_new_ns(QEMU_CLOCK_VIRTUAL,
-                     ncr710_reselection_retry_callback,
-                     &s->ncr710);
-
-    memset(s->ncr710.msg, 0, sizeof(s->ncr710.msg));
-
-    memory_region_init_io(&s->iomem, OBJECT(s), &ncr710_mmio_ops, &s->ncr710,
-                          "ncr710", 0x100);
-    sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->iomem);
-    sysbus_init_irq(SYS_BUS_DEVICE(s), &s->ncr710.irq);
-
-}
-
-static void sysbus_ncr710_init(Object *obj)
-{
-    SysBusNCR710State *s = SYSBUS_NCR710_SCSI(obj);
-    memset(&s->ncr710, 0, sizeof(NCR710State));
-    s->ncr710.ctest0 = 0x01;
-    s->ncr710.scid = 0x80 | NCR710_HOST_ID;
-    s->ncr710.dstat = NCR710_DSTAT_DFE;
-}
-
-static void sysbus_ncr710_class_init(ObjectClass *oc, const void *data)
-{
-    DeviceClass *dc = DEVICE_CLASS(oc);
-
-    dc->realize = sysbus_ncr710_realize;
-    device_class_set_legacy_reset(dc, ncr710_device_reset);
-    dc->bus_type = NULL;
-    set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
-    dc->desc = "NCR53C710 SCSI I/O Processor (SysBus)";
-    dc->vmsd = &vmstate_sysbus_ncr710;
-}
-
-static const TypeInfo sysbus_ncr710_info = {
-    .name = TYPE_SYSBUS_NCR710_SCSI,
-    .parent = TYPE_SYS_BUS_DEVICE,
-    .instance_size = sizeof(SysBusNCR710State),
-    .instance_init = sysbus_ncr710_init,
-    .class_init = sysbus_ncr710_class_init,
-};
-
-static void ncr710_register_types(void)
-{
-    type_register_static(&sysbus_ncr710_info);
-}
-
-type_init(ncr710_register_types)
diff --git a/hw/scsi/trace-events b/hw/scsi/trace-events
index a8ac1e7f1d44..f0eb1457022e 100644
--- a/hw/scsi/trace-events
+++ b/hw/scsi/trace-events
@@ -314,9 +314,32 @@ ncr710_script_scsi_interrupt(uint8_t stat0, uint8_t sstat0) "SCSI interrupt stat
 ncr710_script_dma_interrupt(uint8_t stat, uint8_t dstat) "DMA interrupt stat=0x%02x dstat=0x%02x"
 ncr710_command_complete(uint32_t tag, uint8_t status) "tag=0x%x status=0x%02x"
 ncr710_disconnect(uint8_t waiting) "waiting=%d"
+ncr710_reselect(int id) "Reselect id=%d"
+ncr710_queue_command(uint32_t tag) "queue command tag=0x%x"
+ncr710_queue_req(uint32_t tag) "defer queued req tag=0x%x"
 ncr710_bad_selection(uint32_t target) "target=%d"
-ncr710_parity_sense_changed(const char *parity) "Parity sense changed to %s"
-ncr710_device_realize(void) "Device realized"
+ncr710_execute_script(uint32_t dsp, uint32_t insn, uint32_t addr) "dsp=0x%08x insn=0x%08x addr=0x%08x"
+ncr710_do_dma(uint32_t addr, uint32_t len) "addr=0x%08x len=%d"
+ncr710_do_command(uint32_t dbc, uint8_t op, uint32_t lba, uint32_t xfer) "len=%d op=0x%02x lba=%u xfer=%u"
+ncr710_do_status(uint32_t dbc, uint8_t status) "len=%d status=0x%02x"
+ncr710_do_msgin(uint32_t dbc, int msg_len) "len=%d msg_len=%d"
+ncr710_do_msgout(uint32_t dbc) "len=%d"
+ncr710_transfer_data(uint32_t tag, uint32_t len) "tag=0x%x len=%d"
+ncr710_awoken(void) "SIGP woke Wait Reselect"
+ncr710_set_phase(int phase) "phase=%d"
+ncr710_update_irq(int level, uint8_t istat, uint8_t sstat0, uint8_t dstat) "level=%d istat=0x%02x sstat0=0x%02x dstat=0x%02x"
+ncr710_select(int id, int atn) "Select id=%d atn=%d"
+ncr710_block_move_badphase(int have, int want) "phase mismatch have=%d want=%d"
+ncr710_resume_script(int waiting) "resume waiting=%d"
+ncr710_script_yield(int insns) "yield after %d insns"
+ncr710_tc_jump(uint32_t addr) "JUMP 0x%08x"
+ncr710_tc_call(uint32_t addr) "CALL 0x%08x"
+ncr710_tc_return(uint32_t addr) "RETURN 0x%08x"
+ncr710_interrupt_insn(uint32_t dsps) "INT vector=0x%08x"
+ncr710_memmove(uint32_t dest, uint32_t src, int count) "MOVE MEMORY dest=0x%08x src=0x%08x count=%d"
+ncr710_do_dma_unavailable(void) "DMA: data not yet available"
+ncr710_wait_disconnect(void) "Wait Disconnect"
+ncr710_illegal_insn(uint32_t insn) "ILLEGAL instruction 0x%08x"
 
 # lasi_ncr710.c
 lasi_ncr710_device_realize(void) "Device realized"
@@ -324,16 +347,13 @@ lasi_ncr710_device_reset(void) "Device reset"
 lasi_ncr710_reg_read(uint32_t addr, uint32_t val, unsigned size) "addr=0x%03x val=0x%08x size=%u"
 lasi_ncr710_reg_write(uint32_t addr, uint32_t val, unsigned size) "addr=0x%03x val=0x%08x size=%u"
 lasi_ncr710_reg_read_id(uint32_t hw_type, uint32_t sversion, uint32_t val) "hw_type=%u sversion=0x%04x val=0x%08x"
-lasi_ncr710_reg_read_hversion(uint32_t hversion) "LASI NCR710: HVersion read -> 0x%02x"
-lasi_ncr710_reg_forward_read(uint32_t addr, uint32_t val) "LASI NCR710: Forward read to NCR710 core addr=0x%03x val=0x%08x"
-lasi_ncr710_reg_forward_write(uint32_t addr, uint32_t val) "LASI NCR710: Forward write to NCR710 core addr=0x%03x val=0x%08x"
-lasi_ncr710_command_complete(uint32_t status, size_t resid) "LASI NCR710: Command complete status=0x%02x resid=%zu"
-lasi_ncr710_transfer_data(uint32_t len) "LASI NCR710: Transfer data len=%u"
-lasi_ncr710_request_cancelled(void *req) "LASI NCR710: Request cancelled req=%p"
+lasi_ncr710_reg_read_hversion(uint32_t hversion) "HVersion read -> 0x%02x"
+lasi_ncr710_reg_forward_read(uint32_t addr, uint32_t val) "Forward read to NCR710 core addr=0x%03x val=0x%08x"
+lasi_ncr710_reg_forward_write(uint32_t addr, uint32_t val) "Forward write to NCR710 core addr=0x%03x val=0x%08x"
+lasi_ncr710_command_complete(uint32_t status, size_t resid) "Command complete status=0x%02x resid=%zu"
+lasi_ncr710_transfer_data(uint32_t len) "Transfer data len=%u"
+lasi_ncr710_request_cancelled(void *req) "Request cancelled req=%p"
 lasi_ncr710_timers_initialized(uint64_t reselection) "Timers: reselection=0x%" PRIx64
-lasi_ncr710_handle_legacy_cmdline(int busnr, int found_drives) "LASI NCR710: Handle legacy cmdline busnr=%d found_drives=%d"
-lasi_ncr710_legacy_drive_found(int busnr, int unit) "LASI NCR710: Found legacy drive at bus=%d unit=%d"
-lasi_ncr710_scsi_device_created(const char *type) "LASI NCR710: SCSI device created: %s"
 
 # virtio-scsi.c
 virtio_scsi_cmd_req(int lun, uint32_t tag, uint8_t cmd) "virtio_scsi_cmd_req lun=%u tag=0x%x cmd=0x%x"
-- 
2.55.0



  parent reply	other threads:[~2026-11-20 17:14 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-20 17:12 [RFC PATCH-for-11.2 v4 00/14] nc53c710 rewrite Philippe Mathieu-Daudé
2026-11-20 17:12 ` [RFC PATCH-for-11.2 v4 01/14] hw/scsi/ncr53c710: Cancel the in-flight request on soft reset Philippe Mathieu-Daudé
2026-11-20 17:12 ` [RFC PATCH-for-11.2 v4 02/14] hw/scsi/ncr53c710: Do not load SBCL from DBC after a SCRIPTS phase move Philippe Mathieu-Daudé
2026-11-20 17:12 ` [RFC PATCH-for-11.2 v4 03/14] hw/scsi/scsi-disk: Add quirk_mode_page_no_flexible_disk, use it on the 715 Philippe Mathieu-Daudé
2026-11-20 17:12 ` [RFC PATCH-for-11.2 v4 04/14] hw/scsi/lasi_ncr710: Limit max_target and max_lun to 7 Philippe Mathieu-Daudé
2026-11-20 17:12 ` [RFC PATCH-for-11.2 v4 05/14] hw/scsi/ncr53c710: Keep DCNTL.EA and DMODE.FC1 across an ISTAT.RST reset Philippe Mathieu-Daudé
2026-11-20 17:12 ` [RFC PATCH-for-11.2? v4 06/14] hw/scsi: Move shared LSI/NCR definitions to lsi_scsi.h Philippe Mathieu-Daudé
2026-11-20 22:10   ` BALATON Zoltan
2026-11-20 17:12 ` Philippe Mathieu-Daudé [this message]
2026-11-20 22:13   ` [RFC PATCH-for-11.2??? v4 07/14] hw/scsi/ncr53c710: Rewrite the 53C710 SCRIPTS engine BALATON Zoltan
2026-11-20 17:12 ` [RFC PATCH-for-11.2? v4 08/14] hw/scsi/ncr53c710: Deliver completions from bottom halves Philippe Mathieu-Daudé
2026-11-20 17:12 ` [RFC PATCH-for-11.2? v4 09/14] hw/scsi/ncr53c710: Drain asynchronous transfers in the register write Philippe Mathieu-Daudé
2026-11-20 17:12 ` [RFC PATCH-for-11.2? v4 10/14] hw/scsi/ncr53c710: Append SAVE DATA POINTERS after MESSAGE REJECT for HP-UX Philippe Mathieu-Daudé
2026-11-20 17:12 ` [RFC PATCH-for-11.2? v4 11/14] hw/scsi/ncr53c710: Guard SCRIPTS reentrancy and cancel requests on soft reset Philippe Mathieu-Daudé
2026-11-20 22:17   ` BALATON Zoltan
2026-11-20 17:12 ` [RFC PATCH-for-11.2? v4 12/14] hw/scsi/lasi_ncr710: Map the full LASI SCSI module page Philippe Mathieu-Daudé
2026-11-20 17:12 ` [RFC PATCH-for-11.2? v4 13/14] hw/scsi/ncr53c710: Document the SIGP latch deviation Philippe Mathieu-Daudé
2026-11-20 17:12 ` [RFC PATCH-for-11.2? v4 14/14] hw/scsi/ncr53c710: Bump the migration version Philippe Mathieu-Daudé
2026-11-20 22:21   ` BALATON Zoltan
2026-11-20 17:20 ` [RFC PATCH-for-11.2 v4 00/14] nc53c710 rewrite Philippe Mathieu-Daudé
2026-11-20 22:09   ` BALATON Zoltan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261120171235.61325-8-philmd@oss.qualcomm.com \
    --to=philmd@oss.qualcomm.com \
    --cc=balaton@eik.bme.hu \
    --cc=deller@gmx.de \
    --cc=fam@euphon.net \
    --cc=keith@techtravels.org \
    --cc=mark.cave-ayland@ilande.co.uk \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.