16.5 SCSI Subsystem

<< Click to Display Table of Contents >>

Navigation:  ASA-EMulatR Reference Guide > Introduction > Architecture Overview > Chapter 16 – Device Model & DMA >

16.5 SCSI Subsystem

16.5.1 SCSI Architecture in EMulatR

 

The SCSI subsystem follows a layered structure that separates protocol types from bus controllers and from virtual device backends:

 

Guest OS SCSI Driver

 │

 ▼

SCSI HBA Controller (e.g., ScsiControllerKzpba)

 ├── MMIO registers (command, status, DMA descriptors)

 ├── Owns SCSIBus instance

 └── Dispatches SCSI commands to target LUNs

 │

 ▼

SCSIBus → LUN routing

 │

 ▼

Virtual SCSI Devices

 ├── SCSIDisk (block storage)

 ├── SCSITape (sequential access, tape format variants)

 └── SCSICDROM (read-only, ISO backing)

 

The SCSI protocol core headers reside in deviceLib/: ISCSIDevice.h (interface), SCSIDisk.h, SCSITape.h, SCSIBus.h, and SCSI_helpers.h. These headers define SCSI types, opcodes, CDB structures, and sense data formats. They depend only on Qt containers and basic types — they have no dependency on AlphaCPU, PAL, or the pipeline.

 

Bus-facing controllers (KZPBA, QLogic ISP1020) reside in mmioLib/ alongside other MMIO devices. The controller owns the SCSIBus instance, translates MMIO register writes into SCSI commands, performs DMA between GuestMemory and the device data buffers, and asserts interrupts upon command completion.

 


 

16.5.2 SCSI Command Flow

 

A typical SCSI disk read proceeds as follows: the guest OS driver writes DMA descriptor addresses and a command doorbell to the HBA's MMIO registers. The onWrite() handler (executing in the CPU thread) queues the command to the device's I/O worker thread and returns immediately. The I/O worker thread decodes the CDB, routes the command via SCSIBus to the target LUN, the virtual SCSI device performs host-side I/O (file read for container-backed, block read for RAW-backed), data is written into GuestMemory via DMA (through DMACoherencyManager), and the device asserts an interrupt to signal completion.

 


 

16.5.3 Supported SCSI Operations

 

The SCSI protocol core provides CDB decoding for standard SCSI command sets: 6-byte CDBs (READ6, WRITE6, INQUIRY, MODE_SENSE6), 10-byte CDBs (READ10, WRITE10, READ_CAPACITY, MODE_SENSE10), and extended formats (12-byte, 16-byte) for large LBA addressing. Sense data generation covers common conditions: NOT_READY, MEDIUM_ERROR, ILLEGAL_REQUEST, UNIT_ATTENTION, and CHECK_CONDITION.

 

See Also: deviceLib/SCSIDisk.h; deviceLib/SCSITape.h; deviceLib/SCSIBus.h; mmioLib/ScsiControllerKzpba.h – KZPBA HBA controller.