m5.c (3125:febd811bccc6) m5.c (3545:a49b07ba610e)
1/*
2 * Copyright (c) 2003-2005 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 * Authors: Nathan Binkert
29 */
30
31#include <inttypes.h>
32#include <stdio.h>
33#include <stdlib.h>
34#include <string.h>
35#include <unistd.h>
36
37#include "m5op.h"
38
39char *progname;
40
41void
42usage()
43{
1/*
2 * Copyright (c) 2003-2005 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 * Authors: Nathan Binkert
29 */
30
31#include <inttypes.h>
32#include <stdio.h>
33#include <stdlib.h>
34#include <string.h>
35#include <unistd.h>
36
37#include "m5op.h"
38
39char *progname;
40
41void
42usage()
43{
44 printf("usage: m5 ivlb <interval>\n"
45 " m5 ivle <interval>\n"
46 " m5 initparam\n"
44 printf("usage: m5 initparam\n"
47 " m5 sw99param\n"
48 " m5 exit [delay]\n"
49 " m5 resetstats [delay [period]]\n"
50 " m5 dumpstats [delay [period]]\n"
51 " m5 dumpresetstats [delay [period]]\n"
52 " m5 checkpoint [delay [period]]\n"
53 " m5 readfile\n"
54 "\n"
55 "All times in nanoseconds!\n");
56 exit(1);
57}
58
59#define COMPARE(X) (strcmp(X, command) == 0)
60
61int
62main(int argc, char *argv[])
63{
64 char *command;
65 uint64_t param;
66 uint64_t arg1 = 0;
67 uint64_t arg2 = 0;
68
69 progname = argv[0];
70 if (argc < 2)
71 usage();
72
73 command = argv[1];
74
75 if (COMPARE("ivlb")) {
76 if (argc != 3)
77 usage();
78
79 arg1 = strtoul(argv[2], NULL, 0);
80 m5_ivlb(arg1);
81 return 0;
82 }
83
84 if (COMPARE("ivle")) {
85 if (argc != 3)
86 usage();
87
88 arg1 = strtoul(argv[2], NULL, 0);
89 m5_ivle(arg1);
90 return 0;
91 }
92
93 if (COMPARE("initparam")) {
94 if (argc != 2)
95 usage();
96
97 printf("%ld", m5_initparam());
98 return 0;
99 }
100
101 if (COMPARE("sw99param")) {
102 if (argc != 2)
103 usage();
104
105 param = m5_initparam();
106 // run-time, rampup-time, rampdown-time, warmup-time, connections
107 printf("%d %d %d %d %d", (param >> 48) & 0xfff,
108 (param >> 36) & 0xfff, (param >> 24) & 0xfff,
109 (param >> 12) & 0xfff, (param >> 0) & 0xfff);
110
111 return 0;
112 }
113
114 if (COMPARE("exit")) {
115 switch (argc) {
116 case 3:
117 arg1 = strtoul(argv[2], NULL, 0);
118 case 2:
119 m5_exit(arg1);
120 return 0;
121
122 default:
123 usage();
124 }
125 }
126
127 if (COMPARE("resetstats")) {
128 switch (argc) {
129 case 4:
130 arg2 = strtoul(argv[3], NULL, 0);
131 case 3:
132 arg1 = strtoul(argv[2], NULL, 0);
133 case 2:
134 m5_reset_stats(arg1, arg2);
135 return 0;
136
137 default:
138 usage();
139 }
140 }
141
142 if (COMPARE("dumpstats")) {
143 switch (argc) {
144 case 4:
145 arg2 = strtoul(argv[3], NULL, 0);
146 case 3:
147 arg1 = strtoul(argv[2], NULL, 0);
148 case 2:
149 m5_dump_stats(arg1, arg2);
150 return 0;
151
152 default:
153 usage();
154 }
155 }
156
157 if (COMPARE("dumpresetstats")) {
158 switch (argc) {
159 case 4:
160 arg2 = strtoul(argv[3], NULL, 0);
161 case 3:
162 arg1 = strtoul(argv[2], NULL, 0);
163 case 2:
164 m5_dumpreset_stats(arg1, arg2);
165 return 0;
166
167 default:
168 usage();
169 }
170 }
171
172 if (COMPARE("readfile")) {
173 char buf[256*1024];
174 int offset = 0;
175 int len;
176
177 if (argc != 2)
178 usage();
179
180 while ((len = m5_readfile(buf, sizeof(buf), offset)) > 0) {
181 write(STDOUT_FILENO, buf, len);
182 offset += len;
183 }
184
185 return 0;
186 }
187
188 if (COMPARE("checkpoint")) {
189 switch (argc) {
190 case 4:
191 arg2 = strtoul(argv[3], NULL, 0);
192 case 3:
193 arg1 = strtoul(argv[2], NULL, 0);
194 case 2:
195 m5_checkpoint(arg1, arg2);
196 return 0;
197
198 default:
199 usage();
200 }
201
202 return 0;
203 }
204
205 if (COMPARE("loadsymbol")) {
206 m5_loadsymbol(arg1);
207 return 0;
208 if (COMPARE("readfile")) {
209 char buf[256*1024];
210 int offset = 0;
211 int len;
212
213 if (argc != 2)
214 usage();
215
216 while ((len = m5_readfile(buf, sizeof(buf), offset)) > 0) {
217 write(STDOUT_FILENO, buf, len);
218 offset += len;
219 }
220
221 return 0;
222 }
223
224 usage();
225}
45 " m5 sw99param\n"
46 " m5 exit [delay]\n"
47 " m5 resetstats [delay [period]]\n"
48 " m5 dumpstats [delay [period]]\n"
49 " m5 dumpresetstats [delay [period]]\n"
50 " m5 checkpoint [delay [period]]\n"
51 " m5 readfile\n"
52 "\n"
53 "All times in nanoseconds!\n");
54 exit(1);
55}
56
57#define COMPARE(X) (strcmp(X, command) == 0)
58
59int
60main(int argc, char *argv[])
61{
62 char *command;
63 uint64_t param;
64 uint64_t arg1 = 0;
65 uint64_t arg2 = 0;
66
67 progname = argv[0];
68 if (argc < 2)
69 usage();
70
71 command = argv[1];
72
73 if (COMPARE("ivlb")) {
74 if (argc != 3)
75 usage();
76
77 arg1 = strtoul(argv[2], NULL, 0);
78 m5_ivlb(arg1);
79 return 0;
80 }
81
82 if (COMPARE("ivle")) {
83 if (argc != 3)
84 usage();
85
86 arg1 = strtoul(argv[2], NULL, 0);
87 m5_ivle(arg1);
88 return 0;
89 }
90
91 if (COMPARE("initparam")) {
92 if (argc != 2)
93 usage();
94
95 printf("%ld", m5_initparam());
96 return 0;
97 }
98
99 if (COMPARE("sw99param")) {
100 if (argc != 2)
101 usage();
102
103 param = m5_initparam();
104 // run-time, rampup-time, rampdown-time, warmup-time, connections
105 printf("%d %d %d %d %d", (param >> 48) & 0xfff,
106 (param >> 36) & 0xfff, (param >> 24) & 0xfff,
107 (param >> 12) & 0xfff, (param >> 0) & 0xfff);
108
109 return 0;
110 }
111
112 if (COMPARE("exit")) {
113 switch (argc) {
114 case 3:
115 arg1 = strtoul(argv[2], NULL, 0);
116 case 2:
117 m5_exit(arg1);
118 return 0;
119
120 default:
121 usage();
122 }
123 }
124
125 if (COMPARE("resetstats")) {
126 switch (argc) {
127 case 4:
128 arg2 = strtoul(argv[3], NULL, 0);
129 case 3:
130 arg1 = strtoul(argv[2], NULL, 0);
131 case 2:
132 m5_reset_stats(arg1, arg2);
133 return 0;
134
135 default:
136 usage();
137 }
138 }
139
140 if (COMPARE("dumpstats")) {
141 switch (argc) {
142 case 4:
143 arg2 = strtoul(argv[3], NULL, 0);
144 case 3:
145 arg1 = strtoul(argv[2], NULL, 0);
146 case 2:
147 m5_dump_stats(arg1, arg2);
148 return 0;
149
150 default:
151 usage();
152 }
153 }
154
155 if (COMPARE("dumpresetstats")) {
156 switch (argc) {
157 case 4:
158 arg2 = strtoul(argv[3], NULL, 0);
159 case 3:
160 arg1 = strtoul(argv[2], NULL, 0);
161 case 2:
162 m5_dumpreset_stats(arg1, arg2);
163 return 0;
164
165 default:
166 usage();
167 }
168 }
169
170 if (COMPARE("readfile")) {
171 char buf[256*1024];
172 int offset = 0;
173 int len;
174
175 if (argc != 2)
176 usage();
177
178 while ((len = m5_readfile(buf, sizeof(buf), offset)) > 0) {
179 write(STDOUT_FILENO, buf, len);
180 offset += len;
181 }
182
183 return 0;
184 }
185
186 if (COMPARE("checkpoint")) {
187 switch (argc) {
188 case 4:
189 arg2 = strtoul(argv[3], NULL, 0);
190 case 3:
191 arg1 = strtoul(argv[2], NULL, 0);
192 case 2:
193 m5_checkpoint(arg1, arg2);
194 return 0;
195
196 default:
197 usage();
198 }
199
200 return 0;
201 }
202
203 if (COMPARE("loadsymbol")) {
204 m5_loadsymbol(arg1);
205 return 0;
206 if (COMPARE("readfile")) {
207 char buf[256*1024];
208 int offset = 0;
209 int len;
210
211 if (argc != 2)
212 usage();
213
214 while ((len = m5_readfile(buf, sizeof(buf), offset)) > 0) {
215 write(STDOUT_FILENO, buf, len);
216 offset += len;
217 }
218
219 return 0;
220 }
221
222 usage();
223}