view ProcrContext.c @ 197:f6d81915512c

update include headers
author Nina Engelhardt <nengel@mailbox.tu-berlin.de>
date Fri, 10 Feb 2012 18:35:00 +0100
parents 50b29548d4f0
children
line source
1 /*
2 * This File contains all hardware dependent C code.
3 */
6 #include "VMS.h"
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;
24 newPr->startOfStack = stackLocs;
25 newPr->procrID = _VMSMasterEnv->numProcrsCreated++;
26 newPr->numTimesScheduled = 0;
27 newPr->initialData = initialData;
28 newPr->requests = NULL;
29 newPr->schedSlot = NULL;
30 newPr->isMasterVP = FALSE;
31 newPr->isShutdownVP = FALSE;
32 /*
33 * Hardware dependent part
34 */
35 //instead of calling the function directly, call a wrapper function to fetch
36 //arguments from stack
37 newPr->nextInstrPt = (VirtProcrFnPtr)&startVirtProcrFn;
39 //fnPtr takes two params -- void *initData & void *animProcr
40 //alloc stack locations, make stackPtr be the highest addr minus room
41 // for 2 params + return addr. Return addr (NULL) is in loc pointed to
42 // by stackPtr, initData at stackPtr + 8 bytes, animatingPr just above
43 stackPtr = ( (void *)stackLocs + VIRT_PROCR_STACK_SIZE - 4*sizeof(void*));
45 //setup __cdecl on stack -- coreloop will switch to stackPtr before jmp
46 *((VirtProcr**)stackPtr + 2 ) = newPr; //rightmost param
47 *((void**)stackPtr + 1 ) = initialData; //next param to left
48 *((void**)stackPtr) = (void*)fnPtr;
50 /*
51 * end of Hardware dependent part
52 */
54 newPr->stackPtr = stackPtr; //core loop will switch to this, then
55 newPr->framePtr = stackPtr; //suspend loop will save new stack & frame ptr
57 //============================= MEASUREMENT STUFF ========================
58 #ifdef STATS__TURN_ON_PROBES
59 //struct timeval timeStamp;
60 //gettimeofday( &(timeStamp), NULL);
61 //newPr->createPtInSecs = timeStamp.tv_sec +(timeStamp.tv_usec/1000000.0) -
62 // _VMSMasterEnv->createPtInSecs;
63 #endif
64 #ifdef MEAS__PERF_COUNTERS
65 /*
66 newPr->counter_history = VMS__malloc(10*sizeof(void*));
67 newPr->counter_history_array_info = makePrivDynArrayInfoFrom((void*)&(newPr->counter_history),10);
68 CounterRecord* newRecord = VMS__malloc(sizeof(CounterRecord));
69 newRecord->task_position = 0;
70 newRecord->vp_id = newPr->procrID;
71 newRecord->addr_of_libcall_for_req = fnPtr;
72 newRecord->sc_done_cycles = 0;
73 newRecord->sc_done_instrs = 0;
74 newRecord->req_cycles = 0;
75 newRecord->req_instrs = 0;
76 addToDynArray( (void*) newRecord, newPr->counter_history_array_info);
77 */
78 #endif
79 //========================================================================
81 return newPr;
82 }