diff options
author | kbyanc <kbyanc@FreeBSD.org> | 2001-08-27 01:29:30 +0000 |
---|---|---|
committer | kbyanc <kbyanc@FreeBSD.org> | 2001-08-27 01:29:30 +0000 |
commit | d4bbe5708a7e6f2319c93354c1ba08c4b616ea28 (patch) | |
tree | ec2a5d85a5fa04a53bf877a50c32af980b09f850 /sys/cam | |
parent | 1df82af8cb7a354b16b8db05947dfa4ebe01873a (diff) | |
download | FreeBSD-src-d4bbe5708a7e6f2319c93354c1ba08c4b616ea28.zip FreeBSD-src-d4bbe5708a7e6f2319c93354c1ba08c4b616ea28.tar.gz |
Add interfaces for SCSI LOG SELECT and LOG SENSE commands.
Reviewed by: ken
Diffstat (limited to 'sys/cam')
-rw-r--r-- | sys/cam/scsi/scsi_all.c | 67 | ||||
-rw-r--r-- | sys/cam/scsi/scsi_all.h | 86 |
2 files changed, 153 insertions, 0 deletions
diff --git a/sys/cam/scsi/scsi_all.c b/sys/cam/scsi/scsi_all.c index 0fe832e..e4061dc 100644 --- a/sys/cam/scsi/scsi_all.c +++ b/sys/cam/scsi/scsi_all.c @@ -2508,6 +2508,73 @@ scsi_mode_select(struct ccb_scsiio *csio, u_int32_t retries, timeout); } +void +scsi_log_sense(struct ccb_scsiio *csio, u_int32_t retries, + void (*cbfcnp)(struct cam_periph *, union ccb *), + u_int8_t tag_action, u_int8_t page_code, u_int8_t page, + int save_pages, int ppc, u_int32_t paramptr, + u_int8_t *param_buf, u_int32_t param_len, u_int8_t sense_len, + u_int32_t timeout) +{ + struct scsi_log_sense *scsi_cmd; + u_int8_t cdb_len; + + scsi_cmd = (struct scsi_log_sense *)&csio->cdb_io.cdb_bytes; + bzero(scsi_cmd, sizeof(*scsi_cmd)); + scsi_cmd->opcode = LOG_SENSE; + scsi_cmd->page = page_code | page; + if (save_pages != 0) + scsi_cmd->byte2 |= SLS_SP; + if (ppc != 0) + scsi_cmd->byte2 |= SLS_PPC; + scsi_ulto2b(paramptr, scsi_cmd->paramptr); + scsi_ulto2b(param_len, scsi_cmd->length); + cdb_len = sizeof(*scsi_cmd); + + cam_fill_csio(csio, + retries, + cbfcnp, + /*flags*/CAM_DIR_IN, + tag_action, + /*data_ptr*/param_buf, + /*dxfer_len*/param_len, + sense_len, + cdb_len, + timeout); +} + +void +scsi_log_select(struct ccb_scsiio *csio, u_int32_t retries, + void (*cbfcnp)(struct cam_periph *, union ccb *), + u_int8_t tag_action, u_int8_t page_code, int save_pages, + int pc_reset, u_int8_t *param_buf, u_int32_t param_len, + u_int8_t sense_len, u_int32_t timeout) +{ + struct scsi_log_select *scsi_cmd; + u_int8_t cdb_len; + + scsi_cmd = (struct scsi_log_select *)&csio->cdb_io.cdb_bytes; + bzero(scsi_cmd, sizeof(*scsi_cmd)); + scsi_cmd->opcode = LOG_SELECT; + scsi_cmd->page = page_code & SLS_PAGE_CODE; + if (save_pages != 0) + scsi_cmd->byte2 |= SLS_SP; + if (pc_reset != 0) + scsi_cmd->byte2 |= SLS_PCR; + scsi_ulto2b(param_len, scsi_cmd->length); + cdb_len = sizeof(*scsi_cmd); + + cam_fill_csio(csio, + retries, + cbfcnp, + /*flags*/CAM_DIR_OUT, + tag_action, + /*data_ptr*/param_buf, + /*dxfer_len*/param_len, + sense_len, + cdb_len, + timeout); +} /* XXX allow specification of address and PMI bit and LBA */ void diff --git a/sys/cam/scsi/scsi_all.h b/sys/cam/scsi/scsi_all.h index 3c47b6e..6a873f09 100644 --- a/sys/cam/scsi/scsi_all.h +++ b/sys/cam/scsi/scsi_all.h @@ -260,6 +260,74 @@ struct scsi_mode_block_descr u_int8_t block_len[3]; }; +struct scsi_log_sense +{ + u_int8_t opcode; + u_int8_t byte2; +#define SLS_SP 0x01 +#define SLS_PPC 0x02 + u_int8_t page; +#define SLS_PAGE_CODE 0x3F +#define SLS_ALL_PAGES_PAGE 0x00 +#define SLS_OVERRUN_PAGE 0x01 +#define SLS_ERROR_WRITE_PAGE 0x02 +#define SLS_ERROR_READ_PAGE 0x03 +#define SLS_ERROR_READREVERSE_PAGE 0x04 +#define SLS_ERROR_VERIFY_PAGE 0x05 +#define SLS_ERROR_NONMEDIUM_PAGE 0x06 +#define SLS_ERROR_LASTN_PAGE 0x07 +#define SLS_PAGE_CTRL_MASK 0xC0 +#define SLS_PAGE_CTRL_THRESHOLD 0x00 +#define SLS_PAGE_CTRL_CUMULATIVE 0x40 +#define SLS_PAGE_CTRL_THRESH_DEFAULT 0x80 +#define SLS_PAGE_CTRL_CUMUL_DEFAULT 0xC0 + u_int8_t reserved[2]; + u_int8_t paramptr[2]; + u_int8_t length[2]; + u_int8_t control; +}; + +struct scsi_log_select +{ + u_int8_t opcode; + u_int8_t byte2; +/* SLS_SP 0x01 */ +#define SLS_PCR 0x02 + u_int8_t page; +/* SLS_PAGE_CTRL_MASK 0xC0 */ +/* SLS_PAGE_CTRL_THRESHOLD 0x00 */ +/* SLS_PAGE_CTRL_CUMULATIVE 0x40 */ +/* SLS_PAGE_CTRL_THRESH_DEFAULT 0x80 */ +/* SLS_PAGE_CTRL_CUMUL_DEFAULT 0xC0 */ + u_int8_t reserved[4]; + u_int8_t length[2]; + u_int8_t control; +}; + +struct scsi_log_header +{ + u_int8_t page; + u_int8_t reserved; + u_int8_t datalen[2]; +}; + +struct scsi_log_param_header { + u_int8_t param_code[2]; + u_int8_t param_control; +#define SLP_LP 0x01 +#define SLP_LBIN 0x02 +#define SLP_TMC_MASK 0x0C +#define SLP_TMC_ALWAYS 0x00 +#define SLP_TMC_EQUAL 0x04 +#define SLP_TMC_NOTEQUAL 0x08 +#define SLP_TMC_GREATER 0x0C +#define SLP_ETC 0x10 +#define SLP_TSD 0x20 +#define SLP_DS 0x40 +#define SLP_DU 0x80 + u_int8_t param_len; +}; + struct scsi_control_page { u_int8_t page_code; u_int8_t page_length; @@ -433,6 +501,8 @@ struct scsi_start_stop_unit #define WRITE_BUFFER 0x3b #define READ_BUFFER 0x3c #define CHANGE_DEFINITION 0x40 +#define LOG_SELECT 0x4c +#define LOG_SENSE 0x4d #define MODE_SELECT_10 0x55 #define MODE_SENSE_10 0x5A #define MOVE_MEDIUM 0xa5 @@ -857,6 +927,22 @@ void scsi_mode_select(struct ccb_scsiio *csio, u_int32_t retries, u_int32_t param_len, u_int8_t sense_len, u_int32_t timeout); +void scsi_log_sense(struct ccb_scsiio *csio, u_int32_t retries, + void (*cbfcnp)(struct cam_periph *, union ccb *), + u_int8_t tag_action, u_int8_t page_code, + u_int8_t page, int save_pages, int ppc, + u_int32_t paramptr, u_int8_t *param_buf, + u_int32_t param_len, u_int8_t sense_len, + u_int32_t timeout); + +void scsi_log_select(struct ccb_scsiio *csio, u_int32_t retries, + void (*cbfcnp)(struct cam_periph *, + union ccb *), u_int8_t tag_action, + u_int8_t page_code, int save_pages, + int pc_reset, u_int8_t *param_buf, + u_int32_t param_len, u_int8_t sense_len, + u_int32_t timeout); + void scsi_read_capacity(struct ccb_scsiio *csio, u_int32_t retries, void (*cbfcnp)(struct cam_periph *, union ccb *), u_int8_t tag_action, |