From patchwork Tue Feb 20 18:03:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 128947 Delivered-To: patches@linaro.org Received: by 10.46.124.24 with SMTP id x24csp4910155ljc; Tue, 20 Feb 2018 10:03:28 -0800 (PST) X-Google-Smtp-Source: AH8x2262OZ46WGWbEcqluPXG0CTGP/9kocSXYXJxzkWFT2xi79wezw6vQqD3sk6oPwHjP+kRhyO8 X-Received: by 10.46.29.23 with SMTP id d23mr316086ljd.7.1519149808038; Tue, 20 Feb 2018 10:03:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519149808; cv=none; d=google.com; s=arc-20160816; b=ZfdErdj0BayVo9VXT1llUyw+DhnFEZHRyyFaSMbGUbsSZYGfp5jcF9nBCLaM/9k24w sh0MIbJQpv+xEbyM6sN/uxokKVFvpXknUdJHnbXf7oIpxiWlNYzVHTsfjFSJ8fo2DWX3 3tO8ufodBdU2a5u1VdSFN/IjneiuaGEcCce6rZljW/wuwAws3dhnddZaqexnZNp+/Lgn VeSP9qO+RNxMDN/DbvZR8FujrBrAM+uOqVa+AsMN1wepLuQkVSMrMUss868iwDjOpdol mfwIEM6KbC4PUuWmOniHA11CrPXQshXU0tAARz/qUaR/wo/JYMLGF5svsqjmrjDJ5Bjc +xiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=7f0sNNTmrWJTgLGdjJGjEqgA0HBDv0++gqLlWY9ztKE=; b=fPheqiZLJibS7B9n/Piz0CAFbHx/oDqviJSyNNLJQVSlqooWATojvYgiXy2yZI3d97 3PWzNGIxgBm4S7sAaDOPtaipXgic4uPgDExHL2mw8tVi6W+O6Twh2dHbVV5lg///MKqC vwdeViIlLjLVR7UuJyRWdyrr3tFZn3DrgP/LmRMseaJ9bzYcaxr/q2uQqXRc6xfMuzUS 3ExqcKdwjFsaFGIvKVC8LEHxBRo4I2prH1L/+PsHzc0Z/KyIrx/GXNUagUNdHjKl5gNc 0Dv0clAATLtqQ0JMsui71ZkWdl35w0emFxYaf7H3vQ/B0c6AvyxpS8rfniHlwQQ/uPYA XqAQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) smtp.mailfrom=pm215@archaic.org.uk; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by mx.google.com with ESMTPS id o2si816451ljd.366.2018.02.20.10.03.27 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 20 Feb 2018 10:03:27 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) client-ip=2001:8b0:1d0::2; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) smtp.mailfrom=pm215@archaic.org.uk; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1eoCGF-0008QD-25; Tue, 20 Feb 2018 18:03:27 +0000 From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Cc: patches@linaro.org Subject: [PATCH 01/19] loader: Add new load_ramdisk_as() Date: Tue, 20 Feb 2018 18:03:07 +0000 Message-Id: <20180220180325.29818-2-peter.maydell@linaro.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180220180325.29818-1-peter.maydell@linaro.org> References: <20180220180325.29818-1-peter.maydell@linaro.org> MIME-Version: 1.0 Add a function load_ramdisk_as() which behaves like the existing load_ramdisk() but allows the caller to specify the AddressSpace to use. This matches the pattern we have already for various other loader functions. Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé --- include/hw/loader.h | 12 +++++++++++- hw/core/loader.c | 8 +++++++- 2 files changed, 18 insertions(+), 2 deletions(-) -- 2.16.1 Reviewed-by: Richard Henderson diff --git a/include/hw/loader.h b/include/hw/loader.h index 5edbe02b1c..2504cc2259 100644 --- a/include/hw/loader.h +++ b/include/hw/loader.h @@ -162,16 +162,26 @@ int load_uimage(const char *filename, hwaddr *ep, void *translate_opaque); /** - * load_ramdisk: + * load_ramdisk_as: * @filename: Path to the ramdisk image * @addr: Memory address to load the ramdisk to * @max_sz: Maximum allowed ramdisk size (for non-u-boot ramdisks) + * @as: The AddressSpace to load the ELF to. The value of address_space_memory + * is used if nothing is supplied here. * * Load a ramdisk image with U-Boot header to the specified memory * address. * * Returns the size of the loaded image on success, -1 otherwise. */ +int load_ramdisk_as(const char *filename, hwaddr addr, uint64_t max_sz, + AddressSpace *as); + +/** + * load_ramdisk: + * Same as load_ramdisk_as(), but doesn't allow the caller to specify + * an AddressSpace. + */ int load_ramdisk(const char *filename, hwaddr addr, uint64_t max_sz); ssize_t gunzip(void *dst, size_t dstlen, uint8_t *src, size_t srclen); diff --git a/hw/core/loader.c b/hw/core/loader.c index 91669d65aa..2b9e7394a1 100644 --- a/hw/core/loader.c +++ b/hw/core/loader.c @@ -729,9 +729,15 @@ int load_uimage_as(const char *filename, hwaddr *ep, hwaddr *loadaddr, /* Load a ramdisk. */ int load_ramdisk(const char *filename, hwaddr addr, uint64_t max_sz) +{ + return load_ramdisk_as(filename, addr, max_sz, NULL); +} + +int load_ramdisk_as(const char *filename, hwaddr addr, uint64_t max_sz, + AddressSpace *as) { return load_uboot_image(filename, NULL, &addr, NULL, IH_TYPE_RAMDISK, - NULL, NULL, NULL); + NULL, NULL, as); } /* Load a gzip-compressed kernel to a dynamically allocated buffer. */