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