summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Neuling <mikey@neuling.org>2018-06-19 15:25:34 +1000
committerAlistair Popple <alistair@popple.id.au>2018-06-25 15:11:03 +1000
commit81d2d2fa8d8a9cd1b51c39ba74e9426064263f34 (patch)
tree9e4cff5445df9616e96a9ca83e216a09b9a06933
parent6ac2a7b441a0aa5ac4d6123c16a18338631a8a01 (diff)
downloadpdbg-81d2d2fa8d8a9cd1b51c39ba74e9426064263f34.tar.gz
pdbg-81d2d2fa8d8a9cd1b51c39ba74e9426064263f34.zip
htm: Change buffer wrappings semantics
"htm record" is set to non-wrapping mode "htm start" is in wrapping mode since it's assumed "htm stop" will stop it. Signed-off-by: Michael Neuling <mikey@neuling.org>
-rw-r--r--libpdbg/htm.c33
-rw-r--r--src/htm.c4
2 files changed, 24 insertions, 13 deletions
diff --git a/libpdbg/htm.c b/libpdbg/htm.c
index fb1d415..4a49628 100644
--- a/libpdbg/htm.c
+++ b/libpdbg/htm.c
@@ -436,9 +436,9 @@ static int configure_debugfs_memtrace(struct htm *htm)
return 0;
}
-static int configure_chtm(struct htm *htm)
+static int configure_chtm(struct htm *htm, bool wrap)
{
- uint64_t hid0, ncu;
+ uint64_t hid0, ncu, val;
if (!pdbg_target_is_class(&htm->target, "chtm"))
return 0;
@@ -446,8 +446,9 @@ static int configure_chtm(struct htm *htm)
if (HTM_ERR(configure_debugfs_memtrace(htm)))
return -1;
+ val = wrap ? HTM_MODE_WRAP : 0;
if (HTM_ERR(pib_write(&htm->target, HTM_COLLECTION_MODE,
- HTM_MODE_ENABLE)))
+ HTM_MODE_ENABLE | val)))
return -1;
if (HTM_ERR(pib_read(htm->target.parent, HID0_REGISTER, &hid0)))
@@ -493,7 +494,7 @@ static int deconfigure_chtm(struct htm *htm)
return 0;
}
-static int configure_nhtm(struct htm *htm)
+static int configure_nhtm(struct htm *htm, bool wrap)
{
uint64_t val;
@@ -507,10 +508,11 @@ static int configure_nhtm(struct htm *htm)
* The constant is the VGTARGET field, taken from a cronus
* booted system which presumably set it up correctly
*/
+ val = wrap ? HTM_MODE_WRAP : 0;
if (HTM_ERR(pib_write(&htm->target, HTM_COLLECTION_MODE,
HTM_MODE_ENABLE |
NHTM_MODE_CRESP_PRECISE |
- HTM_MODE_WRAP |
+ val |
0xFFFF000000)))
return -1;
@@ -710,7 +712,7 @@ static int configure_memory(struct htm *htm)
return 0;
}
-static int do_htm_reset(struct htm *htm)
+static int do_htm_reset(struct htm *htm, bool wrap)
{
struct htm_status status;
@@ -718,9 +720,9 @@ static int do_htm_reset(struct htm *htm)
return -1;
if (!is_resetable(&status) || !is_configured(htm)) {
- if (configure_nhtm(htm) < 0)
+ if (configure_nhtm(htm, wrap) < 0)
return -1;
- if (configure_chtm(htm) < 0)
+ if (configure_chtm(htm, wrap) < 0)
return -1;
}
@@ -755,11 +757,11 @@ static int htm_toggle_debug_bit(struct htm *htm)
return 0;
}
-static int do_htm_start(struct htm *htm)
+static int __do_htm_start(struct htm *htm, bool wrap)
{
struct htm_status status;
- if (do_htm_reset(htm) < 0)
+ if (do_htm_reset(htm, wrap) < 0)
return -1;
if (HTM_ERR(get_status(htm, &status)))
@@ -790,6 +792,11 @@ static int do_htm_start(struct htm *htm)
return 1;
}
+static int do_htm_start(struct htm *htm)
+{
+ return __do_htm_start(htm, true);
+}
+
static int do_htm_stop(struct htm *htm)
{
struct htm_status status;
@@ -926,6 +933,10 @@ static int do_htm_status(struct htm *htm)
return 1;
}
+/*
+ * FIXME:
+ * Look for eyecatcher 0xacef_f000 at start, otherwise assume wrapping
+ */
static int do_htm_dump(struct htm *htm, uint64_t size, char *filename)
{
char *trace_file;
@@ -1008,7 +1019,7 @@ static int do_htm_dump(struct htm *htm, uint64_t size, char *filename)
static int do_htm_record(struct htm *htm, char *filename)
{
- if (do_htm_start(htm) < 0)
+ if (__do_htm_start(htm, false) < 0)
return -1;
if (htm_wait_complete(htm))
diff --git a/src/htm.c b/src/htm.c
index eff46a6..02e55c1 100644
--- a/src/htm.c
+++ b/src/htm.c
@@ -86,7 +86,7 @@ static int run_start(enum htm_type type)
if (target_is_disabled(target))
continue;
- printf("Starting HTM@");
+ printf("Starting with buffer wrapping HTM@");
print_htm_address(type, target);
if (htm_start(target) != 1) {
printf("Couldn't start HTM@");
@@ -195,7 +195,7 @@ static int run_record(enum htm_type type)
return 0;
/* size = 0 will dump everything */
- printf("Recording HTM@");
+ printf("Recording till buffer wraps HTM@");
print_htm_address(type, target);
if (htm_record(target, filename) != 1) {
printf("Couldn't record HTM@");
OpenPOWER on IntegriCloud