X-Git-Url: http://sraa.de/git/?a=blobdiff_plain;f=dol%2Fsrc%2Fdol%2Fvisitor%2Fcell%2Flib%2Fspu%2FdolSupport.cpp;fp=dol%2Fsrc%2Fdol%2Fvisitor%2Fcell%2Flib%2Fspu%2FdolSupport.cpp;h=4bf2b6e93fe3e4c0f91f72084472f5f794ff5812;hb=8c411cf24ed0eb889191aaeafd8fa1e69081df42;hp=0000000000000000000000000000000000000000;hpb=dea7a4fb1ed110d3ce6e6d9255103d724bd66c0e;p=jump.git diff --git a/dol/src/dol/visitor/cell/lib/spu/dolSupport.cpp b/dol/src/dol/visitor/cell/lib/spu/dolSupport.cpp new file mode 100644 index 0000000..4bf2b6e --- /dev/null +++ b/dol/src/dol/visitor/cell/lib/spu/dolSupport.cpp @@ -0,0 +1,98 @@ +#include "dolSupport.h" + +/** + * + */ +unsigned read(void* fifo, void* buf, unsigned len, DOLProcess* p) { + unsigned int + pos = + static_cast ((static_cast (p->wptr))->wrapper)->readPos; + pos += ((Fifo*) fifo)->read((char *) buf + pos, len - pos); + + if (pos == len) + static_cast ((static_cast (p->wptr))->wrapper)->readPos + = 0; + else + static_cast ((static_cast (p->wptr))->wrapper)->readPos + = pos; + return pos; +} + +/** + * + */ +unsigned write(void* fifo, void* buf, unsigned len, DOLProcess* p) { + unsigned int + pos = + static_cast ((static_cast (p->wptr))->wrapper)->writePos; + pos += ((Fifo*) fifo)->write((char *) buf + pos, len - pos); + + if (pos == len) + static_cast ((static_cast (p->wptr))->wrapper)->writePos + = 0; + else + static_cast ((static_cast (p->wptr))->wrapper)->writePos + = pos; + return pos; +} + +/** + * + */ +void DOL_detach(DOLProcess* p) { + static_cast ((static_cast (p->wptr))->wrapper)->detach(); +} + +/** + * + */ +unsigned reserve(void* fifo, void** destination, unsigned len, + DOLProcess* p) { + return ((WindowedFifo*) fifo)->reserve((char **) destination, len); +} + +/** + * + */ +void release(void* fifo, DOLProcess* p) { + ((WindowedFifo*) fifo)->release(); +} + +/** + * + */ +unsigned capture(void* fifo, void** destination, unsigned len, + DOLProcess* p) { + return ((WindowedFifo*) fifo)->capture((char **) destination, len); +} + +/** + * + */ +void consume(void* fifo, DOLProcess* p) { + ((WindowedFifo*) fifo)->consume(); +} + +void createPort(void** port, void* base, int number_of_indices, + int index0, int range0) { + *port = (void**) ((void**) base)[index0]; +} + +void createPort(void** port, void* base, int number_of_indices, + int index0, int range0, int index1, int range1) { + *port = (void**) ((void**) base)[index0 * range1 + index1]; +} + +void createPort(void** port, void* base, int number_of_indices, + int index0, int range0, int index1, int range1, int index2, + int range2) { + *port = (void**) ((void**) base)[index0 * range1 * range2 + index1 + * range2 + index2]; +} + +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) { + *port = (void**) ((void**) base)[index0 * range1 * range2 * range3 + + index1 * range2 * range3 + index2 * range3 + index3]; +}