Jon Medhurst | 15ce78d | 2014-04-10 09:02:02 +0100 | [diff] [blame] | 1 | /** |
Jon Medhurst | b1d0744 | 2015-05-08 12:04:18 +0100 | [diff] [blame] | 2 | * Copyright (C) ARM Limited 2013-2015. All rights reserved. |
Jon Medhurst | 15ce78d | 2014-04-10 09:02:02 +0100 | [diff] [blame] | 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 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 | |
| 17 | class Sender; |
| 18 | |
| 19 | class PerfBuffer { |
| 20 | public: |
| 21 | PerfBuffer(); |
| 22 | ~PerfBuffer(); |
| 23 | |
Jon Medhurst | 96b5615 | 2014-10-30 18:01:15 +0000 | [diff] [blame] | 24 | bool useFd(const int cpu, const int fd); |
Jon Medhurst | 15ce78d | 2014-04-10 09:02:02 +0100 | [diff] [blame] | 25 | void discard(const int cpu); |
| 26 | bool isEmpty(); |
Jon Medhurst | b1d0744 | 2015-05-08 12:04:18 +0100 | [diff] [blame] | 27 | bool isFull(); |
Jon Medhurst | 15ce78d | 2014-04-10 09:02:02 +0100 | [diff] [blame] | 28 | bool send(Sender *const sender); |
| 29 | |
| 30 | private: |
| 31 | void *mBuf[NR_CPUS]; |
| 32 | // After the buffer is flushed it should be unmaped |
| 33 | bool mDiscard[NR_CPUS]; |
Jon Medhurst | 96b5615 | 2014-10-30 18:01:15 +0000 | [diff] [blame] | 34 | // fd that corresponds to the mBuf |
| 35 | int mFds[NR_CPUS]; |
Jon Medhurst | 15ce78d | 2014-04-10 09:02:02 +0100 | [diff] [blame] | 36 | |
| 37 | // Intentionally undefined |
| 38 | PerfBuffer(const PerfBuffer &); |
| 39 | PerfBuffer &operator=(const PerfBuffer &); |
| 40 | }; |
| 41 | |
| 42 | #endif // PERF_BUFFER |