diff mbox series

[1/3] libpdbg: Add api to set short/long running application context

Message ID 20220128061221.1054173-2-amitay@ozlabs.org
State Accepted
Headers show
Series Add long/short running application context | expand

Commit Message

Amitay Isaacs Jan. 28, 2022, 6:12 a.m. UTC
For P10 systems, BMC applications use libpdbg for hardware access and
are typically long running.  Such applications may need slightly
different behaviour of libpdbg when doing probe or other hardware
access than pdbg tool.  The default behaviour of libpdbg is set to be
used in long running application.

Pdbg tool (or similar applications, e.g. ecmd) can set the short running
application context explicitly using pdbg_context_short().

Signed-off-by: Amitay Isaacs <amitay@ozlabs.org>
---
 libpdbg/libpdbg.c | 17 +++++++++++++++++
 libpdbg/libpdbg.h |  9 +++++++++
 libpdbg/target.h  |  2 ++
 3 files changed, 28 insertions(+)
diff mbox series

Patch

diff --git a/libpdbg/libpdbg.c b/libpdbg/libpdbg.c
index bca727e..a153b07 100644
--- a/libpdbg/libpdbg.c
+++ b/libpdbg/libpdbg.c
@@ -5,6 +5,7 @@ 
 #include "libpdbg.h"
 
 static pdbg_progress_tick_t progress_tick;
+static bool pdbg_short_context = false;
 
 struct pdbg_target *get_parent(struct pdbg_target *target, bool system)
 {
@@ -342,3 +343,19 @@  void pdbg_set_progress_tick(pdbg_progress_tick_t fn)
 {
 	progress_tick = fn;
 }
+
+bool pdbg_context_short(void)
+{
+	if (pdbg_target_root()) {
+		pdbg_log(PDBG_ERROR, "pdbg_context_short() must be called before pdbg_targets_init()\n");
+		return false;
+	}
+
+	pdbg_short_context = true;
+	return true;
+}
+
+bool pdbg_context_is_short(void)
+{
+	return pdbg_short_context;
+}
diff --git a/libpdbg/libpdbg.h b/libpdbg/libpdbg.h
index 633d571..05e54f7 100644
--- a/libpdbg/libpdbg.h
+++ b/libpdbg/libpdbg.h
@@ -1441,6 +1441,15 @@  void pdbg_set_loglevel(int loglevel);
  */
 void pdbg_log(int loglevel, const char *fmt, ...);
 
+/**
+ * @brief Set the library context for short running application
+ *
+ * This distinguishes the long running applications using libpdbg from the
+ * pdbg tool like applications which terminate after short execution and do
+ * not set particular hardware state for a long time.
+ */
+bool pdbg_context_short(void);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/libpdbg/target.h b/libpdbg/target.h
index 5fb4e63..5cc694c 100644
--- a/libpdbg/target.h
+++ b/libpdbg/target.h
@@ -95,4 +95,6 @@  bool target_is_virtual(struct pdbg_target *target);
 struct pdbg_target *target_to_real(struct pdbg_target *target, bool strict);
 struct pdbg_target *target_to_virtual(struct pdbg_target *target, bool strict);
 
+bool pdbg_context_is_short(void);
+
 #endif