|
|
DataMuseum.dkPresents historical artifacts from the history of: Regnecentalen RC-900 |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about Regnecentalen RC-900 Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T U g
Length: 18774 (0x4956)
Types: TextFile
Notes: UNIX file
Names: »genscsi.h«
└─⟦5fb5a153b⟧ Bits:30004042/hpdd.imd SW95705I 386/ix Multi-user Release 1.2
└─⟦5fb5a153b⟧ UNIX Filesystem
└─⟦this⟧ »hp/new/usr/include/sys/genscsi.h«
/*
* Copyright 1986, INTERACTIVE Systems Corporation
*
* RESTRICTED RIGHTS: Use, duplication or disclosure is subject to
* restrictions stated in your contract with
* Interactive Systems Corp.
*/
#ident "@(#)genscsi.h 1.4 - 88/08/19"
/*
* in the following two definitions, a "device" is assumed to be a unique,
* valid <target-id><LUN> pair...
* NOTE: the following 3 numbers allow the config table to fit in 256 bytes.
*/
#define SCSI_DISK_DEVS 24 /* Maximum number of Direct Access (disk) */
/* devices on any single SCSI bus */
#define SCSI_SEQ_DEVS 16 /* Maximum number of Sequential Access devices */
/* (tapes) on any single bus */
#define SCSI_OTHER_DEVS 20 /* Max number of 'other' devs on a bus */
/*
* Definitions for use by SCSI device drivers and host adapter drivers
*/
/******************* Message Codes *******************/
#define MC_CMD_DONE 0x0 /* Command Complete */
#define MC_EXMSG 0x1 /* Extended Message */
#define MC_SAVDP 0x2 /* Save Data Pointer */
#define MC_RESP 0x3 /* Restore Pointers */
#define MC_DISC 0x4 /* DISCONNECT */
#define MC_IDERR 0x5 /* Initiator detected error */
#define MC_ABORT 0x6 /* ABORT */
#define MC_MREJECT 0x7 /* Message REJECT */
#define MC_NOOP 0x8 /* No operation */
#define MC_PARERR 0x9 /* Message Parity Error */
#define MC_LKCOMP 0xA /* Linked Command complete */
#define MC_FLKCOMP 0xB /* linked command complete (w/Flag) */
#define MC_BRST 0xC /* BUS device reset */
#define MC_IDENT 0x80 /* IDENTIFY bit mask */
#define MC_IDISC 0x40 /* disconnect bit for IDENTIFY */
#define MC_LUMASK 0x7 /* mask target lu during reselection */
/* Status Codes returned by SCSI target during status phase */
#define S_GOOD 0x00 /* Target has successfully completed command */
#define S_CK_COND 0x02 /* CHECK CONDITION
* Any error, exception, or abnormal condition
* that causes sense data to be set
*/
#define S_COND_MET 0x04 /* CONDITION MET/GOOD
* returned by SEARCH DATA commands whenever
* search condition is satisfied
*/
#define S_BUSY 0x08 /* BUSY, the target is busy */
#define S_IGOOD 0x10 /* INTERMEDIATE/GOOD
* returned for every command in a
* series of linked commands, unless error
*/
#define S_IMET 0x12 /* INTERMEDIATE/CONDITION MET/GOOD */
#define S_RESERV 0x18 /* RESERVATION CONFLICT
* returned whenever an SCSI device attempts to
* accesses a logical unit reserved by another
* SCSI device
*/
/* SCSI Commands Group 0 */
#define SC_TESTUNIT 0x00 /* TEST UNIT READY */
#define SC_REZERO 0x01 /* Rezero unit */
#define SC_REWIND 0x01 /* Rewind tape */
#define SC_RSENSE 0x03 /* Request Sense */
#define SC_FORMAT 0x04 /* Format */
#define SC_RBLOCKL 0x05 /* READ BLOCK LIMIT */
#define SC_REASSIGNB 0x07 /* Reassign blocks */
#define SC_READ 0x08 /* Read */
#define SC_RECEIVE 0x08 /* Receive */
#define SC_WRITE 0x0A /* write */
#define SC_PRINT 0x0A /* print - write to printer */
#define SC_SEND 0x0A /* send - write to processor device */
#define SC_SEEK 0x0B /* seek */
#define SC_TRK_SLCT 0x0B /* track select */
#define SC_PRT_SLEW 0x0B /* print and slew */
#define SC_READ_REV 0x0F /* read reverse - tape */
#define SC_FILEMARK 0x10 /* write file mark - tape */
#define SC_FLSHB 0x10 /* flush buffer - printer */
#define SC_SPACE 0x11 /* Space - tape */
#define SC_INQUIRY 0x12 /* inquiry */
#define SC_VERIFY 0x13 /* verify - tape */
#define SC_RECOVR 0x14 /* Recover buffered data */
#define SC_MSEL 0x15 /* Mode Select */
#define SC_RELEASE 0x17 /* Release */
#define SC_COPY 0x18 /* Copy */
#define SC_ERASE 0x19 /* Erase - tape */
#define SC_MSEN 0x1A /* Mode Sense */
#define SC_STRT_STOP 0x1B /* Start/Stop unit */
#define SC_LOAD 0x1B /* Load/UNLOAD */
#define SC_ULOAD 0x1B /* Load/UNLOAD */
#define SC_RDIAG 0x1C /* Receive diagnostic results */
#define SC_SDIAG 0x1D /* Send Diagnostic */
#define SC_REMOV 0x1E /* prevent/allow medium removal */
/*
* Code bits for SC_SPACE command (go in bits 0-1 of byte 1):
*/
#define SCSPAC_BLOCKS 0 /* Count spceifies data blocks */
#define SCSPAC_MARKS 1 /* Count spceifies file marks */
#define SCSPAC_SEQMARKS 2 /* Count spceifies sequential file marks */
#define SCSPAC_DATAEND 3 /* Space to end-of-data (ignore count) */
/* SCSI Commands Group 1 - Extended */
#define SX_READCAP 0x25 /* Read Capacity */
#define SX_READ 0x28 /* Read */
#define SX_WRITE 0x2A /* Write */
#define SX_SEEK 0x2B /* Seek */
#define SX_WRITE_VER 0x2E /* Write and Verify */
#define SX_VERIFY 0x2f /* Verify */
#define SX_HISEARCH 0x30 /* Search Data High */
#define SX_EQSEARCH 0x31 /* Search Data Equal */
#define SX_LOWSEARCH 0x32 /* Search Data Low */
#define SX_DEFDATA 0x37 /* Read Defect Data */
#define SX_COMPARE 0x39 /* Compare */
#define SX_COPYVER 0x3A /* Copy and Verify */
#define CMDCTRL 0 /* control byte in the cdb is usually 0 */
#define RQSENLEN 18 /* size of request sense buffer */
/* definitions for use in conjunction with gendisk.[ch] */
#define ctl_t struct gdev_ctl_block
#define drv_t struct gdev_parm_block
#define cfg_t struct gdev_cfg_entry
#define dpb_scsi dpb_lowlev[5] /* must be cast on each use */
/*
* function def's for space.c files
*/
extern void startscsi();
extern int scsi_ctl_init();
extern int scsi_tp_ctl_init();
extern int scsi_drv_init();
extern int scsi_tp_drv_init();
extern int scsi_mid_cmd();
extern int scsi_drv_open();
extern struct gdev_parm_block *tmc_diskint();
extern struct gdev_parm_block *tmc_tapeint();
extern int tmc_mastint();
/**************************************************************************
*
* Data structure common to all SCSI devices
*
**************************************************************************/
typedef struct scsi
{
unchar s_cdb[12]; /* SCSI command descriptor block */
unchar s_errcdb[12]; /* SCSI command descriptor block for
error handling (request sense) */
unchar s_scratch[12]; /* SCSI scratch buffer */
unchar s_errdata[RQSENLEN]; /* data returned by request sense */
unchar *s_cdbptr; /* pointer to SCSI command, either
s_cdb or s_errcdb */
int s_cdblen; /* SCSI command length in bytes */
int s_errlen; /* request sense command length */
int s_edblen; /* request sense data block len */
int *s_lenptr; /* pointer to SCSI command length,
either s_cdblen or s_errlen */
long s_blksiz; /* block size */
long s_capacity; /* disk drive capacity (#sectors) */
char s_lu; /* logical unit number */
char s_id; /* target id number */
char s_type; /* device type (disk, tape, etc.) */
char s_errcnt; /* retry count */
struct scsi
*s_link; /* for host adapter use */
int s_flags; /* for host adapter use */
paddr_t s_addr; /* address for DMA transfers */
long s_bcount; /* byte count for DMA transfers */
paddr_t s_lastaddr; /* for host adapter use */
long s_lastbcount; /* for host adapter use */
int (*s_open)(); /* ptr to function to open device */
int (*s_close)(); /* ptr to function to close device */
int (*s_rqsen)(); /* ptr to function to analyze
* request sense information
*/
void (*s_dequeue)(); /* ptr to function called by scsiintr
* when current command is complete.
*/
int s_dqparam; /* parameter to function s_dequeue */
int s_driveridx; /* index to our driver on this cntler */
drv_t *s_dpb; /* pointer back to generic disk
* parameter block
*/
ctl_t *s_dcb; /* pointer back to generic disk
* controller block
*/
} scsi_t;
extern scsi_t scsitab[]; /* actual instances of the structure */
/*
* structure member initialized where?
* ---------------- ------------------
*
* unchar s_cdb[12] device driver calls build_[td]_cdb() (genscsi.c)
* unchar s_errcdb[12] scsiinit()
* unchar s_scratch[12] N/A (just scratch)
* unchar s_errdata[32] scsiintr() after a check condition and a
* .. request sense command is issued
* unchar *s_cdbptr device driver calls build_[td]_cdb() (genscsi.c)
* .. or by scsiintr for request sense
* int s_cdblen device driver calls build_[td]_cdb() (genscsi.c)
* int s_errlen scsiinit()
* int *s_lenptr device driver calls build_[td]_cdb() (genscsi.c)
* .. or by scsiintr for request sense
* long s_blksiz scsiinit()
* long s_capacity scsiinit()
* unchar s_lu scsiinit()
* unchar s_id scsiinit()
* unchar s_type; scsiinit()
* unchar s_errcnt; adapter driver
* scsi_t *s_link startscsi() and scsiintr() as appropriate
* int s_flags device driver init, host adapter init,
* .. startscsi() and scsiintr()
* .. as appropriate
* paddr_t s_addr device driver just before call to startscsi()
* (i.e. (sp->s_dequeue)() )
* long s_bcount device driver just before call to startscsi()
* (i.e. (sp->s_dequeue)() )
* paddr_t s_lastaddr adapter driver
* long s_lastbcount adapter driver
* int (*s_open)(); device driver init, host adapter init
* int (*s_close)(); device driver init, host adapter init
* int (*s_rqsen)() device driver init, host adapter init
* int (*s_dequeue)() device driver init, host adapter init
* int s_dqparam; device driver command function
* struct dpb s_dpb device driver init, host adapter init
* struct dcb s_dcb device driver init, host adapter init
*/
/* definitions for s_flag */
#define SF_READ 0x001 /* direction of data transfer (input) */
#define SF_WRITE 0x002 /* direction of data transfer (output) */
#define SF_INPUT 0x004 /* transfer data in (like request sense) */
#define SF_ACTIVE 0x008 /* I/O has been initiated on this drive */
#define SF_IONEEDED 0x010 /* I/O needs to be initiated on this drive */
#define SF_REQUEST 0x020 /* Request Sense Transaction needed */
#define SF_OUTPUT 0x040 /* transfer data out (like mode select) */
#define SF_CHECK 0x080 /* The device is being checked for status */
#define SF_NOSWITCH 0x100 /* Device cannot switch between Read/Write */
#define SF_BKUPWFM 0x200 /* Device requires (-1 space) after WFM */
/* definitions for s_type
* bit number set to 1 means
* 0 is a disk
* 1 is a floppy disk (0 => hard disk)
* 2 is a tape
* 3 is a streaming tape (1 => magnetic tape)
*/
#define ST_DISK 0x1 /* mask for disks */
#define ST_HDISK 0x1 /* hard disk */
#define ST_FDISK 0x3 /* floppy disk */
#define ST_TAPE 0x4 /* mask for tapes */
#define ST_STAPE 0x4 /* streaming tape */
#define ST_MTAPE 0xC /* magnetic tape */
/*********
*
* Macros to extract important fields
*
*/
#define SENSE_VALID(X) (X->s_errdata[0] & 0x80)
#define SENSE_INFO(X) (X->s_errdata[3]) /* this is 4 bytes of info */
#define SENSE_KEY(X) (X->s_errdata[2] & 0xF)
#define SENSE_CODE(X) (X->s_errdata[0] & 0xF)
#define SENSE_EOM(X) (X->s_errdata[2] & 0x40)
#define SENSE_FM(X) (X->s_errdata[2] & 0x80)
/***********************************************************************
*
* Macros to efficiently build SCSI command descriptor blocks
*
* NOTE: these macros assume that two variables exist (ptr and reg),
* both of which should be register variables for efficency.
* "reg" is a 4-byte quantity, which is hopefully an "int".
* "ptr" is a char * (or unchar *), which is hopefully an "int".
*/
/* zero out 1, 2, 3, or 4 bytes of the cdb, advancing ptr */
#define LZ1 *ptr = 0; ptr++
#define LZ2 LZ1; LZ1
#define LZ3 LZ1; LZ1; LZ1
#define LZ4 LZ1; LZ1; LZ1; LZ1
/* load a variable 1, 2, 3, or 4 byte quantity into the cdb, advancing ptr */
#define LV1(X) *ptr = X; ptr++
#define LV2(X) reg = X; \
*(ptr+1) = reg; reg >>= 8; \
*ptr = reg; \
ptr++; ptr++
#define LV3(X) reg = X; \
*(ptr+2) = reg; reg >>= 8; \
*(ptr+1) = reg; reg >>= 8; \
*ptr = reg; \
ptr += 3
#define LV4(X) reg = X; \
*(ptr+3) = reg; reg >>= 8; \
*(ptr+2) = reg; reg >>= 8; \
*(ptr+1) = reg; reg >>= 8; \
*ptr = reg; \
ptr += 4
/* load a constant 1, 2, 3, or 4 byte quantity into the cdb, advancing ptr */
#define LC1(X) LV1(X)
#define LC2(X) *ptr = (X)>>8; \
ptr++; \
*ptr = (X); \
ptr++
#define LC3(X) *ptr = (X)>>16; \
ptr++; \
*ptr = (X)>>8; \
ptr++; \
*ptr = (X); \
ptr++
#define LC4(X) *ptr = (X)>>24; \
ptr++; \
*ptr = (X)>>16; \
ptr++; \
*ptr = (X)>>8; \
ptr++; \
*ptr = (X); \
ptr ++
/*************************************************************************
*
* Macros to combine in the correct byte order, groups of bytes from
* a SCSI data block given a pointer to the first byte of the group
*/
#define GET1(X) ( *(unchar *)(X ))
#define GET2(X) ((*(unchar *)(X ) << 8) + \
*(unchar *)(X+1))
#define GET3(X) ((*(unchar *)(X ) << 16) + \
(*(unchar *)(X+1) << 8) + \
*(unchar *)(X+2))
#define GET4(X) ((*(unchar *)(X ) << 24) + \
(*(unchar *)(X+1) << 16) + \
(*(unchar *)(X+2) << 8) + \
*(unchar *)(X+3))
extern build_d_cdb(), build_t_cdb();
extern int initscsi();
/*
* The SCSI configuration table. This table is built by the primary init
* routine (usually a Generic Disk Driver BDINIT routine) for each host
* adapter present in the system. A pointer to this structure will be
* left in the dcb_scsi_conf field of the adapter's dcb. (note that this
* is a virtual field in dcb_lowlev, and thus must be coerced from a ulong).
* Secondary init routines for the same host adapter can find their devices
* by examining this table. The data contained in each scsi_config_entry
* is obtained by an 'inquiry' command at primary init time.
*/
struct scsi_config_entry
{
unchar sce_targ; /* Target ID for this device */
unchar sce_lun; /* LUN for this device */
unchar sce_rmb; /* Removable Medium flag (1 if remov) */
unchar sce_devtype; /* Peripheral Device Type from 'inquiry' cmd */
};
struct scsi_config_table
{
ushort sct_hatype; /* host adpter type (below) */
ushort sct_diskcnt; /* number of valid entries in sct_disks */
ushort sct_remdisk; /* number of removable drives in sct_disks */
ushort sct_seqcnt; /* number of valid entries in sct_seqs */
ushort sct_othcnt; /* number of valid entries in sct_others */
struct scsi_config_entry sct_disks[SCSI_DISK_DEVS];
struct scsi_config_entry sct_seqs[SCSI_SEQ_DEVS];
struct scsi_config_entry sct_others[SCSI_OTHER_DEVS];
};
/*
* values for sct_hatype:
*/
#define SCHA_TMC8X0 1 /* Future Domain TMC-8X0 */
#define SCHA_AD1540 2 /* Adaptec AHA-1540 */
/*
* definitions for overlays on dcb_lowlev fields:
*/
#define dcb_scsi_conf dcb_lowlev[GDEV_LOWLEV-1]
/*
* structure of some data returned by SCSI commands is below:
*/
/* INQUIRY DATA */
struct inquiry_data
{
unchar inqd_pdt; /* Peripheral Device Type (see below) */
unchar inqd_dtq; /* Device Type Qualifier (see below) */
unchar inqd_ver; /* Version #s */
unchar inqd_pad1; /* pad must be zero */
unchar inqd_len; /* additional length */
unchar inqd_pad2[3]; /* pad must be zero */
unchar inqd_vid[8]; /* Vendor ID */
unchar inqd_pid[16]; /* Product ID */
unchar inqd_prl[4]; /* Product Revision Level */
};
/* values for inqd_pdt: */
#define INQD_PDT_DA 0x00 /* Direct-access (DISK) device */
#define INQD_PDT_SEQ 0x01 /* Sequential-access (TAPE) device */
#define INQD_PDT_PRINT 0x02 /* Printer device */
#define INQD_PDT_PROC 0x03 /* Processor device */
#define INQD_PDT_WORM 0x04 /* Write-once read-many direct-access device */
#define INQD_PDT_ROM 0x05 /* Read-only directe-access device */
#define INQD_PDT_NOLUN 0x7f /* Logical Unit Not Present */
/* masks for inqd_dtq: */
#define INQD_DTQ_RMB 0x80 /* Removable Medium Bit mask */
#define INQD_DTQ_MASK 0x7f /* mask for device type qualifier field */
/* READ CAPACITY DATA */
struct readcap_data
{
unchar rdcd_lba[4]; /* Logical Block Address (MSB first, LSB last) */
unchar rdcd_bl[4]; /* Block Length (MSB first, LSB last) */
};
/* SENSE DATA (non-extended) */
struct nxsense_data
{
unchar nxsd_err; /* error class and code (see fields, below) */
unchar nxsd_lba[3]; /* logical block number */
};
#define NXSD_LBA_MASK0 0x1f /* mask for block # portion of nxsd_lba[0] */
/* SENSE DATA (extended) */
struct exsense_data
{
unchar exsd_err; /* error class and code (see fields, below) */
unchar exsd_seg; /* segment number */
unchar exsd_key; /* sense key & other fields (defined below) */
unchar exsd_info[4]; /* information bytes */
unchar exsd_adlen; /* additional sense length */
unchar exsd_adsd[1]; /* additional sense bytes */
};
/* fields for nxsd_err and exsd_err bytes: */
union sd_err_fields
{
struct
{
uint sder_errcod : 4; /* error code (0 for extended sense) */
uint sder_errcls : 3; /* error class (7 for ext sense) */
uint sder_valid : 1; /* Address Valid bit */
} sef;
unchar sec;
};
/* fields for exsd_key byte: */
union sd_key_fields
{
struct
{
uint sdky_key : 4; /* actual sense key */
uint sdky_res1 : 1; /* reserved */
uint sdky_ili : 1; /* Incorrect Length Indicator */
uint sdky_eom : 1; /* End of Medium bit */
uint sdky_fmark : 1; /* Filemark bit */
} skf;
unchar skc;
};
/* Read Block Limits Data */
struct blocklim_data
{
unchar bkld_res; /* reserved */
unchar bkld_max[3]; /* Maximum block length */
unchar bkld_min[2]; /* Minimum block length */
};
/* Viper Tape (Archive) Mode Sense Data */
struct tpmsen_data
{
unchar tmsd_dl; /* Sense Data Length */
unchar tmsd_med; /* Medium Type */
unchar tmsd_modes; /* WP bit, buffer mode, speed (below) */
unchar tmsd_bdl; /* Block Descriptor Length */
/* Following 8 bytes are Block Descriptors */
unchar tmsd_den; /* Density code (below) */
unchar tmds_nblk[3]; /* Number of blocks field */
unchar tmds_res; /* Reserved */
unchar tmds_blkl[3]; /* Block Length */
};
/* Field for accessing tmsd_modes byte */
union tms_mode_fields
{
struct
{
uint tmsm_speed : 4; /* Speed */
uint tmsm_bufm : 3; /* Buffer mode (below) */
uint tmsm_wp : 1; /* Write-Protect bit */
} tmf;
unchar tmc;
};
/* Definitions for Buffer Mode field */
#define TMSD_NOBUF 0 /* Unbuffered mode */
#define TMSD_BUF 1 /* Buffered mode */
/* Definitions for Density Code field */
#define TMSD_60MB 5 /* Low-density (9-trk) mode */
#define TMSD_125MB 0x0f /* Medium-density (15-trk) mode */
#define TMSD_150MB 0x10 /* High-density (18-trk) mode */