From patchwork Fri Jun 24 15:42:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 9197859 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 163B46075F for ; Fri, 24 Jun 2016 16:00:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0735220587 for ; Fri, 24 Jun 2016 16:00:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EE70128499; Fri, 24 Jun 2016 16:00:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 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.wl.linuxfoundation.org (Postfix) with ESMTPS id 0196320587 for ; Fri, 24 Jun 2016 16:00:27 +0000 (UTC) Received: from localhost ([::1]:44490 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bGTWs-0004MT-IS for patchwork-qemu-devel@patchwork.kernel.org; Fri, 24 Jun 2016 12:00:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55418) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bGTFj-0000xL-2P for qemu-devel@nongnu.org; Fri, 24 Jun 2016 11:42:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bGTFe-0002cm-JN for qemu-devel@nongnu.org; Fri, 24 Jun 2016 11:42:42 -0400 Received: from mail-cys01nam02on0053.outbound.protection.outlook.com ([104.47.37.53]:64165 helo=NAM02-CY1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bGTFe-0002cT-7v for qemu-devel@nongnu.org; Fri, 24 Jun 2016 11:42:38 -0400 Received: from BL2NAM02FT048.eop-nam02.prod.protection.outlook.com (10.152.76.51) by BL2NAM02HT172.eop-nam02.prod.protection.outlook.com (10.152.77.60) with Microsoft SMTP Server (TLS) id 15.1.523.9; Fri, 24 Jun 2016 15:42:35 +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.523.9 via Frontend Transport; Fri, 24 Jun 2016 15:42:35 +0000 Received: from 172-16-1-203.xilinx.com ([172.16.1.203]:45513 helo=xsj-tvapsmtp02.xilinx.com) by xsj-tvapsmtpgw01 with esmtp (Exim 4.63) (envelope-from ) id 1bGTFa-0002SC-Qf; Fri, 24 Jun 2016 08:42:34 -0700 Received: from [127.0.0.1] (port=54353 helo=tsj-smtp-dlp1.xlnx.xilinx.com) by xsj-tvapsmtp02.xilinx.com with esmtp (Exim 4.63) (envelope-from ) id 1bGTFa-0004b7-NY; Fri, 24 Jun 2016 08:42:34 -0700 Received: from xsj-tvapsmtp02 (smtptest.xilinx.com [172.16.1.203]) by tsj-smtp-dlp1.xlnx.xilinx.com (8.13.8/8.13.1) with ESMTP id u5OFa2gY022980; Fri, 24 Jun 2016 08:36:02 -0700 Received: from [172.19.74.182] (port=54342 helo=xsjalistai50.xilinx.com) by xsj-tvapsmtp02 with esmtp (Exim 4.63) (envelope-from ) id 1bGTFZ-0004b2-Sg; Fri, 24 Jun 2016 08:42:33 -0700 From: Alistair Francis To: , Date: Fri, 24 Jun 2016 08:42:20 -0700 Message-ID: <93d07e2a25e23575adf19f7b1291ab7fff14b348.1466782459.git.alistair.francis@xilinx.com> X-Mailer: git-send-email 2.7.4 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-22410.005 X-TM-AS-Result: No--10.101-7.0-31-10 X-imss-scan-details: No--10.101-7.0-31-10 X-TMASE-MatchedRID: 5HHZS01SLJz/uyguzMmOKBWCVBr+Ay98YKeVO7aMEHNUjspoiX02FzQz 47GqDWjpmzdGVlkj6gq+daZEFcM/u13MeDPg67BexEwSTOeVUQ67nrAU9KQxUaJd7mc2dRi3nb6 jRFO110ghMcYfYbjfqxIuFMMW4kD5IaVPgU+koVG628cXbnOhT7BHhbCLbhDI33Nl3elSfsoiTB zOVyM14HtR9RvBzPIj70Qm3YXk6SwfE8yM4pjsDwtuKBGekqUpI/NGWt0UYPD4uAz0szeBSGkfU s5yppkqrFnDFYrIDPp/y2AUM0+acKq31eEgHAP+ X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:149.199.60.96; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(7916002)(2980300002)(1110001)(1109001)(339900001)(199003)(189002)(86362001)(50466002)(33646002)(229853001)(2950100001)(6806005)(64026002)(77096005)(36756003)(92566002)(118296001)(71366001)(87936001)(85426001)(76176999)(50986999)(11100500001)(189998001)(5001770100001)(105606002)(106466001)(48376002)(4326007)(2906002)(81166006)(305945005)(7846002)(47776003)(5003940100001)(8676002)(50226002)(586003)(8936002)(9786002)(19580405001)(81156014)(356003)(7696003)(5003600100003)(19580395003)(107986001); DIR:OUT; SFP:1101; SCL:1; SRVR:BL2NAM02HT172; H:xsj-tvapsmtpgw01; FPR:; SPF:Fail; PTR:unknown-60-96.xilinx.com; A:1; MX:1; CAT:NONE; LANG:en; CAT:NONE; MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 55447d32-5494-4f99-40e9-08d39c462a1a X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BL2NAM02HT172; X-Microsoft-Antispam-PRVS: <11fe522c3d304e61b2db2c0eca3b6685@BL2NAM02HT172.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)(13017025)(8121501046)(5005006)(13018025)(13024025)(13023025)(13015025)(10201501046)(3002001)(6055026); SRVR:BL2NAM02HT172; BCL:0; PCL:0; RULEID:; SRVR:BL2NAM02HT172; X-Forefront-PRVS: 0983EAD6B2 X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jun 2016 15:42:35.4879 (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: BL2NAM02HT172 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 104.47.37.53 Subject: [Qemu-devel] [PATCH v8 5/8] register: QOMify 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: , 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 Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" 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. Signed-off-by: Peter Crosthwaite Signed-off-by: Alistair Francis Reviewed-by: KONRAD Frederic Reviewed-by: Peter Maydell --- V7: - Remove uneeded struct - Fixup documentation V5: - Convert to using only one memory region 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 07f5d4f..058c998 100644 --- a/hw/core/register.c +++ b/hw/core/register.c @@ -158,6 +158,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); +} + void register_write_memory(void *opaque, hwaddr addr, uint64_t value, unsigned size) { @@ -216,3 +227,15 @@ uint64_t register_read_memory(void *opaque, hwaddr addr, return extract64(read_val, 0, size * 8); } + +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 e8c58a1..61c53fb 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; @@ -72,6 +73,9 @@ struct RegisterAccessInfo { */ struct RegisterInfo { + /* */ + DeviceState parent_obj; + /* */ void *data; int data_size; @@ -81,6 +85,9 @@ struct RegisterInfo { void *opaque; }; +#define TYPE_REGISTER "qemu,register" +#define REGISTER(obj) OBJECT_CHECK(RegisterInfo, (obj), TYPE_REGISTER) + /** * This structure is used to group all of the individual registers which are * modeled using the RegisterInfo structure. @@ -132,6 +139,13 @@ uint64_t register_read(RegisterInfo *reg, uint64_t re, const char* prefix, void register_reset(RegisterInfo *reg); /** + * Initialize a register. + * @reg: Register to initialize + */ + +void register_init(RegisterInfo *reg); + +/** * Memory API MMIO write handler that will write to a Register API register. * @opaque: RegisterInfo to write to * @addr: Address to write