From patchwork Fri Feb 1 16:06:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 157258 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp624782jaa; Fri, 1 Feb 2019 08:12:37 -0800 (PST) X-Google-Smtp-Source: AHgI3IZArKInLAeFwzjp14k8uVz9+wnhRf4GLUCWt1qwr7c1iG4Uos8PSJd2WR5J+8RBsd3lw2KT X-Received: by 2002:a25:424c:: with SMTP id p73mr21721260yba.164.1549037557800; Fri, 01 Feb 2019 08:12:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549037557; cv=none; d=google.com; s=arc-20160816; b=pcx3TimRYTADXEOlTBMi5h7VuWL27LC7NKIESvJUPypUxD1SeLLkx4VMVeBCx7z274 zRj/eKh0tiWVbLIWFPFTnt9qcRDFSVUrNDD2ywj++wkXeDozuNRUT9pRqsrpXCf8OzHW y+ZlYYnBEBG1FspoFSRmiJ635wZbNVaTBZ5BnPctQ1pskXVbFTI/8nxW8uhRIM/npG8y i4DO19/kv1pB0MQxDh3KKSMeIhwg8NajDJ8/XdOcfdKjh3SIEbQIA0j7QWFfBZyfere3 NxqgAFdDiNvLz+qOJ1LehljXd4GeF/hgh+MXHE8FprO3RxvsKSETZ2p5TVNMCBkMAtLd xHvA== 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=4UPPjD2Lc3v/0oKd3fE09zG+nF6YujmpdD12J2pAABI=; b=xT7aRgNmhx9CvpluCPklU1tVPsW7PsLc4EaT3pjLgzhxrOn1ma49vf80/NjUGB3aSd 7fHJz99YgLA/y0K9pgx1MLxJVqeOyl4/vMgVTDXw4C4O7G+7ZqcLlvmwH06yT5y5h3ii NFbq0RJqoxtaIgjUxKvqsY7pwwyMp4gO+yGTFxR+EmwhU92YpOPODjj5q5u1CL+fSsu0 I24I9o0GueyWwPNgjEjtHk8KT2RTnJffG6WvLGXDT9XGCGUYCyxYXn0HkCgq3zTVc7U8 manKDKD2WIIw3sx3ZH2lbKLO5saHYY9ugBajK51DhIgL14u5EuuLyxIZoksnzsSJK6lD KgzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Lz+GsPV0; 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 h95si4982219ybi.407.2019.02.01.08.12.37 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 01 Feb 2019 08:12:37 -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=Lz+GsPV0; 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]:57302 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gpbQj-0002ph-8Z for patch@linaro.org; Fri, 01 Feb 2019 11:12:37 -0500 Received: from eggs.gnu.org ([209.51.188.92]:58796) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gpbM1-00085y-3n for qemu-devel@nongnu.org; Fri, 01 Feb 2019 11:07:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gpbLp-0003UB-4i for qemu-devel@nongnu.org; Fri, 01 Feb 2019 11:07:37 -0500 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]:40194) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gpbLf-0003If-Je for qemu-devel@nongnu.org; Fri, 01 Feb 2019 11:07:27 -0500 Received: by mail-wm1-x336.google.com with SMTP id f188so6725360wmf.5 for ; Fri, 01 Feb 2019 08:07:05 -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=4UPPjD2Lc3v/0oKd3fE09zG+nF6YujmpdD12J2pAABI=; b=Lz+GsPV0udX5xWqkA2IQX4XxSUtqhS/7DtXpd2pOioTjXyEVq0V/amu2bb6a0MojVQ 3Zw2fdUPECM0WqPhcHdn1nzbPu2BdVZD7hvi4cJK8MBJKgz9yOa/gHhW4pwVxv1HhBJ8 jFibplK/BRhKJ/V2txsd2TvthFlBsXIzS+Rb0= 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=4UPPjD2Lc3v/0oKd3fE09zG+nF6YujmpdD12J2pAABI=; b=ifqOwawhNPQ9tTNxN8DOyWIYfRhKmbxIVGuvLJKZjIqoneCjOt6d9PDQbnxxj6uvhU 7hos5S1OZ0bmvQ33Fk4s4nCBf+DdFnJhA19IjIDGCmr1v7L4TNqGcICOZqIky6FDorEq pAxaBoo2Kx0HxU2EWLP8uPzeWUOicc1lww5C/MK/nOEcJSRp1Hd0q3U+V+4xw4jBp31t 4QJTHsUpwoNdQAAS6IZWitqEEYfvkqnvNCiYbWACB0D0CkBeC0AOWgS5WJvQfLJhr9QK s3PcMIzIESU7lsByt6hT2aNoBd9slNbec+W1Yg6rK/HZwgnCACeJdetXnZYys/UtF0+P nn/g== X-Gm-Message-State: AHQUAuZgYNpPbFlZlWyCAymLwDTKuC27O2/Dfuk1Edj9m1q3+4GBTeGv EtG3HP+Ll0jPbziujzq7Z5Ab/h20xghlGw== X-Received: by 2002:a1c:1f83:: with SMTP id f125mr2967836wmf.56.1549037224662; Fri, 01 Feb 2019 08:07:04 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id n6sm2847250wmk.9.2019.02.01.08.07.02 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 01 Feb 2019 08:07:02 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Date: Fri, 1 Feb 2019 16:06:12 +0000 Message-Id: <20190201160653.13829-7-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190201160653.13829-1-peter.maydell@linaro.org> References: <20190201160653.13829-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::336 Subject: [Qemu-devel] [PULL 06/47] 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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é Reviewed-by: Richard Henderson Message-id: 20190121185118.18550-6-peter.maydell@linaro.org --- include/hw/arm/iotkit.h | 22 +++++++++++++++++----- hw/arm/iotkit.c | 34 +++++++++++++++++++++++++++++----- 2 files changed, 46 insertions(+), 10 deletions(-) -- 2.20.1 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" -#define TYPE_ARMSSE "iotkit" +#define TYPE_ARMSSE "arm-sse" #define ARMSSE(obj) OBJECT_CHECK(ARMSSE, (obj), TYPE_ARMSSE) /* - * 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" /* 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; +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" +struct ARMSSEInfo { + const char *name; +}; + +static const ARMSSEInfo armsse_variants[] = { + { + .name = TYPE_IOTKIT, + }, +}; + /* Clock frequency in HZ of the 32KHz "slow clock" */ #define S32KCLK (32 * 1000) @@ -732,29 +742,43 @@ static void iotkit_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); IDAUInterfaceClass *iic = IDAU_INTERFACE_CLASS(klass); + ARMSSEClass *asc = ARMSSE_CLASS(klass); dc->realize = iotkit_realize; dc->vmsd = &iotkit_vmstate; dc->props = iotkit_properties; dc->reset = iotkit_reset; iic->check = iotkit_idau_check; + asc->info = data; } -static const TypeInfo iotkit_info = { +static const TypeInfo armsse_info = { .name = TYPE_ARMSSE, .parent = TYPE_SYS_BUS_DEVICE, .instance_size = sizeof(ARMSSE), .instance_init = iotkit_init, - .class_init = iotkit_class_init, + .abstract = true, .interfaces = (InterfaceInfo[]) { { TYPE_IDAU_INTERFACE }, { } } }; -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 = 0; i < ARRAY_SIZE(armsse_variants); i++) { + TypeInfo ti = { + .name = armsse_variants[i].name, + .parent = TYPE_ARMSSE, + .class_init = iotkit_class_init, + .class_data = (void *)&armsse_variants[i], + }; + type_register(&ti); + } } -type_init(iotkit_register_types); +type_init(armsse_register_types);