Received: from eggs.gnu.org ([2001:4830:134:3::10]:37504) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bn7hb-0005h0-FA for qemu-devel@nongnu.org; Thu, 22 Sep 2016 13:22:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bn7hZ-0002e3-16 for qemu-devel@nongnu.org; Thu, 22 Sep 2016 13:22:26 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:47094) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bn7hY-0002dT-Rq for qemu-devel@nongnu.org; Thu, 22 Sep 2016 13:22:24 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.84_2) (envelope-from ) id 1bn7hY-0007GP-CT for qemu-devel@nongnu.org; Thu, 22 Sep 2016 18:22:24 +0100 From: Peter Maydell Date: Thu, 22 Sep 2016 18:21:54 +0100 Message-Id: <1474564935-23831-16-git-send-email-peter.maydell@linaro.org> In-Reply-To: <1474564935-23831-1-git-send-email-peter.maydell@linaro.org> References: <1474564935-23831-1-git-send-email-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [Qemu-devel] [PULL 15/36] aspeed: allocate RAM after the memory controller has checked the size List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org From: Cédric Le Goater If the RAM size is invalid, the memory controller will use a default value. Signed-off-by: Cédric Le Goater Reviewed-by: Andrew Jeffery Message-id: 1473438177-26079-15-git-send-email-clg@kaod.org Signed-off-by: Peter Maydell --- hw/arm/aspeed.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c index 562bbb2..6b18c7f 100644 --- a/hw/arm/aspeed.c +++ b/hw/arm/aspeed.c @@ -108,11 +108,6 @@ static void aspeed_board_init(MachineState *machine, sc = ASPEED_SOC_GET_CLASS(&bmc->soc); - memory_region_allocate_system_memory(&bmc->ram, NULL, "ram", ram_size); - memory_region_add_subregion(get_system_memory(), sc->info->sdram_base, - &bmc->ram); - object_property_add_const_link(OBJECT(&bmc->soc), "ram", OBJECT(&bmc->ram), - &error_abort); object_property_set_int(OBJECT(&bmc->soc), ram_size, "ram-size", &error_abort); object_property_set_int(OBJECT(&bmc->soc), cfg->hw_strap1, "hw-strap1", @@ -120,6 +115,19 @@ static void aspeed_board_init(MachineState *machine, object_property_set_bool(OBJECT(&bmc->soc), true, "realized", &error_abort); + /* + * Allocate RAM after the memory controller has checked the size + * was valid. If not, a default value is used. + */ + ram_size = object_property_get_int(OBJECT(&bmc->soc), "ram-size", + &error_abort); + + memory_region_allocate_system_memory(&bmc->ram, NULL, "ram", ram_size); + memory_region_add_subregion(get_system_memory(), sc->info->sdram_base, + &bmc->ram); + object_property_add_const_link(OBJECT(&bmc->soc), "ram", OBJECT(&bmc->ram), + &error_abort); + aspeed_board_init_flashes(&bmc->soc.smc, "n25q256a", &error_abort); aspeed_board_init_flashes(&bmc->soc.spi, "mx25l25635e", &error_abort); -- 2.7.4