X-Git-Url: http://sraa.de/git/?a=blobdiff_plain;f=dol%2Fsrc%2Fdol%2Fvisitor%2Fprotothread%2Flib%2FdolSupport.h;fp=dol%2Fsrc%2Fdol%2Fvisitor%2Fprotothread%2Flib%2FdolSupport.h;h=f07a8047cd1c3427d7ba838d779cb13b7a31ceeb;hb=8c411cf24ed0eb889191aaeafd8fa1e69081df42;hp=0000000000000000000000000000000000000000;hpb=dea7a4fb1ed110d3ce6e6d9255103d724bd66c0e;p=jump.git diff --git a/dol/src/dol/visitor/protothread/lib/dolSupport.h b/dol/src/dol/visitor/protothread/lib/dolSupport.h new file mode 100644 index 0000000..f07a804 --- /dev/null +++ b/dol/src/dol/visitor/protothread/lib/dolSupport.h @@ -0,0 +1,76 @@ +#ifndef DOLSUPPORT_H +#define DOLSUPPORT_H + +#include "dol.h" +#include "ProcessWrapper.h" +#include "Fifo.h" +#include "WindowedFifo.h" +#include "pt.h" + +typedef struct _process_data { + int lc; + ProcessWrapper *wrapper; +} process_data; + + +#define DOL_read(port, buf, size, process) \ + PT_WAIT_UNTIL((pt*)(p->wptr), read(port, buf, size, process) == size); + +#define DOL_write(port, buf, size, process) \ + PT_WAIT_UNTIL((pt*)(p->wptr), write(port, buf, size, process) == size); + +#define DOL_reserve(port, buf, size, process) \ + PT_WAIT_UNTIL((pt*)(p->wptr), reserve(port, (void**)buf, size, process) == size); + +#define DOL_release(port, process) \ + release(port, process); + +#define DOL_capture(port, buf, size, process) \ + PT_WAIT_UNTIL((pt*)(p->wptr), capture(port, (void**)buf, size, process) == size); + +#define DOL_consume(port, process) \ + consume(port, process); + +void DOL_detach(DOLProcess* p); + +//macros to deal with iterated ports +/** + * macro to create a variable to store a port name + * + * @param name name of the variable + */ +#define CREATEPORTVAR(name) static Fifo *name + +/** + * Create the port name of an iterated port based on its basename and the + * given indices. + * + * @param port buffer where the result is stored (created using + * CREATEPORTVAR) + * @param base basename of the port + * @param number_of_indices number of dimensions of the port + * @param index_range_pairs index and range values for each dimension + */ + +#define CREATEPORT(port, base, number_of_indices, index_range_pairs...) \ + createPort((void**)(&port), base, number_of_indices, index_range_pairs) + +#define GETINDEX(dimension) \ + static_cast((static_cast(p->wptr))->wrapper)->getIndex(dimension) + +void createPort(void** port, void* base, int number_of_indices, int index0, int range0); +void createPort(void** port, void* base, int number_of_indices, int index0, int range0, int index1, int range1); +void createPort(void** port, void* base, int number_of_indices, int index0, int range0, int index1, int range1, int index2, int range2); +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); + +//fifo access functions +unsigned write(void* fifo, void* buf, unsigned len, DOLProcess* p); +unsigned read(void* fifo, void* buf, unsigned len, DOLProcess* p); + +//windowed fifo access functions +unsigned reserve(void* fifo, void** destination, unsigned len, DOLProcess* p); +void release(void* fifo, DOLProcess* p); +unsigned capture(void* fifo, void** destination, unsigned len, DOLProcess* p); +void consume(void* fifo, DOLProcess* p); + +#endif