scsi_ses.h revision 56069
1/* $FreeBSD: head/sys/cam/scsi/scsi_ses.h 56069 2000-01-15 22:40:04Z mjacob $ */
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
32#define	SESIOC			(('s' - 040) << 8)
33#define	SESIOC_GETNOBJ		_IO(SESIOC, 1)
34#define	SESIOC_GETOBJMAP	_IO(SESIOC, 2)
35#define	SESIOC_GETENCSTAT	_IO(SESIOC, 3)
36#define	SESIOC_SETENCSTAT	_IO(SESIOC, 4)
37#define	SESIOC_GETOBJSTAT	_IO(SESIOC, 5)
38#define	SESIOC_SETOBJSTAT	_IO(SESIOC, 6)
39#define	SESIOC_GETTEXT		_IO(SESIOC, 7)
40#define	SESIOC_INIT		_IO(SESIOC, 8)
41
42/*
43 * Platform Independent Definitions for SES devices.
44 */
45/*
46 * SCSI Based Environmental Services Application Defines
47 *
48 * Based almost entirely on SCSI-3 SES Revision 8A specification,
49 * but slightly abstracted as the underlying device may in fact
50 * be a SAF-TE or vendor unique device.
51 */
52/*
53 * SES Driver Operations:
54 * (The defines themselves are platform and access method specific)
55 *
56 * SESIOC_GETNOBJ
57 * SESIOC_GETOBJMAP
58 * SESIOC_GETENCSTAT
59 * SESIOC_SETENCSTAT
60 * SESIOC_GETOBJSTAT
61 * SESIOC_SETOBJSTAT
62 * SESIOC_INIT
63 *
64 *
65 * An application finds out how many objects an SES instance
66 * is managing by performing a SESIOC_GETNOBJ operation. It then
67 * performs a SESIOC_GETOBJMAP to get the map that contains the
68 * object identifiers for all objects (see ses_object below).
69 * This information is static.
70 *
71 * The application may perform SESIOC_GETOBJSTAT operations to retrieve
72 * status on an object (see the ses_objstat structure below), SESIOC_SETOBJSTAT
73 * operations to set status for an object.
74 *
75 * Similarly overall enclosure status me be fetched or set via
76 * SESIOC_GETENCSTAT or  SESIOC_SETENCSTAT operations (see ses_encstat below).
77 *
78 * Readers should note that there is nothing that requires either a set
79 * or a clear operation to actually latch and do anything in the target.
80 *
81 * A SESIOC_INIT operation causes the enclosure to be initialized.
82 */
83
84typedef struct {
85	unsigned int	obj_id;		/* Object Identifier */
86	unsigned char	subencid;	/* SubEnclosure ID */
87	unsigned char	object_type;	/* Object Type */
88} ses_object;
89
90/* Object Types */
91#define	SESTYP_UNSPECIFIED	0x00
92#define	SESTYP_DEVICE		0x01
93#define	SESTYP_POWER		0x02
94#define	SESTYP_FAN		0x03
95#define	SESTYP_THERM		0x04
96#define	SESTYP_DOORLOCK		0x05
97#define	SESTYP_ALARM		0x06
98#define	SESTYP_ESCC		0x07	/* Enclosure SCC */
99#define	SESTYP_SCC		0x08	/* SCC */
100#define	SESTYP_NVRAM		0x09
101#define	SESTYP_UPS		0x0b
102#define	SESTYP_DISPLAY		0x0c
103#define	SESTYP_KEYPAD		0x0d
104#define	SESTYP_SCSIXVR		0x0f
105#define	SESTYP_LANGUAGE		0x10
106#define	SESTYP_COMPORT		0x11
107#define	SESTYP_VOM		0x12
108#define	SESTYP_AMMETER		0x13
109#define	SESTYP_SCSI_TGT		0x14
110#define	SESTYP_SCSI_INI		0x15
111#define	SESTYP_SUBENC		0x16
112
113/*
114 * Overall Enclosure Status
115 */
116typedef unsigned char ses_encstat;
117#define	SES_ENCSTAT_UNRECOV		0x1
118#define	SES_ENCSTAT_CRITICAL		0x2
119#define	SES_ENCSTAT_NONCRITICAL		0x4
120#define	SES_ENCSTAT_INFO		0x8
121
122/*
123 * Object Status
124 */
125typedef struct {
126	unsigned int	obj_id;
127	unsigned char	cstat[4];
128} ses_objstat;
129
130/* Summary SES Status Defines, Common Status Codes */
131#define	SES_OBJSTAT_UNSUPPORTED		0
132#define	SES_OBJSTAT_OK			1
133#define	SES_OBJSTAT_CRIT		2
134#define	SES_OBJSTAT_NONCRIT		3
135#define	SES_OBJSTAT_UNRECOV		4
136#define	SES_OBJSTAT_NOTINSTALLED	5
137#define	SES_OBJSTAT_UNKNOWN		6
138#define	SES_OBJSTAT_NOTAVAIL		7
139
140/*
141 * For control pages, cstat[0] is the same for the
142 * enclosure and is common across all device types.
143 *
144 * If SESCTL_CSEL is set, then PRDFAIL, DISABLE and RSTSWAP
145 * are checked, otherwise bits that are specific to the device
146 * type in the other 3 bytes of cstat or checked.
147 */
148#define	SESCTL_CSEL		0x80
149#define	SESCTL_PRDFAIL		0x40
150#define	SESCTL_DISABLE		0x20
151#define	SESCTL_RSTSWAP		0x10
152
153
154/* Control bits, Device Elements, byte 2 */
155#define	SESCTL_DRVLCK	0x40	/* "DO NOT REMOVE" */
156#define	SESCTL_RQSINS	0x08	/* RQST INSERT */
157#define	SESCTL_RQSRMV	0x04	/* RQST REMOVE */
158#define	SESCTL_RQSID	0x02	/* RQST IDENT */
159/* Control bits, Device Elements, byte 3 */
160#define	SESCTL_RQSFLT	0x20	/* RQST FAULT */
161#define	SESCTL_DEVOFF	0x10	/* DEVICE OFF */
162
163/* Control bits, Generic, byte 3 */
164#define	SESCTL_RQSTFAIL	0x40
165#define	SESCTL_RQSTON	0x20
166
167/*
168 * Getting text for an object type is a little
169 * trickier because it's string data that can
170 * go up to 64 KBytes. Build this union and
171 * fill the obj_id with the id of the object who's
172 * help text you want, and if text is available,
173 * obj_text will be filled in, null terminated.
174 */
175
176typedef union {
177	unsigned int obj_id;
178	char obj_text[1];
179} ses_hlptxt;
180