blob: a2d0e9b447256db4219a9d21e6fd2bdaabfe223a [file] [log] [blame]
Jon Medhurst15ce78d2014-04-10 09:02:02 +01001/**
Jon Medhurstb1d07442015-05-08 12:04:18 +01002 * Copyright (C) ARM Limited 2013-2015. All rights reserved.
Jon Medhurst15ce78d2014-04-10 09:02:02 +01003 *
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 PERF_BUFFER
10#define PERF_BUFFER
11
12#include "Config.h"
13
14#define BUF_SIZE (gSessionData->mTotalBufferSize * 1024 * 1024)
15#define BUF_MASK (BUF_SIZE - 1)
16
17class Sender;
18
19class PerfBuffer {
20public:
21 PerfBuffer();
22 ~PerfBuffer();
23
Jon Medhurst96b56152014-10-30 18:01:15 +000024 bool useFd(const int cpu, const int fd);
Jon Medhurst15ce78d2014-04-10 09:02:02 +010025 void discard(const int cpu);
26 bool isEmpty();
Jon Medhurstb1d07442015-05-08 12:04:18 +010027 bool isFull();
Jon Medhurst15ce78d2014-04-10 09:02:02 +010028 bool send(Sender *const sender);
29
30private:
31 void *mBuf[NR_CPUS];
32 // After the buffer is flushed it should be unmaped
33 bool mDiscard[NR_CPUS];
Jon Medhurst96b56152014-10-30 18:01:15 +000034 // fd that corresponds to the mBuf
35 int mFds[NR_CPUS];
Jon Medhurst15ce78d2014-04-10 09:02:02 +010036
37 // Intentionally undefined
38 PerfBuffer(const PerfBuffer &);
39 PerfBuffer &operator=(const PerfBuffer &);
40};
41
42#endif // PERF_BUFFER