2 * Copyright (C) ARM Limited 2013-2014. All rights reserved.
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.
14 #include "mxml/mxml.h"
21 DriverCounter(DriverCounter *const next, const char *const name);
22 virtual ~DriverCounter();
24 DriverCounter *getNext() const { return mNext; }
25 const char *getName() const { return mName; }
26 int getKey() const { return mKey; }
27 bool isEnabled() const { return mEnabled; }
28 void setEnabled(const bool enabled) { mEnabled = enabled; }
29 virtual int64_t read() { return -1; }
32 DriverCounter *const mNext;
33 const char *const mName;
37 // Intentionally unimplemented
38 DriverCounter(const DriverCounter &);
39 DriverCounter &operator=(const DriverCounter &);
44 static Driver *getHead() { return head; }
48 // Returns true if this driver can manage the counter
49 virtual bool claimCounter(const Counter &counter) const = 0;
50 // Clears and disables all counters
51 virtual void resetCounters() = 0;
52 // Enables and prepares the counter for capture
53 virtual void setupCounter(Counter &counter) = 0;
55 // Performs any actions needed for setup or based on eventsXML
56 virtual void readEvents(mxml_node_t *const) {}
57 // Emits available counters
58 virtual int writeCounters(mxml_node_t *const root) const = 0;
59 // Emits possible dynamically generated events/counters
60 virtual void writeEvents(mxml_node_t *const) const {}
62 Driver *getNext() const { return next; }
71 // Intentionally unimplemented
72 Driver(const Driver &);
73 Driver &operator=(const Driver &);
76 class SimpleDriver : public Driver {
78 virtual ~SimpleDriver();
80 bool claimCounter(const Counter &counter) const;
81 bool countersEnabled() const;
83 void setupCounter(Counter &counter);
84 int writeCounters(mxml_node_t *root) const;
87 SimpleDriver() : mCounters(NULL) {}
89 DriverCounter *getCounters() const { return mCounters; }
90 void setCounters(DriverCounter *const counter) { mCounters = counter; }
92 DriverCounter *findCounter(const Counter &counter) const;
95 DriverCounter *mCounters;
97 // Intentionally unimplemented
98 SimpleDriver(const SimpleDriver &);
99 SimpleDriver &operator=(const SimpleDriver &);
102 class PolledDriver : public SimpleDriver {
104 virtual ~PolledDriver();
106 virtual void start() {}
107 virtual void read(Buffer *const buffer);
113 // Intentionally unimplemented
114 PolledDriver(const PolledDriver &);
115 PolledDriver &operator=(const PolledDriver &);