Mercurial > cgi-bin > hgwebdir.cgi > PR > Applications > HWSim > HWSim__PingPong__HWDef
diff SimParams.c @ 26:0deed3ee0b02
update comments for public viewing
| author | kshalle |
|---|---|
| date | Wed, 25 Feb 2015 15:20:16 -0800 |
| parents | fa277c6ce6f2 |
| children |
line diff
1.1 --- a/SimParams.c Thu May 24 08:14:21 2012 -0700 1.2 +++ b/SimParams.c Wed Feb 25 15:20:16 2015 -0800 1.3 @@ -1,77 +1,77 @@ 1.4 -/* 1.5 - * Copyright 2009 OpenSourceStewardshipFoundation.org 1.6 - * Licensed under GNU General Public License version 2 1.7 - * 1.8 - * Author: seanhalle@yahoo.com 1.9 - * 1.10 - * Created on November 15, 2009, 2:35 AM 1.11 - */ 1.12 - 1.13 - 1.14 -#include <malloc.h> 1.15 -#include <stdlib.h> 1.16 - 1.17 - 1.18 -#include "SimParams.h" 1.19 - 1.20 - 1.21 -uint8 * 1.22 -read_Machine_Code_From_File( int numBytesInFile, char *machineCodeFileName ); 1.23 - 1.24 - 1.25 -void 1.26 -fill_sim_params_from_bag( SimulationParams *simParams, ParamBag *paramBag ) 1.27 - { char *guestAppFileName, *systemCodeFileName; 1.28 - int numBytesInGuestApp, numBytesInSystemCode; 1.29 - 1.30 - ParamStruc *param; 1.31 - 1.32 - param = getParamFromBag( "GuestApplicationFileName", paramBag ); 1.33 - guestAppFileName = param->strValue; 1.34 - 1.35 - param = getParamFromBag( "numBytesInGuestApp", paramBag ); 1.36 - numBytesInGuestApp = param->intValue; 1.37 - 1.38 - simParams->guestApp = 1.39 - read_Machine_Code_From_File( numBytesInGuestApp, guestAppFileName ); 1.40 - 1.41 - param = getParamFromBag( "SystemCodeFileName", paramBag ); 1.42 - systemCodeFileName = param->strValue; 1.43 - 1.44 - param = getParamFromBag( "numBytesInSystemCode", paramBag ); 1.45 - numBytesInSystemCode = param->intValue; 1.46 - 1.47 - simParams->systemCode = 1.48 - read_Machine_Code_From_File( numBytesInSystemCode, systemCodeFileName ); 1.49 - 1.50 - param = getParamFromBag( "numNodes", paramBag ); 1.51 - simParams->numNodes = param->intValue; 1.52 - } 1.53 - 1.54 - 1.55 -uint8 * 1.56 -read_Machine_Code_From_File( int numBytesInFile, char *machineCodeFileName ) 1.57 - { int byte; 1.58 - FILE *file; 1.59 - char *machineCode = malloc( numBytesInFile ); 1.60 - if( machineCode == NULL ) printf( "\nno mem for machine code\n" ); 1.61 - 1.62 - file = fopen( machineCodeFileName, "r" ); 1.63 - if( file == NULL ) { printf( "\nCouldn't open file!!\n"); exit(1);} 1.64 - 1.65 - fseek( file, 0, SEEK_SET ); 1.66 - for( byte = 0; byte < numBytesInFile; byte++ ) 1.67 - { 1.68 - if( feof( file ) ) printf( "file ran out too soon" ); 1.69 -// machineCode[byte] = getchar( file ); 1.70 - } 1.71 - return machineCode; 1.72 - } 1.73 - 1.74 - 1.75 -//========================================================================== 1.76 -void 1.77 -printSimResults( SimulationResults simResults ) 1.78 - { 1.79 - } 1.80 - 1.81 +/* 1.82 + * Copyright 2009 OpenSourceResearchInstitute.org 1.83 + * Licensed under GNU General Public License version 2 1.84 + * 1.85 + * Author: seanhalle@yahoo.com 1.86 + * 1.87 + * Created on November 15, 2009, 2:35 AM 1.88 + */ 1.89 + 1.90 + 1.91 +#include <malloc.h> 1.92 +#include <stdlib.h> 1.93 + 1.94 + 1.95 +#include "SimParams.h" 1.96 + 1.97 + 1.98 +uint8 * 1.99 +read_Machine_Code_From_File( int numBytesInFile, char *machineCodeFileName ); 1.100 + 1.101 + 1.102 +void 1.103 +fill_sim_params_from_bag( SimulationParams *simParams, ParamBag *paramBag ) 1.104 + { char *guestAppFileName, *systemCodeFileName; 1.105 + int numBytesInGuestApp, numBytesInSystemCode; 1.106 + 1.107 + ParamStruc *param; 1.108 + 1.109 + param = getParamFromBag( "GuestApplicationFileName", paramBag ); 1.110 + guestAppFileName = param->strValue; 1.111 + 1.112 + param = getParamFromBag( "numBytesInGuestApp", paramBag ); 1.113 + numBytesInGuestApp = param->intValue; 1.114 + 1.115 + simParams->guestApp = 1.116 + read_Machine_Code_From_File( numBytesInGuestApp, guestAppFileName ); 1.117 + 1.118 + param = getParamFromBag( "SystemCodeFileName", paramBag ); 1.119 + systemCodeFileName = param->strValue; 1.120 + 1.121 + param = getParamFromBag( "numBytesInSystemCode", paramBag ); 1.122 + numBytesInSystemCode = param->intValue; 1.123 + 1.124 + simParams->systemCode = 1.125 + read_Machine_Code_From_File( numBytesInSystemCode, systemCodeFileName ); 1.126 + 1.127 + param = getParamFromBag( "numNodes", paramBag ); 1.128 + simParams->numNodes = param->intValue; 1.129 + } 1.130 + 1.131 + 1.132 +uint8 * 1.133 +read_Machine_Code_From_File( int numBytesInFile, char *machineCodeFileName ) 1.134 + { int byte; 1.135 + FILE *file; 1.136 + char *machineCode = malloc( numBytesInFile ); 1.137 + if( machineCode == NULL ) printf( "\nno mem for machine code\n" ); 1.138 + 1.139 + file = fopen( machineCodeFileName, "r" ); 1.140 + if( file == NULL ) { printf( "\nCouldn't open file!!\n"); exit(1);} 1.141 + 1.142 + fseek( file, 0, SEEK_SET ); 1.143 + for( byte = 0; byte < numBytesInFile; byte++ ) 1.144 + { 1.145 + if( feof( file ) ) printf( "file ran out too soon" ); 1.146 +// machineCode[byte] = getchar( file ); 1.147 + } 1.148 + return machineCode; 1.149 + } 1.150 + 1.151 + 1.152 +//========================================================================== 1.153 +void 1.154 +printSimResults( SimulationResults simResults ) 1.155 + { 1.156 + } 1.157 +
