X-Git-Url: http://sraa.de/git/?a=blobdiff_plain;f=dol%2Fsrc%2Fdol%2Fvisitor%2Fhds%2Flib%2FdolSupport.cpp;fp=dol%2Fsrc%2Fdol%2Fvisitor%2Fhds%2Flib%2FdolSupport.cpp;h=1db732abe97e1dcfc47b9338c34f4fd4d6d31c3a;hb=8c411cf24ed0eb889191aaeafd8fa1e69081df42;hp=0000000000000000000000000000000000000000;hpb=dea7a4fb1ed110d3ce6e6d9255103d724bd66c0e;p=jump.git diff --git a/dol/src/dol/visitor/hds/lib/dolSupport.cpp b/dol/src/dol/visitor/hds/lib/dolSupport.cpp new file mode 100644 index 0000000..1db732a --- /dev/null +++ b/dol/src/dol/visitor/hds/lib/dolSupport.cpp @@ -0,0 +1,149 @@ +#include "dolSupport.h" +#include "ProcessWrapper.h" + +/** + * + */ +unsigned write(void *port, void *buf, unsigned len, DOLProcess *process) +{ + Fifo *fifo = static_cast(port); + char *str = static_cast(buf); + #ifdef INCLUDE_PROFILER + (static_cast(process->wptr))->addToProfile( + "w", port, len); + #endif + fifo->write((void*)str, len); + #ifdef INCLUDE_TRACE + strcpy((static_cast(process->wptr))->channel_name, + fifo->getName()); + #endif + return len; +} + + +/** + * + */ +unsigned read(void *port, void *buf, unsigned len, DOLProcess *process) { + Fifo *fifo = static_cast(port); + char *str = static_cast(buf); + #ifdef INCLUDE_PROFILER + (static_cast(process->wptr))->addToProfile( + "r", port, len); + #endif + fifo->read((void*)str, len); + #ifdef INCLUDE_TRACE + strcpy((static_cast(process->wptr))->channel_name, + fifo->getName()); + #endif + return len; +} + + +/** + * + */ +int wtest(void *port, unsigned len, DOLProcess *process) { + Fifo *fifo = static_cast(port); + return (fifo->unused() >= len) ? 1 : 0; +} + + +/** + * + */ +int rtest(void *port, unsigned len, DOLProcess *process) { + Fifo *fifo = static_cast(port); + return (fifo->used() >= len) ? 1 : 0; +} + + +/** + * + */ +unsigned reserve(void* fifo, void** destination, unsigned len, DOLProcess* p) { + return ((WindowedFifo*)fifo)->reserve(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(destination, len); +} + +/** + * + */ +void consume(void* fifo, DOLProcess* p) { + ((WindowedFifo*)fifo)->consume(); +} + + +/** + * + */ +void DOL_detach(DOLProcess* p) { + static_cast(p->wptr)->detach(); +} + + +/** + * + */ +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]; +}