Add type definition for SCSI sense data.
This commit is contained in:
@@ -35,6 +35,52 @@
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/**
|
||||
Structure of a SCSI/MMC sense reply.
|
||||
|
||||
This has been adapted from GNU/Linux request_sense of <linux/cdrom.h>
|
||||
include this for direct MMC access.
|
||||
See SCSI Primary Commands-2 (SPC-2) table 102 or
|
||||
SPC 4.5.3, Table 26.
|
||||
*/
|
||||
struct mmc_request_sense {
|
||||
#if defined(WORDS_BIGENDIAN)
|
||||
uint8_t valid : 1; /**< valid bit is 1 if info is valid */
|
||||
uint8_t error_code : 7;
|
||||
#else
|
||||
uint8_t error_code : 7;
|
||||
uint8_t valid : 1; /**< valid bit is 1 if info is valid */
|
||||
#endif
|
||||
uint8_t segment_number;
|
||||
#if defined(WORDS_BIGENDIAN)
|
||||
uint8_t filemark : 1; /**< manditory in sequential
|
||||
* access devices */
|
||||
uint8_t eom : 1; /**< end of medium. manditory in
|
||||
* sequential access and
|
||||
* printer devices */
|
||||
uint8_t ili : 1; /**< incorrect length indicator */
|
||||
uint8_t reserved1 : 1;
|
||||
uint8_t sense_key : 4;
|
||||
#else
|
||||
uint8_t sense_key : 4;
|
||||
uint8_t reserved1 : 1;
|
||||
uint8_t ili : 1; /**< incorrect length indicator */
|
||||
uint8_t eom : 1; /**< end of medium. manditory in
|
||||
* sequential access and
|
||||
* printer devices */
|
||||
uint8_t filemark : 1; /**< manditory in sequential
|
||||
* access devices */
|
||||
#endif
|
||||
uint8_t information[4];
|
||||
uint8_t additional_sense_len; /**< Additional sense length (n-7) */
|
||||
uint8_t command_info[4]; /**< Command-specific information */
|
||||
uint8_t asc; /**< Additional sense code */
|
||||
uint8_t ascq; /**< Additional sense code qualifier */
|
||||
uint8_t fruc; /**< Field replaceable unit code */
|
||||
uint8_t sks[3]; /**< Sense-key specific */
|
||||
uint8_t asb[46]; /**< Additional sense bytes */
|
||||
};
|
||||
|
||||
/**
|
||||
Set this to the maximum value in milliseconds that we will
|
||||
wait on an MMC command.
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
/*
|
||||
$Id: types.h,v 1.37 2008/03/25 15:59:09 karl Exp $
|
||||
|
||||
Copyright (C) 2002, 2003, 2004, 2005, 2006, 2008
|
||||
Rocky Bernstein <rocky@gnu.org>
|
||||
Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org>
|
||||
|
||||
@@ -1250,7 +1250,7 @@ run_mmc_cmd_linux(void *p_user_data,
|
||||
{
|
||||
_img_private_t *p_env = p_user_data;
|
||||
struct cdrom_generic_command cgc;
|
||||
struct request_sense sense;
|
||||
struct mmc_request_sense sense;
|
||||
unsigned char *u_sense = (unsigned char *) &sense;
|
||||
|
||||
p_env->gen.scsi_mmc_sense_valid = 0;
|
||||
@@ -1258,7 +1258,7 @@ run_mmc_cmd_linux(void *p_user_data,
|
||||
memcpy(&cgc.cmd, p_cdb, i_cdb);
|
||||
cgc.buflen = i_buf;
|
||||
cgc.buffer = p_buf;
|
||||
cgc.sense = &sense;
|
||||
cgc.sense = (struct request_sense *) &sense;
|
||||
|
||||
cgc.data_direction = (SCSI_MMC_DATA_READ == e_direction) ? CGC_DATA_READ :
|
||||
(SCSI_MMC_DATA_WRITE == e_direction) ? CGC_DATA_WRITE :
|
||||
@@ -1274,14 +1274,15 @@ run_mmc_cmd_linux(void *p_user_data,
|
||||
|
||||
/* Record SCSI sense reply for API call mmc_last_cmd_sense().
|
||||
*/
|
||||
if (u_sense[7]) {
|
||||
int sense_size = u_sense[7] + 8; /* SPC 4.5.3, Table 26:
|
||||
252 bytes legal, 263 bytes
|
||||
possible */
|
||||
if (sense_size > sizeof(sense))
|
||||
sense_size = sizeof(sense);
|
||||
memcpy((void *) p_env->gen.scsi_mmc_sense, &sense, sense_size);
|
||||
p_env->gen.scsi_mmc_sense_valid = sense_size;
|
||||
if (sense.additional_sense_len) {
|
||||
/* SCSI Primary Command standard
|
||||
SPC 4.5.3, Table 26: 252 bytes legal, 263 bytes possible */
|
||||
int sense_size = sense.additional_sense_len + 8;
|
||||
|
||||
if (sense_size > sizeof(sense))
|
||||
sense_size = sizeof(sense);
|
||||
memcpy((void *) p_env->gen.scsi_mmc_sense, &sense, sense_size);
|
||||
p_env->gen.scsi_mmc_sense_valid = sense_size;
|
||||
}
|
||||
|
||||
if (0 == i_rc) return DRIVER_OP_SUCCESS;
|
||||
|
||||
Reference in New Issue
Block a user