Mercurial > cgi-bin > hgwebdir.cgi > VMS > VMS_Implementations > VMS_impls > VMS__MC_shared_impl
diff 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 |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/ProcrContext.c Wed Jun 22 16:12:27 2011 +0200 1.3 @@ -0,0 +1,65 @@ 1.4 +/* 1.5 + * This File contains all hardware dependent C code. 1.6 + */ 1.7 + 1.8 + 1.9 +#include "VMS.h" 1.10 + 1.11 +/*Create stack, then create __cdecl structure on it and put initialData and 1.12 + * pointer to the new structure instance into the parameter positions on 1.13 + * the stack 1.14 + *Then put function pointer into nextInstrPt -- the stack is setup in std 1.15 + * call structure, so jumping to function ptr is same as a GCC generated 1.16 + * function call 1.17 + *No need to save registers on old stack frame, because there's no old 1.18 + * animator state to return to -- 1.19 + * 1.20 + */ 1.21 +inline VirtProcr * 1.22 +create_procr_helper( VirtProcr *newPr, VirtProcrFnPtr fnPtr, 1.23 + void *initialData, void *stackLocs ) 1.24 + { 1.25 + void *stackPtr; 1.26 + 1.27 + newPr->startOfStack = stackLocs; 1.28 + newPr->procrID = _VMSMasterEnv->numProcrsCreated++; 1.29 + newPr->initialData = initialData; 1.30 + newPr->requests = NULL; 1.31 + newPr->schedSlot = NULL; 1.32 + 1.33 + /* 1.34 + * Hardware dependent part 1.35 + */ 1.36 + //instead of calling the function directly, call a wrapper function to fetch 1.37 + //arguments from stack 1.38 + newPr->nextInstrPt = (VirtProcrFnPtr)&startVirtProcrFn; 1.39 + 1.40 + //fnPtr takes two params -- void *initData & void *animProcr 1.41 + //alloc stack locations, make stackPtr be the highest addr minus room 1.42 + // for 2 params + return addr. Return addr (NULL) is in loc pointed to 1.43 + // by stackPtr, initData at stackPtr + 8 bytes, animatingPr just above 1.44 + stackPtr = ( (void *)stackLocs + VIRT_PROCR_STACK_SIZE - 4*sizeof(void*)); 1.45 + 1.46 + //setup __cdecl on stack -- coreloop will switch to stackPtr before jmp 1.47 + *((VirtProcr**)stackPtr + 2 ) = newPr; //rightmost param 1.48 + *((void**)stackPtr + 1 ) = initialData; //next param to left 1.49 + *((void**)stackPtr) = (void*)fnPtr; 1.50 + 1.51 + /* 1.52 + * end of Hardware dependent part 1.53 + */ 1.54 + 1.55 + newPr->stackPtr = stackPtr; //core loop will switch to this, then 1.56 + newPr->framePtr = stackPtr; //suspend loop will save new stack & frame ptr 1.57 + 1.58 + //============================= MEASUREMENT STUFF ======================== 1.59 + #ifdef STATS__TURN_ON_PROBES 1.60 + struct timeval timeStamp; 1.61 + gettimeofday( &(timeStamp), NULL); 1.62 + newPr->createPtInSecs = timeStamp.tv_sec +(timeStamp.tv_usec/1000000.0) - 1.63 + _VMSMasterEnv->createPtInSecs; 1.64 + #endif 1.65 + //======================================================================== 1.66 + 1.67 + return newPr; 1.68 + } 1.69 \ No newline at end of file
