From patchwork Thu Feb 21 18:57:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 158950 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp851551jaa; Thu, 21 Feb 2019 11:16:38 -0800 (PST) X-Google-Smtp-Source: AHgI3IbbbbghrS61hePKczj8Xpkpsu3fcjkUmAZZ6rZaiAhm9EeUkCQ5+wYyyaXv5sUUPy3WgNDq X-Received: by 2002:a5b:8:: with SMTP id a8mr89913ybp.75.1550776598937; Thu, 21 Feb 2019 11:16:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550776598; cv=none; d=google.com; s=arc-20160816; b=WaR8R4875CLQOriqJxIlQhDLHkjOJipx7hI/eTPwqoNVONO7dMZZbR84mxcfC6MQ8f TQx9pCK5otytSV0p4puga8GcWMZUDz70Jd/+zynU7GRpKX4yhgpb4geOMz9K551nN+2o fxudZ0dsgmd5CtCXJV4FsYwWfRY2F8v4ZelMXFpLsFbyU5FiZeu5BXrrcoxv6WCeaaF9 c0xJETMoPa33HX8ex6YUjHLabLqa6ItdBrmmJ1Co/llbFdf+U4lB+kMd+3sU5IN21K8E rRuFeGLC1hfwbpqbO8FeIMqSCSsMIcei/r8S/nkRcP79MC3YxPiHkOt0fxoO2v5quGTt edig== 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:dkim-signature; bh=SFWNo4DOeSTbEhbJ/U71HXoPGnhz14OVBzoHq8mGqTw=; b=uC1SzLlZefXIrHqqKseuGReWPUitBHVLwOEWRyXPdL1XGH85lFAC0ihMm0j0pcVeTR 7dNpW8rZbAOAkJS/PBEGhKTPRzcLgJl3JdKo2D4Ccu2ivrDk0emlsaRx0pBLfeTG1SEn frswY1A2w927+Bk9Ty1z8nAQ2LChEozn9X9FIRlGuVgcbh9Jfd7sRHmqF9klr/UB2l3G aSDi6fxPt1ZcKhllyPK+LtlTFfvMkiA8252FVFa/gln4zqsRZdmgJEMk21GI4FXGWFEn qnzTRhFCZ95iCF17v8DQatXPfy8YvzmQtaKy4z4rkbBHLsQXNJFkynMYgWywPD6hv7nB OjsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Ol3uPvLk; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 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. [209.51.188.17]) by mx.google.com with ESMTPS id l5si12956958ywc.81.2019.02.21.11.16.38 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 21 Feb 2019 11:16:38 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Ol3uPvLk; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 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 ([127.0.0.1]:37126 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwtpm-0006xQ-Be for patch@linaro.org; Thu, 21 Feb 2019 14:16:38 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52157) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwtXq-0008Tw-Jy for qemu-devel@nongnu.org; Thu, 21 Feb 2019 13:58:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwtXp-0007SP-18 for qemu-devel@nongnu.org; Thu, 21 Feb 2019 13:58:06 -0500 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]:41440) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gwtXn-0007NM-8Z for qemu-devel@nongnu.org; Thu, 21 Feb 2019 13:58:04 -0500 Received: by mail-wr1-x429.google.com with SMTP id n2so19644084wrw.8 for ; Thu, 21 Feb 2019 10:57:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=SFWNo4DOeSTbEhbJ/U71HXoPGnhz14OVBzoHq8mGqTw=; b=Ol3uPvLkxaM0GPCr4JU/XogLaJALqametMvTNCHQic48LLlHD/BN0YaDub1kd2keRv gUBOS0Eak3TzRlYcRYrCEp8/TcivTV4NuJAnt5+NuoFzHOiqaPX8mYS8jqzLx9tHqfgG LEfoc4b9kOrT+l3AMe2kAA2HxoCf009d0nXbEkUWJkLZAE5BLbqhI/rfA19hJfSi/nmj JXZQnESrKjZlhDN2DRkdAq/r7eZnfvEXsi8Lp+YqdMdi4+rM+DutKbZAab+X/iya3Vgt gGQkE+7fw1zwXTEv66Vfl1IjUS1iDyBWINQtQ7wqjgbw0tw58aaaD/t8XW+r2q3CVg3k h4sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=SFWNo4DOeSTbEhbJ/U71HXoPGnhz14OVBzoHq8mGqTw=; b=cbc8mWpj8EjvjqVzFn4SsFGcr4yfbunAbM1vxtT0i0FNcs+uwT2UkmkNV4d1TXLyc1 vn1khTx1ZpiXBQylmBa3InqwIOxuVpokeEcJ8c4hZclr/JpKs6Y9Hj556SkFJzwoi8hO LV8pieoGDOUC25Qnp09hl0QBTje5C2JCEoVknC8ZqPY5ikZYcxLaxW3Pix0kX9bSjBBw LF2yn6BNlTpcAeZUcpRBoHWw9M8rV3ET/ICXjZs/7dn2RtVf3vg03r6Un0ufFQp9wqVg SxeEDw6rDSL07tCxg/ne2IYQnDyhU4tk1nyPCPvJjE/W/sd8onMg/jyMAN9ExASLpjC2 eKhA== X-Gm-Message-State: AHQUAubFsGcXOAWbus/4f+gL3PtfK07JivgqoqPHs8MWaxV/ZwthSydE n/64z1/20MWlUtUPbQC1zUvIy0oT6lM= X-Received: by 2002:adf:e487:: with SMTP id i7mr12176wrm.202.1550775476666; Thu, 21 Feb 2019 10:57:56 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id c18sm29065085wre.32.2019.02.21.10.57.55 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Feb 2019 10:57:56 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 21 Feb 2019 18:57:29 +0000 Message-Id: <20190221185739.25362-12-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190221185739.25362-1-peter.maydell@linaro.org> References: <20190221185739.25362-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: 2a00:1450:4864:20::429 Subject: [Qemu-devel] [PULL 11/21] hw/char/pl011: Allow use as an embedded-struct device 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" Create a new include file for the pl011's device struct, type macros, etc, so that it can be instantiated using the "embedded struct" coding style. Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- include/hw/char/pl011.h | 34 ++++++++++++++++++++++++++++++++++ hw/char/pl011.c | 31 ++----------------------------- 2 files changed, 36 insertions(+), 29 deletions(-) -- 2.20.1 diff --git a/include/hw/char/pl011.h b/include/hw/char/pl011.h index 83649324b6a..1b52bfd5c90 100644 --- a/include/hw/char/pl011.h +++ b/include/hw/char/pl011.h @@ -15,6 +15,40 @@ #ifndef HW_PL011_H #define HW_PL011_H +#include "hw/sysbus.h" +#include "chardev/char-fe.h" + +#define TYPE_PL011 "pl011" +#define PL011(obj) OBJECT_CHECK(PL011State, (obj), TYPE_PL011) + +/* This shares the same struct (and cast macro) as the base pl011 device */ +#define TYPE_PL011_LUMINARY "pl011_luminary" + +typedef struct PL011State { + SysBusDevice parent_obj; + + MemoryRegion iomem; + uint32_t readbuff; + uint32_t flags; + uint32_t lcr; + uint32_t rsr; + uint32_t cr; + uint32_t dmacr; + uint32_t int_enabled; + uint32_t int_level; + uint32_t read_fifo[16]; + uint32_t ilpr; + uint32_t ibrd; + uint32_t fbrd; + uint32_t ifl; + int read_pos; + int read_count; + int read_trigger; + CharBackend chr; + qemu_irq irq; + const unsigned char *id; +} PL011State; + static inline DeviceState *pl011_create(hwaddr addr, qemu_irq irq, Chardev *chr) diff --git a/hw/char/pl011.c b/hw/char/pl011.c index 2aa277fc4f2..0c4711e4027 100644 --- a/hw/char/pl011.c +++ b/hw/char/pl011.c @@ -8,39 +8,12 @@ */ #include "qemu/osdep.h" +#include "hw/char/pl011.h" #include "hw/sysbus.h" #include "chardev/char-fe.h" #include "qemu/log.h" #include "trace.h" -#define TYPE_PL011 "pl011" -#define PL011(obj) OBJECT_CHECK(PL011State, (obj), TYPE_PL011) - -typedef struct PL011State { - SysBusDevice parent_obj; - - MemoryRegion iomem; - uint32_t readbuff; - uint32_t flags; - uint32_t lcr; - uint32_t rsr; - uint32_t cr; - uint32_t dmacr; - uint32_t int_enabled; - uint32_t int_level; - uint32_t read_fifo[16]; - uint32_t ilpr; - uint32_t ibrd; - uint32_t fbrd; - uint32_t ifl; - int read_pos; - int read_count; - int read_trigger; - CharBackend chr; - qemu_irq irq; - const unsigned char *id; -} PL011State; - #define PL011_INT_TX 0x20 #define PL011_INT_RX 0x10 @@ -357,7 +330,7 @@ static void pl011_luminary_init(Object *obj) } static const TypeInfo pl011_luminary_info = { - .name = "pl011_luminary", + .name = TYPE_PL011_LUMINARY, .parent = TYPE_PL011, .instance_init = pl011_luminary_init, };