18729f5ecSAllan Jude /*
28729f5ecSAllan Jude * Copyright (c) 2000 by Matthew Jacob
38729f5ecSAllan Jude * All rights reserved.
48729f5ecSAllan Jude *
58729f5ecSAllan Jude * Redistribution and use in source and binary forms, with or without
68729f5ecSAllan Jude * modification, are permitted provided that the following conditions
78729f5ecSAllan Jude * are met:
88729f5ecSAllan Jude * 1. Redistributions of source code must retain the above copyright
98729f5ecSAllan Jude * notice, this list of conditions, and the following disclaimer,
108729f5ecSAllan Jude * without modification, immediately at the beginning of the file.
118729f5ecSAllan Jude * 2. The name of the author may not be used to endorse or promote products
128729f5ecSAllan Jude * derived from this software without specific prior written permission.
138729f5ecSAllan Jude *
148729f5ecSAllan Jude * Alternatively, this software may be distributed under the terms of the
158729f5ecSAllan Jude * the GNU Public License ("GPL").
168729f5ecSAllan Jude *
178729f5ecSAllan Jude * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
188729f5ecSAllan Jude * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
198729f5ecSAllan Jude * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
208729f5ecSAllan Jude * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
218729f5ecSAllan Jude * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
228729f5ecSAllan Jude * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
238729f5ecSAllan Jude * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
248729f5ecSAllan Jude * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
258729f5ecSAllan Jude * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
268729f5ecSAllan Jude * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
278729f5ecSAllan Jude * SUCH DAMAGE.
288729f5ecSAllan Jude *
298729f5ecSAllan Jude * Matthew Jacob
308729f5ecSAllan Jude * Feral Software
318729f5ecSAllan Jude * mjacob@feral.com
328729f5ecSAllan Jude */
338729f5ecSAllan Jude
34d7654478SBaptiste Daroussin #include <sys/types.h>
35d7654478SBaptiste Daroussin
368729f5ecSAllan Jude #include <stddef.h>
378729f5ecSAllan Jude #include <stdlib.h>
388729f5ecSAllan Jude #include <stdio.h>
398729f5ecSAllan Jude #include <cam/scsi/scsi_enc.h>
40d25c1ff6SBaptiste Daroussin #include <libxo/xo.h>
418729f5ecSAllan Jude
428729f5ecSAllan Jude #include "eltsub.h"
438729f5ecSAllan Jude
44d7654478SBaptiste Daroussin /*
45d7654478SBaptiste Daroussin * offset by +20 degrees.
46d7654478SBaptiste Daroussin * The range of the value expresses a temperature between -19 and +235 degrees
47d7654478SBaptiste Daroussin * Celsius. A value of 00h is reserved.
48d7654478SBaptiste Daroussin */
49d7654478SBaptiste Daroussin #define TEMPERATURE_OFFSET 20
50d7654478SBaptiste Daroussin
51b5566692SBaptiste Daroussin const char *
geteltnm(int type)528729f5ecSAllan Jude geteltnm(int type)
538729f5ecSAllan Jude {
548729f5ecSAllan Jude static char rbuf[132];
558729f5ecSAllan Jude
568729f5ecSAllan Jude switch (type) {
578729f5ecSAllan Jude case ELMTYP_UNSPECIFIED:
58b5566692SBaptiste Daroussin return ("Unspecified");
598729f5ecSAllan Jude case ELMTYP_DEVICE:
60b5566692SBaptiste Daroussin return ("Device Slot");
618729f5ecSAllan Jude case ELMTYP_POWER:
62b5566692SBaptiste Daroussin return ("Power Supply");
638729f5ecSAllan Jude case ELMTYP_FAN:
64b5566692SBaptiste Daroussin return ("Cooling");
658729f5ecSAllan Jude case ELMTYP_THERM:
66*2b2710a7SEdward Tomasz Napierala return ("Temperature Sensor");
678729f5ecSAllan Jude case ELMTYP_DOORLOCK:
68b5566692SBaptiste Daroussin return ("Door Lock");
698729f5ecSAllan Jude case ELMTYP_ALARM:
70*2b2710a7SEdward Tomasz Napierala return ("Audible Alarm");
718729f5ecSAllan Jude case ELMTYP_ESCC:
72b5566692SBaptiste Daroussin return ("Enclosure Services Controller Electronics");
738729f5ecSAllan Jude case ELMTYP_SCC:
74b5566692SBaptiste Daroussin return ("SCC Controller Electronics");
758729f5ecSAllan Jude case ELMTYP_NVRAM:
76b5566692SBaptiste Daroussin return ("Nonvolatile Cache");
778729f5ecSAllan Jude case ELMTYP_INV_OP_REASON:
78b5566692SBaptiste Daroussin return ("Invalid Operation Reason");
798729f5ecSAllan Jude case ELMTYP_UPS:
80b5566692SBaptiste Daroussin return ("Uninterruptible Power Supply");
818729f5ecSAllan Jude case ELMTYP_DISPLAY:
82b5566692SBaptiste Daroussin return ("Display");
838729f5ecSAllan Jude case ELMTYP_KEYPAD:
84b5566692SBaptiste Daroussin return ("Key Pad Entry");
858729f5ecSAllan Jude case ELMTYP_ENCLOSURE:
86b5566692SBaptiste Daroussin return ("Enclosure");
878729f5ecSAllan Jude case ELMTYP_SCSIXVR:
88b5566692SBaptiste Daroussin return ("SCSI Port/Transceiver");
898729f5ecSAllan Jude case ELMTYP_LANGUAGE:
90b5566692SBaptiste Daroussin return ("Language");
918729f5ecSAllan Jude case ELMTYP_COMPORT:
92b5566692SBaptiste Daroussin return ("Communication Port");
938729f5ecSAllan Jude case ELMTYP_VOM:
94b5566692SBaptiste Daroussin return ("Voltage Sensor");
958729f5ecSAllan Jude case ELMTYP_AMMETER:
96b5566692SBaptiste Daroussin return ("Current Sensor");
978729f5ecSAllan Jude case ELMTYP_SCSI_TGT:
98b5566692SBaptiste Daroussin return ("SCSI Target Port");
998729f5ecSAllan Jude case ELMTYP_SCSI_INI:
100b5566692SBaptiste Daroussin return ("SCSI Initiator Port");
1018729f5ecSAllan Jude case ELMTYP_SUBENC:
102b5566692SBaptiste Daroussin return ("Simple Subenclosure");
1038729f5ecSAllan Jude case ELMTYP_ARRAY_DEV:
104b5566692SBaptiste Daroussin return ("Array Device Slot");
1058729f5ecSAllan Jude case ELMTYP_SAS_EXP:
106b5566692SBaptiste Daroussin return ("SAS Expander");
1078729f5ecSAllan Jude case ELMTYP_SAS_CONN:
108b5566692SBaptiste Daroussin return ("SAS Connector");
1098729f5ecSAllan Jude default:
110b5566692SBaptiste Daroussin snprintf(rbuf, sizeof(rbuf), "<Type 0x%x>", type);
1118729f5ecSAllan Jude return (rbuf);
1128729f5ecSAllan Jude }
113b5566692SBaptiste Daroussin }
1148729f5ecSAllan Jude
115b5566692SBaptiste Daroussin const char *
scode2ascii(u_char code)1168729f5ecSAllan Jude scode2ascii(u_char code)
1178729f5ecSAllan Jude {
1188729f5ecSAllan Jude static char rbuf[32];
1198729f5ecSAllan Jude switch (code & 0xf) {
1208729f5ecSAllan Jude case SES_OBJSTAT_UNSUPPORTED:
121b5566692SBaptiste Daroussin return ("Unsupported");
1228729f5ecSAllan Jude case SES_OBJSTAT_OK:
123b5566692SBaptiste Daroussin return ("OK");
1248729f5ecSAllan Jude case SES_OBJSTAT_CRIT:
125b5566692SBaptiste Daroussin return ("Critical");
1268729f5ecSAllan Jude case SES_OBJSTAT_NONCRIT:
127b5566692SBaptiste Daroussin return ("Noncritical");
1288729f5ecSAllan Jude case SES_OBJSTAT_UNRECOV:
129b5566692SBaptiste Daroussin return ("Unrecoverable");
1308729f5ecSAllan Jude case SES_OBJSTAT_NOTINSTALLED:
131b5566692SBaptiste Daroussin return ("Not Installed");
1328729f5ecSAllan Jude case SES_OBJSTAT_UNKNOWN:
133b5566692SBaptiste Daroussin return ("Unknown");
1348729f5ecSAllan Jude case SES_OBJSTAT_NOTAVAIL:
135b5566692SBaptiste Daroussin return ("Not Available");
1368729f5ecSAllan Jude case SES_OBJSTAT_NOACCESS:
137b5566692SBaptiste Daroussin return ("No Access Allowed");
1388729f5ecSAllan Jude default:
139b5566692SBaptiste Daroussin snprintf(rbuf, sizeof(rbuf), "<Status 0x%x>", code & 0xf);
1408729f5ecSAllan Jude return (rbuf);
1418729f5ecSAllan Jude }
142b5566692SBaptiste Daroussin }
143