gator: Version 5.19
[firefly-linux-kernel-4.4.55.git] / tools / gator / daemon / PerfDriver.h
1 /**
2  * Copyright (C) ARM Limited 2013-2014. All rights reserved.
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation.
7  */
8
9 #ifndef PERFDRIVER_H
10 #define PERFDRIVER_H
11
12 #include "Driver.h"
13
14 // If debugfs is not mounted at /sys/kernel/debug, update DEBUGFS_PATH
15 #define DEBUGFS_PATH "/sys/kernel/debug"
16 #define EVENTS_PATH DEBUGFS_PATH "/tracing/events"
17
18 #define SCHED_SWITCH "sched/sched_switch"
19
20 class Buffer;
21 class DynBuf;
22 class PerfCounter;
23 class PerfGroup;
24
25 class PerfDriver : public Driver {
26 public:
27         PerfDriver();
28         ~PerfDriver();
29
30         bool getLegacySupport() const { return mLegacySupport; }
31
32         bool setup();
33         bool summary(Buffer *const buffer);
34         bool isSetup() const { return mIsSetup; }
35
36         bool claimCounter(const Counter &counter) const;
37         void resetCounters();
38         void setupCounter(Counter &counter);
39
40         int writeCounters(mxml_node_t *root) const;
41
42         bool enable(PerfGroup *const group, Buffer *const buffer) const;
43
44         static long long getTracepointId(const char *const name, DynBuf *const printb);
45
46 private:
47         PerfCounter *findCounter(const Counter &counter) const;
48         void addCpuCounters(const char *const counterName, const int type, const int numCounters);
49         void addUncoreCounters(const char *const counterName, const int type, const int numCounters);
50
51         PerfCounter *mCounters;
52         bool mIsSetup;
53         bool mLegacySupport;
54
55         // Intentionally undefined
56         PerfDriver(const PerfDriver &);
57         PerfDriver &operator=(const PerfDriver &);
58 };
59
60 #endif // PERFDRIVER_H