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