From patchwork Fri Feb 1 16:06:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 1034947 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" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="F0p/4Wh8"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43rjWG1fqnz9sDr for ; Sat, 2 Feb 2019 03:39:54 +1100 (AEDT) Received: from localhost ([127.0.0.1]:57693 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gpbr6-0001DC-54 for incoming@patchwork.ozlabs.org; Fri, 01 Feb 2019 11:39:52 -0500 Received: from eggs.gnu.org ([209.51.188.92]:59115) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gpbMG-0008Iw-3d for qemu-devel@nongnu.org; Fri, 01 Feb 2019 11:08:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gpbMB-0003kb-Fu for qemu-devel@nongnu.org; Fri, 01 Feb 2019 11:08:00 -0500 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:36414) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gpbMB-0003KC-52 for qemu-devel@nongnu.org; Fri, 01 Feb 2019 11:07:55 -0500 Received: by mail-wm1-x343.google.com with SMTP id p6so6752822wmc.1 for ; Fri, 01 Feb 2019 08:07:12 -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=DFsCOXSyUlVKLSOPLT46GVfHlVTaSxW0mj320UGcQyE=; b=F0p/4Wh8qHK5Ef45bYKBwYuaAqbceuR1QngrgeHj+9E9jC5sEU1B1vH/6jWkr2VP3L 53lhF9JWGoQ2gN8O2oO4xFXtztuzy+LKdFQB1Qu2zhbAJ6EpN9GjbAPx1Vw3Vg6O/C5f 0fmCCOWqy7fLtahCUzr2hPs+mJyQWPn29Tr8o= 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=DFsCOXSyUlVKLSOPLT46GVfHlVTaSxW0mj320UGcQyE=; b=ooZqWuJkhRTKSmknVfjcZSC2NV7fvv0QfGx26HswRkwGzuT6Ul5ebBGtWL4RS4unyq RUprEsHH1zgfG5d0laTp37py9X9mEk2RbjcgOT/C6Aj+MhztIs2Zziif/e0ZtPLBeeaZ kMtmWp2XI58lWW4WSTCRv3VfglHTuEPFadi0agdNx52fIb+8ioFqEIH5WoNKcISEkr23 fsgf41TjTqDpPi2Kb84gAYEtm/x/jdkMslTpiNBnjJi0+GycQqE/FSM2h/2gM5rgYuHe 30AAkBU74j+eM9mUB303NpZ/8DsuzvzQfidIUAurAaXMMLbkdYrn+9W8chTsnfU7sXx9 cxkA== X-Gm-Message-State: AHQUAuaSYcYEGSNfL+RplYScZ44d2tOD4hRRMvwKxwPBbhLHYL9OLA0D jDa3Fb3og73/whrLSnHC5OpP3nTg7y9Xpw== X-Google-Smtp-Source: AHgI3IYag6sYCCrk5aZyqETapbCmPPfh+Nz1igtig4zGMIOco3XRdXY6qZk2PSXH+yug1iC10xmG6Q== X-Received: by 2002:a7b:c757:: with SMTP id w23mr2882781wmk.59.1549037230898; Fri, 01 Feb 2019 08:07:10 -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.09 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 01 Feb 2019 08:07:10 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Date: Fri, 1 Feb 2019 16:06:17 +0000 Message-Id: <20190201160653.13829-12-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::343 Subject: [Qemu-devel] [PULL 11/47] hw/arm/armsse: Make SRAM bank size 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" For the IoTKit the SRAM bank size is always 32K (15 bits); for the SSE-200 this is a configurable parameter, which defaults to 32K but can be changed when it is built into a particular SoC. For instance the Musca-B1 board sets it to 128K (17 bits). Make the bank size a QOM property. We follow the SSE-200 hardware in naming the parameter SRAM_ADDR_WIDTH, which specifies the number of address bits of a single SRAM bank. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 20190121185118.18550-11-peter.maydell@linaro.org --- include/hw/arm/armsse.h | 1 + hw/arm/armsse.c | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/include/hw/arm/armsse.h b/include/hw/arm/armsse.h index 99714aa63cd..e4a05013316 100644 --- a/include/hw/arm/armsse.h +++ b/include/hw/arm/armsse.h @@ -146,6 +146,7 @@ typedef struct ARMSSE { MemoryRegion *board_memory; uint32_t exp_numirq; uint32_t mainclk_frq; + uint32_t sram_addr_width; } ARMSSE; typedef struct ARMSSEInfo ARMSSEInfo; diff --git a/hw/arm/armsse.c b/hw/arm/armsse.c index b639b54e0db..a2ae5d3c4b9 100644 --- a/hw/arm/armsse.c +++ b/hw/arm/armsse.c @@ -221,6 +221,7 @@ static void armsse_realize(DeviceState *dev, Error **errp) DeviceState *dev_apb_ppc1; DeviceState *dev_secctl; DeviceState *dev_splitter; + uint32_t addr_width_max; if (!s->board_memory) { error_setg(errp, "memory property was not set"); @@ -232,6 +233,15 @@ static void armsse_realize(DeviceState *dev, Error **errp) return; } + /* max SRAM_ADDR_WIDTH: 24 - log2(SRAM_NUM_BANK) */ + assert(is_power_of_2(info->sram_banks)); + addr_width_max = 24 - ctz32(info->sram_banks); + if (s->sram_addr_width < 1 || s->sram_addr_width > addr_width_max) { + error_setg(errp, "SRAM_ADDR_WIDTH must be between 1 and %d", + addr_width_max); + return; + } + /* Handling of which devices should be available only to secure * code is usually done differently for M profile than for A profile. * Instead of putting some devices only into the secure address space, @@ -352,8 +362,10 @@ static void armsse_realize(DeviceState *dev, Error **errp) for (i = 0; i < info->sram_banks; i++) { char *ramname = g_strdup_printf("armsse.sram%d", i); SysBusDevice *sbd_mpc; + uint32_t sram_bank_size = 1 << s->sram_addr_width; - memory_region_init_ram(&s->sram[i], NULL, ramname, 0x00008000, &err); + memory_region_init_ram(&s->sram[i], NULL, ramname, + sram_bank_size, &err); g_free(ramname); if (err) { error_propagate(errp, err); @@ -372,7 +384,8 @@ static void armsse_realize(DeviceState *dev, Error **errp) } /* Map the upstream end of the MPC into the right place... */ sbd_mpc = SYS_BUS_DEVICE(&s->mpc[i]); - memory_region_add_subregion(&s->container, 0x20000000 + i * 0x8000, + memory_region_add_subregion(&s->container, + 0x20000000 + i * sram_bank_size, sysbus_mmio_get_region(sbd_mpc, 1)); /* ...and its register interface */ memory_region_add_subregion(&s->container, 0x50083000 + i * 0x1000, @@ -748,6 +761,7 @@ static Property armsse_properties[] = { MemoryRegion *), DEFINE_PROP_UINT32("EXP_NUMIRQ", ARMSSE, exp_numirq, 64), DEFINE_PROP_UINT32("MAINCLK", ARMSSE, mainclk_frq, 0), + DEFINE_PROP_UINT32("SRAM_ADDR_WIDTH", ARMSSE, sram_addr_width, 15), DEFINE_PROP_END_OF_LIST() };