Mercurial > cgi-bin > hgwebdir.cgi > VMS > VMS_Implementations > VMS_impls > VMS__MC_shared_impl
comparison ProcrContext.c @ 77:fe5ec83f1baf
separated hardware dependent code
| author | Merten Sach <msach@mailbox.tu-berlin.de> |
|---|---|
| date | Wed, 22 Jun 2011 16:12:27 +0200 |
| parents | |
| children | 521c75d64cef |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:e6029b4269b3 |
|---|---|
| 1 /* | |
| 2 * This File contains all hardware dependent C code. | |
| 3 */ | |
| 4 | |
| 5 | |
| 6 #include "VMS.h" | |
| 7 | |
| 8 /*Create stack, then create __cdecl structure on it and put initialData and | |
| 9 * pointer to the new structure instance into the parameter positions on | |
| 10 * the stack | |
| 11 *Then put function pointer into nextInstrPt -- the stack is setup in std | |
| 12 * call structure, so jumping to function ptr is same as a GCC generated | |
| 13 * function call | |
| 14 *No need to save registers on old stack frame, because there's no old | |
| 15 * animator state to return to -- | |
| 16 * | |
| 17 */ | |
| 18 inline VirtProcr * | |
| 19 create_procr_helper( VirtProcr *newPr, VirtProcrFnPtr fnPtr, | |
| 20 void *initialData, void *stackLocs ) | |
| 21 { | |
| 22 void *stackPtr; | |
| 23 | |
| 24 newPr->startOfStack = stackLocs; | |
| 25 newPr->procrID = _VMSMasterEnv->numProcrsCreated++; | |
| 26 newPr->initialData = initialData; | |
| 27 newPr->requests = NULL; | |
| 28 newPr->schedSlot = NULL; | |
| 29 | |
| 30 /* | |
| 31 * Hardware dependent part | |
| 32 */ | |
| 33 //instead of calling the function directly, call a wrapper function to fetch | |
| 34 //arguments from stack | |
| 35 newPr->nextInstrPt = (VirtProcrFnPtr)&startVirtProcrFn; | |
| 36 | |
| 37 //fnPtr takes two params -- void *initData & void *animProcr | |
| 38 //alloc stack locations, make stackPtr be the highest addr minus room | |
| 39 // for 2 params + return addr. Return addr (NULL) is in loc pointed to | |
| 40 // by stackPtr, initData at stackPtr + 8 bytes, animatingPr just above | |
| 41 stackPtr = ( (void *)stackLocs + VIRT_PROCR_STACK_SIZE - 4*sizeof(void*)); | |
| 42 | |
| 43 //setup __cdecl on stack -- coreloop will switch to stackPtr before jmp | |
| 44 *((VirtProcr**)stackPtr + 2 ) = newPr; //rightmost param | |
| 45 *((void**)stackPtr + 1 ) = initialData; //next param to left | |
| 46 *((void**)stackPtr) = (void*)fnPtr; | |
| 47 | |
| 48 /* | |
| 49 * end of Hardware dependent part | |
| 50 */ | |
| 51 | |
| 52 newPr->stackPtr = stackPtr; //core loop will switch to this, then | |
| 53 newPr->framePtr = stackPtr; //suspend loop will save new stack & frame ptr | |
| 54 | |
| 55 //============================= MEASUREMENT STUFF ======================== | |
| 56 #ifdef STATS__TURN_ON_PROBES | |
| 57 struct timeval timeStamp; | |
| 58 gettimeofday( &(timeStamp), NULL); | |
| 59 newPr->createPtInSecs = timeStamp.tv_sec +(timeStamp.tv_usec/1000000.0) - | |
| 60 _VMSMasterEnv->createPtInSecs; | |
| 61 #endif | |
| 62 //======================================================================== | |
| 63 | |
| 64 return newPr; | |
| 65 } |
