1 /* $FreeBSD$ */ 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 * Matthew Jacob 31 * Feral Software 32 * mjacob@feral.com 33 */ 34 35 #include <sys/types.h> 36 37 #include <err.h> 38 #include <stddef.h> 39 #include <stdlib.h> 40 #include <stdio.h> 41 #include <cam/scsi/scsi_enc.h> 42 43 #include "eltsub.h" 44 45 /* 46 * offset by +20 degrees. 47 * The range of the value expresses a temperature between -19 and +235 degrees 48 * Celsius. A value of 00h is reserved. 49 */ 50 #define TEMPERATURE_OFFSET 20 51 52 const char * 53 geteltnm(int type) 54 { 55 static char rbuf[132]; 56 57 switch (type) { 58 case ELMTYP_UNSPECIFIED: 59 return ("Unspecified"); 60 case ELMTYP_DEVICE: 61 return ("Device Slot"); 62 case ELMTYP_POWER: 63 return ("Power Supply"); 64 case ELMTYP_FAN: 65 return ("Cooling"); 66 case ELMTYP_THERM: 67 return ("Temperature Sensors"); 68 case ELMTYP_DOORLOCK: 69 return ("Door Lock"); 70 case ELMTYP_ALARM: 71 return ("Audible alarm"); 72 case ELMTYP_ESCC: 73 return ("Enclosure Services Controller Electronics"); 74 case ELMTYP_SCC: 75 return ("SCC Controller Electronics"); 76 case ELMTYP_NVRAM: 77 return ("Nonvolatile Cache"); 78 case ELMTYP_INV_OP_REASON: 79 return ("Invalid Operation Reason"); 80 case ELMTYP_UPS: 81 return ("Uninterruptible Power Supply"); 82 case ELMTYP_DISPLAY: 83 return ("Display"); 84 case ELMTYP_KEYPAD: 85 return ("Key Pad Entry"); 86 case ELMTYP_ENCLOSURE: 87 return ("Enclosure"); 88 case ELMTYP_SCSIXVR: 89 return ("SCSI Port/Transceiver"); 90 case ELMTYP_LANGUAGE: 91 return ("Language"); 92 case ELMTYP_COMPORT: 93 return ("Communication Port"); 94 case ELMTYP_VOM: 95 return ("Voltage Sensor"); 96 case ELMTYP_AMMETER: 97 return ("Current Sensor"); 98 case ELMTYP_SCSI_TGT: 99 return ("SCSI Target Port"); 100 case ELMTYP_SCSI_INI: 101 return ("SCSI Initiator Port"); 102 case ELMTYP_SUBENC: 103 return ("Simple Subenclosure"); 104 case ELMTYP_ARRAY_DEV: 105 return ("Array Device Slot"); 106 case ELMTYP_SAS_EXP: 107 return ("SAS Expander"); 108 case ELMTYP_SAS_CONN: 109 return ("SAS Connector"); 110 default: 111 snprintf(rbuf, sizeof(rbuf), "<Type 0x%x>", type); 112 return (rbuf); 113 } 114 } 115 116 const char * 117 scode2ascii(u_char code) 118 { 119 static char rbuf[32]; 120 switch (code & 0xf) { 121 case SES_OBJSTAT_UNSUPPORTED: 122 return ("Unsupported"); 123 case SES_OBJSTAT_OK: 124 return ("OK"); 125 case SES_OBJSTAT_CRIT: 126 return ("Critical"); 127 case SES_OBJSTAT_NONCRIT: 128 return ("Noncritical"); 129 case SES_OBJSTAT_UNRECOV: 130 return ("Unrecoverable"); 131 case SES_OBJSTAT_NOTINSTALLED: 132 return ("Not Installed"); 133 case SES_OBJSTAT_UNKNOWN: 134 return ("Unknown"); 135 case SES_OBJSTAT_NOTAVAIL: 136 return ("Not Available"); 137 case SES_OBJSTAT_NOACCESS: 138 return ("No Access Allowed"); 139 default: 140 snprintf(rbuf, sizeof(rbuf), "<Status 0x%x>", code & 0xf); 141 return (rbuf); 142 } 143 } 144