1 /* $OpenBSD: scsi_ses.h,v 1.3 2005/04/12 20:44:18 marco Exp $ */
2 /*
3  * Copyright (c) 2005 Marco Peereboom
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  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
16  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR
19  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25  * SUCH DAMAGE.
26  *
27  */
28 
29 #ifndef _SCSI_SES_H_
30 #define _SCSI_SES_H_
31 
32 /* FIXME add all other elements as well currently this only contains "device" */
33 
34 struct ses_config_page {
35 	/* diagnostic page header */
36 	u_int8_t page_code;
37 #define SES_CFG_DIAG_PAGE (0x01)
38 	u_int8_t nr_sub_enc;
39 	u_int8_t length[2]; /* n - 3 */
40 	u_int8_t gencode[4];
41 	/* enclosure descriptor header */
42 	u_int8_t rsvd;
43 	u_int8_t sub_enc_id;
44 	u_int8_t nr_elem_typ; /* = T */
45 	u_int8_t enc_desc_len; /* = m */
46 	/* enclosure descriptor */
47 	u_int8_t enc_logical_id[8];
48 	u_int8_t enc_vendor_id[8];
49 	u_int8_t prod_id[16];
50 	u_int8_t prod_rev[4];
51 	u_int8_t vendor[0]; /* 48 - (11 + m) */
52 	/* type descriptor header list */
53 	/* ses_type_descr_hdr[T] */
54 	/* type descriptor text */
55 	/* variable, length n */
56 };
57 
58 struct ses_type_desc_hdr {
59 	u_int8_t elem_type;
60 #define STDH_UNSPECIFIED	(0x00)
61 #define STDH_DEVICE		(0x01)
62 #define STDH_POWER_SUPPLY	(0x02)
63 #define STDH_COOLING		(0x03)
64 #define STDH_TEMP_SENSOR	(0x04)
65 #define STDH_DOOR_LOCK		(0x05)
66 #define STDH_AUDIBLE_ALARM	(0x06)
67 #define STDH_ENC_SRVC_CTRL	(0x07)
68 #define STDH_SCC_CTRL		(0x08)
69 #define STDH_NONVOL_CACHE	(0x09)
70 #define STDH_INV_OPER_REASON	(0x0a)
71 #define STDH_UNINT_POWER_SUPP	(0x0b)
72 #define STDH_DISPLAY		(0x0c)
73 #define STDH_KEY_PAD		(0x0d)
74 #define STDH_ENCLOSURE		(0x0e)
75 #define STDH_SCSI_PORT_TRANS	(0x0f)
76 #define STDH_LANGUAGE		(0x10)
77 #define STDH_COMM_PORT		(0x11)
78 #define STDH_VOLTAGE_SENSOR	(0x12)
79 #define STDH_CURRENT_SENSOR	(0x13)
80 #define STDH_SCSI_TARGET_PORT	(0x14)
81 #define STDH_SCSI_INIT_PORT	(0x15)
82 #define STDH_SIMP_SUBENC	(0x16)
83 #define STDH_ARRAY_DEVICE	(0x17)
84 	u_int8_t nr_elem;
85 	u_int8_t sub_enc_id;
86 	u_int8_t type_desc_len;
87 };
88 
89 /* control structures, control structs are used when SENDING */
90 struct ses_dev_elmt_ctrl_diag {
91 	u_int8_t common_ctrl;
92 #define SDECD_RST_SWAP	(0x10)
93 #define SDECD_DISABLE	(0x20)
94 #define SDECD_PRDFAIL	(0x40)
95 #define SDECD_SELECT	(0x80)
96 
97 	u_int8_t reserved;
98 	u_int8_t byte3;
99 #define SDECD_RQST_IDENT	(0x02)
100 #define SDECD_RQST_REMOVE	(0x04)
101 #define SDECD_RQST_INSERT	(0x08)
102 #define SDECD_DONT_REMOVE	(0x40)
103 #define SDECD_ACTIVE		(0x80)
104 	u_int8_t byte4;
105 #define SDECD_ENABLE_BYP_B	(0x04)
106 #define SDECD_ENABLE_BYP_A	(0x08)
107 #define SDECD_DEVICE_OFF	(0x10)
108 #define SDECD_RQST_FAULT	(0x20)
109 };
110 
111 struct ses_enc_ctrl_diag_page {
112 	u_int8_t page_code;
113 #define SES_CTRL_DIAG_PAGE (0x02)
114 	u_int8_t byte2;
115 #define SECDP_UNREC	(0x01)
116 #define SECDP_CRIT	(0x02)
117 #define SECDP_NONCRIT	(0x04)
118 #define SECDP_INFO	(0x08)
119 	u_int8_t length[2];
120 	u_int8_t gencode[4];
121 	u_int8_t overallctrl[4];
122 	/* first element starts here */
123 	struct ses_dev_elmt_ctrl_diag elmts[0];
124 };
125 
126 /* status structures, status structs are uses when RECEIVING */
127 /* device type, disk really */
128 struct ses_dev_elmt_status_diag {
129 	u_int8_t common_status;
130 #define SDESD_UNSUPPORTED	(0x00)
131 #define SDESD_OK		(0x01)
132 #define SDESD_CRITICAL		(0x02)
133 #define SDESD_NONCRITICAL	(0x03)
134 #define SDESD_UNRECOVERABLE	(0x04)
135 #define SDESD_NOT_INSTALLED	(0x05)
136 #define SDESD_UNKNOWN		(0x06)
137 #define SDESD_NOT_AVAILABLE	(0x07)
138 	u_int8_t slot_addr;
139 	u_int8_t byte3;
140 #define SDESD_REPORT		(0x01)
141 #define SDESD_IDENT		(0x02)
142 #define SDESD_RMV		(0x04)
143 #define SDESD_RDY_INSRT		(0x08)
144 #define SDESD_ENC_BYP_B		(0x10)
145 #define SDESD_ENC_BYP_A		(0x20)
146 #define SDESD_DONT_REMV		(0x40)
147 #define SDESD_CLNT_BYP_A	(0x80)
148 	u_int8_t byte4;
149 #define SDESD_DEV_BYP_B		(0x01)
150 #define SDESD_DEV_BYP_A		(0x02)
151 #define SDESD_BYP_B		(0x04)
152 #define SDESD_BYP_A		(0x08)
153 #define SDESD_DEV_OFF		(0x10)
154 #define SDESD_FLT_RQSTD		(0x20)
155 #define SDESD_FLT_SENSED	(0x40)
156 #define SDESD_CLNT_BYP_B	(0x80)
157 };
158 
159 struct ses_enc_stat_diag_page {
160 	u_int8_t page_code;
161 	u_int8_t byte2;
162 #define SESDP_UNREC	(0x01)
163 #define SESDP_CRIT	(0x02)
164 #define SESDP_NONCRIT	(0x04)
165 #define SESDP_INFO	(0x08)
166 	u_int8_t length[2];
167 	u_int8_t gencode[4];
168 	u_int8_t overallstat[4];
169 	struct ses_dev_elmt_status_diag elmts[0];
170 };
171 #endif /* _SCSI_SES_H_ */
172