m5.c (287:afb495378ac2) m5.c (1762:6bf5cf6d9903)
1/*
1/*
2 * Copyright (c) 2003 The Regents of The University of Michigan
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
29#include <inttypes.h>
30#include <stdio.h>
31#include <stdlib.h>
32#include <string.h>
33
34#include "m5op.h"
35
36char *progname;
37
38void
39usage()
40{
41 printf("usage: m5 ivlb <interval>\n"
42 " m5 ivle <interval>\n"
43 " m5 initparam\n"
44 " m5 sw99param\n"
45 " m5 exit [delay]\n"
46 " m5 resetstats [delay [period]]\n"
47 " m5 dumpstats [delay [period]]\n"
48 " m5 dumpresetstats [delay [period]]\n"
49 " m5 checkpoint [delay [period]]\n"
50 "\n"
51 "All times in nanoseconds!\n");
52 exit(1);
53}
54
55#define COMPARE(X) (strcmp(X, command) == 0)
56
57int
58main(int argc, char *argv[])
59{
60 char *command;
61 uint64_t param;
62 uint64_t arg1 = 0;
63 uint64_t arg2 = 0;
64
65 progname = argv[0];
66 if (argc < 2)
67 usage();
68
69 command = argv[1];
70
71 if (COMPARE("ivlb")) {
72 if (argc != 3)
73 usage();
74
75 arg1 = strtoul(argv[2], NULL, 0);
76 ivlb(arg1);
77 return 0;
78 }
79
80 if (COMPARE("ivle")) {
81 if (argc != 3)
82 usage();
83
84 arg1 = strtoul(argv[2], NULL, 0);
85 ivle(arg1);
86 return 0;
87 }
88
89 if (COMPARE("initparam")) {
90 if (argc != 2)
91 usage();
92
93 printf("%ld", initparam());
94 return 0;
95 }
96
97 if (COMPARE("sw99param")) {
98 if (argc != 2)
99 usage();
100
101 param = initparam();
102 // run-time, rampup-time, rampdown-time, warmup-time, connections
103 printf("%d %d %d %d %d", (param >> 48) & 0xfff,
104 (param >> 36) & 0xfff, (param >> 24) & 0xfff,
105 (param >> 12) & 0xfff, (param >> 0) & 0xfff);
106
107 return 0;
108 }
109
110 if (COMPARE("exit")) {
111 switch (argc) {
112 case 3:
113 arg1 = strtoul(argv[2], NULL, 0);
114 case 2:
115 m5exit(arg1);
116 return 0;
117
118 default:
119 usage();
120 }
121 }
122
123 if (COMPARE("resetstats")) {
124 switch (argc) {
125 case 4:
126 arg2 = strtoul(argv[3], NULL, 0);
127 case 3:
128 arg1 = strtoul(argv[2], NULL, 0);
129 case 2:
130 reset_stats(arg1, arg2);
131 return 0;
132
133 default:
134 usage();
135 }
136 }
137
138 if (COMPARE("dumpstats")) {
139 switch (argc) {
140 case 4:
141 arg2 = strtoul(argv[3], NULL, 0);
142 case 3:
143 arg1 = strtoul(argv[2], NULL, 0);
144 case 2:
145 dump_stats(arg1, arg2);
146 return 0;
147
148 default:
149 usage();
150 }
151 }
152
153 if (COMPARE("dumpresetstats")) {
154 switch (argc) {
155 case 4:
156 arg2 = strtoul(argv[3], NULL, 0);
157 case 3:
158 arg1 = strtoul(argv[2], NULL, 0);
159 case 2:
160 dumpreset_stats(arg1, arg2);
161 return 0;
162
163 default:
164 usage();
165 }
166 }
167
168 if (COMPARE("checkpoint")) {
169 switch (argc) {
170 case 4:
171 arg2 = strtoul(argv[3], NULL, 0);
172 case 3:
173 arg1 = strtoul(argv[2], NULL, 0);
174 case 2:
175 checkpoint(arg1, arg2);
176 return 0;
177
178 default:
179 usage();
180 }
181
182 return 0;
183 }
184
185 usage();
186}
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
29#include <inttypes.h>
30#include <stdio.h>
31#include <stdlib.h>
32#include <string.h>
33
34#include "m5op.h"
35
36char *progname;
37
38void
39usage()
40{
41 printf("usage: m5 ivlb <interval>\n"
42 " m5 ivle <interval>\n"
43 " m5 initparam\n"
44 " m5 sw99param\n"
45 " m5 exit [delay]\n"
46 " m5 resetstats [delay [period]]\n"
47 " m5 dumpstats [delay [period]]\n"
48 " m5 dumpresetstats [delay [period]]\n"
49 " m5 checkpoint [delay [period]]\n"
50 "\n"
51 "All times in nanoseconds!\n");
52 exit(1);
53}
54
55#define COMPARE(X) (strcmp(X, command) == 0)
56
57int
58main(int argc, char *argv[])
59{
60 char *command;
61 uint64_t param;
62 uint64_t arg1 = 0;
63 uint64_t arg2 = 0;
64
65 progname = argv[0];
66 if (argc < 2)
67 usage();
68
69 command = argv[1];
70
71 if (COMPARE("ivlb")) {
72 if (argc != 3)
73 usage();
74
75 arg1 = strtoul(argv[2], NULL, 0);
76 ivlb(arg1);
77 return 0;
78 }
79
80 if (COMPARE("ivle")) {
81 if (argc != 3)
82 usage();
83
84 arg1 = strtoul(argv[2], NULL, 0);
85 ivle(arg1);
86 return 0;
87 }
88
89 if (COMPARE("initparam")) {
90 if (argc != 2)
91 usage();
92
93 printf("%ld", initparam());
94 return 0;
95 }
96
97 if (COMPARE("sw99param")) {
98 if (argc != 2)
99 usage();
100
101 param = initparam();
102 // run-time, rampup-time, rampdown-time, warmup-time, connections
103 printf("%d %d %d %d %d", (param >> 48) & 0xfff,
104 (param >> 36) & 0xfff, (param >> 24) & 0xfff,
105 (param >> 12) & 0xfff, (param >> 0) & 0xfff);
106
107 return 0;
108 }
109
110 if (COMPARE("exit")) {
111 switch (argc) {
112 case 3:
113 arg1 = strtoul(argv[2], NULL, 0);
114 case 2:
115 m5exit(arg1);
116 return 0;
117
118 default:
119 usage();
120 }
121 }
122
123 if (COMPARE("resetstats")) {
124 switch (argc) {
125 case 4:
126 arg2 = strtoul(argv[3], NULL, 0);
127 case 3:
128 arg1 = strtoul(argv[2], NULL, 0);
129 case 2:
130 reset_stats(arg1, arg2);
131 return 0;
132
133 default:
134 usage();
135 }
136 }
137
138 if (COMPARE("dumpstats")) {
139 switch (argc) {
140 case 4:
141 arg2 = strtoul(argv[3], NULL, 0);
142 case 3:
143 arg1 = strtoul(argv[2], NULL, 0);
144 case 2:
145 dump_stats(arg1, arg2);
146 return 0;
147
148 default:
149 usage();
150 }
151 }
152
153 if (COMPARE("dumpresetstats")) {
154 switch (argc) {
155 case 4:
156 arg2 = strtoul(argv[3], NULL, 0);
157 case 3:
158 arg1 = strtoul(argv[2], NULL, 0);
159 case 2:
160 dumpreset_stats(arg1, arg2);
161 return 0;
162
163 default:
164 usage();
165 }
166 }
167
168 if (COMPARE("checkpoint")) {
169 switch (argc) {
170 case 4:
171 arg2 = strtoul(argv[3], NULL, 0);
172 case 3:
173 arg1 = strtoul(argv[2], NULL, 0);
174 case 2:
175 checkpoint(arg1, arg2);
176 return 0;
177
178 default:
179 usage();
180 }
181
182 return 0;
183 }
184
185 usage();
186}