diff VMS.c @ 76:9ddbb071142d

make hardware independent and port to 64bit
author Merten Sach <msach@mailbox.tu-berlin.de>
date Thu, 16 Jun 2011 14:41:15 +0200
parents f6990e1ba998
children fe5ec83f1baf
line diff
     1.1 --- a/VMS.c	Thu Jun 02 13:55:51 2011 +0200
     1.2 +++ b/VMS.c	Thu Jun 16 14:41:15 2011 +0200
     1.3 @@ -8,6 +8,7 @@
     1.4  #include <stdlib.h>
     1.5  #include <string.h>
     1.6  #include <malloc.h>
     1.7 +#include <inttypes.h>
     1.8  #include <sys/time.h>
     1.9  
    1.10  #include "VMS.h"
    1.11 @@ -138,7 +139,7 @@
    1.12        readyToAnimateQs[ coreIdx ] = makeVMSQ();
    1.13        
    1.14           //Q: should give masterVP core-specific info as its init data?
    1.15 -      masterVPs[ coreIdx ] = VMS__create_procr( &masterLoop, masterEnv );
    1.16 +      masterVPs[ coreIdx ] = VMS__create_procr( (VirtProcrFnPtr)&masterLoop, (void*)masterEnv );
    1.17        masterVPs[ coreIdx ]->coreAnimatedBy = coreIdx;
    1.18        allSchedSlots[ coreIdx ] = create_sched_slots(); //makes for one core
    1.19        _VMSMasterEnv->numMasterInARow[ coreIdx ] = 0;
    1.20 @@ -175,7 +176,7 @@
    1.21                                                 "master lock high time hist");
    1.22     #endif
    1.23     
    1.24 -   MakeTheMeasHists
    1.25 +   MakeTheMeasHists();
    1.26     //========================================================================
    1.27  
    1.28   }
    1.29 @@ -293,26 +294,38 @@
    1.30   */
    1.31  inline VirtProcr *
    1.32  create_procr_helper( VirtProcr *newPr,       VirtProcrFnPtr  fnPtr,
    1.33 -                     void      *initialData, char           *stackLocs )
    1.34 +                     void      *initialData, void           *stackLocs )
    1.35   {
    1.36 -   char  *stackPtr;
    1.37 +   void  *stackPtr;
    1.38  
    1.39     newPr->startOfStack = stackLocs;
    1.40     newPr->procrID      = _VMSMasterEnv->numProcrsCreated++;
    1.41 -   newPr->nextInstrPt  = fnPtr;
    1.42     newPr->initialData  = initialData;
    1.43     newPr->requests     = NULL;
    1.44     newPr->schedSlot    = NULL;
    1.45  
    1.46 -      //fnPtr takes two params -- void *initData & void *animProcr
    1.47 -      //alloc stack locations, make stackPtr be the highest addr minus room
    1.48 -      // for 2 params + return addr.  Return addr (NULL) is in loc pointed to
    1.49 -      // by stackPtr, initData at stackPtr + 4 bytes, animatingPr just above
    1.50 -   stackPtr = ( (char *)stackLocs + VIRT_PROCR_STACK_SIZE - 0x10 );
    1.51 +   /*
    1.52 +    * Hardware dependent part           
    1.53 +    */
    1.54 +   //instead of calling the function directly, call a wrapper function to fetch
    1.55 +   //arguments from stack
    1.56 +   newPr->nextInstrPt  = (VirtProcrFnPtr)&startVirtProcrFn;
    1.57 +   
    1.58 +    //fnPtr takes two params -- void *initData & void *animProcr
    1.59 +    //alloc stack locations, make stackPtr be the highest addr minus room
    1.60 +    // for 2 params + return addr.  Return addr (NULL) is in loc pointed to
    1.61 +    // by stackPtr, initData at stackPtr + 8 bytes, animatingPr just above
    1.62 +   stackPtr = ( (void *)stackLocs + VIRT_PROCR_STACK_SIZE - 4*sizeof(void*));
    1.63     
    1.64        //setup __cdecl on stack -- coreloop will switch to stackPtr before jmp
    1.65 -   *( (int *)stackPtr + 2 ) = (int) newPr; //rightmost param -- 32bit pointer
    1.66 -   *( (int *)stackPtr + 1 ) = (int) initialData;  //next  param to left
    1.67 +   *((VirtProcr**)stackPtr + 2 ) = newPr; //rightmost param
    1.68 +   *((void**)stackPtr + 1 ) = initialData;  //next  param to left
    1.69 +   *((void**)stackPtr) = (void*)fnPtr;
    1.70 +   
    1.71 +   /*
    1.72 +    * end of Hardware dependent part           
    1.73 +    */
    1.74 +   
    1.75     newPr->stackPtr = stackPtr; //core loop will switch to this, then
    1.76     newPr->framePtr = stackPtr; //suspend loop will save new stack & frame ptr
    1.77  
    1.78 @@ -331,7 +344,7 @@
    1.79  inline VirtProcr *
    1.80  VMS__create_procr( VirtProcrFnPtr fnPtr, void *initialData )
    1.81   { VirtProcr *newPr;
    1.82 -   char      *stackLocs;
    1.83 +   void      *stackLocs;
    1.84  
    1.85     newPr      = VMS__malloc( sizeof(VirtProcr) );
    1.86     stackLocs  = VMS__malloc( VIRT_PROCR_STACK_SIZE );
    1.87 @@ -585,7 +598,6 @@
    1.88                         ResumePrFnPtr resumePrFnPtr )
    1.89   { VMSSemReq     *semReq;
    1.90     IntervalProbe *newProbe;
    1.91 -   int32          nameLen;
    1.92  
    1.93     semReq = req->semReqData;
    1.94