From patchwork Fri Jun 1 06:30:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 923775 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.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40xvdr5rFvz9s0W for ; Fri, 1 Jun 2018 16:32:48 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="VnglwXai"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 40xvdr49WkzDrph for ; Fri, 1 Jun 2018 16:32:48 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="VnglwXai"; dkim-atps=neutral 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.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 40xvc21yvWzF0cy for ; Fri, 1 Jun 2018 16:31:14 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="VnglwXai"; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPSA id 40xvc06BX8z9s0W; Fri, 1 Jun 2018 16:31:12 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1527834673; bh=PvDXvT2EY4CXmMdS2URQov6+6ulizUPy9AAxMmsZpWk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VnglwXaiBvIhuHfAn6vgKu3ViPeCDuqk1DphHzmBtzL0/aviezihqJIvkUTGYkJg4 PNImr4ToVsAXCAQnBUHwBr+bl1aMfz7OYZw3vsd/vu2oNholEOylCSaBDSMO1uJd6n 80DLJgcv6Aw2pB29+o+T1uVwak+6DzTFCdUgFrbYLXqm5dGiagcndWDQcCX8Ocw0Vg njuGaISwtWrt46s/YkTup7CMt4CMV+W71ZbMTx9dWbC2trJQZdh8TbcitMn9iydcUo dvqafIVe7mM1rGq9fL0t8wWA+IYFZQkwB9BA+zmtLvdszr/ompd19FO8SEH/7KPq1m x68PqwLHEJVSw== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Fri, 1 Jun 2018 16:30:44 +1000 Message-Id: <20180601063050.19286-2-amitay@ozlabs.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180601063050.19286-1-amitay@ozlabs.org> References: <20180601063050.19286-1-amitay@ozlabs.org> Subject: [Pdbg] [PATCH v2 1/7] main: Overhaul target selection X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.26 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 MIME-Version: 1.0 Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Support explicit multiple target selection using ranges and lists. For options -p/-c/-t, support the following valid arguments: 3 0-7 1,2,3 0-5,7,9-11,17,19 For loss of sanity, make sense of the following valid arguments: 3,3,3,3,3,3 1-6,2-5 1,2,3,0-7 Conjunction of -p/-c/-t with -a also works and it's insensitive to order of options specified. -a -c 1,2 processors 0-max; chips 1-2; threads 0-max -p 0 -c 0 -a processors 0; chips 0; threads 0-max -a -c 1 -t 1 processors 0-max; chips 1; threads 1 Signed-off-by: Amitay Isaacs --- src/main.c | 171 ++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 131 insertions(+), 40 deletions(-) diff --git a/src/main.c b/src/main.c index 2200a01..457cda2 100644 --- a/src/main.c +++ b/src/main.c @@ -131,9 +131,9 @@ static void print_usage(char *pname) printf("Usage: %s [options] command ...\n\n", pname); printf(" Options:\n"); - printf("\t-p, --processor=processor-id\n"); - printf("\t-c, --chip=core-id\n"); - printf("\t-t, --thread=thread\n"); + printf("\t-p, --processor=<0-%d>||\n", MAX_PROCESSORS); + printf("\t-c, --chip=<0-%d>||\n", MAX_CHIPS); + printf("\t-t, --thread=<0-%d>||\n", MAX_THREADS); printf("\t-a, --all\n"); printf("\t\tRun command on all possible processors/chips/threads (default)\n"); printf("\t-b, --backend=backend\n"); @@ -166,11 +166,72 @@ static void print_usage(char *pname) } } +/* Parse argument of the form 0-5,7,9-11,15,17 */ +static bool parse_list(const char *arg, int max, int *list, int *count) +{ + char str[strlen(arg)+1]; + char *tok, *tmp, *saveptr = NULL; + int i, n; + + strcpy(str, arg); + + for (i=0; i= max) { + return false; + } + } + + b = strtok_r(NULL, "-", &saveptr2); + if (b == NULL) { + to = from; + } else { + to = atoi(b); + if (to >= max) { + return false; + } + } + + if (from > to) + return false; + + for (i=from; i<=to; i++) + list[i] = 1; + + tmp = NULL; + }; + + n = 0; + for (i=0; i= MAX_PROCESSORS) - opt_error = true; - else - processorsel[current_processor] = &chipsel[current_processor][0]; - } + if (!parse_list(optarg, MAX_PROCESSORS, p_list, &p_count)) + fprintf(stderr, "Failed to parse '-p %s'\n", optarg); + else + opt_error = false; break; case 'c': - errno = 0; - current_chip = strtoul(optarg, &endptr, 0); - opt_error = (errno || *endptr != '\0'); - if (!opt_error) { - if (current_chip >= MAX_CHIPS) - opt_error = true; - else - chipsel[current_processor][current_chip] = &threadsel[current_processor][current_chip][0]; - } + if (!parse_list(optarg, MAX_CHIPS, c_list, &c_count)) + fprintf(stderr, "Failed to parse '-c %s'\n", optarg); + else + opt_error = false; break; case 't': - errno = 0; - current_thread = strtoul(optarg, &endptr, 0); - opt_error = (errno || *endptr != '\0'); - if (!opt_error) { - if (current_thread >= MAX_THREADS) - opt_error = true; - else - threadsel[current_processor][current_chip][current_thread] = 1; - } + if (!parse_list(optarg, MAX_THREADS, t_list, &t_count)) + fprintf(stderr, "Failed to parse '-t %s'\n", optarg); + else + opt_error = false; break; case 'b': @@ -292,10 +348,45 @@ static bool parse_options(int argc, char *argv[]) } } while (c != EOF && !opt_error); - if (opt_error) + if (opt_error) { print_usage(basename(argv[0])); + return false; + } + + if ((c_count > 0 || t_count > 0) && p_count == 0) { + fprintf(stderr, "No processor(s) selected\n"); + fprintf(stderr, "Use -p or -a to select processor(s)\n"); + return false; + } + + if (t_count > 0 && c_count == 0) { + fprintf(stderr, "No chip(s) selected\n"); + fprintf(stderr, "Use -c or -a to select chip(s)\n"); + return false; + } + + for (i=0; i X-Patchwork-Id: 923776 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40xvdv59s5z9s0W for ; Fri, 1 Jun 2018 16:32:51 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="VkrlY/tf"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 40xvdv2Z2mzF0Rs for ; Fri, 1 Jun 2018 16:32:51 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="VkrlY/tf"; dkim-atps=neutral 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.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 40xvc32PS5zF0Vt for ; Fri, 1 Jun 2018 16:31:15 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="VkrlY/tf"; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPSA id 40xvc2053Wz9s0x; Fri, 1 Jun 2018 16:31:13 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1527834674; bh=3Sibv8fNusijJNqFUKgw/Dre9FnmH55ExPBzfDLWL5w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VkrlY/tfq5qvJa24SBrbRr5Z8HFUIhXY3TlMyC5k/ESiWobMEHFIe9W1gXO70fr9F HYg12UryE+PDGFJA0WPnJKTrr9M97DQLpn2AqR3Ep22W1HGWy/HGgP8cnu+Fr77J7d V2C1kYxS50Cw/LPkN0cNgqw5CipWRxUs9PLt9xwYVeAagplS6KAPhR+L9T5GepW5UD dhmImEozLmUKs8+/O72PHT1CeQAZI7gcf8D6naXzEAWqlltSCtVvIFrRyyC3CAZYVX Nf6zmjDK2Ax5dEM/+rg4Dh4INMTfLJ2aEKD+olbEpOgXsnp89DurXMmvNdR84sWGse YujF8tlPFfTjA== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Fri, 1 Jun 2018 16:30:45 +1000 Message-Id: <20180601063050.19286-3-amitay@ozlabs.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180601063050.19286-1-amitay@ozlabs.org> References: <20180601063050.19286-1-amitay@ozlabs.org> Subject: [Pdbg] [PATCH v2 2/7] main: Print specific errors for invalid arguments X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.26 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 MIME-Version: 1.0 Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" This avoids the large usage message obscuring the actual errors from parsing options. Print usage only if an option is invalid. Signed-off-by: Amitay Isaacs Reviewed-By: Alistair Popple --- src/main.c | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/src/main.c b/src/main.c index 457cda2..db27409 100644 --- a/src/main.c +++ b/src/main.c @@ -226,7 +226,7 @@ static bool parse_list(const char *arg, int max, int *list, int *count) static bool parse_options(int argc, char *argv[]) { int c; - bool opt_error = true; + bool opt_error = false; int p_list[MAX_PROCESSORS]; int c_list[MAX_CHIPS]; int t_list[MAX_THREADS]; @@ -255,8 +255,6 @@ static bool parse_options(int argc, char *argv[]) switch(c) { case 'a': - opt_error = false; - if (p_count == 0) { p_count = MAX_PROCESSORS; for (i=0; i X-Patchwork-Id: 923777 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.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40xvdy1YnCz9s08 for ; Fri, 1 Jun 2018 16:32:54 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="o5AjfQJi"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 40xvdx72MzzF0Rs for ; Fri, 1 Jun 2018 16:32:53 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="o5AjfQJi"; dkim-atps=neutral X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (ozlabs.org [IPv6:2401:3900:2:1::2]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 40xvc339xZzDrp0 for ; Fri, 1 Jun 2018 16:31:15 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="o5AjfQJi"; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPSA id 40xvc25kXpz9rvt; Fri, 1 Jun 2018 16:31:14 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1527834675; bh=roWsWnkpOaG1T6ESL3jsOpkTrMwsRlzbfYpaw/7A50A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=o5AjfQJiCTvTYlO/pck88a4XC+t17zSFmsjJ7a4yZVNfeWs1nJBAmUWpodjV1r/m6 mtBU4DYv70n1g5ZxVNT3OM8z7fbdngOFS+3JgurrlAjGrNhvCka0LvGFBXp0Ks3FF7 IDmiMyTYsLyoixw/ohZqEOrw4wtAbcZlsrQBjFCxQHvjrJGWl0xp3xIhkE16pSKYw+ TiSiwUPoDfeaszDC4BpbndO0Ppo1CJreid5WkkAVg8TNbzJbJ1O1QBMxwMHznfOYPB AeDgWz732CRyPRhGh30WWQD4Rf9NoG1+hWA5fprK8kUmxSQrgI8op3BrkabVlD03Ov P67bx1FPdQepA== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Fri, 1 Jun 2018 16:30:46 +1000 Message-Id: <20180601063050.19286-4-amitay@ozlabs.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180601063050.19286-1-amitay@ozlabs.org> References: <20180601063050.19286-1-amitay@ozlabs.org> Subject: [Pdbg] [PATCH v2 3/7] main: Print specific errors for invalid commands X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.26 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 MIME-Version: 1.0 Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" This avoids large usage message obscuring the actual error message. Signed-off-by: Amitay Isaacs Reviewed-by: Alistair Popple --- src/main.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main.c b/src/main.c index db27409..6dacd66 100644 --- a/src/main.c +++ b/src/main.c @@ -732,7 +732,6 @@ int main(int argc, char *argv[]) } PR_ERROR("Unsupported command: %s\n", argv[optind]); - print_usage(basename(argv[0])); return 1; found_action: From patchwork Fri Jun 1 06:30:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 923778 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.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40xvf04ppJz9s0W for ; Fri, 1 Jun 2018 16:32:56 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="vCWj+W8b"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 40xvf03JCvzF0Tj for ; Fri, 1 Jun 2018 16:32:56 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="vCWj+W8b"; dkim-atps=neutral X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (ozlabs.org [IPv6:2401:3900:2:1::2]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 40xvc35qXjzF0dW for ; Fri, 1 Jun 2018 16:31:15 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="vCWj+W8b"; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPSA id 40xvc33NDgz9s08; Fri, 1 Jun 2018 16:31:15 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1527834675; bh=3C9ENttpFnUfDlYh/ityNGM/02Q7s/YPttyb4TRIUbQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vCWj+W8b6EXiX+X3uZdh4BRWigM1YjZc+XQJmMTiAmg3Sa18zXKvlOz/vqr05DFqu gWMzJ9VWtwLRisreMiveZoHwy3AiGMqVAIUR+9xLw1tMOsDRMmEQ74jw15Z4cTf96I 6tXqk74Knc5bnHWXh6+Q4bG+OkNutGrLn/Ku8dAi4azvU/lnjszye1q1sohXgTt+MZ 84bBjiZZF8BOQR/oaMXTR2LHzNhLJCaD4/IwD9rSeMT9Qhhxp9I1Ye1/JqNIAuSQPq 1hsRcmdsabEppj5RrSkyGFY+lQ9fWI6Y1sY23eWVMcka+7ipUJnG6VS55RU+BVUUkj doZi6y3K3mm+w== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Fri, 1 Jun 2018 16:30:47 +1000 Message-Id: <20180601063050.19286-5-amitay@ozlabs.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180601063050.19286-1-amitay@ozlabs.org> References: <20180601063050.19286-1-amitay@ozlabs.org> Subject: [Pdbg] [PATCH v2 4/7] fake.dts: Add more targets for testing X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.26 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 MIME-Version: 1.0 Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" The number of targets (pib/core/thread) can be changed easily by changing the arguments to dump_fsi() macro. The targets have unique addresses, so can be used for testing range-checking (if any) for getscom/putscom operations. Signed-off-by: Amitay Isaacs Reviewed-by: Alistair Popple --- fake.dts.m4 | 121 ++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 103 insertions(+), 18 deletions(-) diff --git a/fake.dts.m4 b/fake.dts.m4 index 56bf35e..4c6c145 100644 --- a/fake.dts.m4 +++ b/fake.dts.m4 @@ -1,22 +1,107 @@ +dnl +dnl forloop([var], [start], [end], [iterator]) +dnl +divert(`-1') +define(`forloop', `pushdef(`$1', `$2')_forloop($@)popdef(`$1')') +define(`_forloop', + `$4`'ifelse($1, `$3', `', `define(`$1', incr($1))$0($@)')') + +dnl +dnl dump_thread([index]) +dnl +define(`dump_thread', +` + thread@$1 { + #address-cells = <0x0>; + #size-cells = <0x0>; + compatible = "ibm,fake-thread"; + reg = <0x$1 0x0>; + index = <0x$1>; + }; +')dnl + +dnl +dnl dump_core_pre([index], [addr]) +dnl +define(`dump_core_pre', +` + core@$2 { + #address-cells = <0x1>; + #size-cells = <0x1>; + compatible = "ibm,fake-core"; + reg = <0x$2 0x0>; + index = <0x$1>;') + +dnl +dnl dump_core_post() +dnl +define(`dump_core_post', ` }; +')dnl + +dnl +dnl dump_core([index], [addr], [num_threads]) +dnl +define(`dump_core', +`dump_core_pre(`$1', `$2') +forloop(`i', `0', eval(`$3-1'), `dump_thread(i)') +dump_core_post()') + +dnl +dnl dump_processor_pre([index], [addr]) +dnl +define(`dump_processor_pre', +` + pib@$2 { + #address-cells = <0x1>; + #size-cells = <0x1>; + compatible = "ibm,fake-pib"; + reg = <0x$2 0x0>; + index = <0x$1>;') + +dnl +dnl dump_processor_post() +dnl +define(`dump_processor_post', ` }; +')dnl + +dnl +dnl dump_processor([index], [addr], [num_cores], [num_threads]) +dnl +define(`dump_processor',dnl +`dump_processor_pre(`$1', `$2') +forloop(`i', `0', eval(`$3-1'), `dump_core(i, eval($2+(i+1)*10), $4)') +dump_processor_post()') + +dnl +dnl dump_fsi_pre([index], [addr]) +dnl +define(`dump_fsi_pre', +` + fsi@$2 { + #address-cells = <0x1>; + #size-cells = <0x1>; + compatible = "ibm,fake-fsi"; + reg = <0x$2 0x0>; + index = <0x$1>;') + +dnl +dnl dump_fsi_post() +dnl +define(`dump_fsi_post', ` };') + +dnl +dnl dump_fsi([index], [addr], [num_processors], [num_cores], [num_threads]) +dnl +define(`dump_fsi', +`dump_fsi_pre(`$1', `$2') +forloop(`i', `0', eval(`$3-1'), `dump_processor(i, eval(10000+i*1000), $4, $5)') +dump_fsi_post()') +divert`'dnl + /dts-v1/; / { - #address-cells = <0x1>; - #size-cells = <0x0>; - - fsi@0 { - #address-cells = <0x2>; - #size-cells = <0x1>; - compatible = "ibm,fake-fsi"; - reg = <0x0 0x0 0x0>; - - index = <0x0>; - status = "mustexist"; - - pib@0 { - compatible = "ibm,fake-pib"; - reg = <0x0 0x0 0x0>; - index = <0x0>; - }; - }; + #address-cells = <0x1>; + #size-cells = <0x1>; +dump_fsi(0, 0, 8, 4, 2) }; From patchwork Fri Jun 1 06:30:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 923779 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.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40xvf45Hk7z9s0W for ; Fri, 1 Jun 2018 16:33:00 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="wtPxeCh0"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 40xvf43bh0zDrph for ; Fri, 1 Jun 2018 16:33:00 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="wtPxeCh0"; dkim-atps=neutral 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.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 40xvc42cPpzDrbn for ; Fri, 1 Jun 2018 16:31:16 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="wtPxeCh0"; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPSA id 40xvc363pcz9rvt; Fri, 1 Jun 2018 16:31:15 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1527834676; bh=XxzB6ezHzf56HlADj5vzNHk43r4NIsIjQfWj4hW562s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wtPxeCh0tiaRV2U0PaI6DIciL63UM0qG8NXDYVBxOZvsOWCaKGEKccxTU3BuxJgpP isztojW+iG07l4wWmQMFoZaRPrIWLpsXjRro8xINwYPCrxwABfcfxScA+7IHyW9hxu ws4ZSXpulwS0YIZCM7DZkaAgkiOSa6JUyZtLpIrsEz/Ovj7eIqGUtyRahfr4InXSJX Mn17RtAnALY+vEM6IWWTX/5V2TLhHKQxIAjr4ivWBAx9fl9HElsq5xZdByUcZ/1Qhm jwGDem5Ltk/9WWyQfUiFF7r/aZYhh+tzh88OhGucny0Mofr3C1Dq85X1Oug/KEH+Cp YQVQD+590yaew== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Fri, 1 Jun 2018 16:30:48 +1000 Message-Id: <20180601063050.19286-6-amitay@ozlabs.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180601063050.19286-1-amitay@ozlabs.org> References: <20180601063050.19286-1-amitay@ozlabs.org> Subject: [Pdbg] [PATCH v2 5/7] fake: Add fake targets for testing X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.26 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 MIME-Version: 1.0 Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Signed-off-by: Amitay Isaacs Reviewed-by: Alistair Popple --- libpdbg/fake.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/libpdbg/fake.c b/libpdbg/fake.c index ec03ccf..58e7e18 100644 --- a/libpdbg/fake.c +++ b/libpdbg/fake.c @@ -64,3 +64,21 @@ static struct pib fake_pib = { .write = fake_pib_write, }; DECLARE_HW_UNIT(fake_pib); + +static struct core fake_core = { + .target = { + .name = "Fake Core", + .compatible = "ibm,fake-core", + .class = "core", + }, +}; +DECLARE_HW_UNIT(fake_core); + +static struct thread fake_thread = { + .target = { + .name = "Fake Thread", + .compatible = "ibm,fake-thread", + .class = "thread", + }, +}; +DECLARE_HW_UNIT(fake_thread); From patchwork Fri Jun 1 06:30:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 923780 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.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40xvf73yRqz9s0W for ; Fri, 1 Jun 2018 16:33:03 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="KwFMcPiD"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 40xvf72CtWzF0Rs for ; Fri, 1 Jun 2018 16:33:03 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="KwFMcPiD"; dkim-atps=neutral X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (ozlabs.org [IPv6:2401:3900:2:1::2]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 40xvc45G6HzDrbn for ; Fri, 1 Jun 2018 16:31:16 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="KwFMcPiD"; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPSA id 40xvc42pH4z9s08; Fri, 1 Jun 2018 16:31:16 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1527834676; bh=rKR8e8hQW8P/pJDN+prPm9KyETjclutnZ6hKWnH4xyA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KwFMcPiDQx061jiDtiVOP6kmpTNYvYgkcg85JkEERWz/2Fy///QhDpLqqWU3gvcCb w6SoElAlRlREDBq53ElDPHa7XDTDWMbRlzg6a2knY5+SpLZffFQRnhNgNlod48uYeB J4F3Um9tAc9UXamuv/GvbElZwLY+fsHW2u+iwSuBv05fHuwR7jsItHnmJTI3WaKBcC 3JNentMgV5Psq4T/YOWtJhdYChO5gR4mvngtKZYRWOYlrJyzwR8lfPxITDrOjaDLmW chyIrAQvyF2kc4/DrOtO0cdcXaLBpyvwdwR3HKdca0ugUa8gozB7DGo4CbUtiTC0RV yXgrEYXIBrATQ== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Fri, 1 Jun 2018 16:30:49 +1000 Message-Id: <20180601063050.19286-7-amitay@ozlabs.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180601063050.19286-1-amitay@ozlabs.org> References: <20180601063050.19286-1-amitay@ozlabs.org> Subject: [Pdbg] [PATCH v2 6/7] dts: Fix more warnings from dtc X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.26 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 MIME-Version: 1.0 Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Signed-off-by: Amitay Isaacs Reviewed-by: Alistair Popple --- p8-fsi.dts.m4 | 4 +++- p8-i2c.dts.m4 | 2 ++ p9-fsi.dtsi.m4 | 6 ++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/p8-fsi.dts.m4 b/p8-fsi.dts.m4 index 5b83781..16dbe3a 100644 --- a/p8-fsi.dts.m4 +++ b/p8-fsi.dts.m4 @@ -50,8 +50,10 @@ }; hmfsi@180000 { + #address-cells = <0x2>; + #size-cells = <0x1>; compatible = "ibm,power8-opb-hmfsi"; - reg = <0x180000 0x80000>; + reg = <0x0 0x180000 0x80000>; port = <0x2>; index = <0x2>; diff --git a/p8-i2c.dts.m4 b/p8-i2c.dts.m4 index b6d2ddc..f1fcbd3 100644 --- a/p8-i2c.dts.m4 +++ b/p8-i2c.dts.m4 @@ -40,6 +40,8 @@ }; hmfsi@180000 { + #address-cells = <0x2>; + #size-cells = <0x1>; compatible = "ibm,power8-opb-hmfsi"; reg = <0x180000 0x80000>; port = <0x2>; diff --git a/p9-fsi.dtsi.m4 b/p9-fsi.dtsi.m4 index 5109f81..afa7d39 100644 --- a/p9-fsi.dtsi.m4 +++ b/p9-fsi.dtsi.m4 @@ -13,6 +13,8 @@ status = "mustexist"; pib@1000 { + #address-cells = <0x2>; + #size-cells = <0x1>; reg = <0x0 0x1000 0x7>; index = <0x0>; compatible = "ibm,fsi-pib", "ibm,power9-fsi-pib"; @@ -20,12 +22,16 @@ }; hmfsi@100000 { + #address-cells = <0x2>; + #size-cells = <0x1>; compatible = "ibm,fsi-hmfsi"; reg = <0x0 0x100000 0x8000>; port = <0x1>; index = <0x1>; pib@1000 { + #address-cells = <0x2>; + #size-cells = <0x1>; reg = <0x0 0x1000 0x7>; index = <0x1>; compatible = "ibm,fsi-pib", "ibm,power9-fsi-pib"; From patchwork Fri Jun 1 06:30:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 923781 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40xvfB0rXtz9s08 for ; Fri, 1 Jun 2018 16:33:06 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="hP9GufXi"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 40xvf96RxtzF0Tj for ; Fri, 1 Jun 2018 16:33:05 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="hP9GufXi"; dkim-atps=neutral X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (ozlabs.org [IPv6:2401:3900:2:1::2]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 40xvc514kyzDrbn for ; Fri, 1 Jun 2018 16:31:17 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="hP9GufXi"; dkim-atps=neutral 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 ozlabs.org (Postfix) with ESMTPSA id 40xvc45RJmz9rvt; Fri, 1 Jun 2018 16:31:16 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1527834676; bh=xbLe+eOAm04t+UgbgOgMMjmskzTDZ281mOmrJ2ZAKD0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hP9GufXiMNKQ7In8lU8qz7MRkh5TL1GYPEvZg8kUHdtqSdsfQfJn4hw1i7tH4/xeS 8UlEfuTvxty6+vSaIRxmfNWA6dim6DRTeBNyQ1eZv5PqucIEfliuhM+nV8+qoFl2R4 71HJX4ntFyX7v0WXzzsIKapkmtmiQ3JL3/GbuMjhfVRi6DTDEF3m4J5pW6lEweeh2B i3Ik1RhJuBcCUdHkYoC3XtUiYIOPDpdCdrfkC2LGgDSOSZONjrT9QxMPynho3Q/7K+ gz9D3jsOoilVlGTlsnj1W7NgRgLofJFHcnOxV7FFNPtc95E2jVzjkIN2EafB2Mu3Xy ub3L/0H67WN3A== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Fri, 1 Jun 2018 16:30:50 +1000 Message-Id: <20180601063050.19286-8-amitay@ozlabs.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180601063050.19286-1-amitay@ozlabs.org> References: <20180601063050.19286-1-amitay@ozlabs.org> Subject: [Pdbg] [PATCH v2 7/7] Makefile: Add dependencies for p9-fsi.dtsi X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.26 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 MIME-Version: 1.0 Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Signed-off-by: Amitay Isaacs Reviewed-by: Alistair Popple --- Makefile.am | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile.am b/Makefile.am index 99b0ee4..dcbd767 100644 --- a/Makefile.am +++ b/Makefile.am @@ -88,6 +88,7 @@ GEN_V_0 = @echo " GEN " $@; %.dtsi: %.dtsi.m4 $(M4_V)$(M4) -I$(dir $<) $< > $@ +p9-fsi.dtsi: p9-fsi.dtsi.m4 p9-pib.dts.m4 p9w-fsi.dts: p9w-fsi.dts.m4 p9-fsi.dtsi p9r-fsi.dts: p9r-fsi.dts.m4 p9-fsi.dtsi p9z-fsi.dts: p9z-fsi.dts.m4 p9-fsi.dtsi