diff options
author | Gabor Dozsa <gabor.dozsa@arm.com> | 2016-01-07 16:33:47 -0600 |
---|---|---|
committer | Gabor Dozsa <gabor.dozsa@arm.com> | 2016-01-07 16:33:47 -0600 |
commit | e67749426054d8ddb7f11b53a89741d4808f3acb (patch) | |
tree | 6070cdd030bb632be375ababdf30680f50fccae0 /util/m5 | |
parent | 6caa2c9b4ea8ed3a29c44dec60b791344b5fd477 (diff) | |
download | gem5-e67749426054d8ddb7f11b53a89741d4808f3acb.tar.xz |
pseudo inst,util: Add optional key to initparam pseudo instruction
The key parameter can be used to read out various config parameters from
within the simulated software.
Diffstat (limited to 'util/m5')
-rw-r--r-- | util/m5/m5.c | 31 | ||||
-rw-r--r-- | util/m5/m5op.h | 2 |
2 files changed, 28 insertions, 5 deletions
diff --git a/util/m5/m5.c b/util/m5/m5.c index 2fd2d1590..522268410 100644 --- a/util/m5/m5.c +++ b/util/m5/m5.c @@ -83,6 +83,27 @@ parse_int_args(int argc, char *argv[], uint64_t ints[], int len) #undef strto64 } +void +parse_str_args_to_regs(int argc, char *argv[], uint64_t regs[], int len) +{ + if (argc > 1 || strlen(argv[0]) > len * sizeof(uint64_t)) + usage(); + + int i; + for (i = 0; i < len; i++) + regs[i] = 0; + + if (argc == 0) + return; + + int n; + for (n = 0, i = 0; i < len && n < strlen(argv[0]); n++) { + *((char *)(®s[i]) + (n % 8)) = argv[0][n]; + if ((n % 8) == 7) + i++; + } +} + int read_file(int dest_fid) { @@ -233,10 +254,12 @@ do_load_symbol(int argc, char *argv[]) void do_initparam(int argc, char *argv[]) { - if (argc != 0) + if (argc > 1) usage(); - uint64_t val = m5_initparam(); + uint64_t key_str[2]; + parse_str_args_to_regs(argc, argv, key_str, 2); + uint64_t val = m5_initparam(key_str[0], key_str[1]); printf("%"PRIu64, val); } @@ -246,7 +269,7 @@ do_sw99param(int argc, char *argv[]) if (argc != 0) usage(); - uint64_t param = m5_initparam(); + uint64_t param = m5_initparam(0, 0); // run-time, rampup-time, rampdown-time, warmup-time, connections printf("%"PRId64" %"PRId64" %"PRId64" %"PRId64" %"PRId64, @@ -298,7 +321,7 @@ struct MainFunc mainfuncs[] = { { "execfile", do_exec_file, "" }, { "checkpoint", do_checkpoint, "[delay [period]]" }, { "loadsymbol", do_load_symbol, "<address> <symbol>" }, - { "initparam", do_initparam, "" }, + { "initparam", do_initparam, "[key] // key must be shorter than 16 chars" }, { "sw99param", do_sw99param, "" }, #ifdef linux { "pin", do_pin, "<cpu> <program> [args ...]" } diff --git a/util/m5/m5op.h b/util/m5/m5op.h index 9df9a7429..34dabce01 100644 --- a/util/m5/m5op.h +++ b/util/m5/m5op.h @@ -48,7 +48,7 @@ void wakeCPU(uint64_t cpuid); void m5_exit(uint64_t ns_delay); void m5_fail(uint64_t ns_delay, uint64_t code); -uint64_t m5_initparam(void); +uint64_t m5_initparam(uint64_t key_str1, uint64_t key_str2); void m5_checkpoint(uint64_t ns_delay, uint64_t ns_period); void m5_reset_stats(uint64_t ns_delay, uint64_t ns_period); void m5_dump_stats(uint64_t ns_delay, uint64_t ns_period); |