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