00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef COSYFIFO_H
00012 #define COSYFIFO_H
00013
00014 #include "rte.h"
00015 #include "rtefifo.h"
00016 #include "bqueue.h"
00017 #include "semaphoreapi.h"
00018 #ifdef PREEMPTIVE
00019 #include "mutexapi.h"
00020 #endif
00021
00022 enum FifoMetric
00023 {
00024 MinSize, MaxSize,
00025 Size, Data, Room,
00026 TokensWritten, TokensRead,
00027 WriteCalls, ReadCalls,
00028 TokensPerWrite, TokensPerRead,
00029 TokenSize,
00030 BytesWritten, BytesRead,
00031 PendingWriteTokens, PendingReadTokens,
00032 NeededWriteTokens, NeededReadTokens
00033 };
00034
00035 class cosySelect;
00036
00037 class cosyFifo : public rteFifo
00038 {
00039
00040 public:
00041 cosyFifo(FifoImpl& f, cosyRte& r);
00042
00043 void read(void* p, unsigned int nitems);
00044 void write(const void* p, unsigned int nitems);
00045
00046 unsigned int size() const;
00047 unsigned int data() const;
00048 unsigned int room() const;
00049
00050 private:
00051 cosyRte* rte;
00052
00053 unsigned int minSize;
00054 unsigned int maxSize;
00055
00056 unsigned int countw;
00057 unsigned int countr;
00058 unsigned int wcount;
00059 unsigned int rcount;
00060
00061 static unsigned int defaultMinSize;
00062 static unsigned int defaultMaxSize;
00063 static unsigned int defaultBytes;
00064
00065 static const char* getMetricName(FifoMetric m);
00066 unsigned int getMetricValue(FifoMetric m);
00067
00068 unsigned int calcSize(unsigned int lo, unsigned int hi, unsigned int s);
00069
00070 bool grow();
00071
00072 bqueue q;
00073 char* wp;
00074 char* rp;
00075
00076 unsigned int wn;
00077 unsigned int rn;
00078
00079 unsigned int ws;
00080 unsigned int rs;
00081
00082 bool block;
00083 Semaphore sema;
00084
00085 friend class cosySelect;
00086 cosySelect* sel;
00087
00088 #ifdef PREEMPTIVE
00089 Mutex mutex;
00090 void lock();
00091 void unlock();
00092 #endif
00093
00094 friend class cosyNetwork;
00095 };
00096
00097 #endif