Home | History | Annotate | Line # | Download | only in sysmon
sysmon_envsys_tables.c revision 1.1.4.1
      1  1.1.4.1     yamt /* $NetBSD: sysmon_envsys_tables.c,v 1.1.4.1 2007/10/14 11:48:19 yamt Exp $ */
      2      1.1  xtraeme 
      3      1.1  xtraeme /*-
      4  1.1.4.1     yamt  * Copyright (c) 2007 Juan Romero Pardines.
      5      1.1  xtraeme  * All rights reserved.
      6      1.1  xtraeme  *
      7      1.1  xtraeme  * Redistribution and use in source and binary forms, with or without
      8      1.1  xtraeme  * modification, are permitted provided that the following conditions
      9      1.1  xtraeme  * are met:
     10      1.1  xtraeme  * 1. Redistributions of source code must retain the above copyright
     11      1.1  xtraeme  *    notice, this list of conditions and the following disclaimer.
     12      1.1  xtraeme  * 2. Redistributions in binary form must reproduce the above copyright
     13      1.1  xtraeme  *    notice, this list of conditions and the following disclaimer in the
     14      1.1  xtraeme  *    documentation and/or other materials provided with the distribution.
     15      1.1  xtraeme  *
     16  1.1.4.1     yamt  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     17  1.1.4.1     yamt  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     18  1.1.4.1     yamt  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     19  1.1.4.1     yamt  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     20  1.1.4.1     yamt  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     21  1.1.4.1     yamt  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     22  1.1.4.1     yamt  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     23  1.1.4.1     yamt  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     24  1.1.4.1     yamt  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     25  1.1.4.1     yamt  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     26      1.1  xtraeme  */
     27      1.1  xtraeme 
     28      1.1  xtraeme #include <sys/cdefs.h>
     29  1.1.4.1     yamt __KERNEL_RCSID(0, "$NetBSD: sysmon_envsys_tables.c,v 1.1.4.1 2007/10/14 11:48:19 yamt Exp $");
     30      1.1  xtraeme 
     31      1.1  xtraeme #include <sys/types.h>
     32      1.1  xtraeme 
     33      1.1  xtraeme #include <dev/sysmon/sysmonvar.h>
     34      1.1  xtraeme #include <dev/sysmon/sysmon_envsysvar.h>
     35      1.1  xtraeme 
     36      1.1  xtraeme /*
     37      1.1  xtraeme  * Available units type descriptions.
     38      1.1  xtraeme  */
     39      1.1  xtraeme static const struct sme_description_table sme_units_description[] = {
     40      1.1  xtraeme 	{ ENVSYS_STEMP,		PENVSYS_TYPE_TEMP,	"Temperature" },
     41      1.1  xtraeme 	{ ENVSYS_SFANRPM,	PENVSYS_TYPE_FAN,	"Fan" },
     42      1.1  xtraeme 	{ ENVSYS_SVOLTS_AC,	PENVSYS_TYPE_VOLTAGE,	"Voltage AC" },
     43      1.1  xtraeme 	{ ENVSYS_SVOLTS_DC,	PENVSYS_TYPE_VOLTAGE,	"Voltage DC" },
     44      1.1  xtraeme 	{ ENVSYS_SOHMS,		PENVSYS_TYPE_RESISTANCE,"Ohms" },
     45      1.1  xtraeme 	{ ENVSYS_SWATTS,	PENVSYS_TYPE_POWER,	"Watts" },
     46      1.1  xtraeme 	{ ENVSYS_SAMPS,		PENVSYS_TYPE_POWER,	"Ampere" },
     47      1.1  xtraeme 	{ ENVSYS_SWATTHOUR,	PENVSYS_TYPE_BATTERY,	"Watt hour" },
     48      1.1  xtraeme 	{ ENVSYS_SAMPHOUR,	PENVSYS_TYPE_BATTERY,	"Ampere hour" },
     49      1.1  xtraeme 	{ ENVSYS_INDICATOR,	PENVSYS_TYPE_INDICATOR,	"Indicator" },
     50      1.1  xtraeme 	{ ENVSYS_INTEGER,	PENVSYS_TYPE_INDICATOR,	"Integer" },
     51      1.1  xtraeme 	{ ENVSYS_DRIVE,		PENVSYS_TYPE_DRIVE,	"Drive" },
     52      1.1  xtraeme 	{ ENVSYS_BATTERY_STATE,	PENVSYS_TYPE_BATTERY,	"Battery state" },
     53      1.1  xtraeme 	{ -1,			-1,			"unknown" }
     54      1.1  xtraeme };
     55      1.1  xtraeme 
     56      1.1  xtraeme /*
     57      1.1  xtraeme  * Available sensor state descriptions.
     58      1.1  xtraeme  */
     59      1.1  xtraeme static const struct sme_description_table sme_state_description[] = {
     60      1.1  xtraeme 	{ ENVSYS_SVALID,	-1, 	"valid" },
     61      1.1  xtraeme 	{ ENVSYS_SINVALID,	-1, 	"invalid" },
     62      1.1  xtraeme 	{ ENVSYS_SCRITICAL,	-1, 	"critical" },
     63      1.1  xtraeme 	{ ENVSYS_SCRITUNDER,	-1, 	"critical-under" },
     64      1.1  xtraeme 	{ ENVSYS_SCRITOVER,	-1, 	"critical-over" },
     65      1.1  xtraeme 	{ ENVSYS_SWARNUNDER,	-1, 	"warning-under" },
     66      1.1  xtraeme 	{ ENVSYS_SWARNOVER,	-1, 	"warning-over" },
     67      1.1  xtraeme 	{ -1,			-1, 	"unknown" }
     68      1.1  xtraeme };
     69      1.1  xtraeme 
     70      1.1  xtraeme /*
     71      1.1  xtraeme  * Available drive state descriptions.
     72      1.1  xtraeme  */
     73      1.1  xtraeme static const struct sme_description_table sme_drivestate_description[] = {
     74      1.1  xtraeme 	{ ENVSYS_DRIVE_EMPTY,		-1, 	"drive state is unknown" },
     75      1.1  xtraeme 	{ ENVSYS_DRIVE_READY,		-1, 	"drive is ready" },
     76      1.1  xtraeme 	{ ENVSYS_DRIVE_POWERUP,		-1, 	"drive is powering up" },
     77      1.1  xtraeme 	{ ENVSYS_DRIVE_ONLINE,		-1, 	"drive is online" },
     78      1.1  xtraeme 	{ ENVSYS_DRIVE_IDLE,		-1, 	"drive is idle" },
     79      1.1  xtraeme 	{ ENVSYS_DRIVE_ACTIVE,		-1, 	"drive is active" },
     80      1.1  xtraeme 	{ ENVSYS_DRIVE_REBUILD,		-1, 	"drive is rebuilding" },
     81      1.1  xtraeme 	{ ENVSYS_DRIVE_POWERDOWN,	-1, 	"drive is powering down" },
     82      1.1  xtraeme 	{ ENVSYS_DRIVE_FAIL,		-1, 	"drive failed" },
     83      1.1  xtraeme 	{ ENVSYS_DRIVE_PFAIL,		-1, 	"drive degraded" },
     84      1.1  xtraeme 	{ -1,				-1, 	"unknown" }
     85      1.1  xtraeme };
     86      1.1  xtraeme 
     87      1.1  xtraeme /*
     88      1.1  xtraeme  * Available battery state descriptions.
     89      1.1  xtraeme  */
     90      1.1  xtraeme static const struct sme_description_table sme_batterystate_description[] = {
     91      1.1  xtraeme 	{ ENVSYS_BATTERY_STATE_NORMAL,		-1,	"NORMAL" },
     92      1.1  xtraeme 	{ ENVSYS_BATTERY_STATE_WARNING,		-1, 	"WARNING" },
     93      1.1  xtraeme 	{ ENVSYS_BATTERY_STATE_CRITICAL,	-1, 	"CRITICAL" },
     94      1.1  xtraeme 	{ ENVSYS_BATTERY_STATE_LOW,		-1,	"LOW" },
     95      1.1  xtraeme 	{ -1,					-1, 	"UNKNOWN" }
     96      1.1  xtraeme };
     97      1.1  xtraeme 
     98      1.1  xtraeme /*
     99      1.1  xtraeme  * Returns the table associated with type.
    100      1.1  xtraeme  */
    101      1.1  xtraeme const struct sme_description_table *
    102      1.1  xtraeme sme_get_description_table(int type)
    103      1.1  xtraeme {
    104      1.1  xtraeme 	const struct sme_description_table *ud = sme_units_description;
    105      1.1  xtraeme 	const struct sme_description_table *sd = sme_state_description;
    106      1.1  xtraeme 	const struct sme_description_table *dd = sme_drivestate_description;
    107      1.1  xtraeme 	const struct sme_description_table *bd = sme_batterystate_description;
    108      1.1  xtraeme 
    109      1.1  xtraeme 	switch (type) {
    110      1.1  xtraeme 	case SME_DESC_UNITS:
    111      1.1  xtraeme 		return ud;
    112      1.1  xtraeme 	case SME_DESC_STATES:
    113      1.1  xtraeme 		return sd;
    114      1.1  xtraeme 	case SME_DESC_DRIVE_STATES:
    115      1.1  xtraeme 		return dd;
    116      1.1  xtraeme 	case SME_DESC_BATTERY_STATES:
    117      1.1  xtraeme 		return bd;
    118      1.1  xtraeme 	default:
    119      1.1  xtraeme 		return NULL;
    120      1.1  xtraeme 	}
    121      1.1  xtraeme }
    122