From patchwork Fri Jan 28 06:12:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1585509 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.a=rsa-sha256 header.s=201707 header.b=qqoNbJ1k; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=112.213.38.117; helo=lists.ozlabs.org; envelope-from=pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4JlRvV033Zz9t3b for ; Fri, 28 Jan 2022 17:12:37 +1100 (AEDT) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4JlRvS3nQrz3bSs for ; Fri, 28 Jan 2022 17:12:36 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.a=rsa-sha256 header.s=201707 header.b=qqoNbJ1k; dkim-atps=neutral X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee2:21ea]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4JlRvN70rrz301M for ; Fri, 28 Jan 2022 17:12:32 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.a=rsa-sha256 header.s=201707 header.b=qqoNbJ1k; dkim-atps=neutral Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 4JlRvN3X5dz4xcS; Fri, 28 Jan 2022 17:12:32 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ozlabs.org; s=201707; t=1643350352; bh=dLRk2L2lYXglM8NejQ/xXy/3Zof1n0gJ6wsjbmBxOy0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qqoNbJ1kR1Pd5y2cIpC+A5lHQVYOk7vtaNnL+XWTi/j0reDyjE2OrCJUNfAekFwN4 SJ+f/Vri4hwTDp5zvSrpiHKR0C3NFTcn4mvpxO5IP3iS5XNBj3lncENNIUbQNHfvyR wxwpk1BgltIFcL4gPS4s/JXkW5PaRwLE3LuopjFmkndTfkRf/E7y9e8Df+RCm1AzP4 5fY8B8zmNVKvBw92BgfuGQ4zzP79FW5tsHChniOE5ZmHXAXPSeonVccOwPVOe6j7Ps Xx1uUELovUfvZ2zKk9hxneDxykcRNE5FVQsxul2QfpaY6cHzk0lShad9GaaFE0N2uO DEVDSZ8PdNbIQ== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Fri, 28 Jan 2022 17:12:19 +1100 Message-Id: <20220128061221.1054173-2-amitay@ozlabs.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220128061221.1054173-1-amitay@ozlabs.org> References: <20220128061221.1054173-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH 1/3] libpdbg: Add api to set short/long running application context X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Amitay Isaacs Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" 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 --- libpdbg/libpdbg.c | 17 +++++++++++++++++ libpdbg/libpdbg.h | 9 +++++++++ libpdbg/target.h | 2 ++ 3 files changed, 28 insertions(+) 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