xref: /dragonfly/sys/bus/cam/scsi/scsi_ses.h (revision 6491ace53ea01b7a48dd053ea96aaf57c79f311d)
1 /* $FreeBSD: src/sys/cam/scsi/scsi_ses.h,v 1.2 2000/01/15 22:40:04 mjacob Exp $ */
2 /*
3  * Copyright (c) 2000 by Matthew Jacob
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions, and the following disclaimer,
11  *    without modification, immediately at the beginning of the file.
12  * 2. The name of the author may not be used to endorse or promote products
13  *    derived from this software without specific prior written permission.
14  *
15  * Alternatively, this software may be distributed under the terms of the
16  * the GNU Public License ("GPL").
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
22  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28  * SUCH DAMAGE.
29  */
30 
31 #include <sys/ioccom.h>
32 
33 #define   SESIOC                        ('s' - 040)
34 #define   SESIOC_GETNOBJ                _IO(SESIOC, 1)
35 #define   SESIOC_GETOBJMAP    _IO(SESIOC, 2)
36 #define   SESIOC_GETENCSTAT   _IO(SESIOC, 3)
37 #define   SESIOC_SETENCSTAT   _IO(SESIOC, 4)
38 #define   SESIOC_GETOBJSTAT   _IO(SESIOC, 5)
39 #define   SESIOC_SETOBJSTAT   _IO(SESIOC, 6)
40 #if 0 /* unimplemented */
41 #define   SESIOC_GETTEXT                _IO(SESIOC, 7)
42 #endif
43 #define   SESIOC_INIT                   _IO(SESIOC, 8)
44 
45 /*
46  * Platform Independent Definitions for SES devices.
47  */
48 /*
49  * SCSI Based Environmental Services Application Defines
50  *
51  * Based almost entirely on SCSI-3 SES Revision 8A specification,
52  * but slightly abstracted as the underlying device may in fact
53  * be a SAF-TE or vendor unique device.
54  */
55 /*
56  * SES Driver Operations:
57  * (The defines themselves are platform and access method specific)
58  *
59  * SESIOC_GETNOBJ
60  * SESIOC_GETOBJMAP
61  * SESIOC_GETENCSTAT
62  * SESIOC_SETENCSTAT
63  * SESIOC_GETOBJSTAT
64  * SESIOC_SETOBJSTAT
65  * SESIOC_INIT
66  *
67  *
68  * An application finds out how many objects an SES instance
69  * is managing by performing a SESIOC_GETNOBJ operation. It then
70  * performs a SESIOC_GETOBJMAP to get the map that contains the
71  * object identifiers for all objects (see ses_object below).
72  * This information is static.
73  *
74  * The application may perform SESIOC_GETOBJSTAT operations to retrieve
75  * status on an object (see the ses_objstat structure below), SESIOC_SETOBJSTAT
76  * operations to set status for an object.
77  *
78  * Similarly overall enclosure status me be fetched or set via
79  * SESIOC_GETENCSTAT or  SESIOC_SETENCSTAT operations (see ses_encstat below).
80  *
81  * Readers should note that there is nothing that requires either a set
82  * or a clear operation to actually latch and do anything in the target.
83  *
84  * A SESIOC_INIT operation causes the enclosure to be initialized.
85  */
86 
87 typedef struct {
88           unsigned int        obj_id;             /* Object Identifier */
89           unsigned char       subencid; /* SubEnclosure ID */
90           unsigned char       object_type;        /* Object Type */
91 } ses_object;
92 
93 /* Object Types */
94 #define   SESTYP_UNSPECIFIED  0x00
95 #define   SESTYP_DEVICE                 0x01
96 #define   SESTYP_POWER                  0x02
97 #define   SESTYP_FAN                    0x03
98 #define   SESTYP_THERM                  0x04
99 #define   SESTYP_DOORLOCK               0x05
100 #define   SESTYP_ALARM                  0x06
101 #define   SESTYP_ESCC                   0x07      /* Enclosure SCC */
102 #define   SESTYP_SCC                    0x08      /* SCC */
103 #define   SESTYP_NVRAM                  0x09
104 #define   SESTYP_UPS                    0x0b
105 #define   SESTYP_DISPLAY                0x0c
106 #define   SESTYP_KEYPAD                 0x0d
107 #define   SESTYP_SCSIXVR                0x0f
108 #define   SESTYP_LANGUAGE               0x10
109 #define   SESTYP_COMPORT                0x11
110 #define   SESTYP_VOM                    0x12
111 #define   SESTYP_AMMETER                0x13
112 #define   SESTYP_SCSI_TGT               0x14
113 #define   SESTYP_SCSI_INI               0x15
114 #define   SESTYP_SUBENC                 0x16
115 
116 /*
117  * Overall Enclosure Status
118  */
119 typedef unsigned char ses_encstat;
120 #define   SES_ENCSTAT_UNRECOV           0x1
121 #define   SES_ENCSTAT_CRITICAL                    0x2
122 #define   SES_ENCSTAT_NONCRITICAL                 0x4
123 #define   SES_ENCSTAT_INFO              0x8
124 
125 /*
126  * Object Status
127  */
128 typedef struct {
129           unsigned int        obj_id;
130           unsigned char       cstat[4];
131 } ses_objstat;
132 
133 /* Summary SES Status Defines, Common Status Codes */
134 #define   SES_OBJSTAT_UNSUPPORTED                 0
135 #define   SES_OBJSTAT_OK                          1
136 #define   SES_OBJSTAT_CRIT              2
137 #define   SES_OBJSTAT_NONCRIT           3
138 #define   SES_OBJSTAT_UNRECOV           4
139 #define   SES_OBJSTAT_NOTINSTALLED      5
140 #define   SES_OBJSTAT_UNKNOWN           6
141 #define   SES_OBJSTAT_NOTAVAIL                    7
142 
143 /*
144  * For control pages, cstat[0] is the same for the
145  * enclosure and is common across all device types.
146  *
147  * If SESCTL_CSEL is set, then PRDFAIL, DISABLE and RSTSWAP
148  * are checked, otherwise bits that are specific to the device
149  * type in the other 3 bytes of cstat or checked.
150  */
151 #define   SESCTL_CSEL                   0x80
152 #define   SESCTL_PRDFAIL                0x40
153 #define   SESCTL_DISABLE                0x20
154 #define   SESCTL_RSTSWAP                0x10
155 
156 
157 /* Control bits, Device Elements, byte 2 */
158 #define   SESCTL_DRVLCK       0x40      /* "DO NOT REMOVE" */
159 #define   SESCTL_RQSINS       0x08      /* RQST INSERT */
160 #define   SESCTL_RQSRMV       0x04      /* RQST REMOVE */
161 #define   SESCTL_RQSID        0x02      /* RQST IDENT */
162 /* Control bits, Device Elements, byte 3 */
163 #define   SESCTL_RQSFLT       0x20      /* RQST FAULT */
164 #define   SESCTL_DEVOFF       0x10      /* DEVICE OFF */
165 
166 /* Control bits, Generic, byte 3 */
167 #define   SESCTL_RQSTFAIL     0x40
168 #define   SESCTL_RQSTON       0x20
169 
170 /*
171  * Getting text for an object type is a little
172  * trickier because it's string data that can
173  * go up to 64 KBytes. Build this union and
174  * fill the obj_id with the id of the object who's
175  * help text you want, and if text is available,
176  * obj_text will be filled in, null terminated.
177  */
178 
179 typedef union {
180           unsigned int obj_id;
181           char obj_text[1];
182 } ses_hlptxt;
183