blob: f6462fc89b56f29a60767d381df0c4596233738f [file] [log] [blame]
Upstreamcc2ee171970-01-12 13:46:40 +00001/**
2 * @file op_events.h
3 * Details of PMC profiling events
4 *
5 * @remark Copyright 2002 OProfile authors
6 * @remark Read the file COPYING
7 *
8 * @author John Levon
9 * @author Philippe Elie
10 */
11
12#ifndef OP_EVENTS_H
13#define OP_EVENTS_H
14
15#ifdef __cplusplus
16extern "C" {
17#endif
18
19#include "op_cpu_type.h"
20#include "op_types.h"
21#include "op_list.h"
22
23/** Describe an unit mask type. Events can optionally use a filter called
24 * the unit mask. the mask type can be a bitmask or a discrete value */
25enum unit_mask_type {
26 utm_mandatory, /**< useless but required by the hardware */
27 utm_exclusive, /**< only one of the values is allowed */
28 utm_bitmask /**< bitmask */
29};
30
Ben Cheng2b16b5f2008-10-23 16:07:43 -070031/** up to thirty two allowed unit masks */
32#define MAX_UNIT_MASK 32
Upstreamcc2ee171970-01-12 13:46:40 +000033
34
35/** Describe an unit mask. */
36struct op_unit_mask {
37 char * name; /**< name of unit mask type */
38 u32 num; /**< number of possible unit masks */
39 enum unit_mask_type unit_type_mask;
Ben Cheng2b16b5f2008-10-23 16:07:43 -070040 u32 default_mask; /**< only the gui use it */
Upstreamcc2ee171970-01-12 13:46:40 +000041 struct op_described_um {
Ben Cheng2b16b5f2008-10-23 16:07:43 -070042 u32 value;
Upstreamcc2ee171970-01-12 13:46:40 +000043 char * desc;
44 } um[MAX_UNIT_MASK];
45 struct list_head um_next; /**< next um in list */
46 int used; /**< used by events file parser */
47};
48
49
50/** Describe an event. */
51struct op_event {
52 u32 counter_mask; /**< bitmask of allowed counter */
Ben Cheng2b16b5f2008-10-23 16:07:43 -070053 u32 val; /**< event number */
Upstreamcc2ee171970-01-12 13:46:40 +000054 /** which unit mask if any allowed */
55 struct op_unit_mask * unit;
56 char * name; /**< the event name */
57 char * desc; /**< the event description */
58 int min_count; /**< minimum counter value allowed */
59 struct list_head event_next; /**< next event in list */
60};
61
62/** Return the known events list. Idempotent */
63struct list_head * op_events(op_cpu cpu_type);
64
65/** Find a given event, returns NULL on error */
Ben Cheng2b16b5f2008-10-23 16:07:43 -070066struct op_event * op_find_event(op_cpu cpu_type, u32 nr);
Upstreamcc2ee171970-01-12 13:46:40 +000067
68/** Find a given event by name */
69struct op_event * find_event_by_name(char const * name);
70
71/**
72 * Find a mapping for a given event ID for architectures requiring additional information
73 * from what is held in the events file.
74 */
Ben Cheng2b16b5f2008-10-23 16:07:43 -070075char const * find_mapping_for_event(u32 val, op_cpu cpu_type);
Upstreamcc2ee171970-01-12 13:46:40 +000076
77
78/** op_check_events() return code */
79enum op_event_check {
80 OP_OK_EVENT = 0, /**< event is valid and allowed */
81 OP_INVALID_EVENT = 1, /**< event number is invalid */
82 OP_INVALID_UM = 2, /**< unit mask is invalid */
83 OP_INVALID_COUNTER = 4 /**< event is not allowed for the given counter */
84};
85
86/**
87 * sanity check event values
88 * @param ctr counter number
89 * @param event value for counter
90 * @param um unit mask for counter
91 * @param cpu_type processor type
92 *
93 * Check that the counter event and unit mask values are allowed.
94 *
95 * The function returns bitmask of failure cause 0 otherwise
96 *
97 * \sa op_cpu, OP_EVENTS_OK
98 */
Ben Cheng2b16b5f2008-10-23 16:07:43 -070099int op_check_events(int ctr, u32 event, u32 um, op_cpu cpu_type);
Upstreamcc2ee171970-01-12 13:46:40 +0000100
101/**
102 * free memory used by any call to above function. Need to be called only once
103 */
104void op_free_events(void);
105
106struct op_default_event_descr {
107 char * name;
108 unsigned long count;
109 unsigned long um;
110};
111
112/**
113 * op_default_event - return the details of the default event
114 * @param cpu_type cpu type
115 * @param descr filled event description
116 *
117 * Fills in the event description if applicable
118 */
119void op_default_event(op_cpu cpu_type, struct op_default_event_descr * descr);
120
121#ifdef __cplusplus
122}
123#endif
124
125#endif /* OP_EVENTS_H */