From patchwork Wed Jul 10 07:33:52 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grant Likely X-Patchwork-Id: 18300 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-gg0-f199.google.com (mail-gg0-f199.google.com [209.85.161.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 4559A25E04 for ; Wed, 10 Jul 2013 07:34:25 +0000 (UTC) Received: by mail-gg0-f199.google.com with SMTP id o1sf7160086ggn.6 for ; Wed, 10 Jul 2013 00:34:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-beenthere:x-forwarded-to:x-forwarded-for :delivered-to:sender:from:to:cc:subject:date:message-id:x-mailer :x-gm-message-state:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-google-group-id:list-post:list-help:list-archive:list-unsubscribe; bh=POFCa5rU64ZDiOqjuoNC1aCpe2vI6DXpyx7+fK+kjc4=; b=pD4QCoOBgdaj9PM/lllhf3GOG2fwTx2dFkClQUfZiBRcnncUQvSp2mM9cMf2G67Qzo gFA3ktd/HZNNIHnpdnRljio0OW5g8EpsVPFsLOaFfz6Eoe8rLVYL0l2Xxaq97HsYXGNG TXMwNS/V9T0X/Lv++lj7N0ksnkgbNH6xOX94XOfDpNjLE6KEOKuxfhzw5ODg5V923vu+ Fpqgl/M3jL5plYlXQgok52G3pIPrQwhT1nxBV9R5oYVraMDDx8QR0D8tLulHtTypPVSs xNrzAkRHmQs53NYV3RpdA25+UK9WLKLRFPHWzLRe7yoL3atpH16m+1GT+H3FRi0xyIpr XqJw== X-Received: by 10.236.91.173 with SMTP id h33mr16360413yhf.17.1373441664477; Wed, 10 Jul 2013 00:34:24 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.35.50 with SMTP id e18ls2652845qej.99.gmail; Wed, 10 Jul 2013 00:34:24 -0700 (PDT) X-Received: by 10.58.41.105 with SMTP id e9mr18424402vel.14.1373441664258; Wed, 10 Jul 2013 00:34:24 -0700 (PDT) Received: from mail-ve0-f173.google.com (mail-ve0-f173.google.com [209.85.128.173]) by mx.google.com with ESMTPS id q1si8852427vex.119.2013.07.10.00.34.24 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 10 Jul 2013 00:34:24 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.173 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.173; Received: by mail-ve0-f173.google.com with SMTP id jw11so5368641veb.18 for ; Wed, 10 Jul 2013 00:34:24 -0700 (PDT) X-Received: by 10.58.154.34 with SMTP id vl2mr12488807veb.35.1373441663909; Wed, 10 Jul 2013 00:34:23 -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.149.77 with SMTP id s13csp10357vcv; Wed, 10 Jul 2013 00:34:23 -0700 (PDT) X-Received: by 10.180.106.72 with SMTP id gs8mr34111145wib.51.1373441662519; Wed, 10 Jul 2013 00:34:22 -0700 (PDT) Received: from mail-we0-f175.google.com (mail-we0-f175.google.com [74.125.82.175]) by mx.google.com with ESMTPS id u2si9770658wja.111.2013.07.10.00.34.21 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 10 Jul 2013 00:34:22 -0700 (PDT) Received-SPF: neutral (google.com: 74.125.82.175 is neither permitted nor denied by best guess record for domain of glikely@secretlab.ca) client-ip=74.125.82.175; Received: by mail-we0-f175.google.com with SMTP id t59so5666289wes.34 for ; Wed, 10 Jul 2013 00:34:21 -0700 (PDT) X-Received: by 10.194.83.195 with SMTP id s3mr17556362wjy.82.1373441661879; Wed, 10 Jul 2013 00:34:21 -0700 (PDT) Received: from localhost ([193.120.41.118]) by mx.google.com with ESMTPSA id w4sm34047599wia.9.2013.07.10.00.34.20 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 10 Jul 2013 00:34:20 -0700 (PDT) Sender: Grant Likely Received: by localhost (Postfix, from userid 1000) id A73D33E0E5B; Wed, 10 Jul 2013 08:34:18 +0100 (BST) From: Grant Likely To: Cc: patches@linaro.org, Grant Likely , Peter Maydell , qemu-devel@nongnu.org Subject: [PATCH] Make -kernel flag optional on ARM. Date: Wed, 10 Jul 2013 08:33:52 +0100 Message-Id: <1373441632-17323-1-git-send-email-grant.likely@linaro.org> X-Mailer: git-send-email 1.8.1.2 X-Gm-Message-State: ALoCoQkGmVLdZc51aguumz6q44T7SOD/9B+pKgUvMM+BvdPeLzl78MWNC2T2mn1m++49ty7+ro5s X-Original-Sender: grant.likely@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.173 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) 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: , Sometimes we want to boot the system via firmware instead of loading a kernel into ram with the -kernel parameter. This patch makes the -kernel parameter optional so that a bios image provided by the -pflash flag will be executed. For example: qemu-system-arm -M vexpress-a15 -pflash Note: Currently the file must be at least the size of the emulated flash device (64M) otherwise QEMU will silently not use the data. This will be fixed in a separate patch This is part of the larger solution. For this to work it requires the platform to have flash mapped or aliased to address 0 so that there is some code for the emulator to execute. Signed-off-by: Grant Likely Cc: Peter Maydell Cc: qemu-devel@nongnu.org --- hw/arm/boot.c | 47 ++++++++++++++++++++++------------------------- 1 file changed, 22 insertions(+), 25 deletions(-) diff --git a/hw/arm/boot.c b/hw/arm/boot.c index 7c0090f..3b9e108 100644 --- a/hw/arm/boot.c +++ b/hw/arm/boot.c @@ -361,12 +361,6 @@ void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info) int big_endian; QemuOpts *machine_opts; - /* Load the kernel. */ - if (!info->kernel_filename) { - fprintf(stderr, "Kernel image must be specified\n"); - exit(1); - } - machine_opts = qemu_opts_find(qemu_find_opts("machine"), 0); if (machine_opts) { info->dtb_filename = qemu_opt_get(machine_opts, "dtb"); @@ -403,26 +397,29 @@ void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info) info->initrd_start = info->loader_start + MIN(info->ram_size / 2, 128 * 1024 * 1024); - /* Assume that raw images are linux kernels, and ELF images are not. */ - kernel_size = load_elf(info->kernel_filename, NULL, NULL, &elf_entry, - NULL, NULL, big_endian, ELF_MACHINE, 1); - entry = elf_entry; - if (kernel_size < 0) { - kernel_size = load_uimage(info->kernel_filename, &entry, NULL, - &is_linux); - } - if (kernel_size < 0) { - entry = info->loader_start + KERNEL_LOAD_ADDR; - kernel_size = load_image_targphys(info->kernel_filename, entry, - info->ram_size - KERNEL_LOAD_ADDR); - is_linux = 1; - } - if (kernel_size < 0) { - fprintf(stderr, "qemu: could not load kernel '%s'\n", - info->kernel_filename); - exit(1); + if (info->kernel_filename) { + /* Assume that raw images are linux kernels, and ELF images are not. */ + kernel_size = load_elf(info->kernel_filename, NULL, NULL, &elf_entry, + NULL, NULL, big_endian, ELF_MACHINE, 1); + entry = elf_entry; + if (kernel_size < 0) { + kernel_size = load_uimage(info->kernel_filename, &entry, NULL, + &is_linux); + } + if (kernel_size < 0) { + entry = info->loader_start + KERNEL_LOAD_ADDR; + kernel_size = load_image_targphys(info->kernel_filename, entry, + info->ram_size - KERNEL_LOAD_ADDR); + is_linux = 1; + } + if (kernel_size < 0) { + fprintf(stderr, "qemu: could not load kernel '%s'\n", + info->kernel_filename); + exit(1); + } + info->entry = entry; } - info->entry = entry; + if (is_linux) { if (info->initrd_filename) { initrd_size = load_image_targphys(info->initrd_filename,