From patchwork Wed May 30 07:50:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?C=C3=A9dric_Le_Goater?= X-Patchwork-Id: 922603 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=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=kaod.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40wjY606tyz9s0q for ; Wed, 30 May 2018 17:54:34 +1000 (AEST) Received: from localhost ([::1]:36870 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fNvwF-0000ga-MA for incoming@patchwork.ozlabs.org; Wed, 30 May 2018 03:54:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47295) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fNvsW-0006Mi-7f for qemu-devel@nongnu.org; Wed, 30 May 2018 03:50:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fNvsU-0001GZ-28 for qemu-devel@nongnu.org; Wed, 30 May 2018 03:50:40 -0400 Received: from 8.mo68.mail-out.ovh.net ([46.105.74.219]:40268) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fNvsT-0001GD-Qx for qemu-devel@nongnu.org; Wed, 30 May 2018 03:50:37 -0400 Received: from player770.ha.ovh.net (unknown [10.109.108.50]) by mo68.mail-out.ovh.net (Postfix) with ESMTP id 7BA64E5546 for ; Wed, 30 May 2018 09:50:36 +0200 (CEST) Received: from zorba.kaod.org.com (LFbn-TOU-1-49-10.w86-201.abo.wanadoo.fr [86.201.141.10]) (Authenticated sender: clg@kaod.org) by player770.ha.ovh.net (Postfix) with ESMTPSA id 356BDC007F; Wed, 30 May 2018 09:50:30 +0200 (CEST) From: =?utf-8?q?C=C3=A9dric_Le_Goater?= To: Peter Maydell Date: Wed, 30 May 2018 09:50:02 +0200 Message-Id: <20180530075002.4618-5-clg@kaod.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180530075002.4618-1-clg@kaod.org> References: <20180530075002.4618-1-clg@kaod.org> MIME-Version: 1.0 X-Ovh-Tracer-Id: 6326431577016339217 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedthedrheelgdduvdehucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddm X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 46.105.74.219 Subject: [Qemu-devel] [PATCH 4/4] hw/arm/aspeed: boot from the FMC CE0 flash module 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: =?utf-8?q?C=C3=A9dric_Le_Goater?= , qemu-arm@nongnu.org, qemu-devel@nongnu.org, Alistair Francis , Peter Crosthwaite Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" When MMIO execution is activated on the FMC controller, remove the copy of the flash module contents in a ROM memory region and boot directly from CE0. Booting from an alternate module (FMC CE1) should be possible. There is still some work to support the module swap when the watchdog resets the system. Signed-off-by: Cédric Le Goater --- hw/arm/aspeed.c | 41 +++++++++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c index e28170b7e1d8..e87a5899845f 100644 --- a/hw/arm/aspeed.c +++ b/hw/arm/aspeed.c @@ -160,6 +160,32 @@ static void write_boot_rom(DriveInfo *dinfo, hwaddr addr, size_t rom_size, g_free(storage); } +static void install_boot_rom(AspeedBoardState *bmc, DriveInfo *drive, + hwaddr addr) +{ + AspeedSMCState *fmc = &bmc->soc.fmc; + AspeedSMCFlash *fl = &fmc->flashes[0]; + bool mmio_exec = object_property_get_bool(OBJECT(fmc), "mmio-exec", + &error_abort); + if (mmio_exec) { + memory_region_add_subregion(get_system_memory(), addr, + &fl->mmio_rom); + } else { + MemoryRegion *boot_rom = g_new(MemoryRegion, 1); + + /* + * create a ROM region using the default mapping window size of + * the flash module. The window size is 64MB for the AST2400 + * SoC and 128MB for the AST2500 SoC, which is twice as big as + * needed by the flash modules of the Aspeed machines. + */ + memory_region_init_rom(boot_rom, OBJECT(bmc), "aspeed.boot_rom", + fl->size, &error_abort); + memory_region_add_subregion(get_system_memory(), addr, boot_rom); + write_boot_rom(drive, addr, fl->size, &error_abort); + } +} + static void aspeed_board_init_flashes(AspeedSMCState *s, const char *flashtype, Error **errp) { @@ -232,20 +258,7 @@ static void aspeed_board_init(MachineState *machine, /* Install first FMC flash content as a boot rom. */ if (drive0) { - AspeedSMCFlash *fl = &bmc->soc.fmc.flashes[0]; - MemoryRegion *boot_rom = g_new(MemoryRegion, 1); - - /* - * create a ROM region using the default mapping window size of - * the flash module. The window size is 64MB for the AST2400 - * SoC and 128MB for the AST2500 SoC, which is twice as big as - * needed by the flash modules of the Aspeed machines. - */ - memory_region_init_rom(boot_rom, OBJECT(bmc), "aspeed.boot_rom", - fl->size, &error_abort); - memory_region_add_subregion(get_system_memory(), FIRMWARE_ADDR, - boot_rom); - write_boot_rom(drive0, FIRMWARE_ADDR, fl->size, &error_abort); + install_boot_rom(bmc, drive0, FIRMWARE_ADDR); } aspeed_board_binfo.kernel_filename = machine->kernel_filename;