xref: /titanic_41/usr/src/cmd/pcidr/pcidr.h (revision 450396635f70344c58b6b1e4db38cf17ff34445c)
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 2005 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_PCIDR_H
28 #define	_PCIDR_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #include <libnvpair.h>
33 #include <config_admin.h>
34 
35 #ifdef	__cplusplus
36 extern "C" {
37 #endif
38 
39 #define	PCIDR_MALLOC_CNT	5
40 #define	PCIDR_MALLOC_TIME	1000000
41 
42 /* .._SYM and .._SYMSTR must match */
43 #define	PCIDR_PLUGIN_SYM	pcidr_event_handler
44 #define	PCIDR_PLUGIN_SYMSTR	"pcidr_event_handler"
45 #define	PCIDR_PLUGIN_NAME	"pcidr_plugin.so"
46 
47 
48 /*
49  * these ATTRNM_* correspond to the built-in sysevent.conf macros
50  * Note that the "publisher" macro used by syseventd is only a subset (third
51  * colon-delimited field) of the full publisher-id string specified in an
52  * event buffer/message.
53  */
54 #define	ATTRNM_CLASS	"class"
55 #define	ATTRNM_SUBCLASS	"subclass"
56 #define	ATTRNM_PUB_NAME	"publisher"
57 
58 /* be sure to match with dpritab! */
59 typedef enum {DNONE = 0, DWARN, DINFO, DDEBUG} dlvl_t;
60 #define	MIN_DLVL DNONE
61 #define	MAX_DLVL DDEBUG
62 
63 /* default set of DR attributes */
64 typedef struct {
65 	char *class;
66 	char *subclass;
67 	char *pub_name;
68 	char *dr_req_type;
69 	char *dr_ap_id;
70 } pcidr_attrs_t;
71 
72 
73 typedef struct {
74 	dlvl_t dlvl;
75 	char *prg;
76 	FILE *dfp;
77 	int dsys;
78 } pcidr_logopt_t;
79 
80 typedef struct {
81 	pcidr_logopt_t logopt;
82 } pcidr_opt_t;
83 
84 typedef int(*pcidr_plugin_t)(nvlist_t *, pcidr_opt_t *);
85 #define	PCIDR_PLUGIN_PROTO(a, b)	\
86 	int PCIDR_PLUGIN_SYM(nvlist_t *a, pcidr_opt_t *b)
87 
88 
89 void *pcidr_malloc(size_t);
90 void dprint(dlvl_t, char *, ...);
91 int pcidr_name2type(char *, data_type_t *);
92 void pcidr_print_attrlist(dlvl_t, nvlist_t *, char *);
93 int pcidr_check_string(char *, ...);
94 int pcidr_get_attrs(nvlist_t *, pcidr_attrs_t *);
95 int pcidr_check_attrs(pcidr_attrs_t *);
96 void pcidr_set_logopt(pcidr_logopt_t *);
97 
98 extern dlvl_t dlvl;
99 extern char *prg;
100 extern FILE *dfp;
101 extern int dsys;
102 extern char *prg;
103 extern int dpritab_len;
104 
105 #ifdef	__cplusplus
106 }
107 #endif
108 
109 #endif	/* _PCIDR_H */
110