From patchwork Wed Apr 10 08:08:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1083242 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.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 44fGyf43Pfz9s8m for ; Wed, 10 Apr 2019 18:09:14 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (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="oeSEl1s6"; 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 44fGyf1GL3zDqMn for ; Wed, 10 Apr 2019 18:09:14 +1000 (AEST) X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [IPv6:2401:3900:2:1::2]) (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 44fGyQ1KRRzDqK1 for ; Wed, 10 Apr 2019 18:09:02 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (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="oeSEl1s6"; 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 44fGyP6CBlz9s8m; Wed, 10 Apr 2019 18:09:01 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1554883741; bh=F7mNzFzazT2RczHLtyDnNbZcgbh1ytcuVyeCtifjyl4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oeSEl1s6z0zhSXTbv92LITktDYyGfF79O3PJZddwybNjGAb/u8+W1lPlTLa3eBln3 2Cs+q/Mpj/2RjwKSBIEQAYY5kxPoti0L8/2jBVzK0zY87pn9M5q9A8MtuYw2eeExJM mhZC6YsRFPCb6eEyglkniYuIelfmGho2+cbPlh5EtoM5yRKT2Cp2IoedULnJ6hn3Pr Vkb45G6E5wvZJJr9hlm7aJwdRzJbSaiZ/FZRugrmXLVOrf+UF1iSaAjjsn50u963rA xRxRk3gyQfX8F2Q0Izrtt1sqKHLErm160CwaoBRimffxgqlNTMu/LSBdNkefoSEXvh 0CjGVljGooiXQ== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Wed, 10 Apr 2019 18:08:49 +1000 Message-Id: <20190410080854.430335-3-amitay@ozlabs.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190410080854.430335-1-amitay@ozlabs.org> References: <20190410080854.430335-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH 2/7] mem: Make _putmem consistent with _getmem 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" Signed-off-by: Amitay Isaacs --- src/mem.c | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/src/mem.c b/src/mem.c index fe76c64..421eea3 100644 --- a/src/mem.c +++ b/src/mem.c @@ -153,31 +153,34 @@ static int _putmem(uint64_t addr, uint8_t block_size, bool ci) { uint8_t *buf; size_t buflen; - int rc = 0; - struct pdbg_target *adu_target; - - pdbg_for_each_class_target("adu", adu_target) - break; - - if (pdbg_target_probe(adu_target) != PDBG_TARGET_ENABLED) - return 0; + int rc, count = 0; + struct pdbg_target *target; buf = read_stdin(&buflen); assert(buf); - pdbg_set_progress_tick(progress_tick); - progress_init(); - rc = mem_write(adu_target, addr, buf, buflen, block_size, ci); - progress_end(); - if (rc) { - printf("Unable to write memory\n"); - free(buf); - return 0; + pdbg_for_each_class_target("adu", target) { + if (pdbg_target_probe(target) != PDBG_TARGET_ENABLED) + continue; + + pdbg_set_progress_tick(progress_tick); + progress_init(); + rc = mem_write(target, addr, buf, buflen, block_size, ci); + progress_end(); + if (rc) { + printf("Unable to write memory\n"); + continue; + } + + count++; + break; } - printf("Wrote %zu bytes starting at 0x%016" PRIx64 "\n", buflen, addr); + if (count > 0) + printf("Wrote %zu bytes starting at 0x%016" PRIx64 "\n", buflen, addr); + free(buf); - return 1; + return count; } static int putmem(uint64_t addr, struct mem_flags flags)