From patchwork Mon Jan 21 18:51:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 156233 Delivered-To: patches@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp6700995jaa; Mon, 21 Jan 2019 10:51:26 -0800 (PST) X-Received: by 2002:adf:f009:: with SMTP id j9mr28837750wro.170.1548096686641; Mon, 21 Jan 2019 10:51:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548096686; cv=none; d=google.com; s=arc-20160816; b=r/s0o0xWtbcsNgDwySdlrOSDiow4/Sh1gff6J11aSNYgrbC/hkiqaW6QY5YU0Bevo/ h/bk5mEhyfsZ9YbZFb7SabAxcG4R/2aSX5nJGb3DtzVkHYGsn93ButrIDvkRYGea0b+W YOmiVt21+UXptHWI5d/6VOqgCkrGml+suqQszg91kSTMLnSD0ySNBCNGhOTjGXTGDb68 7PqNu7ANOH/HYsGz6cCHBI7eUQ4brsMNFzHKBApYJrNWfoGPyqU23Mwcus4WG2TJAB7q GhqLzrHFnwCaX+AfMsgbzI3PVj+25v4sRHEHQ4d8yjIXWv1bKEo+WmNaPa4tRSTjHvjI bSWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=8/8nrDNxFDGGiKzCXqhPzki/Hbmqf6CuZf0plZpfE7M=; b=rhvZvAAFs/ebglkWPjo6Q+9ivRWv1zUs6nbP2P0ifP8M7WJR136ERkUanZhWaMXqA4 R5AyIDvi0OhnlfAawnkrF4pdzJB/RF8ZlY0KJtCYSHP3gm+dOwdSTX2FkbHP/zQYCb6t QZKM/2UP6L3mT+jqYfEcTWJBSPaqJEy3xtFngrU/MIzddhIrAs2TJz2c1M9TQ3bJ//qk UDL7GzwvY4euRBuKLAmri+I2eEBBEzGTCTlsGBcX4MBkflh+dy9iscHWoMLslzQoluaT AIWnxv56saA7cBz59waphy8a+Npnhpgrg+apAAbPqmNeeftqVnp7PncP3Ibf81dHGosZ tJWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XvIAnboj; spf=pass (google.com: domain of peter.maydell@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=peter.maydell@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id w22sor32573197wmi.5.2019.01.21.10.51.26 for (Google Transport Security); Mon, 21 Jan 2019 10:51:26 -0800 (PST) Received-SPF: pass (google.com: domain of peter.maydell@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XvIAnboj; spf=pass (google.com: domain of peter.maydell@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=peter.maydell@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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=aeaHxi1pESIGn1EuG7V7LrekjTaAk/JPeupTmunj9x1d5w9IIwSy/vDFU4B1aDkX0T F+omNeXyWzLzT4JcRUw7hmzE2JEPbAL2UCJ0F1xrbdpYJ418s8O+p0JKlLSw7QbBTbIz 9os1ykXrrOlHimSkO6CGaV/oqz30PGoghsWddTKoEv6S9Ivh2bTp+ib+s22weGKPi2a5 YPNlNHMRNp2sYDDZ6wvDJ7PNda3UIbK+FT+s9HIGl/zooiucHbkDoMkDEAsk2jtu5LBt 8dFg5dnhvhwP/aObCjyp+41G67yL2gwK9L0uMddjkD8enyJjHr52NxFu/4lFccyt7poA lidA== X-Gm-Message-State: AJcUukcaKOTcQmajPzzk0c9SI+yssbZZlsrGwScnmzmTXDrOTZ1uweO3 hG4C/dw5lIdP6hXASys/Ag53Tegr 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) Return-Path: 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) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Cc: patches@linaro.org Subject: [PATCH 05/23] hw/arm/iotkit: Refactor into abstract base class and subclass 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 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 --- include/hw/arm/iotkit.h | 22 +++++++++++++++++----- hw/arm/iotkit.c | 34 +++++++++++++++++++++++++++++----- 2 files changed, 46 insertions(+), 10 deletions(-) -- 2.20.1 Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson 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);