From patchwork Fri Jun 22 04:51:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rashmica Gupta X-Patchwork-Id: 933104 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 41BmPs2rQdz9s0W for ; Fri, 22 Jun 2018 14:52:01 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="DgKYaprW"; 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 41BmPs19rKzF0xF for ; Fri, 22 Jun 2018 14:52:01 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="DgKYaprW"; dkim-atps=neutral X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:400e:c05::233; helo=mail-pg0-x233.google.com; envelope-from=rashmica.g@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="DgKYaprW"; dkim-atps=neutral Received: from mail-pg0-x233.google.com (mail-pg0-x233.google.com [IPv6:2607:f8b0:400e:c05::233]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 41BmPm5jnmzF0x7 for ; Fri, 22 Jun 2018 14:51:56 +1000 (AEST) Received: by mail-pg0-x233.google.com with SMTP id z1-v6so2399855pgv.12 for ; Thu, 21 Jun 2018 21:51:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=cwiI6x0JdqBRE1krnSk9o09MIJFAd2YvLtg6GBpICls=; b=DgKYaprWxfdQa1h4O/W1sYlITnGFQfoitiI3NKkCs7B6S79zLqN7oaIdpQwxhbGbk3 gLwm4vu9BNHBUMHCI1Sbs6v3FoMy8IFXZdNy9740KsglomzwWB0xuXJ0QK+leCcdzCjk /vC6l5O9WSrQ2VogekUVc8tAzz/st2XjgQDRDb1ZoKgsTYyTBEMY45wjuodmWPCcqRDk PDyYGw4BSrDYdScgCdLX2APyxKJSkb/yDYulpF7zadH3LQ2FRST4dluPuJslAdDsEpCT SnLMObFb9v/dN7ggEWtzj7qd0Whc6oT+7+qdsqVCyTd2iJoQpYMJwcbqzUKHp+GxBBmg BiKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=cwiI6x0JdqBRE1krnSk9o09MIJFAd2YvLtg6GBpICls=; b=a6Ygk4TyrM6q2lqnKVsTgm+q2UruYtQyvtcL6pxBzOhY0TuNe+TUhW2qq8T9KAfuKT 3nSkC3lEiXuRiQzaBbbKswch3bOt41/W9S/Zwvn9DPOkZZNc8JnbNJIy9+XpwWVXs4Pp vwgF9yDeYXull2aOv8eilFYpspdwKN3AH/yjk19dPA0Gvuxs8RYrHNUqOqxY/J1OEw7Z igF175atGfpH2SFD5/ODXoBISy55rlkiEAEzj7E7ibm4zEjxQ+b5CRUc+DHWGinj+Ge0 b89wJhS0K3CAYmEvcO8ZCq7vkvlJCKYNR8LBvFyk7p4so82fgxffUAfcfWkz8Ggg5oqx +Nfg== X-Gm-Message-State: APt69E36OiWLk90E4/hPU7UTWq3Hgu+wS3A+FdBLh1HaqwX7o4Aa2iy0 1seb/bEPh2IrDWg3nvOUztF21w== X-Google-Smtp-Source: ADUXVKI/Zv4d/WCv7n29Ns754pyXtDneJQz4jOMm843RDcPT2GIJRDJZjPRx5UgKF0HXHPa5BEgIHw== X-Received: by 2002:a62:1146:: with SMTP id z67-v6mr81148pfi.135.1529643114475; Thu, 21 Jun 2018 21:51:54 -0700 (PDT) Received: from rashmica.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id v27-v6sm11874992pfi.23.2018.06.21.21.51.52 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 21 Jun 2018 21:51:54 -0700 (PDT) From: Rashmica Gupta To: pdbg@lists.ozlabs.org Date: Fri, 22 Jun 2018 14:51:12 +1000 Message-Id: <20180622045116.12059-5-rashmica.g@gmail.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180622045116.12059-1-rashmica.g@gmail.com> References: <20180622045116.12059-1-rashmica.g@gmail.com> Subject: [Pdbg] [PATCH 4/8] libpdbg: Make getcr actually get all of the Condition Register 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: , MIME-Version: 1.0 Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Signed-off-by: Rashmica Gupta --- libpdbg/chip.c | 25 ++++++++++++++++++------- libpdbg/libpdbg.h | 1 + 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/libpdbg/chip.c b/libpdbg/chip.c index 6907765..a4ee1e4 100644 --- a/libpdbg/chip.c +++ b/libpdbg/chip.c @@ -321,7 +321,7 @@ int ram_getmsr(struct pdbg_target *thread, uint64_t *value) return 0; } -int ram_getcr(struct pdbg_target *thread, int cr, uint64_t *value) +int ram_getcr_field(struct pdbg_target *thread, int cr, uint32_t *value) { uint64_t opcodes[] = {mfocrf(0, cr), mtspr(277, 0)}; uint64_t results[] = {0, 0}; @@ -331,6 +331,22 @@ int ram_getcr(struct pdbg_target *thread, int cr, uint64_t *value) return 0; } +int ram_getcr(struct pdbg_target *thread, uint32_t *value) +{ + uint32_t cr_field, cr = 0; + int i; + + for (i = 0; i < 8; i++){ + cr_field = 0; + ram_getcr_field(thread, i, &cr_field); + /* We are not guarenteed that the other bits will be zeroed out */ + cr |= cr_field & (0xf << 4*i); + } + + *value = cr; + return 0; +} + int ram_putmsr(struct pdbg_target *thread, uint64_t value) { uint64_t opcodes[] = {mfspr(0, 277), mtmsr(0)}; @@ -447,12 +463,7 @@ int ram_state_thread(struct pdbg_target *thread, struct thread_regs *regs) ram_getspr(thread, 815, ®s->tar); printf("TAR : 0x%016" PRIx64 "\n", regs->tar); - regs->cr = 0; - for (i = 0; i < 8; i++) { - uint64_t cr; - ram_getcr(thread, i, &cr); - regs->cr |= cr; - } + ram_getcr(thread, ®s->cr); printf("CR : 0x%08" PRIx32 "\n", regs->cr); ram_getxer(thread, ®s->xer); diff --git a/libpdbg/libpdbg.h b/libpdbg/libpdbg.h index 81d6170..28470c3 100644 --- a/libpdbg/libpdbg.h +++ b/libpdbg/libpdbg.h @@ -138,6 +138,7 @@ int ram_putnia(struct pdbg_target *target, uint64_t val); int ram_putspr(struct pdbg_target *target, int spr, uint64_t val); int ram_putgpr(struct pdbg_target *target, int spr, uint64_t val); int ram_getmsr(struct pdbg_target *target, uint64_t *val); +int ram_getcr(struct pdbg_target *thread, uint32_t *value); int ram_getnia(struct pdbg_target *target, uint64_t *val); int ram_getspr(struct pdbg_target *target, int spr, uint64_t *val); int ram_getgpr(struct pdbg_target *target, int gpr, uint64_t *val);