dol: initial dol commit
[jump.git] / dol / src / dol / visitor / cell / lib / ppu / WindowedFifo.h
diff --git a/dol/src/dol/visitor/cell/lib/ppu/WindowedFifo.h b/dol/src/dol/visitor/cell/lib/ppu/WindowedFifo.h
new file mode 100644 (file)
index 0000000..2e94c46
--- /dev/null
@@ -0,0 +1,61 @@
+#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(void** destination, unsigned len);
+        virtual void release();
+
+        // Read
+               virtual unsigned capture(void** destination, unsigned len);
+        virtual void consume();
+
+               // General FIFO 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;
+        
+               unsigned _head;
+        unsigned _tail;
+        unsigned _headRoom;
+        unsigned _tailRoom;
+        
+               unsigned _size;
+        unsigned _use; 
+               
+               unsigned _writeReserve;  
+        unsigned _readReserve; 
+        
+               bool _isHeadReserved;
+        bool _isTailReserved;
+
+               unsigned _blocked;      // Blocked number the request has to wait
+        bool _activeDMA;        // Is there an active DMA on this buffer
+
+};
+
+#endif