annotate src/Application/SimParams.c @ 2:d872169e58fa

Minor changes -- mostly renaming structs and vars
author Me@portablequad
date Wed, 30 Nov 2011 08:40:30 -0800
parents 8ea476474093
children 648207f2e38f
rev   line source
Me@1 1 /*
Me@1 2
Me@1 3 * Copyright 2009 OpenSourceStewardshipFoundation.org
Me@1 4
Me@1 5 * Licensed under GNU General Public License version 2
Me@1 6
Me@1 7 *
Me@1 8
Me@1 9 * Author: seanhalle@yahoo.com
Me@1 10
Me@1 11 *
Me@1 12
Me@1 13 * Created on November 15, 2009, 2:35 AM
Me@1 14
Me@1 15 */
Me@1 16
Me@1 17
Me@1 18
Me@1 19 #include <malloc.h>
Me@1 20
Me@1 21 #include <stdlib.h>
Me@1 22
Me@1 23
Me@1 24
Me@1 25 #include "SimParams.h"
Me@1 26
Me@1 27 #include "ParamHelper/Param.h"
Me@1 28
Me@1 29
Me@1 30
Me@1 31
Me@1 32
Me@1 33 uint8 *
Me@1 34
Me@1 35 read_Machine_Code_From_File( int numBytesInFile, char *machineCodeFileName );
Me@1 36
Me@1 37
Me@1 38
Me@1 39
Me@1 40
Me@1 41 void
Me@1 42
Me@1 43 fill_sim_params_from_bag( SimulationParams *simParams, ParamBag *paramBag )
Me@1 44
Me@1 45 { char *guestAppFileName, *systemCodeFileName;
Me@1 46
Me@1 47 int numBytesInGuestApp, numBytesInSystemCode;
Me@1 48
Me@1 49
Me@1 50
Me@1 51 ParamStruc *param;
Me@1 52
Me@1 53 param = getParamFromBag( "GuestApplicationFileName", paramBag );
Me@1 54
Me@1 55 guestAppFileName = param->strValue;
Me@1 56
Me@1 57 param = getParamFromBag( "numBytesInGuestApp", paramBag );
Me@1 58
Me@1 59 numBytesInGuestApp = param->intValue;
Me@1 60
Me@1 61
Me@1 62
Me@1 63 simParams->guestApp =
Me@1 64
Me@1 65 read_Machine_Code_From_File( numBytesInGuestApp, guestAppFileName );
Me@1 66
Me@1 67
Me@1 68
Me@1 69 param = getParamFromBag( "SystemCodeFileName", paramBag );
Me@1 70
Me@1 71 systemCodeFileName = param->strValue;
Me@1 72
Me@1 73 param = getParamFromBag( "numBytesInSystemCode", paramBag );
Me@1 74
Me@1 75 numBytesInSystemCode = param->intValue;
Me@1 76
Me@1 77
Me@1 78
Me@1 79 simParams->systemCode =
Me@1 80
Me@1 81 read_Machine_Code_From_File( numBytesInSystemCode, systemCodeFileName );
Me@1 82
Me@1 83
Me@1 84
Me@1 85
Me@1 86
Me@1 87 param = getParamFromBag( "numNodes", paramBag );
Me@1 88
Me@1 89 simParams->numNodes = param->intValue;
Me@1 90
Me@1 91
Me@1 92
Me@1 93 }
Me@1 94
Me@1 95
Me@1 96
Me@1 97
Me@1 98
Me@1 99
Me@1 100
Me@1 101 uint8 *
Me@1 102
Me@1 103 read_Machine_Code_From_File( int numBytesInFile, char *machineCodeFileName )
Me@1 104
Me@1 105 { int byte;
Me@1 106
Me@1 107 FILE *file;
Me@1 108
Me@1 109 char *machineCode = malloc( numBytesInFile );
Me@1 110
Me@1 111 if( machineCode == NULL ) printf( "\nno mem for machine code\n" );
Me@1 112
Me@1 113
Me@1 114
Me@1 115 file = fopen( machineCodeFileName, "r" );
Me@1 116
Me@1 117 if( file == NULL ) { printf( "\nCouldn't open file!!\n"); exit(1);}
Me@1 118
Me@1 119
Me@1 120
Me@1 121 fseek( file, 0, SEEK_SET );
Me@1 122
Me@1 123 for( byte = 0; byte < numBytesInFile; byte++ )
Me@1 124
Me@1 125 {
Me@1 126
Me@1 127 if( feof( file ) ) printf( "file ran out too soon" );
Me@1 128
Me@1 129 machineCode[byte] = getchar( file );
Me@1 130
Me@1 131
Me@1 132
Me@1 133 }
Me@1 134
Me@1 135 return machineCode;
Me@1 136
Me@1 137 }
Me@1 138
Me@1 139
Me@1 140
Me@1 141
Me@1 142
Me@1 143 //==========================================================================
Me@1 144
Me@1 145 void
Me@1 146
Me@1 147 printSimResults( SimulationResults simResults )
Me@1 148
Me@1 149 {
Me@1 150
Me@1 151 }
Me@1 152
Me@1 153
Me@1 154