version 1.1.1.1, 2012/02/21 16:32:16
|
version 1.1.1.2, 2013/07/22 01:17:35
|
Line 7
|
Line 7
|
* Copyright (C) 2000 Michael Cornwell <cornwell@acm.org> |
* Copyright (C) 2000 Michael Cornwell <cornwell@acm.org> |
* |
* |
* Additional SCSI work: |
* Additional SCSI work: |
* Copyright (C) 2003-11 Douglas Gilbert <dgilbert@interlog.com> | * Copyright (C) 2003-13 Douglas Gilbert <dgilbert@interlog.com> |
* |
* |
* This program is free software; you can redistribute it and/or modify |
* This program is free software; you can redistribute it and/or modify |
* it under the terms of the GNU General Public License as published by |
* it under the terms of the GNU General Public License as published by |
Line 15
|
Line 15
|
* any later version. |
* any later version. |
* |
* |
* You should have received a copy of the GNU General Public License |
* You should have received a copy of the GNU General Public License |
* (for example COPYING); if not, write to the Free | * (for example COPYING); if not, write to the Free Software Foundation, |
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
* |
* |
* This code was originally developed as a Senior Thesis by Michael Cornwell |
* This code was originally developed as a Senior Thesis by Michael Cornwell |
* at the Concurrent Systems Laboratory (now part of the Storage Systems |
* at the Concurrent Systems Laboratory (now part of the Storage Systems |
Line 78
|
Line 78
|
#ifndef READ_DEFECT_10 |
#ifndef READ_DEFECT_10 |
#define READ_DEFECT_10 0x37 |
#define READ_DEFECT_10 0x37 |
#endif |
#endif |
|
#ifndef READ_DEFECT_12 |
|
#define READ_DEFECT_12 0xb7 |
|
#endif |
#ifndef START_STOP_UNIT |
#ifndef START_STOP_UNIT |
#define START_STOP_UNIT 0x1b |
#define START_STOP_UNIT 0x1b |
#endif |
#endif |
Line 114 struct scsi_cmnd_io
|
Line 117 struct scsi_cmnd_io
|
{ |
{ |
UINT8 * cmnd; /* [in]: ptr to SCSI command block (cdb) */ |
UINT8 * cmnd; /* [in]: ptr to SCSI command block (cdb) */ |
size_t cmnd_len; /* [in]: number of bytes in SCSI command */ |
size_t cmnd_len; /* [in]: number of bytes in SCSI command */ |
int dxfer_dir; /* [in]: DXFER_NONE, DXFER_FROM_DEVICE, or | int dxfer_dir; /* [in]: DXFER_NONE, DXFER_FROM_DEVICE, or |
DXFER_TO_DEVICE */ |
DXFER_TO_DEVICE */ |
UINT8 * dxferp; /* [in]: ptr to outgoing or incoming data buffer */ |
UINT8 * dxferp; /* [in]: ptr to outgoing or incoming data buffer */ |
size_t dxfer_len; /* [in]: bytes to be transferred to/from dxferp */ |
size_t dxfer_len; /* [in]: bytes to be transferred to/from dxferp */ |
UINT8 * sensep; /* [in]: ptr to sense buffer, filled when | UINT8 * sensep; /* [in]: ptr to sense buffer, filled when |
CHECK CONDITION status occurs */ |
CHECK CONDITION status occurs */ |
size_t max_sense_len; /* [in]: max number of bytes to write to sensep */ |
size_t max_sense_len; /* [in]: max number of bytes to write to sensep */ |
unsigned timeout; /* [in]: seconds, 0-> default timeout (60 seconds?) */ |
unsigned timeout; /* [in]: seconds, 0-> default timeout (60 seconds?) */ |
Line 130 struct scsi_cmnd_io
|
Line 133 struct scsi_cmnd_io
|
}; |
}; |
|
|
struct scsi_sense_disect { |
struct scsi_sense_disect { |
UINT8 error_code; | UINT8 resp_code; |
UINT8 sense_key; |
UINT8 sense_key; |
UINT8 asc; | UINT8 asc; |
UINT8 ascq; |
UINT8 ascq; |
|
int progress; /* -1 -> N/A, 0-65535 -> available */ |
}; |
}; |
|
|
/* Useful data from Informational Exception Control mode page (0x1c) */ |
/* Useful data from Informational Exception Control mode page (0x1c) */ |
Line 201 struct scsiNonMediumError {
|
Line 205 struct scsiNonMediumError {
|
/* Log page response lengths */ |
/* Log page response lengths */ |
#define LOG_RESP_SELF_TEST_LEN 0x194 |
#define LOG_RESP_SELF_TEST_LEN 0x194 |
|
|
/* See the SSC-2 document at www.t10.org . Earler note: From IBM | /* See the SSC-2 document at www.t10.org . Earler note: From IBM |
Documentation, see http://www.storage.ibm.com/techsup/hddtech/prodspecs.htm */ |
Documentation, see http://www.storage.ibm.com/techsup/hddtech/prodspecs.htm */ |
#define TAPE_ALERTS_LPAGE 0x2e |
#define TAPE_ALERTS_LPAGE 0x2e |
|
|
Line 240 Documentation, see http://www.storage.ibm.com/techsup/
|
Line 244 Documentation, see http://www.storage.ibm.com/techsup/
|
#define MPAGE_CONTROL_DEFAULT 2 |
#define MPAGE_CONTROL_DEFAULT 2 |
#define MPAGE_CONTROL_SAVED 3 |
#define MPAGE_CONTROL_SAVED 3 |
|
|
|
/* SCSI Vital Product Data (VPD) pages */ |
|
#define SCSI_VPD_SUPPORTED_VPD_PAGES 0x0 |
|
#define SCSI_VPD_UNIT_SERIAL_NUMBER 0x80 |
|
#define SCSI_VPD_DEVICE_IDENTIFICATION 0x83 |
|
#define SCSI_VPD_EXTENDED_INQUIRY_DATA 0x86 |
|
#define SCSI_VPD_ATA_INFORMATION 0x89 |
|
#define SCSI_VPD_POWER_CONDITION 0x8a |
|
#define SCSI_VPD_POWER_CONSUMPTION 0x8d |
|
#define SCSI_VPD_BLOCK_LIMITS 0xb0 |
|
#define SCSI_VPD_BLOCK_DEVICE_CHARACTERISTICS 0xb1 |
|
#define SCSI_VPD_LOGICAL_BLOCK_PROVISIONING 0xb2 |
|
|
/* defines for useful SCSI Status codes */ |
/* defines for useful SCSI Status codes */ |
#define SCSI_STATUS_CHECK_CONDITION 0x2 |
#define SCSI_STATUS_CHECK_CONDITION 0x2 |
|
|
Line 257 Documentation, see http://www.storage.ibm.com/techsup/
|
Line 273 Documentation, see http://www.storage.ibm.com/techsup/
|
#define SCSI_ASC_NOT_READY 0x4 /* more info in ASCQ code */ |
#define SCSI_ASC_NOT_READY 0x4 /* more info in ASCQ code */ |
#define SCSI_ASC_NO_MEDIUM 0x3a /* more info in ASCQ code */ |
#define SCSI_ASC_NO_MEDIUM 0x3a /* more info in ASCQ code */ |
#define SCSI_ASC_UNKNOWN_OPCODE 0x20 |
#define SCSI_ASC_UNKNOWN_OPCODE 0x20 |
#define SCSI_ASC_UNKNOWN_FIELD 0x24 | #define SCSI_ASC_INVALID_FIELD 0x24 |
#define SCSI_ASC_UNKNOWN_PARAM 0x26 |
#define SCSI_ASC_UNKNOWN_PARAM 0x26 |
#define SCSI_ASC_WARNING 0xb |
#define SCSI_ASC_WARNING 0xb |
#define SCSI_ASC_IMPENDING_FAILURE 0x5d |
#define SCSI_ASC_IMPENDING_FAILURE 0x5d |
Line 301 Documentation, see http://www.storage.ibm.com/techsup/
|
Line 317 Documentation, see http://www.storage.ibm.com/techsup/
|
|
|
class scsi_device; |
class scsi_device; |
|
|
|
// Set of supported SCSI VPD pages. Constructor fetches Supported VPD pages |
|
// VPD page and remembers the response for later queries. |
|
class supported_vpd_pages |
|
{ |
|
public: |
|
supported_vpd_pages(scsi_device * device); |
|
~supported_vpd_pages() { num_valid = 0; } |
|
|
|
bool is_supported(int vpd_page_num) const; |
|
|
|
/* Returns 0 or less for VPD pages not supported or error */ |
|
int num_pages() const { return num_valid; } |
|
|
|
private: |
|
int num_valid; /* 0 or less for invalid */ |
|
unsigned char pages[256]; |
|
}; |
|
|
|
extern supported_vpd_pages * supported_vpd_pages_p; |
|
|
|
|
// Print SCSI debug messages? |
// Print SCSI debug messages? |
extern unsigned char scsi_debugmode; |
extern unsigned char scsi_debugmode; |
|
|
Line 354 int scsiReceiveDiagnostic(scsi_device * device, int pc
|
Line 391 int scsiReceiveDiagnostic(scsi_device * device, int pc
|
int scsiReadDefect10(scsi_device * device, int req_plist, int req_glist, int dl_format, |
int scsiReadDefect10(scsi_device * device, int req_plist, int req_glist, int dl_format, |
UINT8 *pBuf, int bufLen); |
UINT8 *pBuf, int bufLen); |
|
|
|
int scsiReadDefect12(scsi_device * device, int req_plist, int req_glist, |
|
int dl_format, int addrDescIndex, UINT8 *pBuf, int bufLen); |
|
|
int scsiReadCapacity10(scsi_device * device, unsigned int * last_lbp, |
int scsiReadCapacity10(scsi_device * device, unsigned int * last_lbp, |
unsigned int * lb_sizep); |
unsigned int * lb_sizep); |
|
|
int scsiReadCapacity16(scsi_device * device, UINT8 *pBuf, int bufLen); |
int scsiReadCapacity16(scsi_device * device, UINT8 *pBuf, int bufLen); |
|
|
uint64_t scsiGetSize(scsi_device * device, unsigned int * lb_sizep); |
|
|
|
|
|
/* SMART specific commands */ |
/* SMART specific commands */ |
int scsiCheckIE(scsi_device * device, int hasIELogPage, int hasTempLogPage, UINT8 *asc, |
int scsiCheckIE(scsi_device * device, int hasIELogPage, int hasTempLogPage, UINT8 *asc, |
UINT8 *ascq, UINT8 *currenttemp, UINT8 *triptemp); |
UINT8 *ascq, UINT8 *currenttemp, UINT8 *triptemp); |
Line 383 int scsiSelfTestInProgress(scsi_device * device, int *
|
Line 420 int scsiSelfTestInProgress(scsi_device * device, int *
|
int scsiFetchControlGLTSD(scsi_device * device, int modese_len, int current); |
int scsiFetchControlGLTSD(scsi_device * device, int modese_len, int current); |
int scsiSetControlGLTSD(scsi_device * device, int enabled, int modese_len); |
int scsiSetControlGLTSD(scsi_device * device, int enabled, int modese_len); |
int scsiFetchTransportProtocol(scsi_device * device, int modese_len); |
int scsiFetchTransportProtocol(scsi_device * device, int modese_len); |
|
int scsiGetRPM(scsi_device * device, int modese_len, int * form_factorp); |
|
int scsiGetSetCache(scsi_device * device, int modese_len, short int * wce, |
|
short int * rcd); |
|
uint64_t scsiGetSize(scsi_device * device, unsigned int * lb_sizep, |
|
int * lb_per_pb_expp); |
|
int scsiGetProtPBInfo(scsi_device * device, unsigned char * rc16_12_31p); |
|
|
|
|
/* T10 Standard IE Additional Sense Code strings taken from t10.org */ |
/* T10 Standard IE Additional Sense Code strings taken from t10.org */ |
const char* scsiGetIEString(UINT8 asc, UINT8 ascq); |
const char* scsiGetIEString(UINT8 asc, UINT8 ascq); |
int scsiGetTemp(scsi_device * device, UINT8 *currenttemp, UINT8 *triptemp); |
int scsiGetTemp(scsi_device * device, UINT8 *currenttemp, UINT8 *triptemp); |
Line 403 const char * scsiTapeAlertsTapeDevice(unsigned short c
|
Line 445 const char * scsiTapeAlertsTapeDevice(unsigned short c
|
const char * scsiTapeAlertsChangerDevice(unsigned short code); |
const char * scsiTapeAlertsChangerDevice(unsigned short code); |
|
|
const char * scsi_get_opcode_name(UINT8 opcode); |
const char * scsi_get_opcode_name(UINT8 opcode); |
|
void scsi_format_id_string(char * out, const unsigned char * in, int n); |
|
|
void dStrHex(const char* str, int len, int no_ascii); |
void dStrHex(const char* str, int len, int no_ascii); |
inline void dStrHex(const unsigned char* str, int len, int no_ascii) |
inline void dStrHex(const unsigned char* str, int len, int no_ascii) |
{ dStrHex((const char *)str, len, no_ascii); } |
{ dStrHex((const char *)str, len, no_ascii); } |
|
|
|
/* Attempt to find the first SCSI sense data descriptor that matches the |
|
given 'desc_type'. If found return pointer to start of sense data |
|
descriptor; otherwise (including fixed format sense data) returns NULL. */ |
|
const unsigned char * sg_scsi_sense_desc_find(const unsigned char * sensep, |
|
int sense_len, int desc_type); |
|
|
|
|
/* SCSI command transmission interface function declaration. Its |
/* SCSI command transmission interface function declaration. Its |
* definition is target OS specific (see os_<OS>.c file). |
* definition is target OS specific (see os_<OS>.c file). |
* Returns 0 if SCSI command successfully launched and response |
* Returns 0 if SCSI command successfully launched and response |
Line 422 inline void dStrHex(const unsigned char* str, int len,
|
Line 472 inline void dStrHex(const unsigned char* str, int len,
|
|
|
|
|
#endif |
#endif |
|
|