#ifndef _DEV_SCSIPI_SCSI_DISK_H_
#define _DEV_SCSIPI_SCSI_DISK_H_
#define SCSI_FORMAT_UNIT 0x04
struct scsi_format_unit {
u_int8_t opcode;
u_int8_t flags;
#define SFU_DLF_MASK 0x07
#define SFU_CMPLST 0x08
#define SFU_FMTDATA 0x10
u_int8_t vendor_specific;
u_int8_t interleave[2];
u_int8_t control;
};
struct scsi_format_unit_defect_list_header {
u_int8_t reserved;
u_int8_t flags;
#define DLH_VS 0x01
#define DLH_IMMED 0x02
#define DLH_DSP 0x04
#define DLH_IP 0x08
#define DLH_STPF 0x10
#define DLH_DCRT 0x20
#define DLH_DPRY 0x40
#define DLH_FOV 0x80
u_int8_t defect_lst_len[2];
};
struct scsi_initialization_pattern_descriptor {
u_int8_t ip_modifier;
u_int8_t pattern_type;
#define IP_TYPE_DEFAULT 0x01
#define IP_TYPE_REPEAT 0x01
u_int8_t pattern_length[2];
#if 0
u_int8_t pattern[...];
#endif
};
struct scsi_defect_descriptor_bf {
u_int8_t block_address[4];
};
struct scsi_defect_descriptor_bfif {
u_int8_t cylinder[3];
u_int8_t head;
u_int8_t bytes_from_index[4];
};
struct scsi_defect_descriptor_psf {
u_int8_t cylinder[3];
u_int8_t head;
u_int8_t sector[4];
};
#define SCSI_REASSIGN_BLOCKS 0x07
struct scsi_reassign_blocks {
u_int8_t opcode;
u_int8_t byte2;
u_int8_t unused[3];
u_int8_t control;
};
#define SCSI_REZERO_UNIT 0x01
struct scsi_rezero_unit {
u_int8_t opcode;
u_int8_t byte2;
u_int8_t reserved[3];
u_int8_t control;
};
#define SCSI_READ_6_COMMAND 0x08
#define SCSI_WRITE_6_COMMAND 0x0a
struct scsi_rw_6 {
u_int8_t opcode;
u_int8_t addr[3];
#define SRW_TOPADDR 0x1F
u_int8_t length;
u_int8_t control;
};
#define SCSI_SYNCHRONIZE_CACHE_10 0x35
struct scsi_synchronize_cache_10 {
u_int8_t opcode;
u_int8_t flags;
#define SSC_RELADR 0x01
#define SSC_IMMED 0x02
#define SSC_SYNC_NV 0x04
u_int8_t addr[4];
u_int8_t byte7;
u_int8_t length[2];
u_int8_t control;
};
#define SCSI_READ_DEFECT_DATA 0x37
struct scsi_read_defect_data {
u_int8_t opcode;
u_int8_t byte2;
#define RDD_PRIMARY 0x10
#define RDD_GROWN 0x08
#define RDD_BF 0x00
#define RDD_BFIF 0x04
#define RDD_PSF 0x05
u_int8_t flags;
u_int8_t reserved[4];
u_int8_t length[2];
u_int8_t control;
};
#define SCSI_SYNCHRONIZE_CACHE_16 0x91
struct scsi_synchronize_cache_16 {
u_int8_t opcode;
u_int8_t flags;
u_int8_t addr[8];
u_int8_t length[4];
u_int8_t byte15;
u_int8_t control;
};
struct scsi_reassign_blocks_data {
u_int8_t reserved[2];
u_int8_t length[2];
struct {
u_int8_t dlbaddr[4];
} defect_descriptor[1];
};
struct scsi_read_defect_data_data {
u_int8_t reserved;
u_int8_t flags;
u_int8_t length[2];
union scsi_defect_descriptor {
struct scsi_defect_descriptor_bf bf;
struct scsi_defect_descriptor_bfif bfif;
struct scsi_defect_descriptor_psf psf;
} defect_descriptor[1];
};
union scsi_disk_pages {
#define DISK_PGCODE 0x3F
struct page_err_recov {
u_int8_t pg_code;
u_int8_t pg_length;
u_int8_t flags;
#define ERR_RECOV_DCR 0x01
#define ERR_RECOV_DTE 0x02
#define ERR_RECOV_PER 0x04
#define ERR_RECOV_EER 0x08
#define ERR_RECOV_RC 0x10
#define ERR_RECOV_TB 0x20
#define ERR_RECOV_ARRE 0x40
#define ERR_RECOV_AWRE 0x80
u_int8_t rd_retry_ct;
u_int8_t corr_span;
u_int8_t hd_off_ct;
u_int8_t dat_strb_off_ct;
u_int8_t reserved1;
u_int8_t wr_retry_ct;
u_int8_t reserved2;
u_int8_t recov_tm_lim[2];
} err_recov_params;
struct page_disk_format {
u_int8_t pg_code;
u_int8_t pg_length;
u_int8_t trk_z[2];
u_int8_t alt_sec[2];
u_int8_t alt_trk_z[2];
u_int8_t alt_trk_v[2];
u_int8_t ph_sec_t[2];
u_int8_t bytes_s[2];
u_int8_t interleave[2];
u_int8_t trk_skew[2];
u_int8_t cyl_skew[2];
u_int8_t flags;
#define DISK_FMT_SURF 0x10
#define DISK_FMT_RMB 0x20
#define DISK_FMT_HSEC 0x40
#define DISK_FMT_SSEC 0x80
u_int8_t reserved1;
u_int8_t reserved2;
u_int8_t reserved3;
} disk_format;
struct page_rigid_geometry {
u_int8_t pg_code;
u_int8_t pg_length;
u_int8_t ncyl[3];
u_int8_t nheads;
u_int8_t st_cyl_wp[3];
u_int8_t st_cyl_rwc[3];
u_int8_t driv_step[2];
u_int8_t land_zone[3];
u_int8_t sp_sync_ctl;
#define SPINDLE_SYNCH_MASK 0x03
#define SPINDLE_SYNCH_NONE 0x00
#define SPINDLE_SYNCH_SLAVE 0x01
#define SPINDLE_SYNCH_MASTER 0x02
#define SPINDLE_SYNCH_MCONTROL 0x03
u_int8_t rot_offset;
u_int8_t reserved1;
u_int8_t rpm[2];
u_int8_t reserved2;
u_int8_t reserved3;
} rigid_geometry;
struct page_flex_geometry {
u_int8_t pg_code;
u_int8_t pg_length;
u_int8_t xfr_rate[2];
u_int8_t nheads;
u_int8_t ph_sec_tr;
u_int8_t bytes_s[2];
u_int8_t ncyl[2];
u_int8_t st_cyl_wp[2];
u_int8_t st_cyl_rwc[2];
u_int8_t driv_step[2];
u_int8_t driv_step_w;
u_int8_t head_settle[2];
u_int8_t motor_on;
u_int8_t motor_off;
u_int8_t flags;
#define MOTOR_ON 0x20
#define START_AT_SECTOR_1 0x40
#define READY_VALID 0x20
u_int8_t step_p_cyl;
u_int8_t write_pre;
u_int8_t head_load;
u_int8_t head_unload;
u_int8_t pin_34_2;
u_int8_t pin_4_1;
u_int8_t rpm[2];
u_int8_t reserved1;
u_int8_t reserved2;
} flex_geometry;
struct page_caching {
u_int8_t pg_code;
u_int8_t pg_length;
u_int8_t flags;
#define CACHING_RCD 0x01
#define CACHING_MF 0x02
#define CACHING_WCE 0x04
#define CACHING_SIZE 0x08
#define CACHING_DISC 0x10
#define CACHING_CAP 0x20
#define CACHING_ABPF 0x40
#define CACHING_IC 0x80
u_int8_t ret_prio;
#define READ_RET_PRIO_SHIFT 4
#define RET_PRIO_DONT_DISTINGUISH 0x0
#define RET_PRIO_REPLACE_READ_WRITE 0x1
#define RET_PRIO_REPLACE_PREFETCH 0xf
u_int8_t dis_prefetch_xfer_len[2];
u_int8_t min_prefetch[2];
u_int8_t max_prefetch[2];
u_int8_t max_prefetch_ceiling[2];
u_int8_t flags2;
#define CACHING2_VS0 0x08
#define CACHING2_VS1 0x10
#define CACHING2_DRA 0x20
#define CACHING2_LBCSS 0x40
#define CACHING2_FSW 0x80
u_int8_t num_cache_segments;
u_int8_t cache_segment_size[2];
u_int8_t reserved1;
u_int8_t non_cache_segment_size[2];
} caching_params;
struct page_control {
u_int8_t pg_code;
u_int8_t pg_length;
u_int8_t ctl_flags1;
#define CTL1_TST_PER_INTR 0x40
#define CTL1_TST_FIELD 0xe0
#define CTL1_D_SENSE 0x04
#define CTL1_GLTSD 0x02
#define CTL1_RLEC 0x01
u_int8_t ctl_flags2;
#define CTL2_QAM_UNRESTRICT 0x10
#define CTL2_QAM_FIELD 0xf0
#define CTL2_QERR_ABRT 0x02
#define CTL2_QERR_ABRT_SELF 0x06
#define CTL2_QERR_FIELD 0x06
#define CTL2_DQUE 0x01
u_int8_t ctl_flags3;
#define CTL3_TAS 0x80
#define CTL3_RAC 0x40
#define CTL3_UAIC_RET 0x10
#define CTL3_UAIC_RET_EST 0x30
#define CTL3_UA_INTRLOCKS 0x30
#define CTL3_SWP 0x08
#define CTL3_RAERP 0x04
#define CTL3_UAAERP 0x02
#define CTL3_EAERP 0x01
u_int8_t ctl_autoload;
#define CTL_AUTOLOAD_FIELD 0x07
u_int8_t ctl_r_hld[2];
u_int8_t ctl_busy[2];
u_int8_t ctl_selt[2];
} control_params;
};
struct scsi_vpd_logical_block_provisioning {
struct {
u_int8_t device;
u_int8_t pagecode;
u_int8_t length[2];
};
u_int8_t threshold_exponent;
u_int8_t flags;
#define VPD_LBP_LBPU 0x80
#define VPD_LBP_LBPWS 0x40
#define VPD_LBP_LBPWS10 0x20
u_int8_t reserved6[2];
} __packed;
#define UNMAP_10 0x42
struct scsi_unmap_10 {
u_int8_t opcode;
u_int8_t byte2;
u_int8_t reserved3[4];
u_int8_t byte7;
u_int8_t length[2];
u_int8_t control;
} __packed;
struct scsi_unmap_10_data {
u_int8_t unmap_data_length[2];
u_int8_t unmap_block_descriptor_data_length[2];
u_int8_t reserved5[4];
struct {
u_int8_t addr[8];
u_int8_t len[4];
u_int8_t reserved13[4];
} unmap_block_descriptor[1];
} __packed;
#endif