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