* Copyright (c) 1990 The Regents of the University of California.
* This code is derived from software contributed to Berkeley by
* Van Jacobson of Lawrence Berkeley Laboratory.
* Redistribution is only permitted until one year after the first shipment
* of 4.4BSD by the Regents. Otherwise, redistribution and use in source and
* binary forms are permitted provided that: (1) source distributions retain
* this entire copyright notice and comment, and (2) distributions including
* binaries display the following acknowledgement: This product includes
* software developed by the University of California, Berkeley and its
* contributors'' in the documentation or other materials provided with the
* distribution and in all advertising materials mentioning features or use
* of this software. Neither the name of the University nor the names of
* its contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
* @(#)scsireg.h 7.1 (Berkeley) 5/8/90
* HP 98265A SCSI Interface Hardware Description.
#define SCSI_IPL(csr) ((((csr)>>4)&3)+3)
#define SCSI_SYNC_XFER(hconf) (((hconf)>>5)&3)
#define HCONF_PARITY 0x08
#define SCTL_DISABLE 0x80
#define SCTL_CTRLRST 0x40
#define SCTL_ABRT_ENAB 0x10
#define SCTL_PARITY_ENAB 0x08
#define SCTL_SEL_ENAB 0x04
#define SCTL_RESEL_ENAB 0x02
#define SCTL_INTR_ENAB 0x01
#define SCMD_ICPT_XFR 0x08
#define SCMD_PROG_XFR 0x04
#define SCMD_PAD 0x01 /* if initiator */
#define SCMD_PERR_STOP 0x01 /* if target */
#define SCMD_BUS_REL 0x00
#define SCMD_RST_ATN 0x40
#define SCMD_SET_ATN 0x60
#define SCMD_XFR_PAUSE 0xa0
#define SCMD_RST_ACK 0xc0
#define SCMD_SET_ACK 0xe0
#define INTS_CMD_DONE 0x10
#define INTS_SRV_REQ 0x08
#define INTS_TIMEOUT 0x04
#define INTS_HARD_ERR 0x02
#define SSTS_INITIATOR 0x80
#define SSTS_ACTIVE (SSTS_INITIATOR|SSTS_XFR)
#define SSTS_DREG_FULL 0x02
#define SSTS_DREG_EMPTY 0x01
#define SERR_SCSI_PAR 0x80
#define SERR_SPC_PAR 0x40
#define SERR_PHASE_ERR 0x04
#define SERR_SHORT_XFR 0x02
#define PCTL_BFINT_ENAB 0x80
/* psns/pctl phase lines as bits */
#define PHASE_CD 0x02 /* =1 if 'command' */
#define PHASE_IO 0x01 /* =1 if data inbound */
/* Phase lines as values */
#define PHASE 0x07 /* mask for psns/pctl phase */
#define DATA_OUT_PHASE 0x00
#define DATA_IN_PHASE 0x01
#define STATUS_PHASE 0x03
#define BUS_FREE_PHASE 0x04
#define ARB_SEL_PHASE 0x05 /* Fuji chip combines arbitration with sel. */
#define MESG_OUT_PHASE 0x06
#define MESG_IN_PHASE 0x07
#define MSG_CMD_COMPLETE 0x00
#define MSG_EXT_MESSAGE 0x01
#define MSG_SAVE_DATA_PTR 0x02
#define MSG_RESTORE_PTR 0x03
#define MSG_DISCONNECT 0x04
#define MSG_INIT_DETECT_ERROR 0x05
#define MSG_PARITY_ERROR 0x09
#define MSG_BUS_DEVICE_RESET 0x0C
#define MSG_IDENTIFY 0x80
#define MSG_IDENTIFY_DR 0xc0 /* (disconnect/reconnect allowed) */
#define MSG_SYNC_REQ 0x01
#define CMD_TEST_UNIT_READY 0x00
#define CMD_REQUEST_SENSE 0x03
#define CMD_SEND_DIAGNOSTIC 0x1D
#define CMD_FORMAT_UNIT 0x04
#define CMD_REASSIGN_BLOCKS 0x07
#define CMD_MODE_SELECT 0x15
#define CMD_RELEASE_UNIT 0x17
#define CMD_MODE_SENSE 0x1A
#define CMD_SEND_DIAG 0x1D
#define CMD_READ_CAPACITY 0x25
#define CMD_READ_EXT 0x28
#define CMD_WRITE_EXT 0x2A
#define CMD_READ_DEFECT_DATA 0x37
#define SD_MANUFAC_DEFECTS 0x14000000
#define SD_GROWN_DEFECTS 0x0c000000
#define CMD_READ_BUFFER 0x3B
#define CMD_WRITE_BUFFER 0x3C
#define CMD_READ_FULL 0xF0
#define CMD_MEDIA_TEST 0xF1
#define CMD_ACCESS_LOG 0xF2
#define CMD_WRITE_FULL 0xFC
#define CMD_MANAGE_PRIMARY 0xFD
#define CMD_EXECUTE_DATA 0xFE
#define STS_CHECKCOND 0x02 /* Check Condition (ie., read sense) */
#define STS_CONDMET 0x04 /* Condition Met (ie., search worked) */
#define STS_INTERMED 0x10 /* Intermediate status sent */
#define STS_EXT 0x80 /* Extended status valid */
/* command descriptor blocks */
u_char cmd
; /* command code */
u_char lun
: 3, /* logical unit on ctlr */
lbah
: 5; /* msb of read/write logical block addr */
u_char lbam
; /* middle byte of l.b.a. */
u_char lbal
; /* lsb of l.b.a. */
u_char len
; /* transfer length */
u_char cmd
; /* command code */
u_char lun
: 3, /* logical unit on ctlr */
rel
: 1; /* l.b.a. is relative addr if =1 */
u_char lbah
; /* msb of read/write logical block addr */
u_char lbahm
; /* high middle byte of l.b.a. */
u_char lbalm
; /* low middle byte of l.b.a. */
u_char lbal
; /* lsb of l.b.a. */
u_char lenh
; /* msb transfer length */
u_char lenl
; /* lsb transfer length */
u_char valid
: 1, /* l.b.a. is valid */
u_char vu
: 4, /* vendor unique */
u_char valid
: 1, /* l.b.a. is valid */
ili
: 1, /* illegal length indicator */
u_char len
; /* additional sense length */
struct scsi_format_parms
{ /* physical BFI format */
struct scsi_reassign_parms
{
u_short list_len
; /* length in bytes of defects only */
unsigned lba
; /* logical block address */
struct scsi_modesel_hdr
{
struct scsi_modesense_hdr
{
* Mode Select / Mode sense "pages"
* Page One - Error Recovery Parameters
struct scsi_err_recovery
{
u_char page_savable
: 1; /* save parameters */
u_char page_code
: 6; /* = 0x01 */
u_char page_length
; /* = 6 */
u_char awre
: 1; /* auto write realloc enabled */
u_char arre
: 1; /* auto read realloc enabled */
u_char tb
: 1; /* transfer block */
u_char rc
: 1; /* read continuous */
u_char eec
: 1; /* enable early correction */
u_char per
: 1; /* post error */
u_char dte
: 1; /* disable transfer on error */
u_char dcr
: 1; /* disable correction */
u_char head_offset_count
;
u_char strobe_offset_count
;
u_char recovery_time_limit
;
* Page Two - Disconnect / Reconnect Control Parameters
u_char page_savable
: 1; /* save parameters */
u_char page_code
: 6; /* = 0x02 */
u_char page_length
; /* = 10 */
u_char buffer_full_ratio
; /* write, how full before reconnect? */
u_char buffer_empty_ratio
; /* read, how full before reconnect? */
u_short bus_inactivity_limit
; /* how much bus time for busy */
u_short disconnect_time_limit
; /* min to remain disconnected */
u_short connect_time_limit
; /* min to remain connected */
* Page Three - Direct Access Device Format Parameters
u_char page_savable
: 1; /* save parameters */
u_char page_code
: 6; /* = 0x03 */
u_char page_length
; /* = 22 */
u_short tracks_per_zone
; /* Handling of Defects Fields */
u_short sect_track
; /* Track Format Field */
u_short data_sect
; /* Sector Format Fields */
u_short track_skew_factor
;
u_char ssec
: 1; /* Drive Type Field */
* Page Four - Rigid Disk Drive Geometry Parameters
u_char page_savable
: 1; /* save parameters */
u_char page_code
: 6; /* = 0x04 */
u_char page_length
; /* = 18 */
u_char cyl_ub
; /* number of cylinders */
u_char heads
; /* number of heads */
u_char precomp_cyl_ub
; /* cylinder to start precomp */
u_char current_cyl_ub
; /* cyl to start reduced current */
u_short step_rate
; /* drive step rate */
u_char landing_cyl_ub
; /* landing zone cylinder */
* Page 0x38 - Cache Control Parameters
u_char page_savable
: 1; /* save parameters */
u_char page_code
: 6; /* = 0x38 */
u_char page_length
; /* = 14 */
u_char wie
: 1; /* write index enable */
u_char ce
: 1; /* cache enable */
u_char prefetch_threshold
;
u_char maximum_threshold
;
u_char maximumprefetch_multiplier
;
u_char minimum_threshold
;
u_char minimum_prefetch_multiplier
;
* Driver ioctl's for various scsi operations.
* Control for SCSI "format" mode.
* "Format" mode allows a privileged process to issue direct SCSI
* commands to a drive (it is intended primarily to allow on-line
* formatting). SDIOCSFORMAT with a non-zero arg will put the drive
* into format mode; a zero arg will take it out. When in format
* mode, only the process that issued the SDIOCFORMAT can read or
* In format mode, process is expected to
* - do SDIOCSCSICOMMAND to supply cdb for next SCSI op
* - do read or write as appropriate for cdb
* - if i/o error, optionally do SDIOCSENSE to get completion
* status and sense data from last scsi operation.
int len
; /* cdb length (in bytes) */
u_char cdb
[28]; /* cdb to use on next read/write */
u_int status
; /* completion status of last op */
u_char sense
[28]; /* sense data (if any) from last op */
#define SDIOCSFORMAT _IOW('S', 0x1, int)
#define SDIOCGFORMAT _IOR('S', 0x2, int)
#define SDIOCSCSICOMMAND _IOW('S', 0x3, struct scsi_fmt_cdb)
#define SDIOCSENSE _IOR('S', 0x4, struct scsi_fmt_sense)