From patchwork Mon Jul 1 07:52:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Popple X-Patchwork-Id: 1125119 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 45cfjN6Bn1z9s4V for ; Mon, 1 Jul 2019 17:52:24 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=popple.id.au Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 45cfjN51W1zDqTM for ; Mon, 1 Jul 2019 17:52:24 +1000 (AEST) X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [203.11.71.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 45cfjK0j1FzDqSx for ; Mon, 1 Jul 2019 17:52:21 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=popple.id.au Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 45cfjJ6pCrz9s4V; Mon, 1 Jul 2019 17:52:20 +1000 (AEST) From: Alistair Popple To: pdbg@lists.ozlabs.org Date: Mon, 1 Jul 2019 17:52:09 +1000 Message-Id: <20190701075209.2226-2-alistair@popple.id.au> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190701075209.2226-1-alistair@popple.id.au> References: <20190701075209.2226-1-alistair@popple.id.au> Subject: [Pdbg] [PATCH 2/2] pdbg: Remove default_backend() selection 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: , MIME-Version: 1.0 Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Now that libpdbg can automatically select the correct device-tree the pdbg application doesn't need code to do the same thing. By default pdbg can just rely on the device-tree selected by libpdbg. Unfortunately to maintain backwards compatibility for users explicitly selecting a device-tree and device-tree node we need to retain most of the code and continue linking the device-trees into the application. It would be good to remove these one day so print a deprecation warning when a user does explicitly select a backend. Signed-off-by: Alistair Popple --- src/main.c | 41 ++++++++++++++++++++++++----------------- src/main.h | 2 +- src/options.h | 3 --- src/options_arm.c | 14 -------------- src/options_def.c | 5 ----- src/options_ppc.c | 5 ----- 6 files changed, 25 insertions(+), 45 deletions(-) diff --git a/src/main.c b/src/main.c index ad40d19..7cee57b 100644 --- a/src/main.c +++ b/src/main.c @@ -64,7 +64,7 @@ #define THREADS_PER_CORE 8 -static enum backend backend = KERNEL; +static enum backend backend = DEFAULT_BACKEND; static char const *device_node; static int i2c_addr = 0x50; @@ -607,17 +607,6 @@ static bool target_selection(void) return false; } - if (pathsel_count) { - if (!path_target_parse(pathsel, pathsel_count)) - return false; - } - - if (!path_target_present()) { - printf("No valid targets found or specified. Try adding -p/-c/-t options to specify a target.\n"); - printf("Alternatively run 'pdbg -a probe' to get a list of all valid targets\n"); - return false; - } - return true; } @@ -677,9 +666,7 @@ int main(int argc, char *argv[]) optcmd_cmd_t *cmd; struct pdbg_target *target; - backend = default_backend(); - - if (!device_node) + if (backend && !device_node) device_node = default_target(backend); if (!parse_options(argc, argv)) @@ -690,9 +677,29 @@ int main(int argc, char *argv[]) return 1; } - /* Disable unselected targets */ - if (!target_selection()) + if (backend) { + fprintf(stderr, "WARNING: Explicit backend selection should no longer be required\n"); + fprintf(stderr, " and will be deprecated in a future release.\n"); + fprintf(stderr, " Removing -b/-d command line options will remove this warning.\n"); + fprintf(stderr, " An explicit device-tree can still be selected using the\n"); + fprintf(stderr, " LPDBG_DTB environment variable instead.\n"); + + if (!target_selection()) + return 1; + } else { + pdbg_targets_init(NULL); + } + + if (pathsel_count) { + if (!path_target_parse(pathsel, pathsel_count)) + return false; + } + + if (!path_target_present()) { + printf("No valid targets found or specified. Try adding -p/-c/-t options to specify a target.\n"); + printf("Alternatively run 'pdbg -a probe' to get a list of all valid targets\n"); return 1; + } /* Probe all selected targets */ for_each_path_target(target) { diff --git a/src/main.h b/src/main.h index 78b4d92..1d5913e 100644 --- a/src/main.h +++ b/src/main.h @@ -19,7 +19,7 @@ #include -enum backend { FSI, I2C, KERNEL, FAKE, HOST }; +enum backend { DEFAULT_BACKEND = 0, FSI, I2C, KERNEL, FAKE, HOST }; static inline bool target_is_disabled(struct pdbg_target *target) { diff --git a/src/options.h b/src/options.h index 67f15a8..cf63cbe 100644 --- a/src/options.h +++ b/src/options.h @@ -14,9 +14,6 @@ * limitations under the License. */ -/* Default backend on this platform */ -enum backend default_backend(void); - /* Print all possible backends on this platform */ void print_backends(FILE *stream); diff --git a/src/options_arm.c b/src/options_arm.c index 0dbc731..99a2d3f 100644 --- a/src/options_arm.c +++ b/src/options_arm.c @@ -28,20 +28,6 @@ #define CHIP_ID_P9 0xd1 #define CHIP_ID_P8P 0xd3 -enum backend default_backend(void) -{ - int rc; - rc = access(AMI_BMC, F_OK); - if (rc == 0) /* AMI BMC */ - return I2C; - - rc = access(OPENFSI_BMC, F_OK); - if (rc == 0) /* Kernel interface. OpenBMC */ - return KERNEL; - - return FAKE; -} - void print_backends(FILE *stream) { fprintf(stream, "Valid backends: i2c kernel fsi fake\n"); diff --git a/src/options_def.c b/src/options_def.c index 4092cea..3fef60d 100644 --- a/src/options_def.c +++ b/src/options_def.c @@ -17,11 +17,6 @@ #include #include "main.h" -enum backend default_backend(void) -{ - return FAKE; -} - void print_backends(FILE *stream) { fprintf(stream, "Valid backends: fake\n"); diff --git a/src/options_ppc.c b/src/options_ppc.c index 62eb7b0..82f410b 100644 --- a/src/options_ppc.c +++ b/src/options_ppc.c @@ -21,11 +21,6 @@ static const char p8[] = "p8"; static const char p9[] = "p9"; -enum backend default_backend(void) -{ - return HOST; -} - void print_backends(FILE *stream) { fprintf(stream, "Valid backends: host fake\n");