xref: /illumos-gate/usr/src/cmd/power/pmconfig.h (revision 46b592853d0f4f11781b6b0a7533f267c6aee132)
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 2009 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef _PMCONFIG_H
27 #define	_PMCONFIG_H
28 
29 #ifdef	__cplusplus
30 extern "C" {
31 #endif
32 
33 #include <sys/types.h>
34 #include <sys/stat.h>
35 #include <sys/cpr.h>
36 #include <sys/pm.h>
37 #include <strings.h>
38 #include <limits.h>
39 #include <libintl.h>
40 #include <stdlib.h>
41 #include <unistd.h>
42 #include <stdio.h>
43 #include <fcntl.h>
44 #include <errno.h>
45 
46 
47 #define	LINEARG(an)		*(line_args + an)
48 #define	LINELEN			80
49 #define	MOREARGS		4
50 
51 #define	ESTAR_VNONE		0
52 #define	ESTAR_V2		'2'
53 #define	ESTAR_V3		'3'
54 
55 #define	LPAREN			'('
56 #define	RPAREN			')'
57 
58 #define	MDEBUG			0
59 #define	MEXIT			1
60 #define	MERR			-1
61 
62 /*
63  * return values from handler routines;
64  * chosen to match syscall return values
65  */
66 #define	NOUP			-1
67 #define	OKUP			0
68 
69 #define	DFLT_THOLD		0.04
70 
71 
72 struct perm_update {
73 	int	perm;			/* cpr or pm permission */
74 	int	update;			/* flag updates from cpr/pm data */
75 	char	*set;			/* "cpr" or "pm" */
76 };
77 typedef struct perm_update prmup_t;
78 
79 
80 struct cinfo {
81 	char	*keyword;		/* keyword string */
82 	int	(*handler)(void);	/* keyword handler routine */
83 	prmup_t	*status;		/* permission and update status */
84 	char	*cmt;			/* config file comment */
85 	short	argc;			/* config line arg count */
86 	uint8_t	any;			/* 0: match argc, 1: at least argc */
87 	uint8_t	alt;			/* conf line OK from an alt source */
88 };
89 typedef struct cinfo cinfo_t;
90 
91 typedef void (*vact_t)(char *, size_t, cinfo_t *);
92 
93 /* Suspend/Resume flags */
94 extern int whitelist_only;
95 extern int verify;
96 
97 /*
98  * "conf.c"
99  */
100 extern prmup_t cpr_status, pm_status;
101 extern struct cprconfig new_cc;
102 extern struct stat def_info;
103 extern char estar_vers;
104 extern int pm_fd, ua_err;
105 extern uid_t ruid;
106 extern int def_src;
107 extern void mesg(int, char *, ...);
108 
109 /*
110  * "parse.c"
111  */
112 extern int lineno;
113 extern char **line_args;
114 extern void lookup_estar_vers(void);
115 extern void lookup_perms(void);
116 extern void parse_conf_file(char *, vact_t, boolean_t);
117 
118 /*
119  * handlers.c
120  */
121 extern int S3_helper(char *, char *, int, int, char *, char *, int *, int);
122 extern int S3sup(void);
123 extern int autoS3(void);
124 extern int autopm(void);
125 extern int autosd(void);
126 extern int cpupm(void);
127 extern int cpuidle(void);
128 extern int cputhr(void);
129 extern int ddprop(void);
130 extern int devdep(void);
131 extern int devthr(void);
132 extern int dreads(void);
133 extern int idlechk(void);
134 extern int loadavg(void);
135 extern int nfsreq(void);
136 extern int sfpath(void);
137 extern int systhr(void);
138 extern int tchars(void);
139 
140 #ifdef	__cplusplus
141 }
142 #endif
143 
144 #endif	/* _PMCONFIG_H */
145