From patchwork Thu Jan 11 21:04:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Filippov X-Patchwork-Id: 10158573 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 40E19605BA for ; Thu, 11 Jan 2018 21:14:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 303DA286E4 for ; Thu, 11 Jan 2018 21:14:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2399028750; Thu, 11 Jan 2018 21:14:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, FROM_LOCAL_NOVOWEL, HK_RANDOM_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9B586286E4 for ; Thu, 11 Jan 2018 21:14:04 +0000 (UTC) Received: from localhost ([::1]:42627 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZkAl-0004Au-Pi for patchwork-qemu-devel@patchwork.kernel.org; Thu, 11 Jan 2018 16:14:03 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34586) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZk2g-00050M-GA for qemu-devel@nongnu.org; Thu, 11 Jan 2018 16:05:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZk2f-00006y-D6 for qemu-devel@nongnu.org; Thu, 11 Jan 2018 16:05:42 -0500 Received: from mail-lf0-x244.google.com ([2a00:1450:4010:c07::244]:45697) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eZk2f-00006B-2z for qemu-devel@nongnu.org; Thu, 11 Jan 2018 16:05:41 -0500 Received: by mail-lf0-x244.google.com with SMTP id y71so3974204lfd.12 for ; Thu, 11 Jan 2018 13:05:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=kZZx15qPwAaz1uwU3pNRqYS/ujZtAP+0TEZ0RR+GAk4=; b=cL9yFf1v2NPB9M76Fxongcn1RyNG9SjLYtvp8DElUlkWjTYiL8h3Of+qIXqkFCjjG5 BFtWafXtMmXluxCWYgUxFbv2h5o2jNvlM4nv3bwrIo3q1WnqKPAAris8kI8ezxZt8/wT fGiDmCya2ZkyeOD70PrMpIf0XQWUrZE4CPSLPiLKm+5QMgDt7b3xPfOie6zo+3dH9q5+ MxNawhwnY1au7F3sjSMUPicLfJwxhcrlk76c/P0Vjb1tL+WpXek1mxh4F6WQIzM+oC2+ JXx1F5e6dgi4XJYARhRs4/LkW8dom6PhAEkLkf8vS79fzcxG6/vOCXZl7++5tirTz7w/ sZPQ== 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; bh=kZZx15qPwAaz1uwU3pNRqYS/ujZtAP+0TEZ0RR+GAk4=; b=ARC2j2CR7DvwmLYGbTYDzZW2MUiDgGYfHvSxLWascetoEWL2cdwp0aLsf0+CjEvcPA ynqycWJIfZlgbzI/1GZKuD5MseqlKSxT6fNEVL9wRY7+t1mM0vY6pByXO2oSElbgmVNF ID9hB6uGDrhmfeBzpAtyDvi+18lLuQiCuchCRyyaUO2h09TZiXfBp9pd1uykgBTZIQ0C hbJqUg5qXfUCbjkOhptzSX9VA2D3QHlkZ19mXkELYh4FDSfIgaCZOYm98yWhIVxsrblr IjorjgLBkHRAyvbNWBtA5LqKbJSYrHyyqzrObXEdlpOv2kKDI+LqFO2zTpBMnGfCGpoQ 46Pw== X-Gm-Message-State: AKGB3mKPIWD3Rnw+Bnme6gThVlZK+GljPAC5xtqrqbIYFIDBZmkgP/6K Tz3Srfix7H6AL2UFVbp3t0BV2w== X-Google-Smtp-Source: ACJfBoveaPCp82UgU7KRv6jLdk4U6BgzlAGA05NRKpxJD2tV4igzD07rS9Rbz23eH92E5KpRsYJpDA== X-Received: by 10.46.93.201 with SMTP id v70mr14141763lje.7.1515704739685; Thu, 11 Jan 2018 13:05:39 -0800 (PST) Received: from octofox.com (jcmvbkbc-1-pt.tunnel.tserv24.sto1.ipv6.he.net. [2001:470:27:1fa::2]) by smtp.gmail.com with ESMTPSA id f126sm2313225lff.82.2018.01.11.13.05.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 11 Jan 2018 13:05:38 -0800 (PST) From: Max Filippov To: qemu-devel@nongnu.org Date: Thu, 11 Jan 2018 13:04:59 -0800 Message-Id: <1515704703-10347-6-git-send-email-jcmvbkbc@gmail.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1515704703-10347-1-git-send-email-jcmvbkbc@gmail.com> References: <1515704703-10347-1-git-send-email-jcmvbkbc@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4010:c07::244 Subject: [Qemu-devel] [PATCH 5/9] hw/xtensa/xtfpga: extract flash configuration 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: Max Filippov Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Extract flash configuration into a separate structure to make it easier to share between MMU and noMMU configurations. Signed-off-by: Max Filippov --- hw/xtensa/xtfpga.c | 66 +++++++++++++++++++++++++++++++++++------------------- 1 file changed, 43 insertions(+), 23 deletions(-) diff --git a/hw/xtensa/xtfpga.c b/hw/xtensa/xtfpga.c index 40e16baa7c34..53bd61fb96df 100644 --- a/hw/xtensa/xtfpga.c +++ b/hw/xtensa/xtfpga.c @@ -46,11 +46,15 @@ #include "bootparam.h" #include "xtensa_memory.h" +typedef struct XtfpgaFlashDesc { + hwaddr base; + size_t size; + size_t boot_base; + size_t sector_size; +} XtfpgaFlashDesc; + typedef struct XtfpgaBoardDesc { - hwaddr flash_base; - size_t flash_size; - size_t flash_boot_base; - size_t flash_sector_size; + const XtfpgaFlashDesc *flash; size_t sram_size; } XtfpgaBoardDesc; @@ -164,14 +168,14 @@ static pflash_t *xtfpga_flash_init(MemoryRegion *address_space, qdev_prop_set_drive(dev, "drive", blk_by_legacy_dinfo(dinfo), &error_abort); qdev_prop_set_uint32(dev, "num-blocks", - board->flash_size / board->flash_sector_size); - qdev_prop_set_uint64(dev, "sector-length", board->flash_sector_size); + board->flash->size / board->flash->sector_size); + qdev_prop_set_uint64(dev, "sector-length", board->flash->sector_size); qdev_prop_set_uint8(dev, "width", 2); qdev_prop_set_bit(dev, "big-endian", be); qdev_prop_set_string(dev, "name", "xtfpga.io.flash"); qdev_init_nofail(dev); s = SYS_BUS_DEVICE(dev); - memory_region_add_subregion(address_space, board->flash_base, + memory_region_add_subregion(address_space, board->flash->base, sysbus_mmio_get_region(s, 0)); return OBJECT_CHECK(pflash_t, (dev), "cfi.pflash01"); } @@ -421,12 +425,12 @@ static void xtfpga_init(const XtfpgaBoardDesc *board, MachineState *machine) MemoryRegion *flash_io = g_malloc(sizeof(*flash_io)); uint32_t size = env->config->sysrom.location[0].size; - if (board->flash_size - board->flash_boot_base < size) { - size = board->flash_size - board->flash_boot_base; + if (board->flash->size - board->flash->boot_base < size) { + size = board->flash->size - board->flash->boot_base; } memory_region_init_alias(flash_io, NULL, "xtfpga.flash", - flash_mr, board->flash_boot_base, size); + flash_mr, board->flash->boot_base, size); memory_region_add_subregion(system_memory, env->config->sysrom.location[0].addr, flash_io); @@ -437,46 +441,62 @@ static void xtfpga_init(const XtfpgaBoardDesc *board, MachineState *machine) } } +static const XtfpgaFlashDesc lx60_flash = { + .base = 0x08000000, + .size = 0x00400000, + .sector_size = 0x10000, +}; + static void xtfpga_lx60_init(MachineState *machine) { static const XtfpgaBoardDesc lx60_board = { - .flash_base = 0x08000000, - .flash_size = 0x00400000, - .flash_sector_size = 0x10000, + .flash = &lx60_flash, .sram_size = 0x20000, }; xtfpga_init(&lx60_board, machine); } +static const XtfpgaFlashDesc lx200_flash = { + .base = 0x08000000, + .size = 0x01000000, + .sector_size = 0x20000, +}; + static void xtfpga_lx200_init(MachineState *machine) { static const XtfpgaBoardDesc lx200_board = { - .flash_base = 0x08000000, - .flash_size = 0x01000000, - .flash_sector_size = 0x20000, + .flash = &lx200_flash, .sram_size = 0x2000000, }; xtfpga_init(&lx200_board, machine); } +static const XtfpgaFlashDesc ml605_flash = { + .base = 0x08000000, + .size = 0x01000000, + .sector_size = 0x20000, +}; + static void xtfpga_ml605_init(MachineState *machine) { static const XtfpgaBoardDesc ml605_board = { - .flash_base = 0x08000000, - .flash_size = 0x01000000, - .flash_sector_size = 0x20000, + .flash = &ml605_flash, .sram_size = 0x2000000, }; xtfpga_init(&ml605_board, machine); } +static const XtfpgaFlashDesc kc705_flash = { + .base = 0x00000000, + .size = 0x08000000, + .boot_base = 0x06000000, + .sector_size = 0x20000, +}; + static void xtfpga_kc705_init(MachineState *machine) { static const XtfpgaBoardDesc kc705_board = { - .flash_base = 0x00000000, - .flash_size = 0x08000000, - .flash_boot_base = 0x06000000, - .flash_sector_size = 0x20000, + .flash = &kc705_flash, .sram_size = 0x2000000, }; xtfpga_init(&kc705_board, machine);