diff options
author | Pawel Moll <pawel.moll@arm.com> | 2011-09-30 11:57:10 +0100 |
---|---|---|
committer | Pawel Moll <pawel.moll@arm.com> | 2011-10-04 10:34:25 +0100 |
commit | 8fc69a3638ca8d08111c161b1487868cb42cd888 (patch) | |
tree | fd55a22f7a950d1d625efdad8553e719c0fa7db5 /daemon/Fifo.h | |
parent | 3f0b05d287e7df2160ea80f14c69444b73b74ed8 (diff) |
gator-daemon: ARM DS-5.7 Streamline gator daemon sourcesDS-5.7
Signed-off-by: Pawel Moll <pawel.moll@arm.com>
Diffstat (limited to 'daemon/Fifo.h')
-rw-r--r-- | daemon/Fifo.h | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/daemon/Fifo.h b/daemon/Fifo.h new file mode 100644 index 0000000..02372d5 --- /dev/null +++ b/daemon/Fifo.h @@ -0,0 +1,41 @@ +/** + * Copyright (C) ARM Limited 2010-2011. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#ifndef __FIFO_H__ +#define __FIFO_H__ + +#include <semaphore.h> + +// Driver buffer size is 512k, large buffer mode with 2GB of total RAM will allocate 256M +#define FIFO_BUFFER_LIMIT 256*1024/512 + +class Fifo { +public: + Fifo(int numBuffers, int bufferSize); + ~Fifo(); + int depth(void); + int numReadToWriteBuffersFilled(); + int numWriteToReadBuffersFilled(); + int numReadToWriteBuffersEmpty() {return depth() - numReadToWriteBuffersFilled();} + int numWriteToReadBuffersEmpty() {return depth() - numWriteToReadBuffersFilled();} + char* start(); + char* write(int length); + char* read(int* length); + +private: + int mNumBuffers; + int mBufferSize; + int mWriteCurrent; + int mReadCurrent; + sem_t mReadToWriteSem[FIFO_BUFFER_LIMIT]; + sem_t mWriteToReadSem[FIFO_BUFFER_LIMIT]; + char* mBuffer[FIFO_BUFFER_LIMIT]; + int mLength[FIFO_BUFFER_LIMIT]; +}; + +#endif //__FIFO_H__ |