17c478bdstevel@tonic-gate/*
27c478bdstevel@tonic-gate * CDDL HEADER START
37c478bdstevel@tonic-gate *
47c478bdstevel@tonic-gate * The contents of this file are subject to the terms of the
57c478bdstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only
67c478bdstevel@tonic-gate * (the "License").  You may not use this file except in compliance
77c478bdstevel@tonic-gate * with the License.
87c478bdstevel@tonic-gate *
97c478bdstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bdstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
117c478bdstevel@tonic-gate * See the License for the specific language governing permissions
127c478bdstevel@tonic-gate * and limitations under the License.
137c478bdstevel@tonic-gate *
147c478bdstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
157c478bdstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bdstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
177c478bdstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
187c478bdstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bdstevel@tonic-gate *
207c478bdstevel@tonic-gate * CDDL HEADER END
217c478bdstevel@tonic-gate */
227c478bdstevel@tonic-gate/*
237c478bdstevel@tonic-gate * Copyright 1999-2001, 2003 Sun Microsystems, Inc.  All rights reserved.
247c478bdstevel@tonic-gate * Use is subject to license terms.
257c478bdstevel@tonic-gate */
267c478bdstevel@tonic-gate
277c478bdstevel@tonic-gate#ifndef	_PSVC_OBJECTS_CLASS_H
287c478bdstevel@tonic-gate#define	_PSVC_OBJECTS_CLASS_H
297c478bdstevel@tonic-gate
307c478bdstevel@tonic-gate#pragma ident	"%Z%%M%	%I%	%E% SMI"
317c478bdstevel@tonic-gate
327c478bdstevel@tonic-gate#ifdef	__cplusplus
337c478bdstevel@tonic-gateextern "C" {
347c478bdstevel@tonic-gate#endif
357c478bdstevel@tonic-gate
367c478bdstevel@tonic-gate/*
377c478bdstevel@tonic-gate * Platform Services Framework private definitions
387c478bdstevel@tonic-gate */
397c478bdstevel@tonic-gate#include	<pthread.h>
407c478bdstevel@tonic-gate
417c478bdstevel@tonic-gate#define	NAMELEN		32
427c478bdstevel@tonic-gate#define	PATHLEN		256
437c478bdstevel@tonic-gate
447c478bdstevel@tonic-gate/* Logical device class */
457c478bdstevel@tonic-gatetypedef struct {
467c478bdstevel@tonic-gate	int32_t		class;
477c478bdstevel@tonic-gate	int32_t		subclass;
487c478bdstevel@tonic-gate	int32_t		instance;
497c478bdstevel@tonic-gate	uint64_t	features;
507c478bdstevel@tonic-gate	uint64_t	addr_spec;
517c478bdstevel@tonic-gate	char		state[32];
527c478bdstevel@tonic-gate	char		previous_state[32];
537c478bdstevel@tonic-gate	char		fault_id[32];
547c478bdstevel@tonic-gate	boolean_t	present;
557c478bdstevel@tonic-gate	boolean_t	previous_presence;
567c478bdstevel@tonic-gate	boolean_t	enabled;
577c478bdstevel@tonic-gate	char		label[32];
587c478bdstevel@tonic-gate	int32_t 	(*constructor)();
597c478bdstevel@tonic-gate	int32_t		(*destructor)();
607c478bdstevel@tonic-gate	int32_t		(*get_attr)();
617c478bdstevel@tonic-gate	int32_t		(*set_attr)();
627c478bdstevel@tonic-gate} EObj_t;
637c478bdstevel@tonic-gate
647c478bdstevel@tonic-gatetypedef struct {
657c478bdstevel@tonic-gate	EObj_t		ld;		/* logical device */
667c478bdstevel@tonic-gate	int32_t		hw_lo_shut;
677c478bdstevel@tonic-gate	int32_t		lo_warn;	/* low warning threshold */
687c478bdstevel@tonic-gate	int32_t		lo_shut;	/* low shutdown threshold */
697c478bdstevel@tonic-gate	int32_t		opt_temp;
707c478bdstevel@tonic-gate	int32_t		hi_warn;	/* high warning threshold */
717c478bdstevel@tonic-gate	int32_t		hi_shut;	/* high shutdown threshold */
727c478bdstevel@tonic-gate	int32_t		hw_hi_shut;
737c478bdstevel@tonic-gate} ETempSensor_t;
747c478bdstevel@tonic-gate
757c478bdstevel@tonic-gatetypedef struct {
767c478bdstevel@tonic-gate	EObj_t		ld;		/* logical device */
777c478bdstevel@tonic-gate	int16_t		setpoint;
787c478bdstevel@tonic-gate	int16_t		hysteresis;
797c478bdstevel@tonic-gate	int16_t		loopgain;
807c478bdstevel@tonic-gate	int16_t		loopbias;
817c478bdstevel@tonic-gate	float		temp_differential[PSVC_MAXERRORS];
827c478bdstevel@tonic-gate	int16_t		temp_differential_index;
837c478bdstevel@tonic-gate} EFan_t;
847c478bdstevel@tonic-gate
857c478bdstevel@tonic-gatetypedef struct {
867c478bdstevel@tonic-gate	EObj_t		ld;			/* logical device */
877c478bdstevel@tonic-gate} ESystem_t;
887c478bdstevel@tonic-gate
897c478bdstevel@tonic-gatetypedef struct {
907c478bdstevel@tonic-gate	EObj_t		ld;		/* logical device */
917c478bdstevel@tonic-gate	int32_t		lo_warn;	/* low warning threshold */
927c478bdstevel@tonic-gate	int32_t		lo_shut;	/* low shutdown threshold */
937c478bdstevel@tonic-gate	int32_t		hi_warn;	/* high warning threshold */
947c478bdstevel@tonic-gate	int32_t		hi_shut;	/* high shutdown threshold */
957c478bdstevel@tonic-gate} EDigiSensor_t;
967c478bdstevel@tonic-gate
977c478bdstevel@tonic-gatetypedef struct {
987c478bdstevel@tonic-gate	EObj_t		ld;			/* logical device */
997c478bdstevel@tonic-gate} EDigiControl_t;
1007c478bdstevel@tonic-gate
1017c478bdstevel@tonic-gatetypedef struct {
1027c478bdstevel@tonic-gate	EObj_t		ld;			/* logical device */
1037c478bdstevel@tonic-gate} EBoolSensor_t;
1047c478bdstevel@tonic-gate
1057c478bdstevel@tonic-gatetypedef struct {
1067c478bdstevel@tonic-gate	EObj_t		ld;
1077c478bdstevel@tonic-gate} EGPIO8_t;
1087c478bdstevel@tonic-gate
1097c478bdstevel@tonic-gatetypedef struct {
1107c478bdstevel@tonic-gate	EObj_t		ld;			/* logical device */
1117c478bdstevel@tonic-gate	int16_t		lit_count;
1127c478bdstevel@tonic-gate	char		color[32];
1137c478bdstevel@tonic-gate	char		is_locator[8];
1147c478bdstevel@tonic-gate	char		locator_name[32];
1157c478bdstevel@tonic-gate} ELed_t;
1167c478bdstevel@tonic-gate
1177c478bdstevel@tonic-gatetypedef struct {
1187c478bdstevel@tonic-gate	EObj_t		ld;		/* logical device */
1197c478bdstevel@tonic-gate	int32_t		lo_warn;	/* low warning threshold */
1207c478bdstevel@tonic-gate	int32_t		lo_shut;	/* low shutdown threshold */
1217c478bdstevel@tonic-gate	int32_t		hi_warn;	/* high warning threshold */
1227c478bdstevel@tonic-gate	int32_t		hi_shut;	/* high shutdown threshold */
1237c478bdstevel@tonic-gate} EFanTach_t;
1247c478bdstevel@tonic-gate
1257c478bdstevel@tonic-gatetypedef struct {
1267c478bdstevel@tonic-gate	EObj_t		ld;			/* logical device */
1277c478bdstevel@tonic-gate	char		switch_state[32];
1287c478bdstevel@tonic-gate} ESwitch_t;
1297c478bdstevel@tonic-gate
1307c478bdstevel@tonic-gatetypedef struct {
1317c478bdstevel@tonic-gate	EObj_t		ld;			/* logical device */
1327c478bdstevel@tonic-gate} EKeySwitch_t;
1337c478bdstevel@tonic-gate
1347c478bdstevel@tonic-gatetypedef struct {
1357c478bdstevel@tonic-gate	EObj_t		ld;			/* logical device */
1367c478bdstevel@tonic-gate	int32_t		(*get_temperature)();
1377c478bdstevel@tonic-gate	int32_t		(*get_fanspeed)();
1387c478bdstevel@tonic-gate	int32_t		(*get_bit)();
1397c478bdstevel@tonic-gate	int32_t		(*set_bit)();
1407c478bdstevel@tonic-gate	int32_t		(*get_port)();
1417c478bdstevel@tonic-gate	int32_t		(*set_port)();
1427c478bdstevel@tonic-gate	int32_t		(*get_reg)();
1437c478bdstevel@tonic-gate	int32_t		(*set_reg)();
1447c478bdstevel@tonic-gate	int32_t		(*get_output)();
1457c478bdstevel@tonic-gate	int32_t		(*set_output)();
1467c478bdstevel@tonic-gate	int32_t		(*get_input)();
1477c478bdstevel@tonic-gate} EPhysDev_t;
1487c478bdstevel@tonic-gate
1497c478bdstevel@tonic-gatetypedef struct {
1507c478bdstevel@tonic-gate	uint8_t		cell_type;
1517c478bdstevel@tonic-gate	uint32_t	size;
1527c478bdstevel@tonic-gate	int64_t		*table;
1537c478bdstevel@tonic-gate} ETable_t;
1547c478bdstevel@tonic-gate
1557c478bdstevel@tonic-gatetypedef struct {
1567c478bdstevel@tonic-gate	char		antecedent_id[NAMELEN];
1577c478bdstevel@tonic-gate	int32_t		ant_key;
1587c478bdstevel@tonic-gate	char		dependent_id[NAMELEN];
1597c478bdstevel@tonic-gate} EAssoc_t;
1607c478bdstevel@tonic-gate
1617c478bdstevel@tonic-gatetypedef struct {
1627c478bdstevel@tonic-gate	char		name[NAMELEN];
1637c478bdstevel@tonic-gate	uint32_t	count;
1647c478bdstevel@tonic-gate	EAssoc_t	*table;
1657c478bdstevel@tonic-gate} EAssocList_t;
1667c478bdstevel@tonic-gate
1677c478bdstevel@tonic-gate/* structure for translating string to id */
1687c478bdstevel@tonic-gatetypedef struct {
1697c478bdstevel@tonic-gate	int32_t		id;
1707c478bdstevel@tonic-gate	char		name[NAMELEN];
1717c478bdstevel@tonic-gate} EStringId_t;
1727c478bdstevel@tonic-gate
1737c478bdstevel@tonic-gatetypedef struct {
1747c478bdstevel@tonic-gate	uint32_t	controller;
1757c478bdstevel@tonic-gate	uint32_t	bus;
1767c478bdstevel@tonic-gate	uint32_t	addr;
1777c478bdstevel@tonic-gate	uint32_t	port;
1787c478bdstevel@tonic-gate	char		path[PATHLEN];
1797c478bdstevel@tonic-gate} EDevice_t;
1807c478bdstevel@tonic-gate
1817c478bdstevel@tonic-gate/* translate name to object (or table) pointer */
1827c478bdstevel@tonic-gatetypedef struct {
1837c478bdstevel@tonic-gate	char		name[NAMELEN];
1847c478bdstevel@tonic-gate	int32_t		key;
1857c478bdstevel@tonic-gate	EObj_t		*objp;
1867c478bdstevel@tonic-gate	int32_t		type;		/* object or table */
1877c478bdstevel@tonic-gate} ENamePtr_t;
1887c478bdstevel@tonic-gate
1897c478bdstevel@tonic-gatetypedef struct {
1907c478bdstevel@tonic-gate	ENamePtr_t	*obj_tbl;	/* object name to pointer translation */
1917c478bdstevel@tonic-gate	uint32_t	obj_count;	/* number of objects */
1927c478bdstevel@tonic-gate	uint32_t	nextid;		/* next open object slot */
1937c478bdstevel@tonic-gate} ETable_Array;
1947c478bdstevel@tonic-gate
1957c478bdstevel@tonic-gate#define	PSVC_OBJ	0
1967c478bdstevel@tonic-gate#define	PSVC_TBL	1
1977c478bdstevel@tonic-gate#define	PSVC_MAX_TABLE_ARRAYS	10
1987c478bdstevel@tonic-gate
1997c478bdstevel@tonic-gatetypedef struct {
2007c478bdstevel@tonic-gate	ETable_Array	tbl_arry[PSVC_MAX_TABLE_ARRAYS];
2017c478bdstevel@tonic-gate	uint32_t	total_obj_count; /* Total number of objects */
2027c478bdstevel@tonic-gate	EStringId_t	*othr_tbl;	/* assoc string to id translations */
2037c478bdstevel@tonic-gate	uint32_t	othr_count;	/* number of assoc strings */
2047c478bdstevel@tonic-gate	EAssocList_t	*assoc_tbl;	/* associations between objects */
2057c478bdstevel@tonic-gate	uint32_t	assoc_count;	/* number of associations */
2067c478bdstevel@tonic-gate	EDevice_t	*dev_tbl;	/* device paths */
2077c478bdstevel@tonic-gate	uint32_t	dev_count;	/* number of device paths */
2087c478bdstevel@tonic-gate	FILE		*fp;		/* config file */
2097c478bdstevel@tonic-gate	pthread_mutex_t	mutex;		/* multi threaded protection */
2107c478bdstevel@tonic-gate} EHdl_t;
2117c478bdstevel@tonic-gate
2127c478bdstevel@tonic-gate/* String lookup table for attributes */
2137c478bdstevel@tonic-gatestatic char *attr_str_tab[] = {
2147c478bdstevel@tonic-gate	"_class",				/* 0 */
2157c478bdstevel@tonic-gate	"Subclass",				/* 1 */
2167c478bdstevel@tonic-gate	"Presence",				/* 2 */
2177c478bdstevel@tonic-gate	"Previous-presence",			/* 3 */
2187c478bdstevel@tonic-gate	"State",				/* 4 */
2197c478bdstevel@tonic-gate	"Previous-state",			/* 5 */
2207c478bdstevel@tonic-gate	"Enabled",				/* 6 */
2217c478bdstevel@tonic-gate	"FaultInformation",			/* 7 */
2227c478bdstevel@tonic-gate	"Features",				/* 8 */
2237c478bdstevel@tonic-gate	"Label",				/* 9 */
2247c478bdstevel@tonic-gate	"Fruid",				/* 10 */
2257c478bdstevel@tonic-gate	"Instance",				/* 11 */
2267c478bdstevel@tonic-gate	"Led-color",				/* 12 */
2277c478bdstevel@tonic-gate	"Lo-warn",				/* 13 */
2287c478bdstevel@tonic-gate	"Lo-shut",				/* 14 */
2297c478bdstevel@tonic-gate	"Hi-warn",				/* 15 */
2307c478bdstevel@tonic-gate	"Hi-shut",				/* 16 */
2317c478bdstevel@tonic-gate	"Opt-temp",				/* 17 */
2327c478bdstevel@tonic-gate	"Hw-hi-shut",				/* 18 */
2337c478bdstevel@tonic-gate	"Hw-lo-shut",				/* 19 */
2347c478bdstevel@tonic-gate	"Setpoint",				/* 20 */
2357c478bdstevel@tonic-gate	"Hysteresis",				/* 21 */
2367c478bdstevel@tonic-gate	"Loopgain",				/* 22 */
2377c478bdstevel@tonic-gate	"Loopbias",				/* 23 */
2387c478bdstevel@tonic-gate	"Temp_differential",			/* 24 */
2397c478bdstevel@tonic-gate	"Temp_differential_index",		/* 25 */
2407c478bdstevel@tonic-gate	"Sensor-value",				/* 26 */
2417c478bdstevel@tonic-gate	"Gpio-value",				/* 27 */
2427c478bdstevel@tonic-gate	"#Bits",				/* 28 */
2437c478bdstevel@tonic-gate	"Control-value",			/* 29 */
2447c478bdstevel@tonic-gate	"Led-state",				/* 30 */
2457c478bdstevel@tonic-gate	"Switch-state",				/* 31 */
2467c478bdstevel@tonic-gate	"Probe-result",				/* 32 */
2477c478bdstevel@tonic-gate	"Table_value",				/* 33 */
2487c478bdstevel@tonic-gate	"Assoc_id",				/* 34 */
2497c478bdstevel@tonic-gate	"Assoc_matches",			/* 35 */
2507c478bdstevel@tonic-gate	"Addr-spec",				/* 36 */
2517c478bdstevel@tonic-gate	"Object-id",				/* 37 */
2527c478bdstevel@tonic-gate	"Led-lit-count",			/* 38 */
2537c478bdstevel@tonic-gate	"FRU-info",				/* 39 */
2547c478bdstevel@tonic-gate	"IsLocator",				/* 40 */
2557c478bdstevel@tonic-gate	"LocatorName"				/* 41 */
2567c478bdstevel@tonic-gate};
2577c478bdstevel@tonic-gate
2587c478bdstevel@tonic-gateint	ATTR_STR_TAB_SIZE = sizeof (attr_str_tab) / sizeof (char *);
2597c478bdstevel@tonic-gate
2607c478bdstevel@tonic-gate#ifdef	__cplusplus
2617c478bdstevel@tonic-gate}
2627c478bdstevel@tonic-gate#endif
2637c478bdstevel@tonic-gate
2647c478bdstevel@tonic-gate#endif /* _PSVC_OBJECTS_CLASS_H */
265