Project

General

Profile

Statistics
| Revision:

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

History | View | Annotate | Download (3.55 KB)

1 13 up20180614
/*        $NetBSD: pmc.h,v 1.5 2005/12/11 12:25:20 christos Exp $        */
2
3
/*
4
 * Copyright (c) 2002 Wasabi Systems, Inc.
5
 * All rights reserved.
6
 *
7
 * Written by Allen Briggs for Wasabi Systems, Inc.
8
 *
9
 * Redistribution and use in source and binary forms, with or without
10
 * modification, are permitted provided that the following conditions
11
 * are met:
12
 * 1. Redistributions of source code must retain the above copyright
13
 *    notice, this list of conditions and the following disclaimer.
14
 * 2. Redistributions in binary form must reproduce the above copyright
15
 *    notice, this list of conditions and the following disclaimer in the
16
 *    documentation and/or other materials provided with the distribution.
17
 * 3. All advertising materials mentioning features or use of this software
18
 *    must display the following acknowledgement:
19
 *      This product includes software developed for the NetBSD Project by
20
 *      Wasabi Systems, Inc.
21
 * 4. The name of Wasabi Systems, Inc. may not be used to endorse
22
 *    or promote products derived from this software without specific prior
23
 *    written permission.
24
 *
25
 * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
26
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
27
 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL WASABI SYSTEMS, INC
29
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35
 * POSSIBILITY OF SUCH DAMAGE.
36
 */
37
38
#ifndef _SYS_PMC_H_
39
#define        _SYS_PMC_H_
40
41
struct pmc_counter_cfg {
42
        pmc_evid_t        event_id;                /* What event to configure */
43
        pmc_ctr_t        reset_value;                /* Value to set counter to */
44
        uint32_t        flags;                        /* PMC_FLAG_* */
45
};
46
47
#if defined(_KERNEL)
48
49
/*
50
 *      The following functions are defined in machine/pmc.h as either
51
 * functions or macros.
52
 *
53
 * int        pmc_get_num_counters(void);
54
 * int        pmc_get_counter_type(int ctr);
55
 *
56
 * void        pmc_save_context(struct proc *p);
57
 * void        pmc_restore_context(struct proc *p);
58
 * void        pmc_process_exit(struct proc *p);
59
 *
60
 * int        pmc_enable_counter(struct proc *p, int ctr);
61
 * int        pmc_disable_counter(struct proc *p, int ctr);
62
 * int        pmc_counter_isrunning(struct proc *p, int ctr);
63
 * int        pmc_counter_isconfigured(struct proc *p, int ctr);
64
 *
65
 * int        pmc_configure_counter(struct proc *p, int ctr, pmc_counter_cfg *cfg);
66
 *
67
 * int        pmc_get_counter_value(struct proc *p, int ctr, int flags,
68
 *          uint64_t *pval);
69
 *
70
 * int        pmc_accumulate(struct proc *p_parent, struct proc *p_exiting);
71
 *
72
 * int        pmc_alloc_kernel_counter(int ctr, struct pmc_counter_cfg *cfg);
73
 * int        pmc_free_kernel_counter(int ctr);
74
 *
75
 * int        pmc_start_profiling(int ctr, struct pmc_counter_cfg *cfg);
76
 * int        pmc_stop_profiling(int ctr);
77
 *
78
 * int        PMC_ENABLED(struct proc *p);
79
 */
80
81
#define PMC_VALUE_FLAGS_CHILDREN        0x00000001
82
83
#endif        /* _KERNEL */
84
85
#include <machine/pmc.h>
86
87
#define PMC_OP_START                1
88
#define PMC_OP_STOP                2
89
#define PMC_OP_CONFIGURE        3
90
#define PMC_OP_PROFSTART        4
91
#define PMC_OP_PROFSTOP                5
92
int        pmc_control(int ctr, int operation, void *args);
93
94
#define PMC_INFO_NCOUNTERS                        1
95
#define PMC_INFO_CPUCTR_TYPE                        2
96
#define PMC_INFO_COUNTER_VALUE                        3
97
#define PMC_INFO_ACCUMULATED_COUNTER_VALUE        4
98
int        pmc_get_info(int ctr, int request, void *data);
99
100
#endif        /* !_SYS_PMC_H_ */