PR/Applications/HWSim/HWSim__PingPong__HWDef

view SimParams.c @ 27:fb4970a0c337

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