1 /* 2 * Copyright (c) 2000 by Matthew Jacob 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions, and the following disclaimer, 10 * without modification, immediately at the beginning of the file. 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 * Alternatively, this software may be distributed under the terms of the 15 * the GNU Public License ("GPL"). 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR 21 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * 29 * Matthew Jacob 30 * Feral Software 31 * mjacob@feral.com 32 */ 33 34 #include <sys/types.h> 35 36 #include <stddef.h> 37 #include <stdlib.h> 38 #include <stdio.h> 39 #include <cam/scsi/scsi_enc.h> 40 #include <libxo/xo.h> 41 42 #include "eltsub.h" 43 44 /* 45 * offset by +20 degrees. 46 * The range of the value expresses a temperature between -19 and +235 degrees 47 * Celsius. A value of 00h is reserved. 48 */ 49 #define TEMPERATURE_OFFSET 20 50 51 const char * 52 geteltnm(int type) 53 { 54 static char rbuf[132]; 55 56 switch (type) { 57 case ELMTYP_UNSPECIFIED: 58 return ("Unspecified"); 59 case ELMTYP_DEVICE: 60 return ("Device Slot"); 61 case ELMTYP_POWER: 62 return ("Power Supply"); 63 case ELMTYP_FAN: 64 return ("Cooling"); 65 case ELMTYP_THERM: 66 return ("Temperature Sensor"); 67 case ELMTYP_DOORLOCK: 68 return ("Door Lock"); 69 case ELMTYP_ALARM: 70 return ("Audible Alarm"); 71 case ELMTYP_ESCC: 72 return ("Enclosure Services Controller Electronics"); 73 case ELMTYP_SCC: 74 return ("SCC Controller Electronics"); 75 case ELMTYP_NVRAM: 76 return ("Nonvolatile Cache"); 77 case ELMTYP_INV_OP_REASON: 78 return ("Invalid Operation Reason"); 79 case ELMTYP_UPS: 80 return ("Uninterruptible Power Supply"); 81 case ELMTYP_DISPLAY: 82 return ("Display"); 83 case ELMTYP_KEYPAD: 84 return ("Key Pad Entry"); 85 case ELMTYP_ENCLOSURE: 86 return ("Enclosure"); 87 case ELMTYP_SCSIXVR: 88 return ("SCSI Port/Transceiver"); 89 case ELMTYP_LANGUAGE: 90 return ("Language"); 91 case ELMTYP_COMPORT: 92 return ("Communication Port"); 93 case ELMTYP_VOM: 94 return ("Voltage Sensor"); 95 case ELMTYP_AMMETER: 96 return ("Current Sensor"); 97 case ELMTYP_SCSI_TGT: 98 return ("SCSI Target Port"); 99 case ELMTYP_SCSI_INI: 100 return ("SCSI Initiator Port"); 101 case ELMTYP_SUBENC: 102 return ("Simple Subenclosure"); 103 case ELMTYP_ARRAY_DEV: 104 return ("Array Device Slot"); 105 case ELMTYP_SAS_EXP: 106 return ("SAS Expander"); 107 case ELMTYP_SAS_CONN: 108 return ("SAS Connector"); 109 default: 110 snprintf(rbuf, sizeof(rbuf), "<Type 0x%x>", type); 111 return (rbuf); 112 } 113 } 114 115 const char * 116 scode2ascii(u_char code) 117 { 118 static char rbuf[32]; 119 switch (code & 0xf) { 120 case SES_OBJSTAT_UNSUPPORTED: 121 return ("Unsupported"); 122 case SES_OBJSTAT_OK: 123 return ("OK"); 124 case SES_OBJSTAT_CRIT: 125 return ("Critical"); 126 case SES_OBJSTAT_NONCRIT: 127 return ("Noncritical"); 128 case SES_OBJSTAT_UNRECOV: 129 return ("Unrecoverable"); 130 case SES_OBJSTAT_NOTINSTALLED: 131 return ("Not Installed"); 132 case SES_OBJSTAT_UNKNOWN: 133 return ("Unknown"); 134 case SES_OBJSTAT_NOTAVAIL: 135 return ("Not Available"); 136 case SES_OBJSTAT_NOACCESS: 137 return ("No Access Allowed"); 138 default: 139 snprintf(rbuf, sizeof(rbuf), "<Status 0x%x>", code & 0xf); 140 return (rbuf); 141 } 142 } 143