From patchwork Mon Jan 7 04:30:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1021173 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 (2048 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43Y2Wd1bGsz9sDP for ; Mon, 7 Jan 2019 15:30:53 +1100 (AEDT) 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="VCEb3fCl"; 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 43Y2Wd0C32zDqF7 for ; Mon, 7 Jan 2019 15:30:53 +1100 (AEDT) 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 43Y2WB1jC8zDqF1 for ; Mon, 7 Jan 2019 15:30:30 +1100 (AEDT) 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="VCEb3fCl"; 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 (2048 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPSA id 43Y2W93BKCz9sDr; Mon, 7 Jan 2019 15:30:29 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1546835429; bh=UZtPmyuimZN29DxhNB9iTWAhWauKnX7Q7qt3HtM+n8s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VCEb3fCluUALEcYMiHMJVT3dBauNAIIY38eD5k8PnsZL6Tpw2vHQW5+PigXUXXglR 2aCtbccAnaxdw6ACvERvxq++dvw2rWat50uCns7JPX20hZgdUJ4L4zN8BjBXQT/wA7 VjovtC8Fj3mMf9L3L3m3rK/VE13g3/gAGA3oEVcsZ5r3mbUzoJYAvmxcr6nyxz9CUG 1jogih7ELVgXy6BzaW5F6RS5XEryGxFQC0+MJnHUSmmBGeIOSi063HFQIuVSZDq8uM Gq3b3Ves5M8zQs25Ay+Bd4BleHOMBgmxrFyHASB1gjqXG+Uzsau1cJ1mWW6s6pG0DU Vr9sMDuolV5KA== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Mon, 7 Jan 2019 15:30:20 +1100 Message-Id: <20190107043020.145107-6-amitay@ozlabs.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190107043020.145107-1-amitay@ozlabs.org> References: <20190107043020.145107-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH 5/5] main: Use new api to read/write memory 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 | 28 ++++++++++------------------ src/pdbgproxy.c | 6 +++--- src/thread.c | 2 +- 3 files changed, 14 insertions(+), 22 deletions(-) diff --git a/src/mem.c b/src/mem.c index 6454739..408ff11 100644 --- a/src/mem.c +++ b/src/mem.c @@ -41,7 +41,7 @@ struct mem_flags { #define MEM_CI_FLAG ("--ci", ci, parse_flag_noarg, false) #define BLOCK_SIZE (parse_number8_pow2, NULL) -static int _getmem(uint64_t addr, uint64_t size, uint8_t block_size) +static int _getmem(uint64_t addr, uint64_t size, uint8_t block_size, bool ci) { struct pdbg_target *target; uint8_t *buf; @@ -60,11 +60,7 @@ static int _getmem(uint64_t addr, uint64_t size, uint8_t block_size) pdbg_set_progress_tick(progress_tick); progress_init(); - if (block_size) - rc = adu_getmem_io(target, addr, buf, size, block_size); - else - rc = adu_getmem(target, addr, buf, size); - + rc = mem_read(target, addr, buf, size, block_size, ci); if (rc) PR_ERROR("Unable to read memory.\n"); @@ -84,20 +80,20 @@ static int _getmem(uint64_t addr, uint64_t size, uint8_t block_size) static int getmem(uint64_t addr, uint64_t size, struct mem_flags flags) { if (flags.ci) - return _getmem(addr, size, 8); + return _getmem(addr, size, 8, true); else - return _getmem(addr, size, 0); + return _getmem(addr, size, 0, false); } OPTCMD_DEFINE_CMD_WITH_FLAGS(getmem, getmem, (ADDRESS, DATA), mem_flags, (MEM_CI_FLAG)); static int getmemio(uint64_t addr, uint64_t size, uint8_t block_size) { - return _getmem(addr, size, block_size); + return _getmem(addr, size, block_size, true); } OPTCMD_DEFINE_CMD_WITH_ARGS(getmemio, getmemio, (ADDRESS, DATA, BLOCK_SIZE)); -static int _putmem(uint64_t addr, uint8_t block_size) +static int _putmem(uint64_t addr, uint8_t block_size, bool ci) { uint8_t *buf; int read_size, rc = 0; @@ -118,11 +114,7 @@ static int _putmem(uint64_t addr, uint8_t block_size) if (read_size <= 0) break; - if (block_size) - rc = adu_putmem_io(adu_target, addr, buf, read_size, block_size); - else - rc = adu_putmem(adu_target, addr, buf, read_size); - + rc = mem_write(adu_target, addr, buf, read_size, block_size, ci); if (rc) { rc = 0; printf("Unable to write memory.\n"); @@ -141,14 +133,14 @@ static int _putmem(uint64_t addr, uint8_t block_size) static int putmem(uint64_t addr, struct mem_flags flags) { if (flags.ci) - return _putmem(addr, 8); + return _putmem(addr, 8, true); else - return _putmem(addr, 0); + return _putmem(addr, 0, false); } OPTCMD_DEFINE_CMD_WITH_FLAGS(putmem, putmem, (ADDRESS), mem_flags, (MEM_CI_FLAG)); static int putmemio(uint64_t addr, uint8_t block_size) { - return _putmem(addr, block_size); + return _putmem(addr, block_size, true); } OPTCMD_DEFINE_CMD_WITH_ARGS(putmemio, putmemio, (ADDRESS, BLOCK_SIZE)); diff --git a/src/pdbgproxy.c b/src/pdbgproxy.c index dedea7a..572af01 100644 --- a/src/pdbgproxy.c +++ b/src/pdbgproxy.c @@ -183,7 +183,7 @@ static void get_spr(uint64_t *stack, void *priv) #define MAX_DATA 0x1000 -/* Returns a real address to use with adu_getmem or -1UL if we +/* Returns a real address to use with mem_read or -1UL if we * couldn't determine a real address. At the moment we only deal with * kernel linear mapping but in future we could walk that page * tables. */ @@ -223,7 +223,7 @@ static void get_mem(uint64_t *stack, void *priv) linear_map = get_real_addr(addr); if (linear_map != -1UL) { - if (adu_getmem(adu_target, linear_map, (uint8_t *) data, len)) { + if (mem_read(adu_target, linear_map, (uint8_t *) data, len, 0, false)) { PR_ERROR("Unable to read memory\n"); err = 1; } @@ -293,7 +293,7 @@ static void put_mem(uint64_t *stack, void *priv) PR_INFO("put_mem 0x%016" PRIx64 " = 0x%016" PRIx64 "\n", addr, stack[2]); - if (adu_putmem(adu_target, addr, data, len)) { + if (mem_write(adu_target, addr, data, len, 0, false)) { PR_ERROR("Unable to write memory\n"); err = 3; } diff --git a/src/thread.c b/src/thread.c index 1fd448d..8f34233 100644 --- a/src/thread.c +++ b/src/thread.c @@ -35,7 +35,7 @@ static bool is_real_address(struct thread_regs *regs, uint64_t addr) static int load8(struct pdbg_target *target, uint64_t addr, uint64_t *value) { - if (adu_getmem(target, addr, (uint8_t *)value, 8)) { + if (mem_read(target, addr, (uint8_t *)value, 8, 0, false)) { pdbg_log(PDBG_ERROR, "Unable to read memory address=%016" PRIx64 ".\n", addr); return 0; }