pcidr.h revision 881:e6bc7f4b8a33
1284677Sdim/*
2284677Sdim * CDDL HEADER START
3284677Sdim *
4284677Sdim * The contents of this file are subject to the terms of the
5284677Sdim * Common Development and Distribution License, Version 1.0 only
6284677Sdim * (the "License").  You may not use this file except in compliance
7284677Sdim * with the License.
8284677Sdim *
9284677Sdim * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10284677Sdim * or http://www.opensolaris.org/os/licensing.
11284677Sdim * See the License for the specific language governing permissions
12284677Sdim * and limitations under the License.
13284677Sdim *
14284677Sdim * When distributing Covered Code, include this CDDL HEADER in each
15284677Sdim * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16284677Sdim * If applicable, add the following below this CDDL HEADER, with the
17284677Sdim * fields enclosed by brackets "[]" replaced with your own identifying
18284677Sdim * information: Portions Copyright [yyyy] [name of copyright owner]
19284677Sdim *
20284677Sdim * CDDL HEADER END
21284677Sdim */
22284677Sdim/*
23284677Sdim * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24284677Sdim * Use is subject to license terms.
25284677Sdim */
26284677Sdim
27284677Sdim#ifndef	_PCIDR_H
28284677Sdim#define	_PCIDR_H
29284677Sdim
30284677Sdim#pragma ident	"%Z%%M%	%I%	%E% SMI"
31284677Sdim
32284677Sdim#include <libnvpair.h>
33284677Sdim#include <config_admin.h>
34284677Sdim
35284677Sdim#ifdef	__cplusplus
36284677Sdimextern "C" {
37284677Sdim#endif
38284677Sdim
39284677Sdim#define	PCIDR_MALLOC_CNT	5
40284677Sdim#define	PCIDR_MALLOC_TIME	1000000
41284677Sdim
42284677Sdim/* .._SYM and .._SYMSTR must match */
43284677Sdim#define	PCIDR_PLUGIN_SYM	pcidr_event_handler
44284677Sdim#define	PCIDR_PLUGIN_SYMSTR	"pcidr_event_handler"
45284677Sdim#define	PCIDR_PLUGIN_NAME	"pcidr_plugin.so"
46284677Sdim
47284677Sdim
48284677Sdim/*
49284677Sdim * these ATTRNM_* correspond to the built-in sysevent.conf macros
50284677Sdim * Note that the "publisher" macro used by syseventd is only a subset (third
51284677Sdim * colon-delimited field) of the full publisher-id string specified in an
52284677Sdim * event buffer/message.
53284677Sdim */
54284677Sdim#define	ATTRNM_CLASS	"class"
55284677Sdim#define	ATTRNM_SUBCLASS	"subclass"
56284677Sdim#define	ATTRNM_PUB_NAME	"publisher"
57284677Sdim
58284677Sdim/* be sure to match with dpritab! */
59284677Sdimtypedef enum {DNONE = 0, DWARN, DINFO, DDEBUG} dlvl_t;
60284677Sdim#define	MIN_DLVL DNONE
61284677Sdim#define	MAX_DLVL DDEBUG
62284677Sdim
63284677Sdim/* default set of DR attributes */
64284677Sdimtypedef struct {
65284677Sdim	char *class;
66284677Sdim	char *subclass;
67284677Sdim	char *pub_name;
68284677Sdim	char *dr_req_type;
69284677Sdim	char *dr_ap_id;
70284677Sdim} pcidr_attrs_t;
71284677Sdim
72284677Sdim
73284677Sdimtypedef struct {
74284677Sdim	dlvl_t dlvl;
75284677Sdim	char *prg;
76284677Sdim	FILE *dfp;
77284677Sdim	int dsys;
78284677Sdim} pcidr_logopt_t;
79284677Sdim
80284677Sdimtypedef struct {
81284677Sdim	pcidr_logopt_t logopt;
82284677Sdim} pcidr_opt_t;
83284677Sdim
84284677Sdimtypedef int(*pcidr_plugin_t)(nvlist_t *, pcidr_opt_t *);
85284677Sdim#define	PCIDR_PLUGIN_PROTO(a, b)	\
86284677Sdim	int PCIDR_PLUGIN_SYM(nvlist_t *a, pcidr_opt_t *b)
87284677Sdim
88284677Sdim
89284677Sdimvoid *pcidr_malloc(size_t);
90284677Sdimvoid dprint(dlvl_t, char *, ...);
91284677Sdimint pcidr_name2type(char *, data_type_t *);
92284677Sdimvoid pcidr_print_attrlist(dlvl_t, nvlist_t *, char *);
93284677Sdimint pcidr_check_string(char *, ...);
94284677Sdimint pcidr_get_attrs(nvlist_t *, pcidr_attrs_t *);
95284677Sdimint pcidr_check_attrs(pcidr_attrs_t *);
96284677Sdimvoid pcidr_set_logopt(pcidr_logopt_t *);
97284677Sdim
98284677Sdimextern dlvl_t dlvl;
99284677Sdimextern char *prg;
100284677Sdimextern FILE *dfp;
101284677Sdimextern int dsys;
102284677Sdimextern char *prg;
103284677Sdimextern int dpritab_len;
104284677Sdim
105284677Sdim#ifdef	__cplusplus
106284677Sdim}
107284677Sdim#endif
108284677Sdim
109284677Sdim#endif	/* _PCIDR_H */
110284677Sdim