~ubuntu-branches/ubuntu/utopic/cdrdao/utopic

« back to all changes in this revision

Viewing changes to dao/sg_err.h

  • Committer: Bazaar Package Importer
  • Author(s): Andrew Suffield
  • Date: 2004-06-24 22:33:16 UTC
  • Revision ID: james.westby@ubuntu.com-20040624223316-534onzugaeeyq61j
Tags: upstream-1.1.9
ImportĀ upstreamĀ versionĀ 1.1.9

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef SG_ERR_H
 
2
#define SG_ERR_H
 
3
#include <linux/../scsi/scsi.h>  /* cope with silly includes */
 
4
 
 
5
/* Feel free to copy and modify this GPL-ed code into your applications. */
 
6
 
 
7
/* Version 0.61 (990519) */
 
8
 
 
9
 
 
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
 
14
   the user space. */
 
15
 
 
16
/* The following are 'host_status' codes */
 
17
#ifndef DID_OK
 
18
#define DID_OK 0x00
 
19
#endif
 
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 */
 
32
#endif
 
33
 
 
34
/* The following are 'driver_status' codes */
 
35
#ifndef DRIVER_OK
 
36
#define DRIVER_OK 0x00
 
37
#endif
 
38
#ifndef DRIVER_BUSY
 
39
#define DRIVER_BUSY 0x01
 
40
#define DRIVER_SOFT 0x02
 
41
#define DRIVER_MEDIA 0x03
 
42
#define DRIVER_ERROR 0x04
 
43
 
 
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 */
 
48
 
 
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
 
56
#endif
 
57
#ifndef DRIVER_MASK
 
58
#define DRIVER_MASK 0x0f
 
59
#endif
 
60
#ifndef SUGGEST_MASK
 
61
#define SUGGEST_MASK 0xf0
 
62
#endif
 
63
 
 
64
#define SG_ERR_MAX_SENSE_LEN 16
 
65
 
 
66
 
 
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);
 
74
 
 
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);
 
80
 
 
81
 
 
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 */
 
90
 
 
91
extern int sg_err_category(int target_status, int host_status,
 
92
               int driver_status, const unsigned char * sense_buffer);
 
93
 
 
94
 
 
95
/* Returns length of SCSI command given the opcode (first byte) */
 
96
int sg_get_command_size(unsigned char opcode);
 
97
 
 
98
#endif