X-Git-Url: http://sraa.de/git/?a=blobdiff_plain;f=dol%2Fsrc%2Fdol%2Fvisitor%2Fcell%2Ftemplate%2Fspu_process_wrapper_template.cpp;fp=dol%2Fsrc%2Fdol%2Fvisitor%2Fcell%2Ftemplate%2Fspu_process_wrapper_template.cpp;h=ebb1f4ce02779c7305989a70b138b19a9b9eba22;hb=8c411cf24ed0eb889191aaeafd8fa1e69081df42;hp=0000000000000000000000000000000000000000;hpb=dea7a4fb1ed110d3ce6e6d9255103d724bd66c0e;p=jump.git diff --git a/dol/src/dol/visitor/cell/template/spu_process_wrapper_template.cpp b/dol/src/dol/visitor/cell/template/spu_process_wrapper_template.cpp new file mode 100644 index 0000000..ebb1f4c --- /dev/null +++ b/dol/src/dol/visitor/cell/template/spu_process_wrapper_template.cpp @@ -0,0 +1,66 @@ +/* + * Square_wrapper.cpp + * + * Created on: Feb 27, 2009 + * Author: lschor + */ + + +#include "@PROCESSNAME@Wrapper.h" +#include "../lib/spu/dolSupport.h" + +#include "@PROCESSNAME@.c" + +@PROCESSNAME@Wrapper::@PROCESSNAME@Wrapper(uint64_t argp) { + // reserve DMA tag ID + uint32_t tag_id; + if((tag_id=mfc_tag_reserve())==MFC_TAG_INVALID){ + printf("SPE: ERROR - can't reserve a tag ID\n"); return; + } + + // Get the context information for the whole system + mfc_get((void*) &ctx_proc, argp, sizeof(ctx_proc), tag_id, 0, 0); + mfc_write_tag_mask(1<name = (char *)_malloc_align((uint32_t)ctx_proc.processNameLen, 4); + if(!this->name) { + fprintf(stderr,"[SPUProcessWrapper] Memory allocation failure\n"); + exit(-1); + } + mfc_get((void *)this->name, ctx_proc.processName, ctx_proc.processNameLen, tag_id, 0, 0); + waittag(tag_id); + + + //initialize the index array + for (int i = 0; i < 4; i++) { + this->_iteratorIndex[i] = getIndex(this->name, "_", i); + } + + try { _state = (LocalState) new @PROCESSNAME_UPPER@_State; } + catch(std::bad_alloc &e) { + fprintf(stderr, "[SPUProcessWrapper] Memory allocation failure\n"); + exit(-1); + } + _process.local = _state; + _process.init = @PROCESSNAME@_init; + _process.fire = @PROCESSNAME@_fire; + _process.wptr = (void*)&_wrapper_data; + + _wrapper_data.wrapper = this; + + // Init the process + _process.init(&_process); + + // release tag ID before exiting + mfc_tag_release(tag_id); +} + +@PROCESSNAME@Wrapper::~@PROCESSNAME@Wrapper() { + // Free the state + if (_state) + delete (@PROCESSNAME_UPPER@_State*) _state; + + // Free the name of the wrapper + _free_align(this->name); +}