3
#include <linux/../scsi/scsi.h> /* cope with silly includes */
5
/* Feel free to copy and modify this GPL-ed code into your applications. */
7
/* Version 0.61 (990519) */
10
/* Some of the following error/status codes are exchanged between the
11
various layers of the SCSI sub-system in Linux and should never
12
reach the user. They are placed here for completeness. What appears
13
here is copied from drivers/scsi/scsi.h which is not visible in
16
/* The following are 'host_status' codes */
20
#ifndef DID_NO_CONNECT
21
#define DID_NO_CONNECT 0x01 /* Unable to connect before timeout */
22
#define DID_BUS_BUSY 0x02 /* Bus remain busy until timeout */
23
#define DID_TIME_OUT 0x03 /* Timed out for some other reason */
24
#define DID_BAD_TARGET 0x04 /* Bad target (id?) */
25
#define DID_ABORT 0x05 /* Told to abort for some other reason */
26
#define DID_PARITY 0x06 /* Parity error (on SCSI bus) */
27
#define DID_ERROR 0x07 /* Internal error */
28
#define DID_RESET 0x08 /* Reset by somebody */
29
#define DID_BAD_INTR 0x09 /* Received an unexpected interrupt */
30
#define DID_PASSTHROUGH 0x0a /* Force command past mid-level */
31
#define DID_SOFT_ERROR 0x0b /* The low-level driver wants a retry */
34
/* The following are 'driver_status' codes */
36
#define DRIVER_OK 0x00
39
#define DRIVER_BUSY 0x01
40
#define DRIVER_SOFT 0x02
41
#define DRIVER_MEDIA 0x03
42
#define DRIVER_ERROR 0x04
44
#define DRIVER_INVALID 0x05
45
#define DRIVER_TIMEOUT 0x06
46
#define DRIVER_HARD 0x07
47
#define DRIVER_SENSE 0x08 /* Sense_buffer has been set */
49
/* Following "suggests" are "or-ed" with one of previous 8 entries */
50
#define SUGGEST_RETRY 0x10
51
#define SUGGEST_ABORT 0x20
52
#define SUGGEST_REMAP 0x30
53
#define SUGGEST_DIE 0x40
54
#define SUGGEST_SENSE 0x80
55
#define SUGGEST_IS_OK 0xff
58
#define DRIVER_MASK 0x0f
61
#define SUGGEST_MASK 0xf0
64
#define SG_ERR_MAX_SENSE_LEN 16
67
/* The following "print" functions send ACSII to stdout */
68
extern void sg_print_command(const unsigned char * command);
69
extern void sg_print_sense(const char * leadin,
70
const unsigned char * sense_buffer);
71
extern void sg_print_target_status(int target_status);
72
extern void sg_print_host_status(int host_status);
73
extern void sg_print_driver_status(int driver_status);
75
/* sg_chk_n_print() returns 1 quietly if there are no errors/warnings
76
else it prints to standard output and returns 0. */
77
extern int sg_chk_n_print(const char * leadin, int target_status,
78
int host_status, int driver_status,
79
const unsigned char * sense_buffer);
82
/* The following "category" function returns one of the following */
83
#define SG_ERR_CAT_CLEAN 0 /* No errors or other information */
84
#define SG_ERR_CAT_MEDIA_CHANGED 1 /* interpreted from sense buffer */
85
#define SG_ERR_CAT_RESET 2 /* interpreted from sense buffer */
86
#define SG_ERR_CAT_TIMEOUT 3
87
#define SG_ERR_CAT_RECOVERED 4 /* Successful command after recovered err */
88
#define SG_ERR_CAT_SENSE 98 /* Something else is in the sense buffer */
89
#define SG_ERR_CAT_OTHER 99 /* Some other error/warning has occurred */
91
extern int sg_err_category(int target_status, int host_status,
92
int driver_status, const unsigned char * sense_buffer);
95
/* Returns length of SCSI command given the opcode (first byte) */
96
int sg_get_command_size(unsigned char opcode);