4 * Created on: Feb 27, 2009
9 #include "@PROCESSNAME@Wrapper.h"
10 #include "../lib/spu/dolSupport.h"
12 #include "@PROCESSNAME@.c"
14 @PROCESSNAME@Wrapper::@PROCESSNAME@Wrapper(uint64_t argp) {
17 if((tag_id=mfc_tag_reserve())==MFC_TAG_INVALID){
18 printf("SPE: ERROR - can't reserve a tag ID\n"); return;
21 // Get the context information for the whole system
22 mfc_get((void*) &ctx_proc, argp, sizeof(ctx_proc), tag_id, 0, 0);
23 mfc_write_tag_mask(1<<tag_id);
24 mfc_read_tag_status_all();
26 this->name = (char *)_malloc_align((uint32_t)ctx_proc.processNameLen, 4);
28 fprintf(stderr,"[SPUProcessWrapper] Memory allocation failure\n");
31 mfc_get((void *)this->name, ctx_proc.processName, ctx_proc.processNameLen, tag_id, 0, 0);
35 //initialize the index array
36 for (int i = 0; i < 4; i++) {
37 this->_iteratorIndex[i] = getIndex(this->name, "_", i);
40 try { _state = (LocalState) new @PROCESSNAME_UPPER@_State; }
41 catch(std::bad_alloc &e) {
42 fprintf(stderr, "[SPUProcessWrapper] Memory allocation failure\n");
45 _process.local = _state;
46 _process.init = @PROCESSNAME@_init;
47 _process.fire = @PROCESSNAME@_fire;
48 _process.wptr = (void*)&_wrapper_data;
50 _wrapper_data.wrapper = this;
53 _process.init(&_process);
55 // release tag ID before exiting
56 mfc_tag_release(tag_id);
59 @PROCESSNAME@Wrapper::~@PROCESSNAME@Wrapper() {
62 delete (@PROCESSNAME_UPPER@_State*) _state;
64 // Free the name of the wrapper
65 _free_align(this->name);