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