parlib: Fix the use-after-func issue
[akaros.git] / user / perfmon / pfmlib_intel_p6.c
1 /*
2  * pfmlib_i386_p6.c : support for the P6 processor family (family=6)
3  *                    incl. Pentium II, Pentium III, Pentium Pro, Pentium M
4  *
5  * Copyright (c) 2005-2007 Hewlett-Packard Development Company, L.P.
6  * Contributed by Stephane Eranian <eranian@hpl.hp.com>
7  *
8  * Permission is hereby granted, free of charge, to any person obtaining a copy
9  * of this software and associated documentation files (the "Software"), to deal
10  * in the Software without restriction, including without limitation the rights
11  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
12  * of the Software, and to permit persons to whom the Software is furnished to do so,
13  * subject to the following conditions:
14  *
15  * The above copyright notice and this permission notice shall be included in all
16  * copies or substantial portions of the Software.
17  *
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
19  * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
20  * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21  * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
22  * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
23  * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24  */
25 /* private headers */
26 #include "pfmlib_priv.h"                        /* library private */
27 #include "pfmlib_intel_x86_priv.h"              /* architecture private */
28 #include "events/intel_p6_events.h"             /* generic P6 (PIII) */
29 #include "events/intel_pii_events.h"            /* Pentium II */
30 #include "events/intel_ppro_events.h"           /* Pentium Pro */
31 #include "events/intel_pm_events.h"             /* Pentium M */
32
33 static const int pii_models[] = {
34         3, /* Pentium II */
35         5, /* Pentium II Deschutes */
36         6, /* Pentium II Mendocino */
37         0
38 };
39
40 static const int ppro_models[] = {
41         1, /* Pentium Pro */
42         0
43 };
44
45 static const int piii_models[] = {
46         7, /* Pentium III Katmai */
47         8, /* Pentium III Coppermine */
48         10,/* Pentium III Cascades */
49         11,/* Pentium III Tualatin */
50         0
51 };
52
53 static const int pm_models[] = {
54         9, /* Pentium M */
55         13, /* Pentium III Coppermine */
56         0
57 };
58
59 /* Pentium II support */
60 pfmlib_pmu_t intel_pii_support={
61         .desc                   = "Intel Pentium II",
62         .name                   = "pii",
63         .pmu                    = PFM_PMU_INTEL_PII,
64         .pme_count              = LIBPFM_ARRAY_SIZE(intel_pii_pe),
65         .pe                     = intel_pii_pe,
66         .atdesc                 = intel_x86_mods,
67         .flags                  = PFMLIB_PMU_FL_RAW_UMASK,
68         .type                   = PFM_PMU_TYPE_CORE,
69         .supported_plm          = INTEL_X86_PLM,
70         .cpu_family             = 6,
71         .cpu_models             = pii_models,
72         .pmu_detect             = pfm_intel_x86_model_detect,
73         .num_cntrs              = 2,
74         .max_encoding           = 1,
75
76         .get_event_encoding[PFM_OS_NONE] = pfm_intel_x86_get_encoding,
77          PFMLIB_ENCODE_PERF(pfm_intel_x86_get_perf_encoding),
78
79         .get_event_first        = pfm_intel_x86_get_event_first,
80         .get_event_next         = pfm_intel_x86_get_event_next,
81         .event_is_valid         = pfm_intel_x86_event_is_valid,
82         .validate_table         = pfm_intel_x86_validate_table,
83         .get_event_info         = pfm_intel_x86_get_event_info,
84         .get_event_attr_info    = pfm_intel_x86_get_event_attr_info,
85         PFMLIB_VALID_PERF_PATTRS(pfm_intel_x86_perf_validate_pattrs),
86         .get_event_nattrs       = pfm_intel_x86_get_event_nattrs,
87 };
88
89 pfmlib_pmu_t intel_p6_support={
90         .desc                   = "Intel P6 Processor Family",
91         .name                   = "p6",
92         .pmu                    = PFM_PMU_I386_P6,
93         .pme_count              = LIBPFM_ARRAY_SIZE(intel_p6_pe),
94         .pe                     = intel_p6_pe,
95         .atdesc                 = intel_x86_mods,
96         .flags                  = PFMLIB_PMU_FL_RAW_UMASK,
97         .type                   = PFM_PMU_TYPE_CORE,
98         .supported_plm          = INTEL_X86_PLM,
99
100         .cpu_family             = 6,
101         .cpu_models             = piii_models,
102         .pmu_detect             = pfm_intel_x86_model_detect,
103         .num_cntrs              = 2,
104         .max_encoding           = 1,
105
106         .get_event_encoding[PFM_OS_NONE] = pfm_intel_x86_get_encoding,
107          PFMLIB_ENCODE_PERF(pfm_intel_x86_get_perf_encoding),
108
109         .get_event_first        = pfm_intel_x86_get_event_first,
110         .get_event_next         = pfm_intel_x86_get_event_next,
111         .event_is_valid         = pfm_intel_x86_event_is_valid,
112         .validate_table         = pfm_intel_x86_validate_table,
113         .get_event_info         = pfm_intel_x86_get_event_info,
114         .get_event_attr_info    = pfm_intel_x86_get_event_attr_info,
115         PFMLIB_VALID_PERF_PATTRS(pfm_intel_x86_perf_validate_pattrs),
116         .get_event_nattrs       = pfm_intel_x86_get_event_nattrs,
117 };
118
119 pfmlib_pmu_t intel_ppro_support={
120         .desc                   = "Intel Pentium Pro",
121         .name                   = "ppro",
122         .pmu                    = PFM_PMU_INTEL_PPRO,
123         .pme_count              = LIBPFM_ARRAY_SIZE(intel_ppro_pe),
124         .pe                     = intel_ppro_pe,
125         .atdesc                 = intel_x86_mods,
126         .flags                  = PFMLIB_PMU_FL_RAW_UMASK,
127         .type                   = PFM_PMU_TYPE_CORE,
128         .supported_plm          = INTEL_X86_PLM,
129
130         .cpu_family             = 6,
131         .cpu_models             = ppro_models,
132         .pmu_detect             = pfm_intel_x86_model_detect,
133         .num_cntrs              = 2,
134         .max_encoding           = 1,
135
136         .get_event_encoding[PFM_OS_NONE] = pfm_intel_x86_get_encoding,
137          PFMLIB_ENCODE_PERF(pfm_intel_x86_get_perf_encoding),
138
139         .get_event_first        = pfm_intel_x86_get_event_first,
140         .get_event_next         = pfm_intel_x86_get_event_next,
141         .event_is_valid         = pfm_intel_x86_event_is_valid,
142         .validate_table         = pfm_intel_x86_validate_table,
143         .get_event_info         = pfm_intel_x86_get_event_info,
144         .get_event_attr_info    = pfm_intel_x86_get_event_attr_info,
145         PFMLIB_VALID_PERF_PATTRS(pfm_intel_x86_perf_validate_pattrs),
146         .get_event_nattrs       = pfm_intel_x86_get_event_nattrs,
147 };
148
149 /* Pentium M support */
150 pfmlib_pmu_t intel_pm_support={
151         .desc                   = "Intel Pentium M",
152         .name                   = "pm",
153         .pmu                    = PFM_PMU_I386_PM,
154         .pe                     = intel_pm_pe,
155         .atdesc                 = intel_x86_mods,
156         .flags                  = PFMLIB_PMU_FL_RAW_UMASK,
157         .supported_plm          = INTEL_X86_PLM,
158
159         .cpu_family             = 6,
160         .cpu_models             = pm_models,
161         .pmu_detect             = pfm_intel_x86_model_detect,
162         .pme_count              = LIBPFM_ARRAY_SIZE(intel_pm_pe),
163         .type                   = PFM_PMU_TYPE_CORE,
164         .num_cntrs              = 2,
165         .max_encoding           = 1,
166
167         .get_event_encoding[PFM_OS_NONE] = pfm_intel_x86_get_encoding,
168          PFMLIB_ENCODE_PERF(pfm_intel_x86_get_perf_encoding),
169
170         .get_event_first        = pfm_intel_x86_get_event_first,
171         .get_event_next         = pfm_intel_x86_get_event_next,
172         .event_is_valid         = pfm_intel_x86_event_is_valid,
173         .validate_table         = pfm_intel_x86_validate_table,
174         .get_event_info         = pfm_intel_x86_get_event_info,
175         .get_event_attr_info    = pfm_intel_x86_get_event_attr_info,
176         PFMLIB_VALID_PERF_PATTRS(pfm_intel_x86_perf_validate_pattrs),
177         .get_event_nattrs       = pfm_intel_x86_get_event_nattrs,
178 };