[Pdbg] [PATCH 08/14] libpdbg/p9chip.c: implement step support

Nicholas Piggin npiggin at gmail.com
Mon Apr 9 17:35:16 AEST 2018


Signed-off-by: Nicholas Piggin <npiggin at gmail.com>
---
 libpdbg/p9chip.c | 32 +++++++++++++++++++++++++++++++-
 1 file changed, 31 insertions(+), 1 deletion(-)

diff --git a/libpdbg/p9chip.c b/libpdbg/p9chip.c
index 25590fc..a45ea5d 100644
--- a/libpdbg/p9chip.c
+++ b/libpdbg/p9chip.c
@@ -104,9 +104,38 @@ static int p9_thread_stop(struct thread *thread)
 	return 0;
 }
 
+static int p9_thread_step(struct thread *thread, int count)
+{
+	uint64_t value;
+	int i;
+
+	/* Can only sreset if a thread is inactive */
+	if (p9_get_thread_status(thread) != (THREAD_STATUS_QUIESCE | THREAD_STATUS_ACTIVE))
+		return 1;
+
+	/* Fence interrupts. */
+	thread_write(thread, P9_RAS_MODEREG, PPC_BIT(57));
+
+	/* Step the core */
+	for (i = 0; i < count; i++) {
+		/* Step */
+		thread_write(thread, P9_DIRECT_CONTROL, PPC_BIT(5 + 8*thread->id));
+
+		/* Poll PPC complete */
+		do {
+			thread_read(thread, P9_RAS_STATUS, &value);
+		} while (!(value & PPC_BIT(4 + 8*thread->id)));
+	}
+
+	/* Un-fence */
+	thread_write(thread, P9_RAS_MODEREG, 0);
+
+	return 0;
+}
+
 static int p9_thread_sreset(struct thread *thread)
 {
-	/* Can only sreset if a thread is inactive, at least on DD1 */
+	/* Can only sreset if a thread is inactive */
 	if (p9_get_thread_status(thread) != (THREAD_STATUS_QUIESCE | THREAD_STATUS_ACTIVE))
 		return 1;
 
@@ -200,6 +229,7 @@ struct thread p9_thread = {
 	},
 	.start = p9_thread_start,
 	.stop = p9_thread_stop,
+	.step = p9_thread_step,
 	.sreset = p9_thread_sreset,
 	.ram_setup = p9_ram_setup,
 	.ram_instruction = p9_ram_instruction,
-- 
2.17.0



More information about the Pdbg mailing list