diff mbox series

[v2] libpdbg: Add a hardware unit for the processor module

Message ID 20200323044508.397886-1-amitay@ozlabs.org
State Accepted
Headers show
Series [v2] libpdbg: Add a hardware unit for the processor module | expand

Checks

Context Check Description
snowpatch_ozlabs/apply_patch success Successfully applied on branch master (8b4611b5d8e7e2279fe4aa80c892fcfe10aa398d)
snowpatch_ozlabs/build-multiarch success Test build-multiarch on branch master

Commit Message

Amitay Isaacs March 23, 2020, 4:45 a.m. UTC
From: Alistair Popple <alistair@popple.id.au>

The processor target is a purely logical target but it can be useful
for storing processor wide properties. This means an easy way of
iterating over the processor targets is required, so add a hardware
unit which assigns them to a specific class.

Signed-off-by: Alistair Popple <alistair@popple.id.au>
Signed-off-by: Amitay Isaacs <amitay@ozlabs.org>
---
 libpdbg/chip.c   | 15 +++++++++++++++
 libpdbg/hwunit.h |  4 ++++
 2 files changed, 19 insertions(+)
diff mbox series

Patch

diff --git a/libpdbg/chip.c b/libpdbg/chip.c
index 908b20d..b45cffa 100644
--- a/libpdbg/chip.c
+++ b/libpdbg/chip.c
@@ -666,3 +666,18 @@  int thread_getregs(struct pdbg_target *thread, struct thread_regs *regs)
 
 	return 0;
 }
+
+static struct proc proc = {
+	.target = {
+		.name = "Processor Module",
+		.compatible = "ibm,processor",
+		.class = "proc",
+	},
+};
+DECLARE_HW_UNIT(proc);
+
+__attribute__((constructor))
+static void register_proc(void)
+{
+	pdbg_hwunit_register(&proc_hw_unit);
+}
diff --git a/libpdbg/hwunit.h b/libpdbg/hwunit.h
index ae8a15a..343de4b 100644
--- a/libpdbg/hwunit.h
+++ b/libpdbg/hwunit.h
@@ -46,6 +46,10 @@  const struct hw_unit_info *pdbg_hwunit_find_compatible(const char *compat);
 	const struct hw_unit_info __used name ##_hw_unit =              \
 	{ .hw_unit = &name, .size = sizeof(name) };
 
+struct proc {
+	struct pdbg_target target;
+};
+
 struct htm {
 	struct pdbg_target target;
 	int (*start)(struct htm *);