Me@1: /* Me@1: Me@1: * Copyright 2009 OpenSourceStewardshipFoundation.org Me@1: Me@1: * Licensed under GNU General Public License version 2 Me@1: Me@1: * Me@1: Me@1: * Author: seanhalle@yahoo.com Me@1: Me@1: * Me@1: Me@1: * Created on November 15, 2009, 2:35 AM Me@1: Me@1: */ Me@1: Me@1: Me@1: Me@1: #include Me@1: Me@1: #include Me@1: Me@1: Me@1: Me@1: #include "SimParams.h" Me@1: Me@1: #include "ParamHelper/Param.h" Me@1: Me@1: Me@1: Me@1: Me@1: Me@1: uint8 * Me@1: Me@1: read_Machine_Code_From_File( int numBytesInFile, char *machineCodeFileName ); Me@1: Me@1: Me@1: Me@1: Me@1: Me@1: void Me@1: Me@1: fill_sim_params_from_bag( SimulationParams *simParams, ParamBag *paramBag ) Me@1: Me@1: { char *guestAppFileName, *systemCodeFileName; Me@1: Me@1: int numBytesInGuestApp, numBytesInSystemCode; Me@1: Me@1: Me@1: Me@1: ParamStruc *param; Me@1: Me@1: param = getParamFromBag( "GuestApplicationFileName", paramBag ); Me@1: Me@1: guestAppFileName = param->strValue; Me@1: Me@1: param = getParamFromBag( "numBytesInGuestApp", paramBag ); Me@1: Me@1: numBytesInGuestApp = param->intValue; Me@1: Me@1: Me@1: Me@1: simParams->guestApp = Me@1: Me@1: read_Machine_Code_From_File( numBytesInGuestApp, guestAppFileName ); Me@1: Me@1: Me@1: Me@1: param = getParamFromBag( "SystemCodeFileName", paramBag ); Me@1: Me@1: systemCodeFileName = param->strValue; Me@1: Me@1: param = getParamFromBag( "numBytesInSystemCode", paramBag ); Me@1: Me@1: numBytesInSystemCode = param->intValue; Me@1: Me@1: Me@1: Me@1: simParams->systemCode = Me@1: Me@1: read_Machine_Code_From_File( numBytesInSystemCode, systemCodeFileName ); Me@1: Me@1: Me@1: Me@1: Me@1: Me@1: param = getParamFromBag( "numNodes", paramBag ); Me@1: Me@1: simParams->numNodes = param->intValue; Me@1: Me@1: Me@1: Me@1: } Me@1: Me@1: Me@1: Me@1: Me@1: Me@1: Me@1: Me@1: uint8 * Me@1: Me@1: read_Machine_Code_From_File( int numBytesInFile, char *machineCodeFileName ) Me@1: Me@1: { int byte; Me@1: Me@1: FILE *file; Me@1: Me@1: char *machineCode = malloc( numBytesInFile ); Me@1: Me@1: if( machineCode == NULL ) printf( "\nno mem for machine code\n" ); Me@1: Me@1: Me@1: Me@1: file = fopen( machineCodeFileName, "r" ); Me@1: Me@1: if( file == NULL ) { printf( "\nCouldn't open file!!\n"); exit(1);} Me@1: Me@1: Me@1: Me@1: fseek( file, 0, SEEK_SET ); Me@1: Me@1: for( byte = 0; byte < numBytesInFile; byte++ ) Me@1: Me@1: { Me@1: Me@1: if( feof( file ) ) printf( "file ran out too soon" ); Me@1: Me@1: machineCode[byte] = getchar( file ); Me@1: Me@1: Me@1: Me@1: } Me@1: Me@1: return machineCode; Me@1: Me@1: } Me@1: Me@1: Me@1: Me@1: Me@1: Me@1: //========================================================================== Me@1: Me@1: void Me@1: Me@1: printSimResults( SimulationResults simResults ) Me@1: Me@1: { Me@1: Me@1: } Me@1: Me@1: Me@1: