annotate SimParams.c @ 26:0deed3ee0b02

update comments for public viewing
author kshalle
date Wed, 25 Feb 2015 15:20:16 -0800
parents fa277c6ce6f2
children
rev   line source
kshalle@26 1 /*
kshalle@26 2 * Copyright 2009 OpenSourceResearchInstitute.org
kshalle@26 3 * Licensed under GNU General Public License version 2
kshalle@26 4 *
kshalle@26 5 * Author: seanhalle@yahoo.com
kshalle@26 6 *
kshalle@26 7 * Created on November 15, 2009, 2:35 AM
kshalle@26 8 */
kshalle@26 9
kshalle@26 10
kshalle@26 11 #include <malloc.h>
kshalle@26 12 #include <stdlib.h>
kshalle@26 13
kshalle@26 14
kshalle@26 15 #include "SimParams.h"
kshalle@26 16
kshalle@26 17
kshalle@26 18 uint8 *
kshalle@26 19 read_Machine_Code_From_File( int numBytesInFile, char *machineCodeFileName );
kshalle@26 20
kshalle@26 21
kshalle@26 22 void
kshalle@26 23 fill_sim_params_from_bag( SimulationParams *simParams, ParamBag *paramBag )
kshalle@26 24 { char *guestAppFileName, *systemCodeFileName;
kshalle@26 25 int numBytesInGuestApp, numBytesInSystemCode;
kshalle@26 26
kshalle@26 27 ParamStruc *param;
kshalle@26 28
kshalle@26 29 param = getParamFromBag( "GuestApplicationFileName", paramBag );
kshalle@26 30 guestAppFileName = param->strValue;
kshalle@26 31
kshalle@26 32 param = getParamFromBag( "numBytesInGuestApp", paramBag );
kshalle@26 33 numBytesInGuestApp = param->intValue;
kshalle@26 34
kshalle@26 35 simParams->guestApp =
kshalle@26 36 read_Machine_Code_From_File( numBytesInGuestApp, guestAppFileName );
kshalle@26 37
kshalle@26 38 param = getParamFromBag( "SystemCodeFileName", paramBag );
kshalle@26 39 systemCodeFileName = param->strValue;
kshalle@26 40
kshalle@26 41 param = getParamFromBag( "numBytesInSystemCode", paramBag );
kshalle@26 42 numBytesInSystemCode = param->intValue;
kshalle@26 43
kshalle@26 44 simParams->systemCode =
kshalle@26 45 read_Machine_Code_From_File( numBytesInSystemCode, systemCodeFileName );
kshalle@26 46
kshalle@26 47 param = getParamFromBag( "numNodes", paramBag );
kshalle@26 48 simParams->numNodes = param->intValue;
kshalle@26 49 }
kshalle@26 50
kshalle@26 51
kshalle@26 52 uint8 *
kshalle@26 53 read_Machine_Code_From_File( int numBytesInFile, char *machineCodeFileName )
kshalle@26 54 { int byte;
kshalle@26 55 FILE *file;
kshalle@26 56 char *machineCode = malloc( numBytesInFile );
kshalle@26 57 if( machineCode == NULL ) printf( "\nno mem for machine code\n" );
kshalle@26 58
kshalle@26 59 file = fopen( machineCodeFileName, "r" );
kshalle@26 60 if( file == NULL ) { printf( "\nCouldn't open file!!\n"); exit(1);}
kshalle@26 61
kshalle@26 62 fseek( file, 0, SEEK_SET );
kshalle@26 63 for( byte = 0; byte < numBytesInFile; byte++ )
kshalle@26 64 {
kshalle@26 65 if( feof( file ) ) printf( "file ran out too soon" );
kshalle@26 66 // machineCode[byte] = getchar( file );
kshalle@26 67 }
kshalle@26 68 return machineCode;
kshalle@26 69 }
kshalle@26 70
kshalle@26 71
kshalle@26 72 //==========================================================================
kshalle@26 73 void
kshalle@26 74 printSimResults( SimulationResults simResults )
kshalle@26 75 {
kshalle@26 76 }
kshalle@26 77