From patchwork Mon Oct 28 15:48:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Palmer Dabbelt X-Patchwork-Id: 11216133 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 007B713B1 for ; Mon, 28 Oct 2019 16:53:30 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BF853208C0 for ; Mon, 28 Oct 2019 16:53:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=sifive.com header.i=@sifive.com header.b="BMZQ6xAh" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BF853208C0 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sifive.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:60112 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iP8Gj-0005xA-0u for patchwork-qemu-devel@patchwork.kernel.org; Mon, 28 Oct 2019 12:53:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34875) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iP7Pn-0005cT-1h for qemu-devel@nongnu.org; Mon, 28 Oct 2019 11:58:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iP7Pl-0003zm-S0 for qemu-devel@nongnu.org; Mon, 28 Oct 2019 11:58:42 -0400 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]:40538) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iP7Pl-0003zQ-Cg for qemu-devel@nongnu.org; Mon, 28 Oct 2019 11:58:41 -0400 Received: by mail-pg1-x543.google.com with SMTP id 15so7157954pgt.7 for ; Mon, 28 Oct 2019 08:58:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding:cc:from:to; bh=2NCHxf2RTfuXrJhdamckaC8gMLlH4bUoRGro3j12kyY=; b=BMZQ6xAhMV1Bhz7Pv6uytvQALaiS65Ikwji5Hp/zCFEdCdgcMhQKlZ8Sdy69JgoAAZ gOO1W9PZrbDA4bYZKZVVQ2dUct86F/zifZLjaMQ7XJ2okR0PBHHf/LvcqpU3EsxgRVpV JYTuHHRDnqBZhwVv0giirFrjeQ0e+GXwqu2dramRGmSOq1f0aVVe5N8gJSXTzSzmlro4 MZdrULS4CFUjhVtDSbMWwzSDx7CU7nCvjCYOR/njAlQcb7uQzK6kAXnhFSWvlZopZgkc SSEHlUi0PBu6DkUdkqSDXOERdnQOuBmK1zZsEHUkkOjpAqBXidJW48dbByQ81a/DZbp3 KGwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:cc:from:to; bh=2NCHxf2RTfuXrJhdamckaC8gMLlH4bUoRGro3j12kyY=; b=ODttzK9r5OWGhhIyH78JlVcaHTxUh8acCaH2YlRlbehN+/Zpgti+YXo65IDj/+ALVH aT0R6x1UhpqS5uHE3NQdwHMFGbkYOHPtRwgezbiXRtck645zVVdY62jWyOnnMMCiQnDh Y4j8jr47+crtywH5daNC5t5j/FdAcqk/LEvD9RAHhjO/QBe/9uoXb3tesJiHmb0lXV4c AbCRLrnFj19RlZKegKt3YDEq6o75dY+NQdSjI8uEjOVSQnWs+LaxYLtKEbs+N4emTlx8 dSKqxeiE85NgDkLvIPmFOgX3cCyXELWz5upafGgxqv+ldYpeT0GIG6t8KIkbO5k8FxJI j3pw== X-Gm-Message-State: APjAAAWXO90PXJuGcm8dRMQ2sEwV2PLp+p9X1RLK9Chaiqe+2kzt4Qp2 YXRJm8KiNop/Czx9FNoKbOjJbLRtuQm6CQ== X-Google-Smtp-Source: APXvYqxXDhAJLe9HLi31OoScyRGZ545RYqLXzk9aXZjSY1aDYbP7hHX7ddZZg2Bkr/5RClm7ijM+YA== X-Received: by 2002:a63:e255:: with SMTP id y21mr21309744pgj.353.1572278320076; Mon, 28 Oct 2019 08:58:40 -0700 (PDT) Received: from localhost ([12.206.222.5]) by smtp.gmail.com with ESMTPSA id c6sm9841073pfj.59.2019.10.28.08.58.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2019 08:58:39 -0700 (PDT) Subject: [PULL 13/18] riscv/virt: Jump to pflash if specified Date: Mon, 28 Oct 2019 08:48:57 -0700 Message-Id: <20191028154902.32491-14-palmer@sifive.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191028154902.32491-1-palmer@sifive.com> References: <20191028154902.32491-1-palmer@sifive.com> MIME-Version: 1.0 From: Palmer Dabbelt To: Peter Maydell X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::543 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-riscv@nongnu.org, Palmer Dabbelt , qemu-devel@nongnu.org, Alistair Francis , Bin Meng , ilippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" From: Alistair Francis If the user supplied pflash to QEMU then change the reset code to jump to the pflash base address instead of the DRAM base address. Signed-off-by: Alistair Francis Reviewed-by: Bin Meng Reviewed-by: Philippe Mathieu-Daudé Tested-by: Bin Meng Signed-off-by: Palmer Dabbelt --- hw/riscv/virt.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c index b2156abd6c..cc8f311e6b 100644 --- a/hw/riscv/virt.c +++ b/hw/riscv/virt.c @@ -443,6 +443,7 @@ static void riscv_virt_board_init(MachineState *machine) MemoryRegion *mask_rom = g_new(MemoryRegion, 1); char *plic_hart_config; size_t plic_hart_config_len; + target_ulong start_addr = memmap[VIRT_DRAM].base; int i; unsigned int smp_cpus = machine->smp.cpus; @@ -489,6 +490,14 @@ static void riscv_virt_board_init(MachineState *machine) } } + if (drive_get(IF_PFLASH, 0, 0)) { + /* + * Pflash was supplied, let's overwrite the address we jump to after + * reset to the base of the flash. + */ + start_addr = virt_memmap[VIRT_FLASH].base; + } + /* reset vector */ uint32_t reset_vec[8] = { 0x00000297, /* 1: auipc t0, %pcrel_hi(dtb) */ @@ -501,7 +510,7 @@ static void riscv_virt_board_init(MachineState *machine) #endif 0x00028067, /* jr t0 */ 0x00000000, - memmap[VIRT_DRAM].base, /* start: .dword memmap[VIRT_DRAM].base */ + start_addr, /* start: .dword */ 0x00000000, /* dtb: */ };