From patchwork Thu Nov 10 20:17:53 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Warren X-Patchwork-Id: 124996 X-Patchwork-Delegate: sr@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 695B11007D1 for ; Fri, 11 Nov 2011 07:18:15 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 6613328ACD; Thu, 10 Nov 2011 21:18:13 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id kWRmkJPcqSgh; Thu, 10 Nov 2011 21:18:13 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id E085928AFA; Thu, 10 Nov 2011 21:18:10 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 97F8828AFC for ; Thu, 10 Nov 2011 21:18:08 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 8l5Z1vcv7x6p for ; Thu, 10 Nov 2011 21:18:07 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from avon.wwwdotorg.org (avon.wwwdotorg.org [70.85.31.133]) by theia.denx.de (Postfix) with ESMTPS id 4C92528ACD for ; Thu, 10 Nov 2011 21:18:05 +0100 (CET) Received: from severn.wwwdotorg.org (unknown [192.168.65.5]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by avon.wwwdotorg.org (Postfix) with ESMTPS id 4D5156316; Thu, 10 Nov 2011 13:20:08 -0700 (MST) Received: from localhost.localdomain (searspoint.nvidia.com [216.228.112.21]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by severn.wwwdotorg.org (Postfix) with ESMTPSA id CF2A4E40F5; Thu, 10 Nov 2011 13:18:00 -0700 (MST) From: Stephen Warren To: Wolfgang Denk Date: Thu, 10 Nov 2011 13:17:53 -0700 Message-Id: <1320956274-16597-1-git-send-email-swarren@nvidia.com> X-Mailer: git-send-email 1.7.0.4 X-NVConfidentiality: public X-Virus-Scanned: clamav-milter 0.96.5 at avon.wwwdotorg.org X-Virus-Status: Clean Cc: U-Boot Mailing List , =?UTF-8?q?Lo=C3=AFc=20Minier?= Subject: [U-Boot] [PATCH 1/2] image: Implement IH_TYPE_KERNEL_NOLOAD X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de The legacy uImage format includes an absolute load and entry-point address. When bootm operates on a kernel uImage in memory that isn't loaded at the address in the image's load address, U-Boot will copy the image to its address in the header. Some kernel images can actually be loaded and used at any arbitrary address. An example is an ARM Linux kernel zImage file. To represent this capability, IH_TYPE_KERNEL_NOLOAD is implemented, which operates just like IH_TYPE_KERNEL, except that the load address header is ignored, and U-Boot does not copy the image to its load address, but rather uses it in-place. This is useful when sharing a single (uImage-wrapped) zImage across multiple boards with different memory layouts; in this case, a specific load address need not be picked when creating the uImage, but instead is selected by the board-specific U-Boot environment used to load and boot that image. v2: Rename from IH_TYPE_KERNEL_ANYLOAD to IH_TYPE_KERNEL_NOLOAD. Signed-off-by: Stephen Warren --- This is a third attempt to support ARM Linux zImage's ability to run from anywhere in RAM. This patch actually ended up being much smaller (patch file size) than previous attempts. Both my previous attempts could probably be rewritten to adjust the image load address in the same way as this patch and hence also be just as small; I don't recommend using any of my previous patches wthout rework because of this. before this patch: text data bss dec hex filename 166642 3568 217020 387230 5e89e ./u-boot with this patch: text data bss dec hex filename 166761 3568 217020 387349 5e915 ./u-boot Is this small enough to do without a config option? I certainly hope so, because ifdefing every one of these tiny code changes would look ugly. Tested on NVIDIA Tegra Seaboard: * Legacy uImage containing a kernel (and appended DT), of type IH_TYPE_KERNEL. * Legacy uImage containing a kernel (and appended DT), of type IH_TYPE_KERNEL_NOLOAD. * Legacy uImage containing a kernel, of type IH_TYPE_KERNEL_NOLOAD, plus a separate plain FDT (no uImage wrapping). * Legacy uImage containing a kernel, of type IH_TYPE_KERNEL_NOLOAD, plus a uImage-wrapped initrd, plus a separate plain FDT (no uImage wrapping). * FIT image containing both kernel of type IH_TYPE_KERNEL_NOLOAD and FDT. * FIT image containing just a kernel of type IH_TYPE_KERNEL_NOLOAD, plus a separate plain FDT (no FIT/legacy uImage wrapping). common/cmd_bootm.c | 10 +++++++++- common/image.c | 1 + include/image.h | 1 + tools/default_image.c | 3 ++- 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c index d301332..1d62c99 100644 --- a/common/cmd_bootm.c +++ b/common/cmd_bootm.c @@ -271,7 +271,13 @@ static int bootm_start(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[] return 1; } + if (images.os.type == IH_TYPE_KERNEL_NOLOAD) { + images.os.load = images.os.image_start; + images.ep += images.os.load; + } + if (((images.os.type == IH_TYPE_KERNEL) || + (images.os.type == IH_TYPE_KERNEL_NOLOAD) || (images.os.type == IH_TYPE_MULTI)) && (images.os.os == IH_OS_LINUX)) { /* find ramdisk */ @@ -795,7 +801,8 @@ static int fit_check_kernel(const void *fit, int os_noffset, int verify) } show_boot_progress(106); - if (!fit_image_check_type(fit, os_noffset, IH_TYPE_KERNEL)) { + if (!fit_image_check_type(fit, os_noffset, IH_TYPE_KERNEL) && + !fit_image_check_type(fit, os_noffset, IH_TYPE_KERNEL_NOLOAD)) { puts("Not a kernel image\n"); show_boot_progress(-106); return 0; @@ -873,6 +880,7 @@ static void *boot_get_kernel(cmd_tbl_t *cmdtp, int flag, int argc, /* get os_data and os_len */ switch (image_get_type(hdr)) { case IH_TYPE_KERNEL: + case IH_TYPE_KERNEL_NOLOAD: *os_data = image_get_data(hdr); *os_len = image_get_data_size(hdr); break; diff --git a/common/image.c b/common/image.c index 555d9d9..aacae5a 100644 --- a/common/image.c +++ b/common/image.c @@ -136,6 +136,7 @@ static const table_entry_t uimage_type[] = { { IH_TYPE_FIRMWARE, "firmware", "Firmware", }, { IH_TYPE_FLATDT, "flat_dt", "Flat Device Tree", }, { IH_TYPE_KERNEL, "kernel", "Kernel Image", }, + { IH_TYPE_KERNEL_NOLOAD, "kernel_noload", "Kernel Image (no loading done)", }, { IH_TYPE_KWBIMAGE, "kwbimage", "Kirkwood Boot Image",}, { IH_TYPE_IMXIMAGE, "imximage", "Freescale i.MX Boot Image",}, { IH_TYPE_INVALID, NULL, "Invalid Image", }, diff --git a/include/image.h b/include/image.h index c56a18d..f01eb92 100644 --- a/include/image.h +++ b/include/image.h @@ -162,6 +162,7 @@ #define IH_TYPE_UBLIMAGE 11 /* Davinci UBL Image */ #define IH_TYPE_OMAPIMAGE 12 /* TI OMAP Config Header Image */ #define IH_TYPE_AISIMAGE 13 /* TI Davinci AIS Image */ +#define IH_TYPE_KERNEL_NOLOAD 14 /* OS Kernel Image, can run from any load address */ /* * Compression Types diff --git a/tools/default_image.c b/tools/default_image.c index 6ea3b46..e9d0729 100644 --- a/tools/default_image.c +++ b/tools/default_image.c @@ -35,7 +35,8 @@ static image_header_t header; static int image_check_image_types(uint8_t type) { - if ((type > IH_TYPE_INVALID) && (type < IH_TYPE_FLATDT)) + if (((type > IH_TYPE_INVALID) && (type < IH_TYPE_FLATDT)) || + (type == IH_TYPE_KERNEL_NOLOAD)) return EXIT_SUCCESS; else return EXIT_FAILURE;