xref: /titanic_50/usr/src/cmd/power/pmconfig.h (revision 554ff184129088135ad2643c1c9832174a17be88)
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 2002 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _PMCONFIG_H
28 #define	_PMCONFIG_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 #include <sys/stat.h>
38 #include <sys/cpr.h>
39 #include <sys/pm.h>
40 #include <strings.h>
41 #include <limits.h>
42 #include <libintl.h>
43 #include <stdlib.h>
44 #include <unistd.h>
45 #include <stdio.h>
46 #include <fcntl.h>
47 #include <errno.h>
48 
49 
50 #define	LINEARG(an)		*(line_args + an)
51 #define	LINELEN			80
52 #define	MOREARGS		4
53 
54 #define	ESTAR_VNONE		0
55 #define	ESTAR_V2		'2'
56 #define	ESTAR_V3		'3'
57 
58 #define	LPAREN			'('
59 #define	RPAREN			')'
60 
61 #define	MDEBUG			0
62 #define	MEXIT			1
63 #define	MERR			-1
64 
65 /*
66  * return values from handler routines;
67  * chosen to match syscall return values
68  */
69 #define	NOUP			-1
70 #define	OKUP			0
71 
72 #define	DFLT_THOLD		0.04
73 
74 
75 struct perm_update {
76 	int	perm;			/* cpr or pm permission */
77 	int	update;			/* flag updates from cpr/pm data */
78 	char	*set;			/* "cpr" or "pm" */
79 };
80 typedef struct perm_update prmup_t;
81 
82 
83 struct cinfo {
84 	char	*keyword;		/* keyword string */
85 	int	(*handler)(void);	/* keyword handler routine */
86 	prmup_t	*status;		/* permission and update status */
87 	char	*cmt;			/* config file comment */
88 	short	argc;			/* config line arg count */
89 	uint8_t	any;			/* 0: match argc, 1: at least argc */
90 	uint8_t	alt;			/* conf line OK from an alt source */
91 };
92 typedef struct cinfo cinfo_t;
93 
94 typedef void (*vact_t)(char *, size_t, cinfo_t *);
95 
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 /*
111  * "parse.c"
112  */
113 extern int lineno;
114 extern char **line_args;
115 extern void lookup_estar_vers(void);
116 extern void lookup_perms(void);
117 extern void parse_conf_file(char *, vact_t);
118 
119 /*
120  * handlers.c
121  */
122 extern int autopm(void);
123 extern int autosd(void);
124 extern int ddprop(void);
125 extern int devdep(void);
126 extern int devthr(void);
127 extern int dreads(void);
128 extern int idlechk(void);
129 extern int loadavg(void);
130 extern int nfsreq(void);
131 extern int sfpath(void);
132 extern int systhr(void);
133 extern int tchars(void);
134 
135 #ifdef	__cplusplus
136 }
137 #endif
138 
139 #endif	/* _PMCONFIG_H */
140