PM(4D) | Devices | PM(4D) |
pm - Power Management driver
/dev/pm
The Power Management ( pm) driver provides an interface for applications to configure devices within the system for Power Management. The interface is provided through ioctl(2) commands. The pm driver may be accessed using /dev/pm.
The Power Management framework model allows the system to be viewed as a collection of devices. Each device is a collection of components that comprise the smallest power manageable units. The device driver controls the definition of a device's power manageable components.
A component can either be busy or idle at the current power level. Normally, the Power Management framework takes an idle component to the next lower power level. The Power Management framework uses two factors to determine this transition: the component must have been idle for at least the threshold time, and the device to which the component belongs must satisfy any dependency requirements. A dependency occurs when a device requires another device to be power managed before it can be power managed. Dependencies occur on a per device basis: when a dependency exists, no components of a device may be managed unless all the devices it depends upon are first power managed.
Using the commands below, an application may take control of the Power Management of a device from the Power Management framework driver and manage the transition of device power levels directly.
For this set of ioctl commands, arg (see ioctl(2)) points to a structure of type pm_req defined in <sys/pm.h>:
typedef struct pm_req {
char *physpath; /* physical path of device */
/* to configure. See libdevinfo(3LIB) */
int component; /* device component */
int value; /* power level, threshold value, or count */
void *data; /* command-dependent variable-sized data */
size_t datasize; /* size of data buffer */
} pm_req_t;
The fields should contain the following data:
physpath
component
value
data
size
Not all fields are used in each command.
PM_DIRECT_PM
Error codes:
EBUSY
EPERM
PM_RELEASE_DIRECT_PM
Error codes:
EINVAL
PM_DIRECT_NOTIFY PM_DIRECT_NOTIFY_WAIT
arg (see ioctl(2)) points to a structure of type
pm_state_change defined in <sys/pm.h>:
typedef struct pm_state_change {
char *physpath; /* device which has changed state */
int component; /* which component changed state */ #if defined(_BIG_ENDIAN) ushort_t flags; /* PSC_EVENT_LOST, PSC_ALL_LOWEST */ ushort_t event; /* type of event */ #else ushort_t event; /* type of event * ushort_t flags; /* PSC_EVENT_LOST, PSC_ALL_LOWEST */ #endif time_t timestamp; /* time of state change */+ int old_level; /* power level changing from */ int new_level; /* power level changing to */ size_t size; /* size of buffer physpath points to */ } pm_state_change_t;
When an event occurs, the struct pointed to by arg is filled in. If the event type is PSC_PENDING_CHANGE, then the information in the rest of the struct describes an action that the framework would have taken if the device were not directly power managed by the caller. The caller is responsible for completing the indicated level changes using PM_SET_CURRENT_POWER below.
An event type of PSC_HAS_CHANGED indicates that the driver for the directly power managed device has called pm_power_has_changed(9F) due to the device changing power on its own. It is provided to allow the caller to track the power state of the device.
The system keeps events in a circular buffer. If the buffer overflow, the oldest events are lost and when the event that next follows a lost event is retrieved it will have PSC_EVENT_LOST set in flags.
PM_DIRECT_NOTIFY returns EWOULDBLOCK if no event is pending, and PM_DIRECT_NOTIFY_WAIT blocks until an event is available.
pm also supports the poll(2) interface. When an event is pending a poll(2) call that includes a file descriptor for /dev/pm and that has POLLIN or POLLRDNORM set in its event mask will return.
PM_SET_CURRENT_POWER
Error codes:
EINVAL
EIO
EPERM
PM_GET_FULL_POWER
PM_GET_CURRENT_POWER
Error codes:
EAGAIN
PM_GET_TIME_IDLE
Note that because the state of the device may change between the time the process issues the PM_GET_TIME_IDLE command and the time the process issues a PM_SET_CURRENT_POWER command to reduce the power level of an idle component, the process must be prepared to deal with a PM_SET_CURRENT_POWER command returning failure because the driver has rejected the command as inappropriate because the device component has become busy. This can be differentiated from other types of failures by issuing the PM_GET_TIME_IDLE command again to see if the component has become busy.
Upon error, the commands will return −1, and set errno. In addition to the error codes listed above by command, the following error codes are common to all commands:
EFAULT
ENODEV
ENXIO
See attributes(7) for descriptions of the following attributes:
ATTRIBUTE TYPE | ATTRIBUTE VALUE |
Interface stability | Unstable |
Intro(2), ioctl(2), libdevinfo(3LIB), power.conf(5), attributes(7), pmconfig(8), attach(9E), detach(9E), power(9E), pm_busy_component(9F), pm_idle_component(9F), pm_lower_power(9F), pm_power_has_changed(9F), pm_raise_power(9F)
Writing Device Drivers
September 20, 1999 | OmniOS |