From f9a597ddf307246b1aee915b59de503d2850ccce Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Fri, 11 Jul 2008 08:52:50 -0700 Subject: m5ops: clean up the m5ops stuff. - insert warnings for deprecated m5ops - reserve opcodes for Ali's stuff - remove code for stuff that has been deprecated forever - simplify m5op_alpha --- util/m5/m5op_alpha.S | 141 +++++++++------------------------------------------ util/m5/m5ops.h | 47 +++++++++-------- 2 files changed, 48 insertions(+), 140 deletions(-) (limited to 'util/m5') diff --git a/util/m5/m5op_alpha.S b/util/m5/m5op_alpha.S index c5d0e65f8..aa7d12aab 100644 --- a/util/m5/m5op_alpha.S +++ b/util/m5/m5op_alpha.S @@ -48,6 +48,12 @@ func: #define END(func) \ .end func +#define SIMPLE_OP(_f, _o) \ + LEAF(_f) \ + _o; \ + RET; \ + END(_f) + #define ARM(reg) INST(m5_op, reg, 0, arm_func) #define QUIESCE INST(m5_op, 0, 0, quiesce_func) #define QUIESCENS(r1) INST(m5_op, r1, 0, quiescens_func) @@ -65,125 +71,24 @@ func: #define SWITCHCPU INST(m5_op, 0, 0, switchcpu_func) #define ADDSYMBOL(r1,r2) INST(m5_op, r1, r2, addsymbol_func) #define PANIC INST(m5_op, 0, 0, panic_func) -#define AN_BEGIN(r1) INST(m5_op, r1, 0, anbegin_func) -#define AN_WAIT(r1,r2) INST(m5_op, r1, r2, anwait_func) .set noreorder - .align 4 -LEAF(arm) - ARM(16) - RET -END(arm) - - .align 4 -LEAF(quiesce) - QUIESCE - RET -END(quiesce) - - .align 4 -LEAF(quiesceNs) - QUIESCENS(16) - RET -END(quiesceNs) - - .align 4 -LEAF(quiesceCycle) - QUIESCECYC(16) - RET -END(quiesceCycle) - - .align 4 -LEAF(quiesceTime) - QUIESCETIME - RET -END(quiesceTime) - - .align 4 -LEAF(m5_exit) - M5EXIT(16) - RET -END(m5_exit) - - .align 4 -LEAF(m5_initparam) - INITPARAM(0) - RET -END(m5_initparam) - - .align 4 -LEAF(m5_loadsymbol) - LOADSYMBOL(0) - RET -END(m5_loadsymbol) - - .align 4 -LEAF(m5_reset_stats) - RESET_STATS(16, 17) - RET -END(m5_reset_stats) - - .align 4 -LEAF(m5_dump_stats) - DUMP_STATS(16, 17) - RET -END(m5_dump_stats) - - .align 4 -LEAF(m5_dumpreset_stats) - DUMPRST_STATS(16, 17) - RET -END(m5_dumpreset_stats) - - .align 4 -LEAF(m5_checkpoint) - CHECKPOINT(16, 17) - RET -END(m5_checkpoint) - - .align 4 -LEAF(m5_readfile) - READFILE - RET -END(m5_readfile) - - .align 4 -LEAF(m5_debugbreak) - DEBUGBREAK - RET -END(m5_debugbreak) - - .align 4 -LEAF(m5_switchcpu) - SWITCHCPU - RET -END(m5_switchcpu) - - .align 4 -LEAF(m5_addsymbol) - ADDSYMBOL(16, 17) - RET -END(m5_addsymbol) - - .align 4 -LEAF(m5_panic) - PANIC - RET -END(m5_panic) - - - .align 4 -LEAF(m5_anbegin) - AN_BEGIN(16) - RET -END(m5_anbegin) - - - .align 4 -LEAF(m5_anwait) - AN_WAIT(16,17) - RET -END(m5_anwait) - +SIMPLE_OP(arm, ARM(16)) +SIMPLE_OP(quiesce, QUIESCE) +SIMPLE_OP(quiesceNs, QUIESCENS(16)) +SIMPLE_OP(quiesceCycle, QUIESCECYC(16)) +SIMPLE_OP(quiesceTime, QUIESCETIME) +SIMPLE_OP(m5_exit, M5EXIT(16)) +SIMPLE_OP(m5_initparam, INITPARAM(0)) +SIMPLE_OP(m5_loadsymbol, LOADSYMBOL(0)) +SIMPLE_OP(m5_reset_stats, RESET_STATS(16, 17)) +SIMPLE_OP(m5_dump_stats, DUMP_STATS(16, 17)) +SIMPLE_OP(m5_dumpreset_stats, DUMPRST_STATS(16, 17)) +SIMPLE_OP(m5_checkpoint, CHECKPOINT(16, 17)) +SIMPLE_OP(m5_readfile, READFILE) +SIMPLE_OP(m5_debugbreak, DEBUGBREAK) +SIMPLE_OP(m5_switchcpu, SWITCHCPU) +SIMPLE_OP(m5_addsymbol, ADDSYMBOL(16, 17)) +SIMPLE_OP(m5_panic, PANIC) diff --git a/util/m5/m5ops.h b/util/m5/m5ops.h index ce0b39b29..3fad6e7bf 100644 --- a/util/m5/m5ops.h +++ b/util/m5/m5ops.h @@ -29,26 +29,29 @@ * Ali Saidi */ -#define arm_func 0x00 -#define quiesce_func 0x01 -#define quiescens_func 0x02 -#define quiescecycle_func 0x03 -#define quiescetime_func 0x04 -#define ivlb 0x10 // obsolete -#define ivle 0x11 // obsolete -#define exit_old_func 0x20 // deprecated! -#define exit_func 0x21 -#define initparam_func 0x30 -#define loadsymbol_func 0x31 -#define resetstats_func 0x40 -#define dumpstats_func 0x41 -#define dumprststats_func 0x42 -#define ckpt_func 0x43 -#define readfile_func 0x50 -#define debugbreak_func 0x51 -#define switchcpu_func 0x52 -#define addsymbol_func 0x53 -#define panic_func 0x54 -#define anbegin_func 0x55 -#define anwait_func 0x56 +#define arm_func 0x00 +#define quiesce_func 0x01 +#define quiescens_func 0x02 +#define quiescecycle_func 0x03 +#define quiescetime_func 0x04 +#define deprecated1_func 0x10 // obsolete ivlb +#define deprecated2_func 0x11 // obsolete ivle +#define deprecated3_func 0x20 // deprecated exit function +#define exit_func 0x21 +#define initparam_func 0x30 +#define loadsymbol_func 0x31 +#define resetstats_func 0x40 +#define dumpstats_func 0x41 +#define dumprststats_func 0x42 +#define ckpt_func 0x43 +#define readfile_func 0x50 +#define debugbreak_func 0x51 +#define switchcpu_func 0x52 +#define addsymbol_func 0x53 +#define panic_func 0x54 +#define reserved1_func 0x55 // Reserved for user +#define reserved2_func 0x56 // Reserved for user +#define reserved3_func 0x57 // Reserved for user +#define reserved4_func 0x58 // Reserved for user +#define reserved5_func 0x59 // Reserved for user -- cgit v1.2.3 From 3a3e356f4e61e86f6f1427dd85cf1e41fa9125c0 Mon Sep 17 00:00:00 2001 From: Ali Saidi Date: Wed, 10 Sep 2008 14:26:15 -0400 Subject: style: Remove non-leading tabs everywhere they shouldn't be. Developers should configure their editors to not insert tabs --- util/m5/m5op_alpha.S | 10 +++++----- util/m5/m5ops.h | 50 +++++++++++++++++++++++++------------------------- 2 files changed, 30 insertions(+), 30 deletions(-) (limited to 'util/m5') diff --git a/util/m5/m5op_alpha.S b/util/m5/m5op_alpha.S index aa7d12aab..7aeffb2c7 100644 --- a/util/m5/m5op_alpha.S +++ b/util/m5/m5op_alpha.S @@ -48,13 +48,13 @@ func: #define END(func) \ .end func -#define SIMPLE_OP(_f, _o) \ - LEAF(_f) \ - _o; \ - RET; \ +#define SIMPLE_OP(_f, _o) \ + LEAF(_f) \ + _o; \ + RET; \ END(_f) -#define ARM(reg) INST(m5_op, reg, 0, arm_func) +#define ARM(reg) INST(m5_op, reg, 0, arm_func) #define QUIESCE INST(m5_op, 0, 0, quiesce_func) #define QUIESCENS(r1) INST(m5_op, r1, 0, quiescens_func) #define QUIESCECYC(r1) INST(m5_op, r1, 0, quiescecycle_func) diff --git a/util/m5/m5ops.h b/util/m5/m5ops.h index 3fad6e7bf..58846e1cf 100644 --- a/util/m5/m5ops.h +++ b/util/m5/m5ops.h @@ -29,29 +29,29 @@ * Ali Saidi */ -#define arm_func 0x00 -#define quiesce_func 0x01 -#define quiescens_func 0x02 -#define quiescecycle_func 0x03 -#define quiescetime_func 0x04 -#define deprecated1_func 0x10 // obsolete ivlb -#define deprecated2_func 0x11 // obsolete ivle -#define deprecated3_func 0x20 // deprecated exit function -#define exit_func 0x21 -#define initparam_func 0x30 -#define loadsymbol_func 0x31 -#define resetstats_func 0x40 -#define dumpstats_func 0x41 -#define dumprststats_func 0x42 -#define ckpt_func 0x43 -#define readfile_func 0x50 -#define debugbreak_func 0x51 -#define switchcpu_func 0x52 -#define addsymbol_func 0x53 -#define panic_func 0x54 +#define arm_func 0x00 +#define quiesce_func 0x01 +#define quiescens_func 0x02 +#define quiescecycle_func 0x03 +#define quiescetime_func 0x04 +#define deprecated1_func 0x10 // obsolete ivlb +#define deprecated2_func 0x11 // obsolete ivle +#define deprecated3_func 0x20 // deprecated exit function +#define exit_func 0x21 +#define initparam_func 0x30 +#define loadsymbol_func 0x31 +#define resetstats_func 0x40 +#define dumpstats_func 0x41 +#define dumprststats_func 0x42 +#define ckpt_func 0x43 +#define readfile_func 0x50 +#define debugbreak_func 0x51 +#define switchcpu_func 0x52 +#define addsymbol_func 0x53 +#define panic_func 0x54 -#define reserved1_func 0x55 // Reserved for user -#define reserved2_func 0x56 // Reserved for user -#define reserved3_func 0x57 // Reserved for user -#define reserved4_func 0x58 // Reserved for user -#define reserved5_func 0x59 // Reserved for user +#define reserved1_func 0x55 // Reserved for user +#define reserved2_func 0x56 // Reserved for user +#define reserved3_func 0x57 // Reserved for user +#define reserved4_func 0x58 // Reserved for user +#define reserved5_func 0x59 // Reserved for user -- cgit v1.2.3 From eb5d9ba72b0309e7f98c382e3a80ce0601dbe084 Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Mon, 10 Nov 2008 11:51:18 -0800 Subject: pseudo inst: Add rpns (read processor nanoseconds) instruction. This instruction basically returns the number of nanoseconds that the CPU has been running. --- util/m5/m5op.h | 1 + util/m5/m5op_alpha.S | 2 ++ util/m5/m5ops.h | 1 + 3 files changed, 4 insertions(+) (limited to 'util/m5') diff --git a/util/m5/m5op.h b/util/m5/m5op.h index f4e6bb0f1..bab2e2b9e 100644 --- a/util/m5/m5op.h +++ b/util/m5/m5op.h @@ -39,6 +39,7 @@ void quiesce(void); void quiesceNs(uint64_t ns); void quiesceCycle(uint64_t cycles); uint64_t quiesceTime(void); +uint64_t rpns(); void m5_exit(uint64_t ns_delay); uint64_t m5_initparam(void); diff --git a/util/m5/m5op_alpha.S b/util/m5/m5op_alpha.S index 7aeffb2c7..77e9afe34 100644 --- a/util/m5/m5op_alpha.S +++ b/util/m5/m5op_alpha.S @@ -59,6 +59,7 @@ func: #define QUIESCENS(r1) INST(m5_op, r1, 0, quiescens_func) #define QUIESCECYC(r1) INST(m5_op, r1, 0, quiescecycle_func) #define QUIESCETIME INST(m5_op, 0, 0, quiescetime_func) +#define RPNS INST(m5_op, 0, 0, rpns_func) #define M5EXIT(reg) INST(m5_op, reg, 0, exit_func) #define INITPARAM(reg) INST(m5_op, reg, 0, initparam_func) #define LOADSYMBOL(reg) INST(m5_op, reg, 0, loadsymbol_func) @@ -79,6 +80,7 @@ SIMPLE_OP(quiesce, QUIESCE) SIMPLE_OP(quiesceNs, QUIESCENS(16)) SIMPLE_OP(quiesceCycle, QUIESCECYC(16)) SIMPLE_OP(quiesceTime, QUIESCETIME) +SIMPLE_OP(rpns, RPNS) SIMPLE_OP(m5_exit, M5EXIT(16)) SIMPLE_OP(m5_initparam, INITPARAM(0)) SIMPLE_OP(m5_loadsymbol, LOADSYMBOL(0)) diff --git a/util/m5/m5ops.h b/util/m5/m5ops.h index 58846e1cf..ab9bdd857 100644 --- a/util/m5/m5ops.h +++ b/util/m5/m5ops.h @@ -34,6 +34,7 @@ #define quiescens_func 0x02 #define quiescecycle_func 0x03 #define quiescetime_func 0x04 +#define rpns_func 0x07 #define deprecated1_func 0x10 // obsolete ivlb #define deprecated2_func 0x11 // obsolete ivle #define deprecated3_func 0x20 // deprecated exit function -- cgit v1.2.3 From ab593c69b6745c49913bd1b18c7a6fa9a3aeb0a4 Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Wed, 3 Dec 2008 04:57:53 -0800 Subject: util/m5: reorganize code so it is easier to add operations --- util/m5/m5.c | 284 ++++++++++++++++++++++++++++++++++------------------------- 1 file changed, 162 insertions(+), 122 deletions(-) (limited to 'util/m5') diff --git a/util/m5/m5.c b/util/m5/m5.c index b103796a8..5eb69ea36 100644 --- a/util/m5/m5.c +++ b/util/m5/m5.c @@ -29,6 +29,8 @@ */ #include +#include +#include #include #include #include @@ -37,154 +39,192 @@ #include "m5op.h" char *progname; +char *command = "unspecified"; +void usage(); void -usage() +parse_int_args(int argc, char *argv[], uint64_t ints[], int len) { - printf("usage: m5 initparam\n" - " m5 sw99param\n" - " m5 exit [delay]\n" - " m5 resetstats [delay [period]]\n" - " m5 dumpstats [delay [period]]\n" - " m5 dumpresetstats [delay [period]]\n" - " m5 checkpoint [delay [period]]\n" - " m5 readfile\n" - "\n" - "All times in nanoseconds!\n"); - exit(1); -} + if (argc > len) + usage(); -#define COMPARE(X) (strcmp(X, command) == 0) + int i; + for (i = 0; i < len; ++i) + ints[i] = (i < argc) ? strtoul(argv[i], NULL, 0) : 0; +} int -main(int argc, char *argv[]) +read_file(int dest_fid) { - char *command; - uint64_t param; - uint64_t arg1 = 0; - uint64_t arg2 = 0; + char buf[256*1024]; + int offset = 0; + int len; - progname = argv[0]; - if (argc < 2) + while ((len = m5_readfile(buf, sizeof(buf), offset)) > 0) { + write(dest_fid, buf, len); + offset += len; + } +} + +void +do_exit(int argc, char *argv[]) +{ + if (argc > 1) usage(); - command = argv[1]; + m5_exit((argc > 0) ? strtoul(argv[0], NULL, 0) : 0); +} - if (COMPARE("initparam")) { - if (argc != 2) - usage(); +void +do_reset_stats(int argc, char *argv[]) +{ + uint64_t ints[2]; + parse_int_args(argc, argv, ints, 2); + m5_reset_stats(ints[0], ints[1]); +} - printf("%ld", m5_initparam()); - return 0; - } +void +do_dump_stats(int argc, char *argv[]) +{ + uint64_t ints[2]; + parse_int_args(argc, argv, ints, 2); + m5_dump_stats(ints[0], ints[1]); +} - if (COMPARE("sw99param")) { - if (argc != 2) - usage(); +void +do_dump_reset_stats(int argc, char *argv[]) +{ + uint64_t ints[2]; + parse_int_args(argc, argv, ints, 2); + m5_dumpreset_stats(ints[0], ints[1]); +} - param = m5_initparam(); - // run-time, rampup-time, rampdown-time, warmup-time, connections - printf("%d %d %d %d %d", (param >> 48) & 0xfff, - (param >> 36) & 0xfff, (param >> 24) & 0xfff, - (param >> 12) & 0xfff, (param >> 0) & 0xfff); +void +do_read_file(int argc, char *argv[]) +{ + if (argc > 0) + usage(); - return 0; - } + read_file(STDOUT_FILENO); +} - if (COMPARE("exit")) { - switch (argc) { - case 3: - arg1 = strtoul(argv[2], NULL, 0); - case 2: - m5_exit(arg1); - return 0; - - default: - usage(); - } - } +void +do_exec_file(int argc, char *argv[]) +{ + if (argc > 0) + usage(); - if (COMPARE("resetstats")) { - switch (argc) { - case 4: - arg2 = strtoul(argv[3], NULL, 0); - case 3: - arg1 = strtoul(argv[2], NULL, 0); - case 2: - m5_reset_stats(arg1, arg2); - return 0; - - default: - usage(); - } - } + const char *destname = "/tmp/execfile"; - if (COMPARE("dumpstats")) { - switch (argc) { - case 4: - arg2 = strtoul(argv[3], NULL, 0); - case 3: - arg1 = strtoul(argv[2], NULL, 0); - case 2: - m5_dump_stats(arg1, arg2); - return 0; - - default: - usage(); - } + int fid = open(destname, O_WRONLY, 0777); + int len = read_file(fid); + close(fid); + if (len > 0) { + execl(destname, "execfile", NULL); + err(1, "execl failed!"); } +} - if (COMPARE("dumpresetstats")) { - switch (argc) { - case 4: - arg2 = strtoul(argv[3], NULL, 0); - case 3: - arg1 = strtoul(argv[2], NULL, 0); - case 2: - m5_dumpreset_stats(arg1, arg2); - return 0; - - default: - usage(); - } - } +void +do_checkpoint(int argc, char *argv[]) +{ + uint64_t ints[2]; + parse_int_args(argc, argv, ints, 2); + m5_checkpoint(ints[0], ints[1]); +} - if (COMPARE("readfile")) { - char buf[256*1024]; - int offset = 0; - int len; +void +do_load_symbol(int argc, char *argv[]) +{ + if (argc != 2) + usage(); - if (argc != 2) - usage(); + uint64_t addr = strtoul(argv[0], NULL, 0); + char *symbol = argv[1]; + m5_loadsymbol(addr, symbol); +} - while ((len = m5_readfile(buf, sizeof(buf), offset)) > 0) { - write(STDOUT_FILENO, buf, len); - offset += len; - } +void +do_initparam(int argc, char *argv[]) +{ + if (argc != 0) + usage(); - return 0; - } + + printf("%ld", m5_initparam()); +} + +void +do_sw99param(int argc, char *argv[]) +{ + if (argc != 0) + usage(); + + uint64_t param = m5_initparam(); + + // run-time, rampup-time, rampdown-time, warmup-time, connections + printf("%d %d %d %d %d", (param >> 48) & 0xfff, + (param >> 36) & 0xfff, (param >> 24) & 0xfff, + (param >> 12) & 0xfff, (param >> 0) & 0xfff); +} + +struct MainFunc +{ + char *name; + void (*func)(int argc, char *argv[]); + char *usage; +}; + +struct MainFunc mainfuncs[] = { + { "exit", do_exit, "[delay]" }, + { "resetstats", do_reset_stats, "[delay [period]]" }, + { "dumpstats", do_dump_stats, "[delay [period]]" }, + { "dumpresetstats", do_dump_reset_stats, "[delay [period]]" }, + { "readfile", do_read_file, "[filename]" }, + { "execfile", do_exec_file, "" }, + { "checkpoint", do_checkpoint, "[delay [period]]" }, + { "loadsymbol", do_load_symbol, "
" }, + { "initparam", do_initparam, "" }, + { "sw99param", do_sw99param, "" }, +}; +int numfuncs = sizeof(mainfuncs) / sizeof(mainfuncs[0]); + +void +usage() +{ + int i; - if (COMPARE("checkpoint")) { - switch (argc) { - case 4: - arg2 = strtoul(argv[3], NULL, 0); - case 3: - arg1 = strtoul(argv[2], NULL, 0); - case 2: - m5_checkpoint(arg1, arg2); - return 0; - - default: - usage(); - } - - return 0; + for (i = 0; i < numfuncs; ++i) { + char *header = i ? "" : "usage:"; + fprintf(stderr, "%-6s %s %s %s\n", + header, progname, mainfuncs[i].name, mainfuncs[i].usage); } + fprintf(stderr, "\n"); + fprintf(stderr, "All times in nanoseconds!\n"); - if (COMPARE("loadsymbol")) { - m5_loadsymbol(arg1); - return 0; + exit(1); +} + +int +main(int argc, char *argv[]) +{ + progname = argv[0]; + if (argc < 2) + usage(1); + + command = argv[1]; + + argv += 2; + argc -= 2; + + int i; + for (i = 0; i < numfuncs; ++i) { + if (strcmp(command, mainfuncs[i].name) != 0) + continue; + + mainfuncs[i].func(argc, argv); + exit(0); } - usage(); + + usage(1); } -- cgit v1.2.3 From 47e2b0889359877cb9a86c02c4bdf862fbd87338 Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Wed, 3 Dec 2008 04:57:54 -0800 Subject: util/m5: Add a new function called pin to bind a program to a set of cores. This is not m5 specific and this currently only works in linux. --- util/m5/m5.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'util/m5') diff --git a/util/m5/m5.c b/util/m5/m5.c index 5eb69ea36..7747fc0bc 100644 --- a/util/m5/m5.c +++ b/util/m5/m5.c @@ -28,6 +28,11 @@ * Authors: Nathan Binkert */ +#ifdef linux +#define _GNU_SOURCE +#include +#endif + #include #include #include @@ -168,6 +173,31 @@ do_sw99param(int argc, char *argv[]) (param >> 12) & 0xfff, (param >> 0) & 0xfff); } +#ifdef linux +void +do_pin(int argc, char *argv[]) +{ + if (argc < 2) + usage(); + + cpu_set_t mask; + CPU_ZERO(&mask); + + const char *sep = ","; + char *target = strtok(argv[0], sep); + while (target) { + CPU_SET(atoi(target), &mask); + target = strtok(NULL, sep); + } + + if (sched_setaffinity(0, sizeof(cpu_set_t), &mask) < 0) + err(1, "setaffinity"); + + execvp(argv[1], &argv[1]); + err(1, "execvp failed!"); +} +#endif + struct MainFunc { char *name; @@ -186,6 +216,9 @@ struct MainFunc mainfuncs[] = { { "loadsymbol", do_load_symbol, "
" }, { "initparam", do_initparam, "" }, { "sw99param", do_sw99param, "" }, +#ifdef linux + { "pin", do_pin, " [args ...]" } +#endif }; int numfuncs = sizeof(mainfuncs) / sizeof(mainfuncs[0]); -- cgit v1.2.3 From 49dcab0ce69ba37938ae5701982b1d1a093d4ee8 Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Wed, 7 Jan 2009 00:05:33 -0800 Subject: X86: Set up support for adding m5 pseudo insts to a binary. --- util/m5/Makefile.x86 | 49 ++++++++++++++++++++++++++++++++++++++ util/m5/m5op_x86.S | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 115 insertions(+) create mode 100644 util/m5/Makefile.x86 create mode 100644 util/m5/m5op_x86.S (limited to 'util/m5') diff --git a/util/m5/Makefile.x86 b/util/m5/Makefile.x86 new file mode 100644 index 000000000..e2d5d3722 --- /dev/null +++ b/util/m5/Makefile.x86 @@ -0,0 +1,49 @@ +# Copyright (c) 2005-2006 The Regents of The University of Michigan +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer; +# redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution; +# neither the name of the copyright holders nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# Authors: Nathan Binkert +# Ali Saidi + +CC=gcc +AS=as +LD=ld + +CFLAGS=-O2 +OBJS=m5.o m5op_x86.o + +all: m5 + +%.o: %.S + $(CC) $(CFLAGS) -o $@ -c $< + +%.o: %.c + $(CC) $(CFLAGS) -o $@ -c $< + +m5: $(OBJS) + $(CC) -o $@ $(OBJS) + +clean: + rm -f *.o m5 diff --git a/util/m5/m5op_x86.S b/util/m5/m5op_x86.S new file mode 100644 index 000000000..e85051d98 --- /dev/null +++ b/util/m5/m5op_x86.S @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2003-2006 The Regents of The University of Michigan + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer; + * redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution; + * neither the name of the copyright holders nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Authors: Gabe Black + * Nathan Binkert + * Ali Saidi + */ + +#include "m5ops.h" + +#define TWO_BYTE_OP(name, number) \ + .globl name; \ + .func name; \ +name: \ + .byte 0x0F, 0x04; \ + .word number; \ + ret; \ + .endfunc; + +TWO_BYTE_OP(arm, arm_func) +TWO_BYTE_OP(quiesce, quiesce_func) +TWO_BYTE_OP(quiesceNs, quiescens_func) +TWO_BYTE_OP(quiesceCycle, quiescecycle_func) +TWO_BYTE_OP(quiesceTime, quiescetime_func) +TWO_BYTE_OP(rpns, rpns_func) +TWO_BYTE_OP(m5_exit, exit_func) +TWO_BYTE_OP(m5_initparam, initparam_func) +TWO_BYTE_OP(m5_loadsymbol, loadsymbol_func) +TWO_BYTE_OP(m5_reset_stats, resetstats_func) +TWO_BYTE_OP(m5_dump_stats, dumpstats_func) +TWO_BYTE_OP(m5_dumpreset_stats, dumprststats_func) +TWO_BYTE_OP(m5_checkpoint, ckpt_func) +TWO_BYTE_OP(m5_readfile, readfile_func) +TWO_BYTE_OP(m5_debugbreak, debugbreak_func) +TWO_BYTE_OP(m5_switchcpu, switchcpu_func) +TWO_BYTE_OP(m5_addsymbol, addsymbol_func) +TWO_BYTE_OP(m5_panic, panic_func) +TWO_BYTE_OP(m5_reserved1_func, reserved1_func) +TWO_BYTE_OP(m5_reserved2_func, reserved2_func) +TWO_BYTE_OP(m5_reserved3_func, reserved3_func) +TWO_BYTE_OP(m5_reserved4_func, reserved4_func) +TWO_BYTE_OP(m5_reserved5_func, reserved5_func) -- cgit v1.2.3 From 64ed39f61b89675237e145ed4a81b49f353921ed Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Sat, 24 Jan 2009 07:27:22 -0800 Subject: pseudo inst: Add new wake cpu instruction for sending a message to wake a cpu. It's instantaneous and so it's somewhat bogus, but it's a first step. --- util/m5/m5op.h | 1 + util/m5/m5op_alpha.S | 2 ++ util/m5/m5ops.h | 1 + 3 files changed, 4 insertions(+) (limited to 'util/m5') diff --git a/util/m5/m5op.h b/util/m5/m5op.h index bab2e2b9e..6377af8b7 100644 --- a/util/m5/m5op.h +++ b/util/m5/m5op.h @@ -40,6 +40,7 @@ void quiesceNs(uint64_t ns); void quiesceCycle(uint64_t cycles); uint64_t quiesceTime(void); uint64_t rpns(); +void wakeCPU(uint64_t cpuid); void m5_exit(uint64_t ns_delay); uint64_t m5_initparam(void); diff --git a/util/m5/m5op_alpha.S b/util/m5/m5op_alpha.S index 77e9afe34..4c04af3f6 100644 --- a/util/m5/m5op_alpha.S +++ b/util/m5/m5op_alpha.S @@ -60,6 +60,7 @@ func: #define QUIESCECYC(r1) INST(m5_op, r1, 0, quiescecycle_func) #define QUIESCETIME INST(m5_op, 0, 0, quiescetime_func) #define RPNS INST(m5_op, 0, 0, rpns_func) +#define WAKE_CPU(r1) INST(m5_op, r1, 0, wakecpu_func) #define M5EXIT(reg) INST(m5_op, reg, 0, exit_func) #define INITPARAM(reg) INST(m5_op, reg, 0, initparam_func) #define LOADSYMBOL(reg) INST(m5_op, reg, 0, loadsymbol_func) @@ -81,6 +82,7 @@ SIMPLE_OP(quiesceNs, QUIESCENS(16)) SIMPLE_OP(quiesceCycle, QUIESCECYC(16)) SIMPLE_OP(quiesceTime, QUIESCETIME) SIMPLE_OP(rpns, RPNS) +SIMPLE_OP(wakeCPU, WAKE_CPU(16)) SIMPLE_OP(m5_exit, M5EXIT(16)) SIMPLE_OP(m5_initparam, INITPARAM(0)) SIMPLE_OP(m5_loadsymbol, LOADSYMBOL(0)) diff --git a/util/m5/m5ops.h b/util/m5/m5ops.h index ab9bdd857..b2f896fb1 100644 --- a/util/m5/m5ops.h +++ b/util/m5/m5ops.h @@ -35,6 +35,7 @@ #define quiescecycle_func 0x03 #define quiescetime_func 0x04 #define rpns_func 0x07 +#define wakecpu_func 0x09 #define deprecated1_func 0x10 // obsolete ivlb #define deprecated2_func 0x11 // obsolete ivle #define deprecated3_func 0x20 // deprecated exit function -- cgit v1.2.3 From d5ef9ee06b4e8be52069b46a65af3a0a7e0a9817 Mon Sep 17 00:00:00 2001 From: Ali Saidi Date: Thu, 26 Feb 2009 19:29:16 -0500 Subject: CPA: Add m5ops for critical path annotation work. --- util/m5/m5op.h | 24 ++++++++++++++++++++++-- util/m5/m5op_alpha.S | 35 +++++++++++++++++++++++++++++++++++ util/m5/m5ops.h | 21 ++++++++++++++++++++- 3 files changed, 77 insertions(+), 3 deletions(-) (limited to 'util/m5') diff --git a/util/m5/m5op.h b/util/m5/m5op.h index 6377af8b7..b8f13da35 100644 --- a/util/m5/m5op.h +++ b/util/m5/m5op.h @@ -53,7 +53,27 @@ void m5_debugbreak(void); void m5_switchcpu(void); void m5_addsymbol(uint64_t addr, char *symbol); void m5_panic(void); -void m5_anbegin(uint64_t s); -void m5_anwait(uint64_t s, uint64_t w); + +// These operations are for critical path annotation +void m5a_bsm(char *sm, const void *id, int flags); +void m5a_esm(char *sm); +void m5a_begin(int flags, char *st); +void m5a_end(void); +void m5a_q(const void *id, char *q, int count); +void m5a_dq(const void *id, char *q, int count); +void m5a_wf(const void *id, char *q, char *sm, int count); +void m5a_we(const void *id, char *q, char *sm, int count); +void m5a_ws(const void *id, char *q, char *sm); +void m5a_sq(const void *id, char *q, int count, int flags); +void m5a_aq(const void *id, char *q, int count); +void m5a_pq(const void *id, char *q, int count); +void m5a_l(char *lsm, const void *id, char *sm); +void m5a_identify(uint64_t id); +uint64_t m5a_getid(void); + +#define M5_AN_FL_NONE 0x0 +#define M5_AN_FL_BAD 0x2 +#define M5_AN_FL_LINK 0x10 +#define M5_AN_FL_RESET 0x20 #endif // __M5OP_H__ diff --git a/util/m5/m5op_alpha.S b/util/m5/m5op_alpha.S index 4c04af3f6..9e8c49338 100644 --- a/util/m5/m5op_alpha.S +++ b/util/m5/m5op_alpha.S @@ -74,6 +74,24 @@ func: #define ADDSYMBOL(r1,r2) INST(m5_op, r1, r2, addsymbol_func) #define PANIC INST(m5_op, 0, 0, panic_func) +#define AN_BSM INST(m5_op, an_bsm, 0, annotate_func) +#define AN_ESM INST(m5_op, an_esm, 0, annotate_func) +#define AN_BEGIN INST(m5_op, an_begin, 0, annotate_func) +#define AN_END INST(m5_op, an_end, 0, annotate_func) +#define AN_Q INST(m5_op, an_q, 0, annotate_func) +#define AN_RQ INST(m5_op, an_rq, 0, annotate_func) +#define AN_DQ INST(m5_op, an_dq, 0, annotate_func) +#define AN_WF INST(m5_op, an_wf, 0, annotate_func) +#define AN_WE INST(m5_op, an_we, 0, annotate_func) +#define AN_WS INST(m5_op, an_ws, 0, annotate_func) +#define AN_SQ INST(m5_op, an_sq, 0, annotate_func) +#define AN_AQ INST(m5_op, an_aq, 0, annotate_func) +#define AN_PQ INST(m5_op, an_pq, 0, annotate_func) +#define AN_L INST(m5_op, an_l, 0, annotate_func) +#define AN_IDENTIFY INST(m5_op, an_identify, 0, annotate_func) +#define AN_GETID INST(m5_op, an_getid, 0, annotate_func) + + .set noreorder SIMPLE_OP(arm, ARM(16)) @@ -96,3 +114,20 @@ SIMPLE_OP(m5_switchcpu, SWITCHCPU) SIMPLE_OP(m5_addsymbol, ADDSYMBOL(16, 17)) SIMPLE_OP(m5_panic, PANIC) +SIMPLE_OP(m5a_bsm, AN_BSM) +SIMPLE_OP(m5a_esm, AN_ESM) +SIMPLE_OP(m5a_begin, AN_BEGIN) +SIMPLE_OP(m5a_end, AN_END) +SIMPLE_OP(m5a_q, AN_Q) +SIMPLE_OP(m5a_rq, AN_RQ) +SIMPLE_OP(m5a_dq, AN_DQ) +SIMPLE_OP(m5a_wf, AN_WF) +SIMPLE_OP(m5a_we, AN_WE) +SIMPLE_OP(m5a_ws, AN_WS) +SIMPLE_OP(m5a_sq, AN_SQ) +SIMPLE_OP(m5a_aq, AN_AQ) +SIMPLE_OP(m5a_pq, AN_PQ) +SIMPLE_OP(m5a_l, AN_L) +SIMPLE_OP(m5a_identify, AN_IDENTIFY) +SIMPLE_OP(m5a_getid, AN_GETID) + diff --git a/util/m5/m5ops.h b/util/m5/m5ops.h index b2f896fb1..7f26fd4d8 100644 --- a/util/m5/m5ops.h +++ b/util/m5/m5ops.h @@ -52,8 +52,27 @@ #define addsymbol_func 0x53 #define panic_func 0x54 -#define reserved1_func 0x55 // Reserved for user #define reserved2_func 0x56 // Reserved for user #define reserved3_func 0x57 // Reserved for user #define reserved4_func 0x58 // Reserved for user #define reserved5_func 0x59 // Reserved for user + +// These operations are for critical path annotation +#define annotate_func 0x55 +#define an_bsm 0x1 +#define an_esm 0x2 +#define an_begin 0x3 +#define an_end 0x4 +#define an_q 0x6 +#define an_dq 0x7 +#define an_wf 0x8 +#define an_we 0x9 +#define an_rq 0xA +#define an_ws 0xB +#define an_sq 0xC +#define an_aq 0xD +#define an_pq 0xE +#define an_l 0xF +#define an_identify 0x10 +#define an_getid 0x11 + -- cgit v1.2.3