From patchwork Tue Feb 9 22:14:51 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 8266031 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 265CD9F38B for ; Tue, 9 Feb 2016 22:19:47 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 782792022D for ; Tue, 9 Feb 2016 22:19:46 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 969D120218 for ; Tue, 9 Feb 2016 22:19:45 +0000 (UTC) Received: from localhost ([::1]:32936 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aTGdM-00071v-U0 for patchwork-qemu-devel@patchwork.kernel.org; Tue, 09 Feb 2016 17:19:44 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46784) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aTGbG-0003mq-2Y for qemu-devel@nongnu.org; Tue, 09 Feb 2016 17:17:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aTGbB-0000yw-PM for qemu-devel@nongnu.org; Tue, 09 Feb 2016 17:17:33 -0500 Received: from mail-sn1nam02on0067.outbound.protection.outlook.com ([104.47.36.67]:58883 helo=NAM02-SN1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aTGbB-0000yn-Hf for qemu-devel@nongnu.org; Tue, 09 Feb 2016 17:17:29 -0500 Received: from BL2NAM02FT048.eop-nam02.prod.protection.outlook.com (10.152.76.56) by BL2NAM02HT043.eop-nam02.prod.protection.outlook.com (10.152.76.78) with Microsoft SMTP Server (TLS) id 15.1.409.7; Tue, 9 Feb 2016 22:17:28 +0000 Authentication-Results: spf=fail (sender IP is 149.199.60.96) smtp.mailfrom=xilinx.com; linaro.org; dkim=none (message not signed) header.d=none; linaro.org; dmarc=none action=none header.from=xilinx.com; Received-SPF: Fail (protection.outlook.com: domain of xilinx.com does not designate 149.199.60.96 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.60.96; helo=xsj-tvapsmtpgw01; Received: from xsj-tvapsmtpgw01 (149.199.60.96) by BL2NAM02FT048.mail.protection.outlook.com (10.152.76.109) with Microsoft SMTP Server (TLS) id 15.1.409.7 via Frontend Transport; Tue, 9 Feb 2016 22:17:27 +0000 Received: from 172-16-1-203.xilinx.com ([172.16.1.203]:35359 helo=xsj-tvapsmtp02.xilinx.com) by xsj-tvapsmtpgw01 with esmtp (Exim 4.63) (envelope-from ) id 1aTGb9-0002ma-0R; Tue, 09 Feb 2016 14:17:27 -0800 Received: from [127.0.0.1] (port=42578 helo=tsj-smtp-dlp1.xlnx.xilinx.com) by xsj-tvapsmtp02.xilinx.com with esmtp (Exim 4.63) (envelope-from ) id 1aTGb8-0007aQ-QS; Tue, 09 Feb 2016 14:17:26 -0800 Received: from xsj-tvapsmtp02 (xsj-tvapsmtp02.xilinx.com [172.16.1.203]) by tsj-smtp-dlp1.xlnx.xilinx.com (8.13.8/8.13.1) with ESMTP id u19MBk7p011553; Tue, 9 Feb 2016 14:11:46 -0800 Received: from [172.19.74.182] (port=49722 helo=xsjalistai50.xlnx.xilinx.com) by xsj-tvapsmtp02 with esmtp (Exim 4.63) (envelope-from ) id 1aTGb7-0007aN-WC; Tue, 09 Feb 2016 14:17:26 -0800 From: Alistair Francis To: , Date: Tue, 9 Feb 2016 14:14:51 -0800 Message-ID: <546149739f5d6a01ede6befd21b565f008c6e8fa.1455055858.git.alistair.francis@xilinx.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: References: X-RCIS-Action: ALLOW X-TM-AS-MML: disable X-TM-AS-Product-Ver: IMSS-7.1.0.1679-8.0.0.1202-22054.006 X-TM-AS-Result: No--8.239-7.0-31-10 X-imss-scan-details: No--8.239-7.0-31-10 X-TMASE-MatchedRID: 5HHZS01SLJz/uyguzMmOKBWCVBr+Ay98Ebs7d+z9c8s4YKAM3oRt9t79 oseDjSdCkZ3T6ylBNAWvXn8ZlTtgDIRSqwm2ppCS3fn7n/ZHGqY7r2Gtb9iBYdjxT3jt1KNe0a3 ++naE7Rc8VyRVdn8owMWTKA6C26DEQdD+lgDCGzq628cXbnOhTxsU7CpMDOCABPUECXLcWy1PCV NdGJmNwVmp8UkMQXk2ModguxHirQsfE8yM4pjsDwtuKBGekqUpI/NGWt0UYPCiQfZafqG4GqwxV Y1Cm8W9fw2dnPAYi0NC4dHJH7/IKeSPyTK27pvM X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:149.199.60.96; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(2980300002)(1110001)(1109001)(339900001)(199003)(189002)(6806005)(105606002)(1096002)(64026002)(586003)(1220700001)(229853001)(5001960100002)(189998001)(5008740100001)(47776003)(106466001)(92566002)(77096005)(2950100001)(19580405001)(50986999)(19580395003)(85426001)(33646002)(76176999)(5001770100001)(5003600100002)(86362001)(2906002)(87936001)(118296001)(5003940100001)(50226001)(36756003)(4326007)(50466002)(48376002)(107986001); DIR:OUT; SFP:1101; SCL:1; SRVR:BL2NAM02HT043; H:xsj-tvapsmtpgw01; FPR:; SPF:Fail; MLV:sfv; A:1; MX:1; LANG:en; MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: ac12a0b5-afc9-41c0-ac1a-08d3319ecbc2 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BL2NAM02HT043; X-Microsoft-Antispam-PRVS: <01547cb8b29049a6be3f16160374bf6e@BL2NAM02HT043.eop-nam02.prod.protection.outlook.com> X-Exchange-Antispam-Report-Test: UriScan:(192813158149592); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(8121501046)(5005006)(13015025)(13017025)(13024025)(13023025)(13018025)(10201501046)(3002001); SRVR:BL2NAM02HT043; BCL:0; PCL:0; RULEID:; SRVR:BL2NAM02HT043; X-Forefront-PRVS: 08476BC6EF X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2016 22:17:27.9998 (UTC) X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c; Ip=[149.199.60.96]; Helo=[xsj-tvapsmtpgw01] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL2NAM02HT043 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 104.47.36.67 Cc: edgar.iglesias@xilinx.com, alistair.francis@xilinx.com, crosthwaitepeter@gmail.com, edgar.iglesias@gmail.com, alex.bennee@linaro.org, afaerber@suse.de, fred.konrad@greensocs.com Subject: [Qemu-devel] [PATCH v4 06/16] register: QOMify X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Peter Crosthwaite QOMify registers as a child of TYPE_DEVICE. This allows registers to define GPIOs. Define an init helper that will do QOM initialisation as well as setup the r/w fast paths. Signed-off-by: Peter Crosthwaite Signed-off-by: Alistair Francis Reviewed-by: KONRAD Frederic --- hw/core/register.c | 23 +++++++++++++++++++++++ include/hw/register.h | 14 ++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/hw/core/register.c b/hw/core/register.c index 9cd50c8..d766517 100644 --- a/hw/core/register.c +++ b/hw/core/register.c @@ -151,6 +151,17 @@ void register_reset(RegisterInfo *reg) register_write_val(reg, reg->access->reset); } +void register_init(RegisterInfo *reg) +{ + assert(reg); + + if (!reg->data || !reg->access) { + return; + } + + object_initialize((void *)reg, sizeof(*reg), TYPE_REGISTER); +} + static inline void register_write_memory(void *opaque, hwaddr addr, uint64_t value, unsigned size, bool be) { @@ -198,3 +209,15 @@ uint64_t register_read_memory_le(void *opaque, hwaddr addr, unsigned size) { return register_read_memory(opaque, addr, size, false); } + +static const TypeInfo register_info = { + .name = TYPE_REGISTER, + .parent = TYPE_DEVICE, +}; + +static void register_register_types(void) +{ + type_register_static(®ister_info); +} + +type_init(register_register_types) diff --git a/include/hw/register.h b/include/hw/register.h index bd03f50..d3469c6 100644 --- a/include/hw/register.h +++ b/include/hw/register.h @@ -11,6 +11,7 @@ #ifndef REGISTER_H #define REGISTER_H +#include "hw/qdev-core.h" #include "exec/memory.h" typedef struct RegisterInfo RegisterInfo; @@ -84,6 +85,8 @@ struct RegisterAccessInfo { struct RegisterInfo { /* */ + DeviceState parent_obj; + MemoryRegion mem; /* */ @@ -98,6 +101,9 @@ struct RegisterInfo { void *opaque; }; +#define TYPE_REGISTER "qemu,register" +#define REGISTER(obj) OBJECT_CHECK(RegisterInfo, (obj), TYPE_REGISTER) + /** * write a value to a register, subject to its restrictions * @reg: register to write to @@ -123,6 +129,14 @@ uint64_t register_read(RegisterInfo *reg); void register_reset(RegisterInfo *reg); /** + * Initialize a register. GPIO's are setup as IOs to the specified device. + * Fast paths for eligible registers are enabled. + * @reg: Register to initialize + */ + +void register_init(RegisterInfo *reg); + +/** * Memory API MMIO write handler that will write to a Register API register. * _be for big endian variant and _le for little endian. * @opaque: RegisterInfo to write to