1
0
mirror of https://github.com/antonblanchard/microwatt.git synced 2026-01-26 03:51:22 +00:00

core_debug: Add support for detecting writes to a memory address

This adds a new type of stop trigger for the log buffer which triggers
when any byte(s) of a specified doubleword of memory are written.
The trigger logic snoops the wishbone for writes to the address
specified and stops the log 256 cycles later (same as for the
instruction fetch address trigger).  The trigger address is a real
address and sees DMA writes from devices as well as stores done by the
CPU.

The mw_debug command has a new 'mtrig' subcommand to set the trigger
and query its state.

Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
This commit is contained in:
Paul Mackerras
2023-08-28 12:22:31 +10:00
parent a2890745d5
commit 4bef477e29
3 changed files with 69 additions and 3 deletions

View File

@@ -45,6 +45,7 @@
#define DBG_LOG_ADDR 0x16
#define DBG_LOG_DATA 0x17
#define DBG_LOG_TRIGGER 0x18
#define DBG_LOG_MTRIGGER 0x19
static bool debug;
@@ -766,6 +767,28 @@ static void ltrig_set(uint64_t addr)
check(dmi_write(DBG_LOG_TRIGGER, (addr & ~(uint64_t)2) | 1), "writing LOG_TRIGGER");
}
static void mtrig_show(void)
{
uint64_t trig;
check(dmi_read(DBG_LOG_MTRIGGER, &trig), "reading LOG_MTRIGGER");
if (trig & 1)
printf("log memory stop trigger at %" PRIx64, trig & ~3);
else
printf("log memory stop trigger disabled");
printf(", %striggered\n", (trig & 2? "": "not "));
}
static void mtrig_off(void)
{
check(dmi_write(DBG_LOG_MTRIGGER, 0), "writing LOG_MTRIGGER");
}
static void mtrig_set(uint64_t addr)
{
check(dmi_write(DBG_LOG_MTRIGGER, (addr & ~(uint64_t)2) | 1), "writing LOG_MTRIGGER");
}
static void usage(const char *cmd)
{
fprintf(stderr, "Usage: %s -b <jtag|ecp5|sim> <command> <args>\n", cmd);
@@ -798,6 +821,9 @@ static void usage(const char *cmd)
fprintf(stderr, " ltrig show logging stop trigger status\n");
fprintf(stderr, " ltrig off clear logging stop trigger address\n");
fprintf(stderr, " ltrig <addr> set logging stop trigger address\n");
fprintf(stderr, " mtrig show logging stop trigger status\n");
fprintf(stderr, " mtrig off clear logging stop trigger address\n");
fprintf(stderr, " mtrig <addr> set logging stop trigger address\n");
fprintf(stderr, "\n");
fprintf(stderr, " JTAG:\n");
@@ -967,6 +993,17 @@ int main(int argc, char *argv[])
addr = strtoul(argv[i], NULL, 16);
ltrig_set(addr);
}
} else if (strcmp(argv[i], "mtrig") == 0) {
uint64_t addr;
if ((i+1) >= argc)
mtrig_show();
else if (strcmp(argv[++i], "off") == 0)
mtrig_off();
else {
addr = strtoul(argv[i], NULL, 16);
mtrig_set(addr);
}
} else {
fprintf(stderr, "Unknown command %s\n", argv[i]);
usage(argv[0]);