drivers/scsi/mac_scsi.c
Source file repositories/reference/linux-study-clean/drivers/scsi/mac_scsi.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/scsi/mac_scsi.c- Extension
.c- Size
- 15748 bytes
- Lines
- 561
- Domain
- Driver Families
- Bucket
- drivers/scsi
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/delay.hlinux/types.hlinux/module.hlinux/ioport.hlinux/init.hlinux/blkdev.hlinux/interrupt.hlinux/platform_device.hasm/hwtest.hasm/io.hasm/macintosh.hasm/macints.hasm/setup.hscsi/scsi_host.hNCR5380.hNCR5380.c
Detected Declarations
function mac_scsi_setupfunction volatilefunction mac_pdma_sendfunction write_ctrl_regfunction macscsi_wait_for_drqfunction macscsi_preadfunction macscsi_pwritefunction macscsi_dma_xfer_lenfunction macscsi_dma_residualfunction mac_scsi_probefunction mac_scsi_remove
Annotated Snippet
if (bytes > 0) {
d += bytes;
hostdata->pdma_residual -= bytes;
}
if (hostdata->pdma_residual == 0)
break;
if (bytes > 0)
continue;
NCR5380_dprint(NDEBUG_PSEUDO_DMA, hostdata->host);
dsprintk(NDEBUG_PSEUDO_DMA, hostdata->host,
"%s: bus error [%d/%d] (%d/%d)\n",
__func__, d - dst, len, bytes, chunk_bytes);
if (bytes == 0)
continue;
if (macscsi_wait_for_drq(hostdata) <= 0)
set_host_byte(hostdata->connected, DID_ERROR);
break;
}
return 0;
}
static inline int macscsi_pwrite(struct NCR5380_hostdata *hostdata,
unsigned char *src, int len)
{
unsigned char *s = src;
u8 __iomem *d = hostdata->pdma_io + (OUTPUT_DATA_REG << 4);
hostdata->pdma_residual = len;
while (macscsi_wait_for_drq(hostdata) == 0) {
int bytes, chunk_bytes;
if (macintosh_config->ident == MAC_MODEL_IIFX)
write_ctrl_reg(hostdata, CTRL_HANDSHAKE_MODE |
CTRL_INTERRUPTS_ENABLE);
chunk_bytes = min(hostdata->pdma_residual, 512);
bytes = mac_pdma_send(s, d, chunk_bytes);
if (macintosh_config->ident == MAC_MODEL_IIFX)
write_ctrl_reg(hostdata, CTRL_INTERRUPTS_ENABLE);
if (bytes > 0) {
s += bytes;
hostdata->pdma_residual -= bytes;
}
if (hostdata->pdma_residual == 0)
break;
if (bytes > 0)
continue;
NCR5380_dprint(NDEBUG_PSEUDO_DMA, hostdata->host);
dsprintk(NDEBUG_PSEUDO_DMA, hostdata->host,
"%s: bus error [%d/%d] (%d/%d)\n",
__func__, s - src, len, bytes, chunk_bytes);
if (bytes == 0)
continue;
if (macscsi_wait_for_drq(hostdata) <= 0)
set_host_byte(hostdata->connected, DID_ERROR);
break;
}
return 0;
}
static int macscsi_dma_xfer_len(struct NCR5380_hostdata *hostdata,
struct scsi_cmnd *cmd)
{
int resid = NCR5380_to_ncmd(cmd)->this_residual;
if (hostdata->flags & FLAG_NO_PSEUDO_DMA || resid < setup_use_pdma)
return 0;
return resid;
}
static int macscsi_dma_residual(struct NCR5380_hostdata *hostdata)
{
return hostdata->pdma_residual;
}
Annotation
- Immediate include surface: `linux/delay.h`, `linux/types.h`, `linux/module.h`, `linux/ioport.h`, `linux/init.h`, `linux/blkdev.h`, `linux/interrupt.h`, `linux/platform_device.h`.
- Detected declarations: `function mac_scsi_setup`, `function volatile`, `function mac_pdma_send`, `function write_ctrl_reg`, `function macscsi_wait_for_drq`, `function macscsi_pread`, `function macscsi_pwrite`, `function macscsi_dma_xfer_len`, `function macscsi_dma_residual`, `function mac_scsi_probe`.
- Atlas domain: Driver Families / drivers/scsi.
- Implementation status: source implementation candidate.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.