ppm.c revision 6c9bfa0b39999e3f2c9448ede1e4cbd8bfaca728
/*
* 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 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* common code for ppm drivers
*/
#include <sys/ddi_impldefs.h>
#ifdef DEBUG
#endif
int ppm_inst = -1;
char *ppm_prefix;
void *ppm_statep;
/*
* common module _init
*/
int
{
#ifdef DEBUG
char *str = "ppm_init";
#endif
int error;
ppm_prefix = prefix;
if (error != DDI_SUCCESS)
return (error);
return (error);
}
/* ARGSUSED */
int
{
int rval;
if (ppm_inst == -1)
return (DDI_FAILURE);
switch (cmd) {
case DDI_INFO_DEVT2DEVINFO:
rval = DDI_SUCCESS;
} else
rval = DDI_FAILURE;
return (rval);
case DDI_INFO_DEVT2INSTANCE:
return (DDI_SUCCESS);
default:
return (DDI_FAILURE);
}
}
/* ARGSUSED */
int
{
return (EINVAL);
return (0);
}
/* ARGSUSED */
int
{
return (DDI_SUCCESS);
}
/*
* lookup arrays of strings from configuration data (XXppm.conf)
*/
static int
{
int err;
if (err != DDI_PROP_SUCCESS) {
break;
}
}
return (err);
}
/*
* free allocated ddi prop strings, and free
* ppm_db_t lists where there's an error.
*/
static int
{
if (cdp) {
}
}
}
if (err != DDI_SUCCESS) {
}
}
err = DDI_FAILURE;
}
return (err);
}
ppm_lookup_domain(char *dname)
{
break;
return (*dompp);
}
/*
* create a ppm-private database from parsed .conf data; we start with
* two string arrays (device pathnames and domain names) and treat them
* as matched pairs where device[N] is part of domain[N]
*/
int
{
#ifdef DEBUG
char *str = "ppm_create_db";
#endif
char *wild;
int err;
("%s: %sppm.conf has a mismatched number of %s and %s\n",
}
/*
* a linked list of devices within known domains
*/
}
/*
* allocate a new ppm db entry and link it to
* the front of conflist within this domain
*/
/*
* when the device name contains a wildcard,
* save the length of the preceding string
*/
}
}
/*
* scan conf devices within each domain for a matching device name
*/
{
char path[MAXNAMELEN];
return (*dompp);
return (*dompp);
}
}
return (NULL);
}
/*
* returns 1 (claimed), 0 (not claimed)
*/
int
{
#ifdef DEBUG
if (domp) {
char path[MAXNAMELEN];
("ppm_claim_dev: \"%s\", matched \"%s\"\n",
}
#endif
}
/*
*/
static ppm_dev_t *
{
char path[MAXNAMELEN];
int cmpt;
/*
* For devs which have exported "pm-components" we want to create
* a data structure for each component. When a driver chooses not
* to export the prop we treat its device as having a single
* component and build a structure for it anyway. All other ppm
* logic will act as if this device were always up and can thus
* make correct decisions about it in relation to other devices
* in its domain.
*/
("ppm_add_dev: \"%s\", \"%s\", ppm_dev 0x%p\n",
}
/*
* devi_pm_ppm_private should be set only after all
* ppm_dev s related to all components have been
* initialized and domain's pwr_cnt is incremented
* for each of them.
*/
return (new);
}
/*
* returns an existing or newly created ppm device reference
*/
{
return (pdp);
}
/*
* scan a domain's device list and remove those with .dip
* matching the arg *dip; we need to scan the entire list
* for the case of devices with multiple components
*/
void
{
continue;
}
}
}
/* ARGSUSED */
int
{
#ifdef DEBUG
char *str = "ppm_ioctl";
char *rwfmt = "%s: mode error: 0x%x is missing %s perm, cmd 0x%x\n";
char *iofmt = "%s: copy%s error, arg 0x%p\n";
#endif
return (EFAULT);
}
/*
* Currently, only PPM_INTERNAL_DEVICE_POWER device type is supported
*/
return (EINVAL);
}
switch (cmd) {
case PPMIOCSET:
if (secpolicy_power_mgmt(cred_p) != 0) {
return (EPERM);
return (EPERM);
}
if ((level != PPM_IDEV_POWER_ON) &&
(level != PPM_IDEV_POWER_OFF)) {
("%s: invalid power level %d, cmd 0x%x\n",
return (EINVAL);
}
return (ENOTSUP);
break;
case PPMIOCGET:
return (EPERM);
}
return (ENOTSUP);
return (EFAULT);
}
break;
default:
return (EINVAL);
}
return (0);
}
#ifdef DEBUG
#define PMR_UNKNOWN -1
/*
* convert a ctlop integer to a char string. this helps printing
* meaningful info when cltops are received from the pm framework.
* since some ctlops are so frequent, we use mask to limit output:
* a valid string is returned when ctlop is found and when
* (cmd.flags & mask) is true; otherwise NULL is returned.
*/
char *
{
struct ctlop_cmd {
int ctlop;
char *str;
};
FLINTSTR(0, PMR_PPM_ATTACH),
FLINTSTR(0, PMR_PPM_DETACH),
};
break;
return (NULL);
}
#endif