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: 1046405 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="Ol3uPvLk"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44540d19rjz9s7h for ; Fri, 22 Feb 2019 06:14:41 +1100 (AEDT) Received: from localhost ([127.0.0.1]:37086 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwtnq-0005h7-UV for incoming@patchwork.ozlabs.org; Thu, 21 Feb 2019 14:14:39 -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-Google-Smtp-Source: AHgI3IYJWmlVQscqOLSmIWeXXoRbUJ+8igPWK2c4CyMvdBuDc0ZtSzt+BBR4SQhMgB7klYvG4DmwyQ== 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+incoming=patchwork.ozlabs.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(-) 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, };