msach@77: /* msach@77: * This File contains all hardware dependent C code. msach@77: */ msach@77: msach@77: msach@77: #include "VMS.h" msach@77: msach@77: /*Create stack, then create __cdecl structure on it and put initialData and msach@77: * pointer to the new structure instance into the parameter positions on msach@77: * the stack msach@77: *Then put function pointer into nextInstrPt -- the stack is setup in std msach@77: * call structure, so jumping to function ptr is same as a GCC generated msach@77: * function call msach@77: *No need to save registers on old stack frame, because there's no old msach@77: * animator state to return to -- msach@77: * msach@77: */ msach@77: inline VirtProcr * msach@77: create_procr_helper( VirtProcr *newPr, VirtProcrFnPtr fnPtr, msach@77: void *initialData, void *stackLocs ) msach@77: { msach@77: void *stackPtr; msach@77: msach@77: newPr->startOfStack = stackLocs; msach@77: newPr->procrID = _VMSMasterEnv->numProcrsCreated++; msach@77: newPr->initialData = initialData; msach@77: newPr->requests = NULL; msach@77: newPr->schedSlot = NULL; msach@77: msach@77: /* msach@77: * Hardware dependent part msach@77: */ msach@77: //instead of calling the function directly, call a wrapper function to fetch msach@77: //arguments from stack msach@77: newPr->nextInstrPt = (VirtProcrFnPtr)&startVirtProcrFn; msach@77: msach@77: //fnPtr takes two params -- void *initData & void *animProcr msach@77: //alloc stack locations, make stackPtr be the highest addr minus room msach@77: // for 2 params + return addr. Return addr (NULL) is in loc pointed to msach@77: // by stackPtr, initData at stackPtr + 8 bytes, animatingPr just above msach@77: stackPtr = ( (void *)stackLocs + VIRT_PROCR_STACK_SIZE - 4*sizeof(void*)); msach@77: msach@77: //setup __cdecl on stack -- coreloop will switch to stackPtr before jmp msach@77: *((VirtProcr**)stackPtr + 2 ) = newPr; //rightmost param msach@77: *((void**)stackPtr + 1 ) = initialData; //next param to left msach@77: *((void**)stackPtr) = (void*)fnPtr; msach@77: msach@77: /* msach@77: * end of Hardware dependent part msach@77: */ msach@77: msach@77: newPr->stackPtr = stackPtr; //core loop will switch to this, then msach@77: newPr->framePtr = stackPtr; //suspend loop will save new stack & frame ptr msach@77: msach@77: //============================= MEASUREMENT STUFF ======================== msach@77: #ifdef STATS__TURN_ON_PROBES msach@78: //struct timeval timeStamp; msach@78: //gettimeofday( &(timeStamp), NULL); msach@78: //newPr->createPtInSecs = timeStamp.tv_sec +(timeStamp.tv_usec/1000000.0) - msach@78: // _VMSMasterEnv->createPtInSecs; msach@77: #endif Nina@109: #ifdef MEAS__PERF_COUNTERS Nina@109: newPr->counter_history = VMS__malloc(10*sizeof(void*)); Nina@129: newPr->counter_history_array_info = makePrivDynArrayInfoFrom((void*)&(newPr->counter_history),10); Nina@109: CounterRecord* newRecord = VMS__malloc(sizeof(CounterRecord)); Nina@111: newRecord->task_position = 0; Nina@112: newRecord->vp_id = newPr->procrID; Nina@112: newRecord->addr_of_libcall_for_req = fnPtr; Nina@165: newRecord->sc_done_cycles = 0; Nina@165: newRecord->sc_done_instrs = 0; Nina@165: newRecord->req_cycles = 0; Nina@165: newRecord->req_instrs = 0; Nina@109: addToDynArray( (void*) newRecord, newPr->counter_history_array_info); Nina@109: #endif msach@77: //======================================================================== msach@77: msach@77: return newPr; msach@77: }