scsi_ses.h revision 139743
167754Smsmith/* $FreeBSD: head/sys/cam/scsi/scsi_ses.h 139743 2005-01-05 22:34:37Z imp $ */ 267754Smsmith/*- 367754Smsmith * Copyright (c) 2000 by Matthew Jacob 467754Smsmith * All rights reserved. 567754Smsmith * 667754Smsmith * Redistribution and use in source and binary forms, with or without 767754Smsmith * modification, are permitted provided that the following conditions 8217365Sjkim * are met: 9245582Sjkim * 1. Redistributions of source code must retain the above copyright 1070243Smsmith * notice, this list of conditions, and the following disclaimer, 1167754Smsmith * without modification, immediately at the beginning of the file. 12217365Sjkim * 2. The name of the author may not be used to endorse or promote products 13217365Sjkim * derived from this software without specific prior written permission. 14217365Sjkim * 15217365Sjkim * Alternatively, this software may be distributed under the terms of the 16217365Sjkim * the GNU Public License ("GPL"). 17217365Sjkim * 18217365Sjkim * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 19217365Sjkim * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20217365Sjkim * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21217365Sjkim * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR 22217365Sjkim * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23217365Sjkim * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24217365Sjkim * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25217365Sjkim * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2667754Smsmith * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27217365Sjkim * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28217365Sjkim * SUCH DAMAGE. 29217365Sjkim * 3067754Smsmith */ 31217365Sjkim 32217365Sjkim#define SESIOC (('s' - 040) << 8) 33217365Sjkim#define SESIOC_GETNOBJ _IO(SESIOC, 1) 34217365Sjkim#define SESIOC_GETOBJMAP _IO(SESIOC, 2) 35217365Sjkim#define SESIOC_GETENCSTAT _IO(SESIOC, 3) 36217365Sjkim#define SESIOC_SETENCSTAT _IO(SESIOC, 4) 37217365Sjkim#define SESIOC_GETOBJSTAT _IO(SESIOC, 5) 38217365Sjkim#define SESIOC_SETOBJSTAT _IO(SESIOC, 6) 39217365Sjkim#define SESIOC_GETTEXT _IO(SESIOC, 7) 40217365Sjkim#define SESIOC_INIT _IO(SESIOC, 8) 41217365Sjkim 42217365Sjkim/* 43217365Sjkim * Platform Independent Definitions for SES devices. 4467754Smsmith */ 4567754Smsmith/* 4667754Smsmith * SCSI Based Environmental Services Application Defines 4767754Smsmith * 48193341Sjkim * Based almost entirely on SCSI-3 SES Revision 8A specification, 49193341Sjkim * but slightly abstracted as the underlying device may in fact 50193341Sjkim * be a SAF-TE or vendor unique device. 5167754Smsmith */ 5267754Smsmith/* 5377424Smsmith * SES Driver Operations: 5491116Smsmith * (The defines themselves are platform and access method specific) 5567754Smsmith * 5667754Smsmith * SESIOC_GETNOBJ 5767754Smsmith * SESIOC_GETOBJMAP 5867754Smsmith * SESIOC_GETENCSTAT 5967754Smsmith * SESIOC_SETENCSTAT 6067754Smsmith * SESIOC_GETOBJSTAT 61151937Sjkim * SESIOC_SETOBJSTAT 6267754Smsmith * SESIOC_INIT 6367754Smsmith * 6467754Smsmith * 6567754Smsmith * An application finds out how many objects an SES instance 6667754Smsmith * is managing by performing a SESIOC_GETNOBJ operation. It then 6767754Smsmith * performs a SESIOC_GETOBJMAP to get the map that contains the 6867754Smsmith * object identifiers for all objects (see ses_object below). 6967754Smsmith * This information is static. 7067754Smsmith * 7167754Smsmith * The application may perform SESIOC_GETOBJSTAT operations to retrieve 7267754Smsmith * status on an object (see the ses_objstat structure below), SESIOC_SETOBJSTAT 7367754Smsmith * operations to set status for an object. 7467754Smsmith * 7591116Smsmith * Similarly overall enclosure status me be fetched or set via 7667754Smsmith * SESIOC_GETENCSTAT or SESIOC_SETENCSTAT operations (see ses_encstat below). 7767754Smsmith * 7867754Smsmith * Readers should note that there is nothing that requires either a set 7967754Smsmith * or a clear operation to actually latch and do anything in the target. 8067754Smsmith * 8167754Smsmith * A SESIOC_INIT operation causes the enclosure to be initialized. 8267754Smsmith */ 8367754Smsmith 8467754Smsmithtypedef struct { 8567754Smsmith unsigned int obj_id; /* Object Identifier */ 8667754Smsmith unsigned char subencid; /* SubEnclosure ID */ 8767754Smsmith unsigned char object_type; /* Object Type */ 8867754Smsmith} ses_object; 8967754Smsmith 9067754Smsmith/* Object Types */ 9167754Smsmith#define SESTYP_UNSPECIFIED 0x00 9267754Smsmith#define SESTYP_DEVICE 0x01 9367754Smsmith#define SESTYP_POWER 0x02 9467754Smsmith#define SESTYP_FAN 0x03 9591116Smsmith#define SESTYP_THERM 0x04 9691116Smsmith#define SESTYP_DOORLOCK 0x05 9791116Smsmith#define SESTYP_ALARM 0x06 9891116Smsmith#define SESTYP_ESCC 0x07 /* Enclosure SCC */ 9991116Smsmith#define SESTYP_SCC 0x08 /* SCC */ 10067754Smsmith#define SESTYP_NVRAM 0x09 10167754Smsmith#define SESTYP_UPS 0x0b 10267754Smsmith#define SESTYP_DISPLAY 0x0c 103200553Sjkim#define SESTYP_KEYPAD 0x0d 10467754Smsmith#define SESTYP_SCSIXVR 0x0f 10567754Smsmith#define SESTYP_LANGUAGE 0x10 10691116Smsmith#define SESTYP_COMPORT 0x11 10767754Smsmith#define SESTYP_VOM 0x12 10867754Smsmith#define SESTYP_AMMETER 0x13 10967754Smsmith#define SESTYP_SCSI_TGT 0x14 11067754Smsmith#define SESTYP_SCSI_INI 0x15 11167754Smsmith#define SESTYP_SUBENC 0x16 11267754Smsmith 11391116Smsmith/* 11491116Smsmith * Overall Enclosure Status 11567754Smsmith */ 11667754Smsmithtypedef unsigned char ses_encstat; 117167802Sjkim#define SES_ENCSTAT_UNRECOV 0x1 11867754Smsmith#define SES_ENCSTAT_CRITICAL 0x2 119167802Sjkim#define SES_ENCSTAT_NONCRITICAL 0x4 12067754Smsmith#define SES_ENCSTAT_INFO 0x8 12167754Smsmith 12267754Smsmith/* 12367754Smsmith * Object Status 12467754Smsmith */ 12567754Smsmithtypedef struct { 12667754Smsmith unsigned int obj_id; 12767754Smsmith unsigned char cstat[4]; 12867754Smsmith} ses_objstat; 12967754Smsmith 13067754Smsmith/* Summary SES Status Defines, Common Status Codes */ 13167754Smsmith#define SES_OBJSTAT_UNSUPPORTED 0 13267754Smsmith#define SES_OBJSTAT_OK 1 13367754Smsmith#define SES_OBJSTAT_CRIT 2 13467754Smsmith#define SES_OBJSTAT_NONCRIT 3 13567754Smsmith#define SES_OBJSTAT_UNRECOV 4 13667754Smsmith#define SES_OBJSTAT_NOTINSTALLED 5 13767754Smsmith#define SES_OBJSTAT_UNKNOWN 6 13867754Smsmith#define SES_OBJSTAT_NOTAVAIL 7 13967754Smsmith 140193267Sjkim/* 14191116Smsmith * For control pages, cstat[0] is the same for the 14267754Smsmith * enclosure and is common across all device types. 14367754Smsmith * 14467754Smsmith * If SESCTL_CSEL is set, then PRDFAIL, DISABLE and RSTSWAP 14567754Smsmith * are checked, otherwise bits that are specific to the device 14667754Smsmith * type in the other 3 bytes of cstat or checked. 14767754Smsmith */ 14867754Smsmith#define SESCTL_CSEL 0x80 14967754Smsmith#define SESCTL_PRDFAIL 0x40 15067754Smsmith#define SESCTL_DISABLE 0x20 15167754Smsmith#define SESCTL_RSTSWAP 0x10 15267754Smsmith 15367754Smsmith 15467754Smsmith/* Control bits, Device Elements, byte 2 */ 15567754Smsmith#define SESCTL_DRVLCK 0x40 /* "DO NOT REMOVE" */ 15691116Smsmith#define SESCTL_RQSINS 0x08 /* RQST INSERT */ 15791116Smsmith#define SESCTL_RQSRMV 0x04 /* RQST REMOVE */ 15891116Smsmith#define SESCTL_RQSID 0x02 /* RQST IDENT */ 15991116Smsmith/* Control bits, Device Elements, byte 3 */ 16091116Smsmith#define SESCTL_RQSFLT 0x20 /* RQST FAULT */ 16167754Smsmith#define SESCTL_DEVOFF 0x10 /* DEVICE OFF */ 16267754Smsmith 16367754Smsmith/* Control bits, Generic, byte 3 */ 164200553Sjkim#define SESCTL_RQSTFAIL 0x40 16567754Smsmith#define SESCTL_RQSTON 0x20 16667754Smsmith 16767754Smsmith/* 16867754Smsmith * Getting text for an object type is a little 16967754Smsmith * trickier because it's string data that can 17067754Smsmith * go up to 64 KBytes. Build this union and 17167754Smsmith * fill the obj_id with the id of the object who's 17267754Smsmith * help text you want, and if text is available, 173209746Sjkim * obj_text will be filled in, null terminated. 174200553Sjkim */ 17567754Smsmith 176114237Snjltypedef union { 17767754Smsmith unsigned int obj_id; 178193267Sjkim char obj_text[1]; 17967754Smsmith} ses_hlptxt; 18067754Smsmith