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