Home | History | Annotate | Line # | Download | only in ibus
      1 /*	$NetBSD: siivar.h,v 1.5 2021/12/26 16:08:20 andvar Exp $	*/
      2 
      3 #ifndef _SIIVAR_H
      4 #define _SIIVAR_H
      5 
      6 /*
      7  * This structure contains information that a SCSI interface controller
      8  * needs to execute a SCSI command.
      9  */
     10 typedef struct ScsiCmd {
     11 	int	unit;		/* unit number passed to device done routine */
     12 	int	flags;		/* control flags for this command (see below) */
     13 	int	buflen;		/* length of the data buffer in bytes */
     14 	char	*buf;		/* pointer to data buffer for this command */
     15 	int	cmdlen;		/* length of data in cmdbuf */
     16 	u_char	*cmd;		/* buffer for the SCSI command */
     17 	int	error;		/* compatibility hack for new scsi */
     18 	int	lun;		/* LUN for MI SCSI */
     19 	struct callout timo_ch;	/* timeout callout handle */
     20 } ScsiCmd;
     21 
     22 typedef struct scsi_state {
     23 	int	statusByte;	/* status byte returned during STATUS_PHASE */
     24 	int	dmaDataPhase;	/* which data phase to expect */
     25 	int	dmaCurPhase;	/* SCSI phase if DMA is in progress */
     26 	int	dmaPrevPhase;	/* SCSI phase of DMA suspended by disconnect */
     27 	u_short	*dmaAddr[2];	/* DMA buffer memory address */
     28 	int	dmaBufIndex;	/* which of the above is currently in use */
     29 	int	dmalen;		/* amount to transfer in this chunk */
     30 	int	cmdlen;		/* total remaining amount of cmd to transfer */
     31 	u_char	*cmd;		/* current pointer within scsicmd->cmd */
     32 	int	buflen;		/* total remaining amount of data to transfer */
     33 	char	*buf;		/* current pointer within scsicmd->buf */
     34 	u_short	flags;		/* see below */
     35 	u_short	prevComm;	/* command reg before disconnect */
     36 	u_short	dmaCtrl;	/* DMA control register if disconnect */
     37 	u_short	dmaAddrL;	/* DMA address register if disconnect */
     38 	u_short	dmaAddrH;	/* DMA address register if disconnect */
     39 	u_short	dmaCnt;		/* DMA count if disconnect */
     40 	u_short	dmaByte;	/* DMA byte if disconnect on odd boundary */
     41 	u_short	dmaReqAck;	/* DMA synchronous xfer offset or 0 if async */
     42 } State;
     43 
     44 /* state flags */
     45 #define FIRST_DMA	0x01	/* true if no data DMA started yet */
     46 #define PARITY_ERR	0x02	/* true if parity error seen */
     47 
     48 #define SII_NCMD	8
     49 struct siisoftc {
     50 	device_t sc_dev;		/* us as a device */
     51 	struct scsipi_channel sc_channel;
     52 	struct scsipi_adapter sc_adapter;	/* scsipi adapter glue */
     53 	ScsiCmd sc_cmd_fake[SII_NCMD];		/* XXX - hack!!! */
     54 	struct scsipi_xfer *sc_xs[SII_NCMD];	/* XXX - hack!!! */
     55 	void *sc_buf;			/* DMA buffer (may be special mem) */
     56 	SIIRegs	*sc_regs;		/* HW address of SII controller chip */
     57 	int	sc_flags;
     58 	int	sc_target;		/* target SCSI ID if connected */
     59 	ScsiCmd	*sc_cmd[SII_NCMD];	/* active command indexed by ID */
     60  	void  (*sii_copytobuf)(u_short *src, volatile u_short *dst, int ln);
     61 	void (*sii_copyfrombuf)(volatile u_short *src, char *dst, int len);
     62 
     63 	State	sc_st[SII_NCMD];	/* state info for each active command */
     64 };
     65 
     66 int	siiintr(void *sc);
     67 
     68 /* Machine-independent back-end attach entry point */
     69 
     70 void	sii_scsi_request(struct scsipi_channel *,
     71 				scsipi_adapter_req_t, void *);
     72 void	siiattach(struct siisoftc *);
     73 
     74 #endif	/* _SIIVAR_H */
     75