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 29#include <inttypes.h> 30#include <stdio.h> 31#include <stdlib.h> 32#include <string.h>
|
33#include <unistd.h> |
34 35#include "m5op.h" 36 37char *progname; 38 39void 40usage() 41{ 42 printf("usage: m5 ivlb <interval>\n" 43 " m5 ivle <interval>\n" 44 " m5 initparam\n" 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 "\n" 52 "All times in nanoseconds!\n"); 53 exit(1); 54} 55 56#define COMPARE(X) (strcmp(X, command) == 0) 57 58int 59main(int argc, char *argv[]) 60{ 61 char *command; 62 uint64_t param; 63 uint64_t arg1 = 0; 64 uint64_t arg2 = 0; 65 66 progname = argv[0]; 67 if (argc < 2) 68 usage(); 69 70 command = argv[1]; 71 72 if (COMPARE("ivlb")) { 73 if (argc != 3) 74 usage(); 75 76 arg1 = strtoul(argv[2], NULL, 0); 77 m5_ivlb(arg1); 78 return 0; 79 } 80 81 if (COMPARE("ivle")) { 82 if (argc != 3) 83 usage(); 84 85 arg1 = strtoul(argv[2], NULL, 0); 86 m5_ivle(arg1); 87 return 0; 88 } 89 90 if (COMPARE("initparam")) { 91 if (argc != 2) 92 usage(); 93 94 printf("%ld", m5_initparam()); 95 return 0; 96 } 97 98 if (COMPARE("sw99param")) { 99 if (argc != 2) 100 usage(); 101 102 param = m5_initparam(); 103 // run-time, rampup-time, rampdown-time, warmup-time, connections 104 printf("%d %d %d %d %d", (param >> 48) & 0xfff, 105 (param >> 36) & 0xfff, (param >> 24) & 0xfff, 106 (param >> 12) & 0xfff, (param >> 0) & 0xfff); 107 108 return 0; 109 } 110 111 if (COMPARE("exit")) { 112 switch (argc) { 113 case 3: 114 arg1 = strtoul(argv[2], NULL, 0); 115 case 2: 116 m5_exit(arg1); 117 return 0; 118 119 default: 120 usage(); 121 } 122 } 123 124 if (COMPARE("resetstats")) { 125 switch (argc) { 126 case 4: 127 arg2 = strtoul(argv[3], NULL, 0); 128 case 3: 129 arg1 = strtoul(argv[2], NULL, 0); 130 case 2: 131 m5_reset_stats(arg1, arg2); 132 return 0; 133 134 default: 135 usage(); 136 } 137 } 138 139 if (COMPARE("dumpstats")) { 140 switch (argc) { 141 case 4: 142 arg2 = strtoul(argv[3], NULL, 0); 143 case 3: 144 arg1 = strtoul(argv[2], NULL, 0); 145 case 2: 146 m5_dump_stats(arg1, arg2); 147 return 0; 148 149 default: 150 usage(); 151 } 152 } 153 154 if (COMPARE("dumpresetstats")) { 155 switch (argc) { 156 case 4: 157 arg2 = strtoul(argv[3], NULL, 0); 158 case 3: 159 arg1 = strtoul(argv[2], NULL, 0); 160 case 2: 161 m5_dumpreset_stats(arg1, arg2); 162 return 0; 163 164 default: 165 usage(); 166 } 167 } 168
|
169 if (COMPARE("readfile")) { 170 char buf[256*1024]; 171 int offset = 0; 172 int len; 173 174 if (argc != 2) 175 usage(); 176 177 while ((len = m5_readfile(buf, sizeof(buf), offset)) > 0) { 178 write(STDOUT_FILENO, buf, len); 179 offset += len; 180 } 181 182 return 0; 183 } 184 |
185 if (COMPARE("checkpoint")) { 186 switch (argc) { 187 case 4: 188 arg2 = strtoul(argv[3], NULL, 0); 189 case 3: 190 arg1 = strtoul(argv[2], NULL, 0); 191 case 2: 192 m5_checkpoint(arg1, arg2); 193 return 0; 194 195 default: 196 usage(); 197 } 198 199 return 0; 200 } 201
|
202 if (COMPARE("loadsymbol")) { 203 m5_loadsymbol(arg1); 204 return 0; 205 } 206 |
207 usage(); 208}
|