/*
* 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 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* This file contains code for setting up environmental related nodes
* and properties in the PICL tree.
*
*/
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <syslog.h>
#include <stdlib.h>
#include <limits.h>
#include <errno.h>
#include <ctype.h>
#include <string.h>
#include <alloca.h>
#include <libintl.h>
#include <sys/systeminfo.h>
#include <picl.h>
#include <picltree.h>
#include <picld_pluginutil.h>
#include <pthread.h>
#include <sys/systeminfo.h>
#include "picldefs.h"
#include "envd.h"
/*
*/
extern int monitor_disk_temp;
extern sensor_ctrl_blk_t sensor_ctrl[];
extern fan_ctrl_blk_t fan_ctrl[];
extern env_tuneable_t tuneables[];
extern int errno;
extern int ntuneables;
/*
* Sensor node data structure
*/
typedef struct {
/*
* Sensor nodes array
*/
};
/*
* Fan node data structure
*/
typedef struct {
} fan_node_t;
/*
* Fan node array
*/
};
/*
* Disk node data structure
*/
typedef struct {
} disk_node_t;
/*
* Disk node array
*/
};
/*
* Miscellaneous declarations
*/
static void delete_sensor_nodes_and_props(void);
static void delete_disk_nodes_and_props(void);
static void delete_fan_nodes_and_props(void);
/*
* Read function for volatile "Temperature" property
*/
static int
{
int i;
/*
* Locate the sensor in our sensor_nodes table by matching the
* property handle and get its temperature.
*/
for (i = 0; i < N_SENSOR_NODES; ++i) {
snodep = &sensor_nodes[i];
continue;
break;
return (PICL_SUCCESS);
}
return (PICL_FAILURE);
}
/*
* Read function for volatile "Temperature" property
*/
static int
{
int i;
/*
* Locate the sensor in our sensor_nodes table by matching the
* property handle and get its temperature.
*/
for (i = 0; i < N_DISK_NODES; ++i) {
dnodep = &disk_nodes[i];
continue;
break;
return (PICL_SUCCESS);
}
return (PICL_FAILURE);
}
/*
* Read function for volatile "Speed" property on "fan" class node
*/
static int
{
int i, ret;
/*
* Locate the fan in our fan_nodes table by matching the
* property handle and get fan speed.
*/
for (i = 0; i < N_FAN_NODES; ++i) {
continue;
continue;
if (ret < 0) {
return (PICL_NOTWRITABLE);
if (ret == -2)
return (PICL_INVALIDARG);
break;
}
return (PICL_SUCCESS);
}
return (PICL_FAILURE);
}
/*
* Read function for volatile "Speed" property on "fan" class node
*/
static int
{
int i;
/*
* Locate the fan in our fan_nodes table by matching the
* property handle and get fan speed.
*/
for (i = 0; i < N_FAN_NODES; ++i) {
continue;
continue;
break;
return (PICL_SUCCESS);
}
return (PICL_FAILURE);
}
/*
* Create and add the specified regular property
*/
static int
{
int err;
if (err != PICL_SUCCESS)
return (err);
return (err);
}
/*
* Create and add the specified volatile property
*/
static int
{
int err;
if (err != PICL_SUCCESS)
return (err);
return (err);
}
/*
* Add temperature threshold properties
*/
static void
{
sizeof (threshp->low_power_off),
sizeof (threshp->low_shutdown),
sizeof (threshp->low_warning),
sizeof (threshp->high_warning),
sizeof (threshp->high_shutdown),
sizeof (threshp->high_power_off),
}
/*
* Go through the sensor_nodes array and create those nodes
* and the Temperature property to report the temperature.
*/
static int
{
int err;
int i;
for (i = 0; i < N_SENSOR_NODES; ++i) {
snodep = &sensor_nodes[i];
/*
* Get the parent nodeh
*/
if (err != PICL_SUCCESS)
continue;
continue;
/*
* Create temperature-sensor node
*/
if (env_debug)
"Creating PICL sensor node '%s' err:%d\n",
if (err != PICL_SUCCESS)
break;
/* save node handle */
/*
* Add "devfs_path" property in child node
*/
if (err != PICL_SUCCESS)
break;
/*
* Now add volatile "temperature" volatile property
* in this "temperature-sensor" class node.
*/
if (err != PICL_SUCCESS)
break;
/* Save prop handle */
/*
* Add threshold related properties
*/
}
if (err != PICL_SUCCESS) {
if (env_debug)
nodename);
return (err);
}
return (PICL_SUCCESS);
}
/*
* Delete all sensor nodes and related properties created by the
* add_sensor_prop() for each sensor node in the PICL tree.
*/
static void
{
int i;
/*
* as well as the sensor node and all properties under it.
* Note that deleiing/destroying a node deletes/destroys
* all properties within that node.
*/
for (i = 0; i < N_SENSOR_NODES; ++i) {
snodep = &sensor_nodes[i];
/* delete node and all properties under it */
}
}
}
/*
* Go through the disk_nodes array and create those nodes
* and the Temperature property to report the temperature.
*/
static int
{
int err;
int i;
for (i = 0; i < N_DISK_NODES; ++i) {
dnodep = &disk_nodes[i];
/*
* Get the parent nodeh
*/
if (err != PICL_SUCCESS) {
if (env_debug)
err = PICL_SUCCESS;
continue;
}
continue;
/*
* Create temperature-sensor node
*/
if (env_debug)
"Creating PICL disk node '%s' err:%d\n",
if (err != PICL_SUCCESS)
break;
/* save node handle */
/*
* Add "devfs_path" property in child node
*/
if (err != PICL_SUCCESS)
break;
/*
* Now add volatile "temperature" volatile property
* in this "temperature-sensor" class node.
*/
if (err != PICL_SUCCESS)
break;
/* Save prop handle */
/*
* Add threshold related properties
*/
sizeof (diskp->low_shutdown),
sizeof (diskp->low_warning),
sizeof (diskp->high_warning),
sizeof (diskp->high_shutdown),
}
if (err != PICL_SUCCESS) {
if (env_debug)
nodename);
return (err);
}
return (PICL_SUCCESS);
}
/*
* Delete all disk nodes and related properties created by the
* add_disk_props() for each disk node in the PICL tree.
*/
static void
{
int i;
/*
* Note that deleting/destroying a node deletes/destroys
* all properties within that node.
*/
for (i = 0; i < N_DISK_NODES; ++i) {
dnodep = &disk_nodes[i];
}
}
}
/*
* For each entry in fan_nodes[] array, do the following:
* - Create specified "fan" class node.
* - Create "Speed" volatile propery under "fan" class node.
* - Create "SpeedUnit" property under "fan" class node.
*/
static int
{
int err;
int i;
for (i = 0; i < N_FAN_NODES; ++i) {
/*
* Add various fan nodes and properties
*/
continue;
/*
* get parent nodeh
*/
if (err != PICL_SUCCESS) {
if (env_debug)
err = PICL_SUCCESS;
continue;
}
/*
* Create "fan" class node and save node handle
*/
PICL_CLASS_FAN, &cnodeh);
if (env_debug)
"Creating PICL fan node '%s' err:%d\n",
if (err != PICL_SUCCESS)
break;
/*
* Add "devfs_path" property in child node
*/
if (err != PICL_SUCCESS)
break;
/*
* Add "Speed" volatile property in this "fan"
* class node and save prop handle.
*/
/*
* We do not permit setting of DIMM FAN speeds.
*/
PICL_READ, sizeof (fanspeed_t),
} else {
}
if (err != PICL_SUCCESS)
break;
/*
* Add other "fan" class properties
*/
if (err != PICL_SUCCESS)
break;
}
if (err != PICL_SUCCESS) {
if (env_debug)
nodename);
return (err);
}
return (PICL_SUCCESS);
}
/*
* Delete all fan nodes and related properties created by the
* add_fan_props() for each fan node in the PICL tree.
*/
static void
{
int i;
/*
* Note that deleting/destroying a node deletes/destroys
* all properties within that node.
*/
for (i = 0; i < N_FAN_NODES; ++i) {
}
}
}
/*
* Tuneables publishing functions
*/
static int
{
case PICL_PTYPE_INT : {
break;
}
case PICL_PTYPE_CHARSTRING : {
break;
}
default : {
return (PICL_FAILURE);
}
}
return (PICL_SUCCESS);
}
static void
{
return;
}
}
}
int
env_picl_setup_tuneables(void)
{
int err;
int i;
return (PICL_FAILURE);
}
PICL_CLASS_PICL, &nodeh);
if (err != PICL_SUCCESS)
return (PICL_FAILURE);
PICL_CLASS_PICL, &nodeh);
if (err != PICL_SUCCESS) {
return (PICL_FAILURE);
}
/*
* Parse the conf file
*/
for (i = 0; i < ntuneables; i++) {
if (err != PICL_SUCCESS) {
/*
* Add volitle functions to environmental node
*/
} else {
/*
* property is persistent
*/
(void) copy_persistent_tuneable(tuneablep,
read_buf);
}
}
return (PICL_SUCCESS);
}
/*
* Find the ENVMODEL_CONF_FILE file.
*/
static int
{
return (0);
}
}
return (0);
}
}
return (0);
}
return (-1);
}
void
env_picl_destroy(void)
{
}
void
env_picl_setup(void)
{
int err;
int i;
/*
* Initialize sensorp and other fields in the sensor_nodes[] array
*/
for (i = 0; i < N_SENSOR_NODES; ++i) {
snodep = &sensor_nodes[i];
}
/*
* Initialize fanp and other fields in the fan_nodes[] array
*/
for (i = 0; i < N_FAN_NODES; ++i) {
}
/*
* Initialize diskp and other fields in the disk_nodes[] array
*/
for (i = 0; i < N_DISK_NODES; ++i) {
dnodep = &disk_nodes[i];
}
/*
* Get platform handle and populate PICL tree with environmental
* nodes and properties
*/
if (err == PICL_SUCCESS)
if (err == PICL_SUCCESS)
/*
* We can safely call delete_xxx_nodes_and_props even
* if nodes were not added.
*/
if (err != PICL_SUCCESS) {
return;
}
/*
* Parse the envmodel.conf file and populate the PICL tree
*/
if (get_envmodel_conf_file(fullfilename) < 0)
if (err != PICL_SUCCESS)
}