dol: initial dol commit
[jump.git] / dol / src / dol / visitor / cell / lib / ppu / dolSupport.h
diff --git a/dol/src/dol/visitor/cell/lib/ppu/dolSupport.h b/dol/src/dol/visitor/cell/lib/ppu/dolSupport.h
new file mode 100644 (file)
index 0000000..14a1c55
--- /dev/null
@@ -0,0 +1,78 @@
+#ifndef DOLSUPPORT_H\r
+#define DOLSUPPORT_H\r
+\r
+#include "dol.h"\r
+#include "pt.h"\r
+\r
+#include "ProcessWrapper.h"\r
+\r
+#include "Fifo.h"\r
+#include "WindowedFifo.h"\r
+\r
+typedef struct _process_data {\r
+    int lc;\r
+    ProcessWrapper *wrapper;\r
+} process_data;\r
+\r
+\r
+#define DOL_read(port, buf, size, process) \\r
+    PT_WAIT_UNTIL((pt*)(p->wptr), read(port, buf, size, process) == size);\r
+\r
+#define DOL_write(port, buf, size, process) \\r
+    PT_WAIT_UNTIL((pt*)(p->wptr), write(port, buf, size, process) == size);\r
+\r
+#define DOL_reserve(port, buf, size, process) \\r
+    PT_WAIT_UNTIL((pt*)(p->wptr), reserve(port, (void**)buf, size, process) == size);\r
+\r
+#define DOL_release(port, process) \\r
+    release(port, process);\r
+\r
+#define DOL_capture(port, buf, size, process) \\r
+    PT_WAIT_UNTIL((pt*)(p->wptr), capture(port, (void**)buf, size, process) == size);\r
+\r
+#define DOL_consume(port, process) \\r
+    consume(port, process);\r
+\r
+void DOL_detach(DOLProcess* p);\r
+\r
+//macros to deal with iterated ports\r
+/**\r
+ * macro to create a variable to store a port name\r
+ *\r
+ * @param name name of the variable\r
+ */\r
+#define CREATEPORTVAR(name) static Fifo *name\r
+\r
+/**\r
+ * Create the port name of an iterated port based on its basename and the\r
+ * given indices.\r
+ *\r
+ * @param port buffer where the result is stored (created using\r
+ *             CREATEPORTVAR)\r
+ * @param base basename of the port\r
+ * @param number_of_indices number of dimensions of the port\r
+ * @param index_range_pairs index and range values for each dimension\r
+ */\r
+\r
+#define CREATEPORT(port, base, number_of_indices, index_range_pairs...) \\r
+  createPort((void**)(&port), base, number_of_indices, index_range_pairs)\r
+\r
+#define GETINDEX(dimension) \\r
+  static_cast<ProcessWrapper *>((static_cast<process_data *>(p->wptr))->wrapper)->getIndex(dimension)\r
+\r
+void createPort(void** port, void* base, int number_of_indices, int index0, int range0);\r
+void createPort(void** port, void* base, int number_of_indices, int index0, int range0, int index1, int range1);\r
+void createPort(void** port, void* base, int number_of_indices, int index0, int range0, int index1, int range1, int index2, int range2);\r
+void createPort(void** port, void* base, int number_of_indices, int index0, int range0, int index1, int range1, int index2, int range2, int index3, int range3);\r
+\r
+//fifo access functions\r
+unsigned write(void* fifo, void* buf, unsigned len, DOLProcess* p);\r
+unsigned read(void* fifo, void* buf, unsigned len, DOLProcess* p);\r
+\r
+//windowed fifo access functions\r
+unsigned reserve(void* fifo, void** destination, unsigned len, DOLProcess* p);\r
+void release(void* fifo, DOLProcess* p);\r
+unsigned capture(void* fifo, void** destination, unsigned len, DOLProcess* p);\r
+void consume(void* fifo, DOLProcess* p);\r
+\r
+#endif\r