Project

General

Profile

Statistics
| Revision:

root / lab4 / .minix-src / include / sys / evcnt.h @ 14

History | View | Annotate | Download (5.84 KB)

1 13 up20180614
/*        $NetBSD: evcnt.h,v 1.8 2011/01/29 18:21:22 matt Exp $        */
2
3
/*
4
 * Copyright (c) 1996, 2000 Christopher G. Demetriou
5
 * All rights reserved.
6
 *
7
 * Redistribution and use in source and binary forms, with or without
8
 * modification, are permitted provided that the following conditions
9
 * are met:
10
 * 1. Redistributions of source code must retain the above copyright
11
 *    notice, this list of conditions and the following disclaimer.
12
 * 2. Redistributions in binary form must reproduce the above copyright
13
 *    notice, this list of conditions and the following disclaimer in the
14
 *    documentation and/or other materials provided with the distribution.
15
 * 3. All advertising materials mentioning features or use of this software
16
 *    must display the following acknowledgement:
17
 *          This product includes software developed for the
18
 *          NetBSD Project.  See http://www.NetBSD.org/ for
19
 *          information about NetBSD.
20
 * 4. The name of the author may not be used to endorse or promote products
21
 *    derived from this software without specific prior written permission.
22
 *
23
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
24
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
25
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
27
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
28
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
32
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33
 *
34
 * --(license Id: LICENSE.proto,v 1.1 2000/06/13 21:40:26 cgd Exp )--
35
 */
36
37
/*
38
 * Copyright (c) 1992, 1993
39
 *        The Regents of the University of California.  All rights reserved.
40
 *
41
 * This software was developed by the Computer Systems Engineering group
42
 * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
43
 * contributed to Berkeley.
44
 *
45
 * All advertising materials mentioning features or use of this software
46
 * must display the following acknowledgement:
47
 *        This product includes software developed by the University of
48
 *        California, Lawrence Berkeley Laboratories.
49
 *
50
 * Redistribution and use in source and binary forms, with or without
51
 * modification, are permitted provided that the following conditions
52
 * are met:
53
 * 1. Redistributions of source code must retain the above copyright
54
 *    notice, this list of conditions and the following disclaimer.
55
 * 2. Redistributions in binary form must reproduce the above copyright
56
 *    notice, this list of conditions and the following disclaimer in the
57
 *    documentation and/or other materials provided with the distribution.
58
 * 3. Neither the name of the University nor the names of its contributors
59
 *    may be used to endorse or promote products derived from this software
60
 *    without specific prior written permission.
61
 *
62
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
63
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
64
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
65
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
66
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
67
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
68
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
69
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
70
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
71
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
72
 * SUCH DAMAGE.
73
 */
74
75
#ifndef _SYS_EVCNT_H_
76
#define        _SYS_EVCNT_H_
77
78
#include <sys/queue.h>
79
#include <sys/stdint.h>
80
81
/*
82
 * event counters
83
 */
84
85
struct evcnt {
86
        uint64_t        ev_count;        /* how many have occurred */
87
        TAILQ_ENTRY(evcnt) ev_list;        /* entry on list of all counters */
88
        unsigned char        ev_type;        /* counter type; see below */
89
        unsigned char        ev_grouplen;        /* 'group' len, excluding NUL */
90
        unsigned char        ev_namelen;        /* 'name' len, excluding NUL */
91
        char                ev_pad1;        /* reserved (for now); 0 */
92
        const struct evcnt *ev_parent;        /* parent, for hierarchical ctrs */
93
        const char        *ev_group;        /* name of group */
94
        const char        *ev_name;        /* name of specific event */
95
};
96
TAILQ_HEAD(evcntlist, evcnt);
97
98
/* maximum group/name lengths, including trailing NUL */
99
#define        EVCNT_STRING_MAX        255
100
101
/* ev_type values */
102
#define        EVCNT_TYPE_ANY                -1        /* for sysctl */
103
#define        EVCNT_TYPE_MISC                0        /* miscellaneous; catch all */
104
#define        EVCNT_TYPE_INTR                1        /* interrupt; count with vmstat -i */
105
#define        EVCNT_TYPE_TRAP                2        /* processor trap/execption */
106
107
/*
108
 * initializer for an event count structure.  the lengths are initted and
109
 * it is added to the evcnt list at attach time.
110
 */
111
#define        EVCNT_INITIALIZER(type, parent, group, name)        \
112
    {                                                        \
113
        .ev_type = type,                                \
114
        .ev_parent = parent,                                \
115
        .ev_group = group,                                \
116
        .ev_name = name,                                \
117
    }
118
119
/*
120
 * Attach a static event counter.  This uses a link set to do the work.
121
 * NOTE: "ev" should not be a pointer to the object, but rather a direct
122
 * reference to the object itself.
123
 */
124
#define        EVCNT_ATTACH_STATIC(ev)                __link_set_add_data(evcnts, ev)
125
#define        EVCNT_ATTACH_STATIC2(ev, n)        __link_set_add_data2(evcnts, ev, n)
126
127
#ifdef _KERNEL
128
129
extern struct evcntlist allevents;        /* list of all event counters */
130
131
void        evcnt_init(void);
132
void        evcnt_attach_static(struct evcnt *);
133
void        evcnt_attach_dynamic_nozero(struct evcnt *, int, const struct evcnt *,
134
            const char *, const char *);
135
void        evcnt_attach_dynamic(struct evcnt *, int, const struct evcnt *,
136
            const char *, const char *);
137
void        evcnt_detach(struct evcnt *);
138
#endif /* _KERNEL */
139
140
#endif /* !_SYS_EVCNT_H_ */