source: trunk/packages/xen-3.1/xen-3.1/xen/arch/ia64/xen/privop_stat.c @ 34

Last change on this file since 34 was 34, checked in by hartmans, 19 years ago

Add xen and xen-common

File size: 4.2 KB
Line 
1#include <xen/lib.h>
2#include <public/xen.h>
3#include <xen/perfc.h>
4#include <asm/atomic.h>
5#include <asm/privop_stat.h>
6
7#ifdef CONFIG_PRIVOP_ADDRS
8
9struct privop_addr_count {
10        unsigned long addr[PRIVOP_COUNT_NADDRS];
11        unsigned int count[PRIVOP_COUNT_NADDRS];
12        unsigned int overflow;
13};
14
15struct privop_addr_info {
16        enum perfcounter perfc_addr;
17        enum perfcounter perfc_count;
18        enum perfcounter perfc_overflow;
19};
20
21#define PERFCOUNTER(var, name)
22#define PERFCOUNTER_ARRAY(var, name, size)
23
24#define PERFSTATUS(var, name)
25#define PERFSTATUS_ARRAY(var, name, size)
26
27#define PERFPRIVOPADDR(name)                        \
28    {                                               \
29        PERFC_privop_addr_##name##_addr,            \
30        PERFC_privop_addr_##name##_count,           \
31        PERFC_privop_addr_##name##_overflow         \
32    },
33
34static const struct privop_addr_info privop_addr_info[] = {
35#include <asm/perfc_defn.h>
36};
37
38#define PRIVOP_COUNT_NINSTS \
39        (sizeof(privop_addr_info) / sizeof(privop_addr_info[0]))
40
41static DEFINE_PER_CPU(struct privop_addr_count[PRIVOP_COUNT_NINSTS], privop_addr_counter);
42
43void privop_count_addr(unsigned long iip, enum privop_inst inst)
44{
45        struct privop_addr_count *v = this_cpu(privop_addr_counter) + inst;
46        int i;
47
48        if (inst >= PRIVOP_COUNT_NINSTS)
49                return;
50        for (i = 0; i < PRIVOP_COUNT_NADDRS; i++) {
51                if (!v->addr[i]) {
52                        v->addr[i] = iip;
53                        v->count[i]++;
54                        return;
55                }
56                else if (v->addr[i] == iip) {
57                        v->count[i]++;
58                        return;
59                }
60        }
61        v->overflow++;;
62}
63
64void gather_privop_addrs(void)
65{
66        unsigned int cpu;
67
68        for_each_cpu ( cpu ) {
69                perfc_t *perfcounters = per_cpu(perfcounters, cpu);
70                struct privop_addr_count *s = per_cpu(privop_addr_counter, cpu);
71                int i, j;
72
73                for (i = 0; i < PRIVOP_COUNT_NINSTS; i++, s++) {
74                        perfc_t *d;
75
76                        /* Note: addresses are truncated!  */
77                        d = perfcounters + privop_addr_info[i].perfc_addr;
78                        for (j = 0; j < PRIVOP_COUNT_NADDRS; j++)
79                                d[j] = s->addr[j];
80
81                        d = perfcounters + privop_addr_info[i].perfc_count;
82                        for (j = 0; j < PRIVOP_COUNT_NADDRS; j++)
83                                d[j] = s->count[j];
84               
85                        perfcounters[privop_addr_info[i].perfc_overflow] =
86                                s->overflow;
87                }
88        }
89}
90
91void reset_privop_addrs(void)
92{
93        unsigned int cpu;
94
95        for_each_cpu ( cpu ) {
96                struct privop_addr_count *v = per_cpu(privop_addr_counter, cpu);
97                int i, j;
98
99                for (i = 0; i < PRIVOP_COUNT_NINSTS; i++, v++) {
100                        for (j = 0; j < PRIVOP_COUNT_NADDRS; j++)
101                                v->addr[j] = v->count[j] = 0;
102                        v->overflow = 0;
103                }
104        }
105}
106#endif
107
108/**************************************************************************
109Privileged operation instrumentation routines
110**************************************************************************/
111
112#if 0
113static const char * const Mpriv_str[64] = {
114        "mov_to_rr", "mov_to_dbr", "mov_to_ibr", "mov_to_pkr",
115        "mov_to_pmc", "mov_to_pmd", "<0x06>", "<0x07>",
116        "<0x08>", "ptc_l", "ptc_g", "ptc_ga",
117        "ptr_d", "ptr_i", "itr_d", "itr_i",
118        "mov_from_rr", "mov_from_dbr", "mov_from_ibr", "mov_from_pkr",
119        "mov_from_pmc", "<0x15>", "<0x16>", "<0x17>",
120        "<0x18>", "<0x19>", "privified-thash", "privified-ttag",
121        "<0x1c>", "<0x1d>", "tpa", "tak",
122        "<0x20>", "<0x21>", "<0x22>", "<0x23>",
123        "mov_from_cr", "mov_from_psr", "<0x26>", "<0x27>",
124        "<0x28>", "<0x29>", "<0x2a>", "<0x2b>",
125        "mov_to_cr", "mov_to_psr", "itc_d", "itc_i",
126        "<0x30>", "<0x31>", "<0x32>", "<0x33>",
127        "ptc_e", "<0x35>", "<0x36>", "<0x37>",
128        "<0x38>", "<0x39>", "<0x3a>", "<0x3b>",
129        "<0x3c>", "<0x3d>", "<0x3e>", "<0x3f>"
130};
131
132#define RS "Rsvd"
133static const char * const cr_str[128] = {
134        "dcr","itm","iva",RS,RS,RS,RS,RS,
135        "pta",RS,RS,RS,RS,RS,RS,RS,
136        "ipsr","isr",RS,"iip","ifa","itir","iipa","ifs",
137        "iim","iha",RS,RS,RS,RS,RS,RS,
138        RS,RS,RS,RS,RS,RS,RS,RS, RS,RS,RS,RS,RS,RS,RS,RS,
139        RS,RS,RS,RS,RS,RS,RS,RS, RS,RS,RS,RS,RS,RS,RS,RS,
140        "lid","ivr","tpr","eoi","irr0","irr1","irr2","irr3",
141        "itv","pmv","cmcv",RS,RS,RS,RS,RS,
142        "lrr0","lrr1",RS,RS,RS,RS,RS,RS,
143        RS,RS,RS,RS,RS,RS,RS,RS, RS,RS,RS,RS,RS,RS,RS,RS,
144        RS,RS,RS,RS,RS,RS,RS,RS, RS,RS,RS,RS,RS,RS,RS,RS,
145        RS,RS,RS,RS,RS,RS,RS,RS
146};
147
148static const char * const hyperpriv_str[HYPERPRIVOP_MAX+1] = {
149        0, "rfi", "rsm.dt", "ssm.dt", "cover", "itc.d", "itc.i", "ssm.i",
150        "=ivr", "=tpr", "tpr=", "eoi", "itm=", "thash", "ptc.ga", "itr.d",
151        "=rr", "rr=", "kr=", "fc", "=cpuid", "=pmd", "=ar.eflg", "ar.eflg="
152};
153#endif
Note: See TracBrowser for help on using the repository browser.