psvcplugin.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2000, 2002 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* PICL Daktari platform plug-in to create environment tree nodes.
*/
#include <poll.h>
#include <picl.h>
#include <picltree.h>
#include <stdio.h>
#include <time.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
#include <libintl.h>
#include <limits.h>
#include <ctype.h>
#include <pthread.h>
#include <errno.h>
#include <syslog.h>
#include <sys/systeminfo.h>
#include <psvc_objects.h>
#include <strings.h>
/*LINTLIBRARY*/
#define BUFSZ 512
static psvc_opaque_t hdlp;
struct proj_prop { /* projected property */
char name[32];
};
typedef struct {
char name[32];
} picl_psvc_t;
extern struct handle {
} psvc_hdl;
extern uint32_t proj_prop_count;
void psvc_psr_plugin_init(void);
void psvc_psr_plugin_fini(void);
"PSVC_PSR",
};
#define PTREE_GET_NODE_MSG \
gettext("%s: ptree_get_node_by_path() failed for %s: %s\n")
#define PTREE_CREATE_PROP_FAILED_MSG \
gettext("%s: ptree_create_prop failed, %s\n")
#define FANSPEED_PROP_NOT_FOUND_MSG \
gettext("%s: Can't find property fan-speed\n")
#define FANSPEED_PROP_DELETE_FAILED_MSG \
gettext("%s: Can't delete property fan-speed\n")
{
long first_record;
char *ret;
break;
++count;
}
return (-1);
}
return (0);
}
/*
* Find start of a section within the config file,
* Returns number of records in the section.
* FILE *fd is set to first data record within section.
*/
static int32_t
{
char *ret;
char name[32];
int found;
break;
}
return (-1);
}
if (found != 1) {
return (-1);
} else {
return (0);
}
}
{
}
{
char msg[256];
}
static int
{
int i;
for (i = 0; i < proj_prop_count; ++i) {
return (PICL_SUCCESS);
}
}
return (PICL_INVALIDHANDLE);
}
int
{
int err;
if (err != PSVC_SUCCESS) {
return (PICL_FAILURE);
}
/* see if there's a tach switch */
if (err != PICL_SUCCESS) {
return (err);
} else {
char id[PICL_PROPNAMELEN_MAX];
char name[PICL_PROPNAMELEN_MAX];
if (err != PICL_SUCCESS) {
return (err);
}
sizeof (tach_switch));
if (err != PICL_SUCCESS) {
return (err);
}
if (err != PSVC_SUCCESS) {
return (err);
}
if (features & PSVC_DEV_PRIMARY) {
sizeof (switch_state));
} else {
sizeof (switch_state));
}
&temp_state, sizeof (temp_state));
&switch_state);
if (err != PSVC_SUCCESS) {
return (err);
}
}
if (err != PICL_SUCCESS) {
return (err);
}
if (err != PICL_SUCCESS) {
return (err);
}
return (PICL_SUCCESS);
}
/* Load projected properties */
/*
* This Routine Searches through the projected properties section of the conf
* file and replaces the currently set up values in the CPU and IO Fan Objects
* Fan-Speed property to Daktari specific values
*/
static void
{
int err, i;
char *funcname = "load_projected_properties";
return;
&proj_prop_count) != 0) {
return;
}
for (i = 0; i < proj_prop_count; ++i) {
dst_prop);
if (found != 4) {
return;
}
continue;
continue;
/* find src node */
if (src[0] == '/') {
/* picl node name, outside psvc subtree */
if (err != 0) {
return;
}
} else {
(int (*)(const void *, const void *))
return;
}
}
/*
* Get the property Handle for the property names "Fan-Speed"
* from the source node
*/
&src_prophdl);
if (err != 0) {
return;
}
/*
* Delete the current property Handle as we are going to replace
* it's values
*/
if (err != 0) {
return;
}
/* destroy property created by generic plugin */
/* find dest node */
if (dst[0] == '/') {
/* picl node name, outside psvc subtree */
if (err != 0) {
return;
}
} else {
(int (*)(const void *, const void *))
return;
}
}
/* determine destination property size */
while (err == 0) {
if (err != 0)
break;
break;
}
if (err != 0) {
return;
}
if (err != 0) {
picl_strerror(err));
return;
}
if (err != 0) {
picl_strerror(err));
return;
}
}
}
void
psvc_psr_plugin_init(void)
{
char *funcname = "psvc_psr_plugin_init";
int32_t i;
int err;
/*
* psvc or picl
*/
if (err != 0) {
}
/*
* Remove nodes whose devices aren't present from the picl tree.
*/
&present);
if (err != PSVC_SUCCESS)
continue;
&features);
if (err != PSVC_SUCCESS)
continue;
(present == PSVC_ABSENT)) {
if (err != 0) {
picl_strerror(err));
return;
}
}
}
}
void
psvc_psr_plugin_fini(void)
{
}
void
psvc_psr_plugin_register(void)
{
}