From patchwork Thu Mar 1 11:23:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 130150 Delivered-To: patch@linaro.org Received: by 10.80.172.228 with SMTP id x91csp2683593edc; Thu, 1 Mar 2018 03:35:38 -0800 (PST) X-Google-Smtp-Source: AG47ELtApms3G7idmKA8yim5HvSSRrfocCzR5LJE9NtLUydjbkaBbrgwHDJUlS3RS0fG0tzGmBn6 X-Received: by 10.129.123.3 with SMTP id w3mr776845ywc.40.1519904138561; Thu, 01 Mar 2018 03:35:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519904138; cv=none; d=google.com; s=arc-20160816; b=MgOVI7LvHRTQg+Jg5tQ1Vm47kY/F7tESR6y4kpJU00Wv2exf1r+mpyITqMAxqbanb+ gEiUYk5Fz7Rbb0ZoYFIGwm8uU8a34u9ThACB+G3+hLghauWtH4QdkDOgxiGjaU7Db3KW niTbj6oJIpuqKYZQzsYK3KPcwCjEB4j5ajEsV/2WhM/YFxLkkB3e71eGo9P+u4hvRxk+ YCWGa6rGw12jBCDJOZ72uSfiqHQoakoeYRkkxHXQHW4X+eEggSGaQcP5qLjNCfqXWTR0 1K7B660tBTNQMZ3pQ3z6pBEOQEDL3SbOzybVmzynzZaZnBJpCd4rzAxNHldIK6ax+ogb b6ZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:arc-authentication-results; bh=UMMfm9r6QQloHyq/9IjfvJ0cUTHHBSXJqjeWZ4QuZkM=; b=zn55YaTxXGtlXzWVIERPmFhejLU0B8sifvvKIuvMaW23srci1yaSxgl5l1US1fnz1Z cxnW7uyO4OHaDQx4jcs1UUhRi4qDQvNJ3L3qxWGY+JUr5VhUVXAK6DPPSrK+O0x8kdF1 UpmF6yrF0JbKrrj4WERDDixZYKEa1k+tRRmvmD0r3PbiDJQ2VMEFvi0dBUQK9TDIekbE Tqp45M9TLJpSqfp1Hvc/3GjKzDX8zNpinUybFqpl3VBrBqhL0t2UltW4FDQHvhYok7xm nyefaJMltPlUvjLz4o4Bv3PuZLVFyHuyW7hOngWdebrxY8PJVfTeFI5VWAGzKyhN3pSq 36uw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id w7si603197ywe.368.2018.03.01.03.35.38 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 01 Mar 2018 03:35:38 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:55761 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1erMUr-0004Me-VB for patch@linaro.org; Thu, 01 Mar 2018 06:35:37 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33904) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1erMK0-0003np-4S for qemu-devel@nongnu.org; Thu, 01 Mar 2018 06:24:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1erMJu-00087a-9u for qemu-devel@nongnu.org; Thu, 01 Mar 2018 06:24:24 -0500 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:46702) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1erMJu-00084x-2Z for qemu-devel@nongnu.org; Thu, 01 Mar 2018 06:24:18 -0500 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1erMJh-0000XL-8n for qemu-devel@nongnu.org; Thu, 01 Mar 2018 11:24:05 +0000 From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 1 Mar 2018 11:23:22 +0000 Message-Id: <20180301112403.12487-2-peter.maydell@linaro.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180301112403.12487-1-peter.maydell@linaro.org> References: <20180301112403.12487-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PULL 01/42] hw: register: Run post_write hook on reset X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Alistair Francis Ensure that the post write hook is called during reset. This allows us to rely on the post write functions instead of having to call them from the reset() function. Signed-off-by: Alistair Francis Reviewed-by: Philippe Mathieu-Daudé Message-id: d131e24b911653a945e46ca2d8f90f572469e1dd.1517856214.git.alistair.francis@xilinx.com Signed-off-by: Peter Maydell --- include/hw/register.h | 6 +++--- hw/core/register.c | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) -- 2.16.2 diff --git a/include/hw/register.h b/include/hw/register.h index de2414e6b4..5796584588 100644 --- a/include/hw/register.h +++ b/include/hw/register.h @@ -34,7 +34,7 @@ typedef struct RegisterInfoArray RegisterInfoArray; * immediately before the actual write. The returned value is what is written, * giving the handler a chance to modify the written value. * @post_write: Post write callback. Passed the written value. Most write side - * effects should be implemented here. + * effects should be implemented here. This is called during device reset. * * @post_read: Post read callback. Passes the value that is about to be returned * for a read. The return value from this function is what is ultimately read, @@ -135,8 +135,8 @@ uint64_t register_read(RegisterInfo *reg, uint64_t re, const char* prefix, bool debug); /** - * reset a register - * @reg: register to reset + * Resets a register. This will also call the post_write hook if it exists. + * @reg: The register to reset. */ void register_reset(RegisterInfo *reg); diff --git a/hw/core/register.c b/hw/core/register.c index 900294b9c4..0741a1af32 100644 --- a/hw/core/register.c +++ b/hw/core/register.c @@ -159,13 +159,21 @@ uint64_t register_read(RegisterInfo *reg, uint64_t re, const char* prefix, void register_reset(RegisterInfo *reg) { + const RegisterAccessInfo *ac; + g_assert(reg); if (!reg->data || !reg->access) { return; } + ac = reg->access; + register_write_val(reg, reg->access->reset); + + if (ac->post_write) { + ac->post_write(reg, reg->access->reset); + } } void register_init(RegisterInfo *reg)