From patchwork Fri Feb 1 16:06:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 157281 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp644522jaa; Fri, 1 Feb 2019 08:29:26 -0800 (PST) X-Google-Smtp-Source: AHgI3IYTLl6RCktARuiKP43+ZlNlksm/zQRiB8f7cl8FdEY0sZyVvhQy3HkF8yXE2NiTVRLA5Xg4 X-Received: by 2002:a25:8b8c:: with SMTP id j12mr1179587ybl.418.1549038566506; Fri, 01 Feb 2019 08:29:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549038566; cv=none; d=google.com; s=arc-20160816; b=wG4WKibXl3y4mBYMLI2cF/x645fqrwWxOv8frIBXnR3Z1hwzL/osYdlEUcsBCm2vvd yeFwbpbj7vb/ZyuBMEyjxHBd43BK+xjH43JWLPupkNxPvw2/g8FU11njGU7HJzjHwR+p AgQSRroXl/HCvHfG4RHu8Armw5VLQkPIgIZh0hMEypYQfIz3+6Q/uWa+8S8QFZgaO4eH fy8y8mr/tN894cAO2EsUBFnOJClLH8d1DZJQk8vx2ki2jWQxLBIOwoj8ITJzJytvu0ds Ioi3ol9G72dDBsJQpWlquUQ+8guGU2VQSHK5a6ZUvLAnmcxBCqaBWaPF6zaK/cLyEDi/ DV4w== 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=aHYwopBPA89RqIPLZk0wAy1HWCXoHIrufkjnBb462e8=; b=zEqRZ/5L1CrWGc+01b3DyUnveSuCwhjZVolYAuTmgkWZAQBosMoaZFvg/7CSkVSeny qp7jmE9mtdUjlMZ9eDbJC1lgBaknxTfvUL2f0Nbrh9DiH2UbUYbe99HCfxrvlhZvfjPC SDAFpHgGxnduLb4/e9Fvwc9T1L/1/A3nxPGA/FmpkNQupiyX52wDWefv9JVuW+NiZl9a PRRiGsmKp2nhLSxu4335UAWMTIfOTgUV0IXzr9JrzEz9QDsuCIPOJwPXRVn9ig+o9lJR z2Uqi0R1FbzkZrERMIUZgzcgavbORV+jqO/PM0eYXfstQxZkekQMdtt86aRLk8vUpaFK auWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=E4ks68sC; 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 l15si4974951ybq.297.2019.02.01.08.29.26 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 01 Feb 2019 08:29:26 -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=E4ks68sC; 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]:57540 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gpbgz-0000Tv-VV for patch@linaro.org; Fri, 01 Feb 2019 11:29:26 -0500 Received: from eggs.gnu.org ([209.51.188.92]:59003) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gpbMD-0008GW-Hj for qemu-devel@nongnu.org; Fri, 01 Feb 2019 11:08:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gpbMA-0003i5-5T for qemu-devel@nongnu.org; Fri, 01 Feb 2019 11:07:57 -0500 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]:39802) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gpbM9-0003LZ-SH for qemu-devel@nongnu.org; Fri, 01 Feb 2019 11:07:54 -0500 Received: by mail-wm1-x341.google.com with SMTP id y8so6725513wmi.4 for ; Fri, 01 Feb 2019 08:07:17 -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=aHYwopBPA89RqIPLZk0wAy1HWCXoHIrufkjnBb462e8=; b=E4ks68sC0UpGPDtFexnoup+s/ZYjq3e/WdLkWpDMeqbaMTid6Fd7igHrNZuAvshRDK yMAWnEB07dvpH6Nmqn5uAy0/qrl20J1FxlqcB8aH67XqKd7DGoTCsvwsrNtbfFT0ais7 N/scmUFZ3InXmiwjvPPDOg2JhC/nb+hxe9GLM= 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=aHYwopBPA89RqIPLZk0wAy1HWCXoHIrufkjnBb462e8=; b=jyrC2y1eh5lV+XzjYSeqjxI97C3gRaeevC5NkF3HutT4SiJ/BEPmlhY+CPB9nwWQUi UOErIhjsX6vQixmk0y8AuEElaHBHqT820ifsq8GMv2Mvx7coaT8yCRyy9enkYuh+N64R Q7kECl4jOJbszjhhTz+Js7cRxGJNM/XAReSg+f7rwRgqxYbKNYWyMWvEEKGI1dpM1OWe M87/HfEbCtADpGbeuvd82lFe0cycj3mjITxapcr0iEnapYtl5uxSGXihJqxWaSPx4PVJ RTZeBZsqmdXXugSuWgsOzyySOeN6CmOQhWKvtSm4Ytu+ERdGHFpvuq7Uqb+HB/Vf3rAw qktQ== X-Gm-Message-State: AHQUAuZ7V0qNf2Y8mP8OxhfYZclOo8yo/uY6u4p2YPldKS+1ukLtY5lm SoJ3OxojS0XmM+v3EUXdvgwhvcPob/qClw== X-Received: by 2002:a1c:c543:: with SMTP id v64mr2909609wmf.123.1549037236053; Fri, 01 Feb 2019 08:07:16 -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.14 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 01 Feb 2019 08:07:15 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Date: Fri, 1 Feb 2019 16:06:21 +0000 Message-Id: <20190201160653.13829-16-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::341 Subject: [Qemu-devel] [PULL 15/47] iotkit-sysinfo: Make SYS_VERSION and SYS_CONFIG configurable 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 SYS_VERSION and SYS_CONFIG register values differ between the IoTKit and SSE-200. Make them configurable via QOM properties rather than hard-coded, and set them appropriately in the ARMSSE code that instantiates the IOTKIT_SYSINFO device. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 20190121185118.18550-15-peter.maydell@linaro.org --- include/hw/misc/iotkit-sysinfo.h | 6 ++++ hw/arm/armsse.c | 51 ++++++++++++++++++++++++++++++++ hw/misc/iotkit-sysinfo.c | 15 ++++++++-- 3 files changed, 70 insertions(+), 2 deletions(-) -- 2.20.1 diff --git a/include/hw/misc/iotkit-sysinfo.h b/include/hw/misc/iotkit-sysinfo.h index 7b2e1a5e48b..d84eb203b90 100644 --- a/include/hw/misc/iotkit-sysinfo.h +++ b/include/hw/misc/iotkit-sysinfo.h @@ -14,6 +14,8 @@ * Arm IoTKit and documented in * http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ecm0601256/index.html * QEMU interface: + * + QOM property "SYS_VERSION": value to use for SYS_VERSION register + * + QOM property "SYS_CONFIG": value to use for SYS_CONFIG register * + sysbus MMIO region 0: the system information register bank */ @@ -32,6 +34,10 @@ typedef struct IoTKitSysInfo { /*< public >*/ MemoryRegion iomem; + + /* Properties */ + uint32_t sys_version; + uint32_t sys_config; } IoTKitSysInfo; #endif diff --git a/hw/arm/armsse.c b/hw/arm/armsse.c index 2eb4ea3bfe0..19cae77e770 100644 --- a/hw/arm/armsse.c +++ b/hw/arm/armsse.c @@ -18,10 +18,18 @@ #include "hw/arm/armsse.h" #include "hw/arm/arm.h" +/* Format of the System Information block SYS_CONFIG register */ +typedef enum SysConfigFormat { + IoTKitFormat, + SSE200Format, +} SysConfigFormat; + struct ARMSSEInfo { const char *name; int sram_banks; int num_cpus; + uint32_t sys_version; + SysConfigFormat sys_config_format; }; static const ARMSSEInfo armsse_variants[] = { @@ -29,9 +37,39 @@ static const ARMSSEInfo armsse_variants[] = { .name = TYPE_IOTKIT, .sram_banks = 1, .num_cpus = 1, + .sys_version = 0x41743, + .sys_config_format = IoTKitFormat, }, }; +static uint32_t armsse_sys_config_value(ARMSSE *s, const ARMSSEInfo *info) +{ + /* Return the SYS_CONFIG value for this SSE */ + uint32_t sys_config; + + switch (info->sys_config_format) { + case IoTKitFormat: + sys_config = 0; + sys_config = deposit32(sys_config, 0, 4, info->sram_banks); + sys_config = deposit32(sys_config, 4, 4, s->sram_addr_width - 12); + break; + case SSE200Format: + sys_config = 0; + sys_config = deposit32(sys_config, 0, 4, info->sram_banks); + sys_config = deposit32(sys_config, 4, 5, s->sram_addr_width); + sys_config = deposit32(sys_config, 24, 4, 2); + if (info->num_cpus > 1) { + sys_config = deposit32(sys_config, 10, 1, 1); + sys_config = deposit32(sys_config, 20, 4, info->sram_banks - 1); + sys_config = deposit32(sys_config, 28, 4, 2); + } + break; + default: + g_assert_not_reached(); + } + return sys_config; +} + /* Clock frequency in HZ of the 32KHz "slow clock" */ #define S32KCLK (32 * 1000) @@ -726,6 +764,19 @@ static void armsse_realize(DeviceState *dev, Error **errp) qdev_get_gpio_in_named(dev_apb_ppc1, "cfg_sec_resp", 0)); + object_property_set_int(OBJECT(&s->sysinfo), info->sys_version, + "SYS_VERSION", &err); + if (err) { + error_propagate(errp, err); + return; + } + object_property_set_int(OBJECT(&s->sysinfo), + armsse_sys_config_value(s, info), + "SYS_CONFIG", &err); + if (err) { + error_propagate(errp, err); + return; + } object_property_set_bool(OBJECT(&s->sysinfo), true, "realized", &err); if (err) { error_propagate(errp, err); diff --git a/hw/misc/iotkit-sysinfo.c b/hw/misc/iotkit-sysinfo.c index 78955bc45f5..026ba942613 100644 --- a/hw/misc/iotkit-sysinfo.c +++ b/hw/misc/iotkit-sysinfo.c @@ -51,15 +51,16 @@ static const int sysinfo_id[] = { static uint64_t iotkit_sysinfo_read(void *opaque, hwaddr offset, unsigned size) { + IoTKitSysInfo *s = IOTKIT_SYSINFO(opaque); uint64_t r; switch (offset) { case A_SYS_VERSION: - r = 0x41743; + r = s->sys_version; break; case A_SYS_CONFIG: - r = 0x31; + r = s->sys_config; break; case A_PID4 ... A_CID3: r = sysinfo_id[(offset - A_PID4) / 4]; @@ -94,6 +95,12 @@ static const MemoryRegionOps iotkit_sysinfo_ops = { .valid.max_access_size = 4, }; +static Property iotkit_sysinfo_props[] = { + DEFINE_PROP_UINT32("SYS_VERSION", IoTKitSysInfo, sys_version, 0), + DEFINE_PROP_UINT32("SYS_CONFIG", IoTKitSysInfo, sys_config, 0), + DEFINE_PROP_END_OF_LIST() +}; + static void iotkit_sysinfo_init(Object *obj) { SysBusDevice *sbd = SYS_BUS_DEVICE(obj); @@ -106,10 +113,14 @@ static void iotkit_sysinfo_init(Object *obj) static void iotkit_sysinfo_class_init(ObjectClass *klass, void *data) { + DeviceClass *dc = DEVICE_CLASS(klass); + /* * This device has no guest-modifiable state and so it * does not need a reset function or VMState. */ + + dc->props = iotkit_sysinfo_props; } static const TypeInfo iotkit_sysinfo_info = {