2015-09-19 16:36:45 +00:00
|
|
|
/* $FreeBSD$ */
|
|
|
|
/*
|
|
|
|
* Copyright (c) 2000 by Matthew Jacob
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions, and the following disclaimer,
|
|
|
|
* without modification, immediately at the beginning of the file.
|
|
|
|
* 2. The name of the author may not be used to endorse or promote products
|
|
|
|
* derived from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* Alternatively, this software may be distributed under the terms of the
|
|
|
|
* the GNU Public License ("GPL").
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
|
|
|
|
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
* Matthew Jacob
|
|
|
|
* Feral Software
|
|
|
|
* mjacob@feral.com
|
|
|
|
*/
|
|
|
|
|
2015-12-11 20:45:39 +00:00
|
|
|
#include <sys/types.h>
|
|
|
|
|
|
|
|
#include <err.h>
|
2015-09-19 16:36:45 +00:00
|
|
|
#include <stddef.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <cam/scsi/scsi_enc.h>
|
2017-06-29 18:52:36 +00:00
|
|
|
#include <libxo/xo.h>
|
2015-09-19 16:36:45 +00:00
|
|
|
|
|
|
|
#include "eltsub.h"
|
|
|
|
|
2015-12-11 20:45:39 +00:00
|
|
|
/*
|
|
|
|
* offset by +20 degrees.
|
|
|
|
* The range of the value expresses a temperature between -19 and +235 degrees
|
|
|
|
* Celsius. A value of 00h is reserved.
|
|
|
|
*/
|
|
|
|
#define TEMPERATURE_OFFSET 20
|
|
|
|
|
2017-06-23 13:26:13 +00:00
|
|
|
const char *
|
2015-09-19 16:36:45 +00:00
|
|
|
geteltnm(int type)
|
|
|
|
{
|
|
|
|
static char rbuf[132];
|
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
case ELMTYP_UNSPECIFIED:
|
2017-06-23 13:26:13 +00:00
|
|
|
return ("Unspecified");
|
2015-09-19 16:36:45 +00:00
|
|
|
case ELMTYP_DEVICE:
|
2017-06-23 13:26:13 +00:00
|
|
|
return ("Device Slot");
|
2015-09-19 16:36:45 +00:00
|
|
|
case ELMTYP_POWER:
|
2017-06-23 13:26:13 +00:00
|
|
|
return ("Power Supply");
|
2015-09-19 16:36:45 +00:00
|
|
|
case ELMTYP_FAN:
|
2017-06-23 13:26:13 +00:00
|
|
|
return ("Cooling");
|
2015-09-19 16:36:45 +00:00
|
|
|
case ELMTYP_THERM:
|
2017-06-23 13:26:13 +00:00
|
|
|
return ("Temperature Sensors");
|
2015-09-19 16:36:45 +00:00
|
|
|
case ELMTYP_DOORLOCK:
|
2017-06-23 13:26:13 +00:00
|
|
|
return ("Door Lock");
|
2015-09-19 16:36:45 +00:00
|
|
|
case ELMTYP_ALARM:
|
2017-06-23 13:26:13 +00:00
|
|
|
return ("Audible alarm");
|
2015-09-19 16:36:45 +00:00
|
|
|
case ELMTYP_ESCC:
|
2017-06-23 13:26:13 +00:00
|
|
|
return ("Enclosure Services Controller Electronics");
|
2015-09-19 16:36:45 +00:00
|
|
|
case ELMTYP_SCC:
|
2017-06-23 13:26:13 +00:00
|
|
|
return ("SCC Controller Electronics");
|
2015-09-19 16:36:45 +00:00
|
|
|
case ELMTYP_NVRAM:
|
2017-06-23 13:26:13 +00:00
|
|
|
return ("Nonvolatile Cache");
|
2015-09-19 16:36:45 +00:00
|
|
|
case ELMTYP_INV_OP_REASON:
|
2017-06-23 13:26:13 +00:00
|
|
|
return ("Invalid Operation Reason");
|
2015-09-19 16:36:45 +00:00
|
|
|
case ELMTYP_UPS:
|
2017-06-23 13:26:13 +00:00
|
|
|
return ("Uninterruptible Power Supply");
|
2015-09-19 16:36:45 +00:00
|
|
|
case ELMTYP_DISPLAY:
|
2017-06-23 13:26:13 +00:00
|
|
|
return ("Display");
|
2015-09-19 16:36:45 +00:00
|
|
|
case ELMTYP_KEYPAD:
|
2017-06-23 13:26:13 +00:00
|
|
|
return ("Key Pad Entry");
|
2015-09-19 16:36:45 +00:00
|
|
|
case ELMTYP_ENCLOSURE:
|
2017-06-23 13:26:13 +00:00
|
|
|
return ("Enclosure");
|
2015-09-19 16:36:45 +00:00
|
|
|
case ELMTYP_SCSIXVR:
|
2017-06-23 13:26:13 +00:00
|
|
|
return ("SCSI Port/Transceiver");
|
2015-09-19 16:36:45 +00:00
|
|
|
case ELMTYP_LANGUAGE:
|
2017-06-23 13:26:13 +00:00
|
|
|
return ("Language");
|
2015-09-19 16:36:45 +00:00
|
|
|
case ELMTYP_COMPORT:
|
2017-06-23 13:26:13 +00:00
|
|
|
return ("Communication Port");
|
2015-09-19 16:36:45 +00:00
|
|
|
case ELMTYP_VOM:
|
2017-06-23 13:26:13 +00:00
|
|
|
return ("Voltage Sensor");
|
2015-09-19 16:36:45 +00:00
|
|
|
case ELMTYP_AMMETER:
|
2017-06-23 13:26:13 +00:00
|
|
|
return ("Current Sensor");
|
2015-09-19 16:36:45 +00:00
|
|
|
case ELMTYP_SCSI_TGT:
|
2017-06-23 13:26:13 +00:00
|
|
|
return ("SCSI Target Port");
|
2015-09-19 16:36:45 +00:00
|
|
|
case ELMTYP_SCSI_INI:
|
2017-06-23 13:26:13 +00:00
|
|
|
return ("SCSI Initiator Port");
|
2015-09-19 16:36:45 +00:00
|
|
|
case ELMTYP_SUBENC:
|
2017-06-23 13:26:13 +00:00
|
|
|
return ("Simple Subenclosure");
|
2015-09-19 16:36:45 +00:00
|
|
|
case ELMTYP_ARRAY_DEV:
|
2017-06-23 13:26:13 +00:00
|
|
|
return ("Array Device Slot");
|
2015-09-19 16:36:45 +00:00
|
|
|
case ELMTYP_SAS_EXP:
|
2017-06-23 13:26:13 +00:00
|
|
|
return ("SAS Expander");
|
2015-09-19 16:36:45 +00:00
|
|
|
case ELMTYP_SAS_CONN:
|
2017-06-23 13:26:13 +00:00
|
|
|
return ("SAS Connector");
|
2015-09-19 16:36:45 +00:00
|
|
|
default:
|
2017-06-23 13:26:13 +00:00
|
|
|
snprintf(rbuf, sizeof(rbuf), "<Type 0x%x>", type);
|
|
|
|
return (rbuf);
|
2015-09-19 16:36:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-23 13:26:13 +00:00
|
|
|
const char *
|
2015-09-19 16:36:45 +00:00
|
|
|
scode2ascii(u_char code)
|
|
|
|
{
|
|
|
|
static char rbuf[32];
|
|
|
|
switch (code & 0xf) {
|
|
|
|
case SES_OBJSTAT_UNSUPPORTED:
|
2017-06-23 13:26:13 +00:00
|
|
|
return ("Unsupported");
|
2015-09-19 16:36:45 +00:00
|
|
|
case SES_OBJSTAT_OK:
|
2017-06-23 13:26:13 +00:00
|
|
|
return ("OK");
|
2015-09-19 16:36:45 +00:00
|
|
|
case SES_OBJSTAT_CRIT:
|
2017-06-23 13:26:13 +00:00
|
|
|
return ("Critical");
|
2015-09-19 16:36:45 +00:00
|
|
|
case SES_OBJSTAT_NONCRIT:
|
2017-06-23 13:26:13 +00:00
|
|
|
return ("Noncritical");
|
2015-09-19 16:36:45 +00:00
|
|
|
case SES_OBJSTAT_UNRECOV:
|
2017-06-23 13:26:13 +00:00
|
|
|
return ("Unrecoverable");
|
2015-09-19 16:36:45 +00:00
|
|
|
case SES_OBJSTAT_NOTINSTALLED:
|
2017-06-23 13:26:13 +00:00
|
|
|
return ("Not Installed");
|
2015-09-19 16:36:45 +00:00
|
|
|
case SES_OBJSTAT_UNKNOWN:
|
2017-06-23 13:26:13 +00:00
|
|
|
return ("Unknown");
|
2015-09-19 16:36:45 +00:00
|
|
|
case SES_OBJSTAT_NOTAVAIL:
|
2017-06-23 13:26:13 +00:00
|
|
|
return ("Not Available");
|
2015-09-19 16:36:45 +00:00
|
|
|
case SES_OBJSTAT_NOACCESS:
|
2017-06-23 13:26:13 +00:00
|
|
|
return ("No Access Allowed");
|
2015-09-19 16:36:45 +00:00
|
|
|
default:
|
2017-06-23 13:26:13 +00:00
|
|
|
snprintf(rbuf, sizeof(rbuf), "<Status 0x%x>", code & 0xf);
|
|
|
|
return (rbuf);
|
2015-09-19 16:36:45 +00:00
|
|
|
}
|
|
|
|
}
|