dol: initial dol commit
[jump.git] / dol / src / dol / visitor / cell / lib / spu / WindowedFifo.h
diff --git a/dol/src/dol/visitor/cell/lib/spu/WindowedFifo.h b/dol/src/dol/visitor/cell/lib/spu/WindowedFifo.h
new file mode 100644 (file)
index 0000000..5ef97d9
--- /dev/null
@@ -0,0 +1,60 @@
+#ifndef _WINDOWEDFIFO_H_
+#define _WINDOWEDFIFO_H_
+
+#include <stdio.h>
+#include <string.h>
+
+#include "../constant.h"
+
+#include "../lib/malloc_align.h"
+#include "../lib/free_align.h"
+
+class WindowedFifo {
+    public:
+        WindowedFifo(unsigned size);
+        virtual ~WindowedFifo();
+
+        // Write
+               virtual unsigned reserve(char** destination, unsigned len);
+        virtual void release();
+
+               // Read
+        virtual unsigned capture(char** destination, unsigned len);
+        virtual void consume();
+
+               // General functions
+        virtual unsigned used() const;
+        virtual unsigned unused() const;
+        virtual unsigned size() const;
+
+               // DMA functions
+        virtual char *getQueuePointer();
+        virtual void dmaRead(unsigned len);
+        virtual unsigned dmaStart();
+        virtual bool dmaAllowed();
+               virtual unsigned dmaWrite(const void *source, unsigned len);
+
+               // Global variables
+               unsigned _inTail;
+
+    protected:
+        char *_buffer;          // Pointer to the buffer
+        
+               unsigned _head;         // Current position of the head
+        unsigned _tail;         // Current position of the tail
+        unsigned _headRoom;     // HeadRoom pointer 
+        unsigned _tailRoom;     // Tailroom pointer
+        
+               unsigned _size;         // Total space of the buffer
+        unsigned _use;          // How many data are used in the buffer
+        unsigned _writeReserve; // Number of tokens one is writing
+        unsigned _readReserve;  // Number of tokens one is reading
+        
+               bool _isHeadReserved;   // Head reserved?
+        bool _isTailReserved;   // Tail reserved?
+
+               unsigned _blocked;      // Blocked number the request has to wait
+        bool _activeDMA;        // Is there an active DMA on this buffer
+};
+
+#endif