xref: /titanic_44/usr/src/uts/common/sys/pm.h (revision b7f45089ccbe01bab3d7c7377b49d80d2ae18a69)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_SYS_PM_H
28 #define	_SYS_PM_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 #include <sys/types.h>
37 
38 /*
39  *	The following ioctls may not exist or may have a different
40  *	interpretation in a future release.
41  */
42 
43 typedef enum {
44 	PM_SCHEDULE,		/* obsolete, not supported */
45 	PM_GET_IDLE_TIME,	/* obsolete, not supported  */
46 	PM_GET_NUM_CMPTS,	/* obsolete, not supported */
47 	PM_GET_THRESHOLD,	/* obsolete, not supported  */
48 	PM_SET_THRESHOLD,	/* obsolete */
49 	PM_GET_NORM_PWR,	/* obsolete */
50 	PM_SET_CUR_PWR,		/* obsolete */
51 	PM_GET_CUR_PWR,		/* obsolete */
52 	PM_GET_NUM_DEPS,	/* obsolete, not supported */
53 	PM_GET_DEP,		/* obsolete, not supported */
54 	PM_ADD_DEP,		/* obsolete */
55 	PM_REM_DEP,		/* obsolete, not supported */
56 	PM_REM_DEVICE,		/* obsolete, not supported */
57 	PM_REM_DEVICES,		/* obsolete */
58 	PM_REPARSE_PM_PROPS,	/* used only by ddivs pm tests */
59 	PM_DISABLE_AUTOPM,	/* obsolete */
60 	PM_REENABLE_AUTOPM,	/* obsolete */
61 	PM_SET_NORM_PWR,	/* obsolete, not supported */
62 	PM_SET_DEVICE_THRESHOLD,
63 	PM_GET_SYSTEM_THRESHOLD,
64 	PM_SET_SYSTEM_THRESHOLD,
65 	PM_START_PM,
66 	PM_STOP_PM,
67 	PM_RESET_PM,
68 	PM_GET_STATS,
69 	PM_GET_DEVICE_THRESHOLD,
70 	PM_GET_POWER_NAME,
71 	PM_GET_POWER_LEVELS,
72 	PM_GET_NUM_COMPONENTS,
73 	PM_GET_COMPONENT_NAME,
74 	PM_GET_NUM_POWER_LEVELS,
75 	PM_GET_STATE_CHANGE,
76 	PM_GET_STATE_CHANGE_WAIT,
77 	PM_DIRECT_PM,
78 	PM_RELEASE_DIRECT_PM,
79 	PM_DIRECT_NOTIFY,
80 	PM_DIRECT_NOTIFY_WAIT,
81 	PM_RESET_DEVICE_THRESHOLD,
82 	PM_GET_PM_STATE,
83 	PM_GET_DEVICE_TYPE,
84 	PM_SET_COMPONENT_THRESHOLDS,
85 	PM_GET_COMPONENT_THRESHOLDS,
86 	PM_IDLE_DOWN,
87 	PM_GET_DEVICE_THRESHOLD_BASIS,
88 	PM_SET_CURRENT_POWER,	/* replaces PM_SET_CUR_PWR */
89 	PM_GET_CURRENT_POWER,	/* replaces PM_GET_CUR_PWR */
90 	PM_GET_FULL_POWER,	/* replaces PM_GET_NORM_PWR */
91 	PM_ADD_DEPENDENT,	/* replaces PM_ADD_DEP */
92 	PM_GET_TIME_IDLE,	/* replaces PM_IDLE_TIME */
93 	PM_GET_DEFAULT_SYSTEM_THRESHOLD,
94 	PM_ADD_DEPENDENT_PROPERTY
95 } pm_cmds;
96 
97 /*
98  * Old name for these ioctls.
99  */
100 #define	PM_GET_POWER		PM_GET_NORM_PWR
101 #define	PM_SET_POWER		PM_SET_CUR_PWR
102 
103 /*
104  * This structure is obsolete and will be removed in a later release
105  */
106 typedef struct {
107 	caddr_t	who;		/* Device to configure */
108 	int	select;		/* Selects the component or dependent */
109 				/* of the device */
110 	int	level;		/* Power or threshold level */
111 	caddr_t dependent;	/* Buffer to hold name of dependent */
112 	int	size;		/* Size of dependent buffer */
113 } pm_request;
114 
115 /*
116  * This is the new struct that replaces pm_request
117  */
118 typedef struct pm_req {
119 	char	*physpath;	/* physical path of device to configure */
120 				/* see libdevinfo(3) */
121 	int	component;	/* Selects the component of the device */
122 	int	value;		/* power level, threshold value, or count */
123 	void	*data;		/* command-dependent variable sized data */
124 	size_t	datasize;	/* Size of data buffer */
125 } pm_req_t;
126 
127 /*
128  * Use these for PM_ADD_DEPENDENT and PM_ADD_DEPENDENT_PROPERTY
129  */
130 #define	pmreq_keeper	physpath	/* keeper in the physpath field */
131 #define	pmreq_kept	data		/* kept in the data field */
132 
133 /*
134  * Possible values for the event field of pm_state_change below
135  */
136 typedef enum {
137 	PSC_PENDING_CHANGE,	/* device needs to change, is blocked */
138 	PSC_HAS_CHANGED		/* device level has changed */
139 } psc_events;
140 
141 #define	PSC_EVENT_LOST	0x4000	/* buffer overrun */
142 #define	PSC_ALL_LOWEST	0x8000	/* all devices at lowest power */
143 
144 /*
145  * Special value for power level fields in pm_state_change below
146  */
147 #define	PM_LEVEL_UNKNOWN	-1	/* power level is unknown */
148 
149 typedef struct pm_state_change {
150 	caddr_t	physpath;	/* Device which has changed state */
151 	int	component;	/* which component changed state */
152 #if defined(_BIG_ENDIAN)
153 	ushort_t flags;		/* PSC_EVENT_LOST, PSC_ALL_LOWEST */
154 	ushort_t event;		/* type of event */
155 #else
156 	ushort_t event;		/* type of event */
157 	ushort_t flags;		/* PSC_EVENT_LOST, PSC_ALL_LOWEST */
158 #endif
159 	time_t	timestamp;	/* time of state change */
160 	int	old_level;	/* power level changing from */
161 	int	new_level;	/* power level changing to */
162 	size_t	size;		/* size of buffer physpath points to */
163 } pm_state_change_t;
164 
165 #ifdef _SYSCALL32
166 
167 /* Kernel's view of ILP32 structure version. */
168 
169 /*
170  * This struct is obsolete and will be removed in a later release
171  */
172 typedef struct {
173 	caddr32_t	who;	/* Device to configure */
174 	int		select;	/* Selects the component or dependent */
175 				/* of the device */
176 	int		level;	/* Power or threshold level */
177 	caddr32_t	dependent;	/* Buffer to hold name of */
178 					/* dependent */
179 	size32_t	size;	/* Size of dependent buffer */
180 } pm_request32;
181 
182 typedef struct pm_req32 {
183 	caddr32_t physpath;	/* physical path of device to configure */
184 				/* see libdevinfo(3) */
185 	int	component;	/* selects the component of the device */
186 	int	value;		/* power level, threshold value, or count */
187 	caddr32_t data;		/* command-dependent variable sized data */
188 	size32_t datasize;	/* Size of data buffer */
189 } pm_req32_t;
190 
191 typedef struct pm_state_change32 {
192 	caddr32_t	physpath;	/* Device which has changed state */
193 	int		component;	/* which component changed state */
194 #if defined(_BIG_ENDIAN)
195 	ushort_t	flags;		/* PSC_EVENT_LOST, PSC_ALL_LOWEST */
196 	ushort_t	event;		/* type of event */
197 #else
198 	ushort_t	event;		/* type of event */
199 	ushort_t	flags;		/* PSC_EVENT_LOST, PSC_ALL_LOWEST */
200 #endif
201 	time32_t	timestamp;	/* time of state change */
202 	int		old_level;	/* power level changing from */
203 	int		new_level;	/* power level changing to */
204 	size32_t	size;		/* size of buffer physpath points to */
205 } pm_state_change32_t;
206 
207 #endif
208 
209 /*
210  * Return values from ioctl commands that return pm state info.
211  */
212 
213 typedef enum {
214 	PM_SYSTEM_PM_ENABLED,
215 	PM_SYSTEM_PM_DISABLED,
216 	PM_NO_PM_COMPONENTS,
217 	PM_CREATE_COMPONENTS,
218 	PM_AUTOPM,
219 	PM_DEFAULT_THRESHOLD,
220 	PM_DEVICE_THRESHOLD,
221 	PM_COMPONENT_THRESHOLD,
222 	PM_OLD_THRESHOLD,
223 	PM_DIRECTLY_MANAGED
224 } pm_states;
225 
226 
227 #ifdef	__cplusplus
228 }
229 #endif
230 
231 #endif	/* _SYS_PM_H */
232