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