From nobody Fri Nov 7 14:45:47 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1548098589924518.8995338632794; Mon, 21 Jan 2019 11:23:09 -0800 (PST) Received: from localhost ([127.0.0.1]:58563 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1glfA4-0003Gn-SQ for importer@patchew.org; Mon, 21 Jan 2019 14:23:08 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38984) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1glevW-000854-0H for qemu-devel@nongnu.org; Mon, 21 Jan 2019 14:08:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1glefT-0002dd-4k for qemu-devel@nongnu.org; Mon, 21 Jan 2019 13:51:32 -0500 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:38971) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1glefR-0002bJ-72 for qemu-devel@nongnu.org; Mon, 21 Jan 2019 13:51:29 -0500 Received: by mail-wm1-x342.google.com with SMTP id y8so11809649wmi.4 for ; Mon, 21 Jan 2019 10:51:27 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id n82sm50386660wma.42.2019.01.21.10.51.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 21 Jan 2019 10:51:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=8/8nrDNxFDGGiKzCXqhPzki/Hbmqf6CuZf0plZpfE7M=; b=XvIAnboji2u7aobGX3RE5JSxCNVqGBP1JBOfYm4yjDB2ljtp5oDzEEj5FM9j/R0MAj K101rhiL0ot6tc63jnBc58PF8Ms+fwyTWhJ5eglyo36AGQ7GOliWyjIrz3pupx9xq+xA 4MPfHSveN1ZfpshNq1bLtyTo33sIhOMtEOTkk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8/8nrDNxFDGGiKzCXqhPzki/Hbmqf6CuZf0plZpfE7M=; b=BzgyW0aLScs74R0734NvW4T3kbYYAtl9kd52LBCw9XkmhEjufSFht6Xht4pNyh6dn2 gujfW+pEOXeB3jjxk9Ytur3G9DoiJZZp6O84eK/nIeHmQCnYPFzPvqpf05SySKWOmOpJ oNjn9S6xsbpWQqeYFkYAOIW97yg+yoPbREshc3IwOeJg8DvTJTOdxwhGIA116tYx8pRC 6DdaNQQR0/UYqONDPney7GyCCtWrB1PBxW2Uon0sgqoboabnHVv5BCNDiRzw0piOU+64 rovxFAvGNNG+KdPZ6yfugej7E/YkL1+Zdp/qfPnAAeAHb3w7joDm/NwWuRC84ijehgLI LcAg== X-Gm-Message-State: AJcUukchvqdbOwZH7w9v4X8Qei+UORHpU2wd33subRnSzry6Ky/cIot3 QKdF2m5Gg4Jj1cTxirAlutnASqj9FdqbfA== X-Google-Smtp-Source: ALg8bN5kpxoBDnrxq6W4QBbtu6bdfs7MHw+7Aw0d+QGJcxhu6iQAxf6VApidNoWtLVVn1tIdREl5ww== X-Received: by 2002:a1c:e913:: with SMTP id q19mr550689wmc.55.1548096686163; Mon, 21 Jan 2019 10:51:26 -0800 (PST) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Date: Mon, 21 Jan 2019 18:51:00 +0000 Message-Id: <20190121185118.18550-6-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190121185118.18550-1-peter.maydell@linaro.org> References: <20190121185118.18550-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::342 Subject: [Qemu-devel] [PATCH 05/23] hw/arm/iotkit: Refactor into abstract base class and subclass 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: patches@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" The Arm SSE-200 Subsystem for Embedded is a revised and extended version of the older IoTKit SoC. Prepare for adding a model of it by refactoring the IoTKit code into an abstract base class which contains the functionality, driven by a class data block specific to each subclass. (This is the same approach used by the existing bcm283x SoC family implementation.) Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- include/hw/arm/iotkit.h | 22 +++++++++++++++++----- hw/arm/iotkit.c | 34 +++++++++++++++++++++++++++++----- 2 files changed, 46 insertions(+), 10 deletions(-) diff --git a/include/hw/arm/iotkit.h b/include/hw/arm/iotkit.h index 9701738ec75..521d1f73757 100644 --- a/include/hw/arm/iotkit.h +++ b/include/hw/arm/iotkit.h @@ -74,15 +74,15 @@ #include "hw/or-irq.h" #include "hw/core/split-irq.h" =20 -#define TYPE_ARMSSE "iotkit" +#define TYPE_ARMSSE "arm-sse" #define ARMSSE(obj) OBJECT_CHECK(ARMSSE, (obj), TYPE_ARMSSE) =20 /* - * For the moment TYPE_IOTKIT is a synonym for TYPE_ARMSSE (and the - * latter's underlying name is left as "iotkit"); in a later - * commit it will become a subclass of TYPE_ARMSSE. + * These type names are for specific IoTKit subsystems; other than + * instantiating them, code using these devices should always handle + * them via the ARMSSE base class, so they have no IOTKIT() etc macros. */ -#define TYPE_IOTKIT TYPE_ARMSSE +#define TYPE_IOTKIT "iotkit" =20 /* We have an IRQ splitter and an OR gate input for each external PPC * and the 2 internal PPCs @@ -143,4 +143,16 @@ typedef struct ARMSSE { uint32_t mainclk_frq; } ARMSSE; =20 +typedef struct ARMSSEInfo ARMSSEInfo; + +typedef struct ARMSSEClass { + DeviceClass parent_class; + const ARMSSEInfo *info; +} ARMSSEClass; + +#define ARMSSE_CLASS(klass) \ + OBJECT_CLASS_CHECK(ARMSSEClass, (klass), TYPE_ARMSSE) +#define ARMSSE_GET_CLASS(obj) \ + OBJECT_GET_CLASS(ARMSSEClass, (obj), TYPE_ARMSSE) + #endif diff --git a/hw/arm/iotkit.c b/hw/arm/iotkit.c index 9360053184e..d5b172933c3 100644 --- a/hw/arm/iotkit.c +++ b/hw/arm/iotkit.c @@ -18,6 +18,16 @@ #include "hw/arm/iotkit.h" #include "hw/arm/arm.h" =20 +struct ARMSSEInfo { + const char *name; +}; + +static const ARMSSEInfo armsse_variants[] =3D { + { + .name =3D TYPE_IOTKIT, + }, +}; + /* Clock frequency in HZ of the 32KHz "slow clock" */ #define S32KCLK (32 * 1000) =20 @@ -732,29 +742,43 @@ static void iotkit_class_init(ObjectClass *klass, voi= d *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); IDAUInterfaceClass *iic =3D IDAU_INTERFACE_CLASS(klass); + ARMSSEClass *asc =3D ARMSSE_CLASS(klass); =20 dc->realize =3D iotkit_realize; dc->vmsd =3D &iotkit_vmstate; dc->props =3D iotkit_properties; dc->reset =3D iotkit_reset; iic->check =3D iotkit_idau_check; + asc->info =3D data; } =20 -static const TypeInfo iotkit_info =3D { +static const TypeInfo armsse_info =3D { .name =3D TYPE_ARMSSE, .parent =3D TYPE_SYS_BUS_DEVICE, .instance_size =3D sizeof(ARMSSE), .instance_init =3D iotkit_init, - .class_init =3D iotkit_class_init, + .abstract =3D true, .interfaces =3D (InterfaceInfo[]) { { TYPE_IDAU_INTERFACE }, { } } }; =20 -static void iotkit_register_types(void) +static void armsse_register_types(void) { - type_register_static(&iotkit_info); + int i; + + type_register_static(&armsse_info); + + for (i =3D 0; i < ARRAY_SIZE(armsse_variants); i++) { + TypeInfo ti =3D { + .name =3D armsse_variants[i].name, + .parent =3D TYPE_ARMSSE, + .class_init =3D iotkit_class_init, + .class_data =3D (void *)&armsse_variants[i], + }; + type_register(&ti); + } } =20 -type_init(iotkit_register_types); +type_init(armsse_register_types); --=20 2.20.1