/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (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
*/
/*
*/
/*
* Implement Operations for Active Power Management Properties
*/
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <strings.h>
#include <libnvpair.h>
#include <libscf.h>
#include <libscf_priv.h>
#include <libpower.h>
#include <libpower_impl.h>
void **);
struct pm_smf_validate_s {
const char *v_name;
};
static const char *exclude_props[] = {
};
/* Property value validation routines for use by setprop */
void **);
const char *, void **);
const char *, void **);
const char *, void **);
};
{
const char **pp;
const char *propname;
const char *pgname;
void *propval;
/*
* An error occurred in the SMF layer. Return that information
* to the caller for processing.
*/
return (PM_ERROR_SCF);
}
err = PM_SUCCESS;
/*
* Some properties that are returned by the libscf simple
* interface are actually internal to the SMF implementation.
* To avoid the user changing their values here, where it is
* inappropriate, those properties are specifically excluded
* from the result set.
*/
break;
}
}
/* Add the value, if any, to the result list */
if (err == PM_ERROR_INVALID_ARGUMENT) {
"%s property %s has no value. Skipping\n",
/* Not having a value is OK */
errno = 0;
err = PM_SUCCESS;
}
} else {
"%s property %s is in the exclude list\n",
}
switch (proptype) {
case DATA_TYPE_STRING:
case DATA_TYPE_STRING_ARRAY: {
int i;
for (i = 0; i < propc; i++) {
}
}
}
break;
case DATA_TYPE_BOOLEAN:
case DATA_TYPE_BOOLEAN_ARRAY:
case DATA_TYPE_UINT64:
case DATA_TYPE_UINT64_ARRAY:
default:
break;
}
}
/* Check the next property */
prop);
}
return (err);
}
{
char *val;
char *pgname;
char *propname;
errno = 0;
/* Retrieve all of the SMF properties for property information */
/*
* An error occurred in the SMF layer. Return that information
* to the caller for processing.
*/
return (PM_ERROR_SCF);
}
/* Extract the property name from the incoming nvpair */
/*
* Find the SMF property that matches this property name. Note that
* the power service uses multiple property groups, but the property
* namespace is unique (otherwise this would not be valid)
*/
char *np;
}
/* Check the next property */
}
"%s could not find SMF property %s instance %s\n",
return (PM_ERROR_PROPERTY_NOT_FOUND);
}
/* The new value comes in as a string value */
return (PM_ERROR_MISSING_PROPERTY_VALUE);
}
/*
* We now have the property from SCF, which is authoritative.
* Initialize the property vector using this information
*/
if (err != PM_SUCCESS) {
return (err);
}
/* Write the property vector to SMF */
/* Clean up allocated memory and return to the caller */
/* The value was allocated by the property validator */
}
return (err);
}
static pm_error_t
{
int err;
/* Write the property vector to the SMF database */
if (err != SCF_SUCCESS) {
"%s scf_write_propvec prop %s failed %d (%s)\n",
scf_strerror(scf_error()));
return (PM_ERROR_SCF);
}
return (PM_SUCCESS);
}
static void *
{
int i;
char **sap;
void *result;
char *propname;
if (nval == 0) {
"%s property %s has no values\n", __FUNCTION__,
propname);
return (NULL);
}
"%s property %s type %d number of values %d\n",
switch (proptype) {
case SCF_TYPE_BOOLEAN:
for (i = 0; i < nval; i++) {
uint8_t *b;
}
}
break;
case SCF_TYPE_INTEGER:
for (i = 0; i < nval; i++) {
}
}
break;
case SCF_TYPE_ASTRING:
for (i = 0; i < nval; i++) {
char *s;
sap[i] = s;
}
}
break;
default:
return (NULL);
break;
}
return (result);
}
{
char *propname;
char *pgname;
/* Retrieve all of the properties from SMF */
/*
* An error occurred in the SMF layer. Return that information
* to the caller for processing.
*/
return (PM_ERROR_SCF);
}
err = PM_SUCCESS;
/* Find the property in the result list */
/*
* The property exists in the result list. Check
* for a property group name.
*/
/*
* Could not find the property group name for
* this property. Add it now.
*/
"%s adding property group name for "
pgname);
if (errno != 0) {
}
}
} else {
"%s could not find property %s in result set\n",
}
/* Check the next property */
prop);
}
return (err);
}
{
int err;
char *propname;
break;
}
return (PM_ERROR_INVALID_PROPERTY_VALUE);
}
/* Call the validation routine for this property */
return (err);
}
void **result)
{
/* Validate that this property takes a string */
"%s property %s has unexpected type %d\n", __FUNCTION__,
return (PM_ERROR_INVALID_AUTHORITY);
}
/* Validate that the given string is a valid authority */
if (authority == PM_AUTHORITY_INVALID) {
return (PM_ERROR_INVALID_AUTHORITY);
}
/* The authority is valid. Make a copy and return to the caller */
return (PM_SUCCESS);
}
void **result)
{
boolean_t b;
boolean_t *r;
/* Validate that this property takes a boolean */
"%s property %s has unexpected type %d\n", __FUNCTION__,
return (PM_ERROR_INVALID_BOOLEAN);
}
/* Validate that the given string is a valid boolean */
if (err != PM_SUCCESS) {
"%s invalid boolean \"%s\" for property %s\n",
return (PM_ERROR_INVALID_BOOLEAN);
}
/* The boolean is valid. Make a copy and return to the caller */
if (r == NULL) {
return (PM_ERROR_SYSTEM);
}
*r = b;
*result = r;
return (PM_SUCCESS);
}
void **result)
{
int64_t i;
int64_t *r;
/* Validate that this property takes an integer */
"%s property %s has unexpected type %d\n", __FUNCTION__,
return (PM_ERROR_INVALID_INTEGER);
}
/*
* Validate that the given string is a valid integer for the power
* service (they are all non-negative)
*/
if (err != PM_SUCCESS || i < 0) {
"%s invalid integer \"%s\" for property %s\n",
return (PM_ERROR_INVALID_INTEGER);
}
/* The boolean is valid. Make a copy and return to the caller */
if (r == NULL) {
return (PM_ERROR_SYSTEM);
}
*r = i;
*result = r;
return (PM_SUCCESS);
}