From patchwork Thu May 29 12:24:28 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 31121 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pb0-f69.google.com (mail-pb0-f69.google.com [209.85.160.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 449F2203E6 for ; Thu, 29 May 2014 12:24:35 +0000 (UTC) Received: by mail-pb0-f69.google.com with SMTP id uo5sf1191764pbc.0 for ; Thu, 29 May 2014 05:24:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=8yhTzkBjgANGVHDJZxkEU6+F2oPvfEafxPxxTy+qwTs=; b=SQbgmIJ4QBKBvnofjQgKRrAUVDcOf2Xp5UIGshvpUeGIWVUozmAprSAv2IbE5UWiet qng7XlJbtjy3GYu3Rdaoc02b2p7cOaxHdC13XaIzpY86O9dADEOMkGW+pxVPBqNx3p9E +Bo7uND97F+GYMixB3BWv/rkdId3LEpZ4Lvhgri0oqXKkiep1qNVgDqrEiGy/jenDB6h +3aVawzQG0RT4sLn0NUmfKjwOclZbc+hFnmWbZ8SzXnaSgSoAOvI4O7iuz2+mS8cqauD exGWeoFuBCOwBaPTmnsKCllmVgd4uAEw+rl+nsRWjhFlyPpg/nOoCH5d9TQqpInxKRDH /odw== X-Gm-Message-State: ALoCoQmSkQt80uAn/ZeeQ8CDx0jiOjsdLZSEoQCcebaA2vM+ZVna4AO/MZe6koghCBNGmUo7svH8 X-Received: by 10.66.65.142 with SMTP id x14mr2949662pas.14.1401366274532; Thu, 29 May 2014 05:24:34 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.19.83 with SMTP id 77ls658245qgg.28.gmail; Thu, 29 May 2014 05:24:34 -0700 (PDT) X-Received: by 10.58.29.76 with SMTP id i12mr401586veh.67.1401366274424; Thu, 29 May 2014 05:24:34 -0700 (PDT) Received: from mail-ve0-f170.google.com (mail-ve0-f170.google.com [209.85.128.170]) by mx.google.com with ESMTPS id im7si330925vec.38.2014.05.29.05.24.34 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 29 May 2014 05:24:34 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.170 as permitted sender) client-ip=209.85.128.170; Received: by mail-ve0-f170.google.com with SMTP id db11so266552veb.29 for ; Thu, 29 May 2014 05:24:34 -0700 (PDT) X-Received: by 10.221.7.71 with SMTP id on7mr6194009vcb.18.1401366274333; Thu, 29 May 2014 05:24:34 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.221.72 with SMTP id ib8csp24224vcb; Thu, 29 May 2014 05:24:33 -0700 (PDT) X-Received: by 10.180.79.9 with SMTP id f9mr44717483wix.52.1401366273458; Thu, 29 May 2014 05:24:33 -0700 (PDT) Received: from mnementh.archaic.org.uk (mnementh.archaic.org.uk. [2001:8b0:1d0::1]) by mx.google.com with ESMTPS id ex6si20432913wib.79.2014.05.29.05.24.30 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 29 May 2014 05:24:32 -0700 (PDT) Received-SPF: none (google.com: pm215@archaic.org.uk does not designate permitted sender hosts) client-ip=2001:8b0:1d0::1; Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1WpzNk-0006nK-FN; Thu, 29 May 2014 13:24:28 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, Grant Likely , Roy Franz Subject: [PATCH v2] vexpress: Add support for the -bios flag to provide firmware Date: Thu, 29 May 2014 13:24:28 +0100 Message-Id: <1401366268-26093-1-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: peter.maydell@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.170 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Grant Likely Right now to run firmware inside the QEMU VExpress model requires padding out the firmware image to the size of the virtual flash and passing it in via the -pflash argument. If the firmware image is passed without padding, then QEMU will fail. Also, when passed as a -pflash argument, QEMU treats the file as persistent storage and will modify the file. The -bios flag provides the semantics that we want for providing a firmware image. This patch maps the contents of the -bios file into the address space at the boot flash location. Tested with the vexpress-a15 model and the Tianocore port. Signed-off-by: Grant Likely Tested-by: Roy Franz [PMM: folded long line, removed stray \n from error message, use correct variable for printing image name, exit(1) rather than 0] Signed-off-by: Peter Maydell Reviewed-by: Peter Crosthwaite --- Grant submitted v1 of this a few months back; it was pretty nearly correct, so I've just tidied up the loose ends so we can get it into QEMU 2.1. Tested by booting the UEFI blob from https://wiki.linaro.org/LEG/Engineering/Kernel/UEFI/VersatileExpress/QEMU hw/arm/vexpress.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/hw/arm/vexpress.c b/hw/arm/vexpress.c index 33ff422..0f8f175 100644 --- a/hw/arm/vexpress.c +++ b/hw/arm/vexpress.c @@ -28,6 +28,7 @@ #include "net/net.h" #include "sysemu/sysemu.h" #include "hw/boards.h" +#include "hw/loader.h" #include "exec/address-spaces.h" #include "sysemu/blockdev.h" #include "hw/block/flash.h" @@ -528,6 +529,18 @@ static void vexpress_common_init(VEDBoardInfo *daughterboard, daughterboard->init(daughterboard, machine->ram_size, machine->cpu_model, pic); + /* + * If a bios file was provided, attempt to map it into memory + */ + if (bios_name) { + const char *fn = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); + if (!fn || load_image_targphys(fn, map[VE_NORFLASH0], + VEXPRESS_FLASH_SIZE) < 0) { + error_report("Could not load rom image '%s'", bios_name); + exit(1); + } + } + /* Motherboard peripherals: the wiring is the same but the * addresses vary between the legacy and A-Series memory maps. */