From patchwork Thu Jan 10 14:58:21 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 211052 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 6841B2C00D8 for ; Fri, 11 Jan 2013 02:02:40 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id A7A854A15C; Thu, 10 Jan 2013 16:01:37 +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 zaWC6nrrO6mg; Thu, 10 Jan 2013 16:01:37 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id E490F4A1B8; Thu, 10 Jan 2013 15:59:39 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id B734B4A0EF for ; Thu, 10 Jan 2013 15:59:24 +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 XOjcLCIDoYFz for ; Thu, 10 Jan 2013 15:59:23 +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 mail-gg0-f201.google.com (mail-gg0-f201.google.com [209.85.161.201]) by theia.denx.de (Postfix) with ESMTPS id B0C024A115 for ; Thu, 10 Jan 2013 15:58:58 +0100 (CET) Received: by mail-gg0-f201.google.com with SMTP id o6so68884ggm.0 for ; Thu, 10 Jan 2013 06:58:56 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:x-gm-message-state; bh=3d+OkpZwx3eFAGBcI1TULJIpRCJfQEqIsVAI2B16jS4=; b=lDZxEmN6RBP46ysfJv6tWrEatTdIdO7P61zb1TTK5XnMa6Sz9H8fwbApqMezNuUjke /b/P+xc3JsX8kuIP/RYa4JzNtheyQ1wRQbUaNxC3R5IfkQsupbJ6f0B6T7viVXAzLC0L e5uJPBRilUOM/IuLboSyG2XonIPSHeYbYsU8lYJhNxKX1zGbI+KnpaFzHFIFEtUAVdM1 yskwKrWEBl7l3yTKOiG+4gFwXzW9iA/cOHbdU84lzPeZN8FBz4binKG9FT3gvyY8ncBD CvixFvKdglBpeFRASoowSE4QYhcAjOJR1iPM7ucIv229HLjDUsrjozowIzHYw7vnJtvP 5Nag== X-Received: by 10.236.159.198 with SMTP id s46mr38866074yhk.40.1357829936690; Thu, 10 Jan 2013 06:58:56 -0800 (PST) Received: from wpzn4.hot.corp.google.com (216-239-44-65.google.com [216.239.44.65]) by gmr-mx.google.com with ESMTPS id i63si80856yhk.5.2013.01.10.06.58.56 (version=TLSv1 cipher=AES128-SHA bits=128/128); Thu, 10 Jan 2013 06:58:56 -0800 (PST) Received: from kaka.mtv.corp.google.com (kaka.mtv.corp.google.com [172.22.73.79]) by wpzn4.hot.corp.google.com (Postfix) with ESMTP id 84ED082004A; Thu, 10 Jan 2013 06:58:56 -0800 (PST) Received: by kaka.mtv.corp.google.com (Postfix, from userid 121222) id 3F0AF1610B7; Thu, 10 Jan 2013 06:58:56 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Date: Thu, 10 Jan 2013 06:58:21 -0800 Message-Id: <1357829905-6579-19-git-send-email-sjg@chromium.org> X-Mailer: git-send-email 1.7.7.3 In-Reply-To: <1357829905-6579-1-git-send-email-sjg@chromium.org> References: <1357829905-6579-1-git-send-email-sjg@chromium.org> X-Gm-Message-State: ALoCoQk0dcl85KIr9UF/ni5JXWb1YtGUQumQZhyluueEv0+JQHpqABj04EQzCWTYtRvGEiN5UShjV3CKC5Y4UywUTtuQWzIM6wiq6bzc9mH2OCmQL5t+Tv7vuVNh3svK5RJAd/79Jy6jDx/i5cqGpjHkqNBU9NO2xAyKWnfLmp82aduM5m+gBgSO6pWzN5FhbV1S1Pj/M2Y/ Cc: Joe Hershberger , Tom Rini , Vadim Bendebury Subject: [U-Boot] [RFC PATCH 18/22] image: Use fit_image_load() to load kernel X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 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 Use the new common code to load a kernel. The functionality should not change. Signed-off-by: Simon Glass --- common/cmd_bootm.c | 153 +++------------------------------------------------- common/image-fit.c | 19 ------- include/image.h | 1 - 3 files changed, 8 insertions(+), 165 deletions(-) diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c index 2dbf4df..58eec83 100644 --- a/common/cmd_bootm.c +++ b/common/cmd_bootm.c @@ -88,11 +88,6 @@ static int do_imls(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]); static void fixup_silent_linux(void); #endif -static image_header_t *image_get_kernel(ulong img_addr, int verify); -#if defined(CONFIG_FIT) -static int fit_check_kernel(const void *fit, int os_noffset, int verify); -#endif - static const void *boot_get_kernel(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[], bootm_headers_t *images, ulong *os_data, ulong *os_len); @@ -778,54 +773,6 @@ static image_header_t *image_get_kernel(ulong img_addr, int verify) } /** - * fit_check_kernel - verify FIT format kernel subimage - * @fit_hdr: pointer to the FIT image header - * os_noffset: kernel subimage node offset within FIT image - * @verify: data CRC verification flag - * - * fit_check_kernel() verifies integrity of the kernel subimage and from - * specified FIT image. - * - * returns: - * 1, on success - * 0, on failure - */ -#if defined(CONFIG_FIT) -static int fit_check_kernel(const void *fit, int os_noffset, int verify) -{ - fit_image_print(fit, os_noffset, " "); - - if (verify) { - puts(" Verifying Hash Integrity ... "); - if (!fit_image_verify(fit, os_noffset)) { - puts("Bad Data Hash\n"); - bootstage_error(BOOTSTAGE_ID_FIT_CHECK_HASH); - return 0; - } - puts("OK\n"); - } - bootstage_mark(BOOTSTAGE_ID_FIT_CHECK_ARCH); - - if (!fit_image_check_target_arch(fit, os_noffset)) { - puts("Unsupported Architecture\n"); - bootstage_error(BOOTSTAGE_ID_FIT_CHECK_ARCH); - return 0; - } - - bootstage_mark(BOOTSTAGE_ID_FIT_CHECK_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"); - bootstage_error(BOOTSTAGE_ID_FIT_CHECK_KERNEL); - return 0; - } - - bootstage_mark(BOOTSTAGE_ID_FIT_CHECKED); - return 1; -} -#endif /* CONFIG_FIT */ - -/** * boot_get_kernel - find kernel image * @os_data: pointer to a ulong variable, will hold os data start address * @os_len: pointer to a ulong variable, will hold os data length @@ -845,12 +792,8 @@ static const void *boot_get_kernel(cmd_tbl_t *cmdtp, int flag, int argc, ulong img_addr; const void *buf; #if defined(CONFIG_FIT) - const void *fit_hdr; const char *fit_uname_config = NULL; const char *fit_uname_kernel = NULL; - const void *data; - size_t len; - int cfg_noffset; int os_noffset; #endif @@ -927,96 +870,16 @@ static const void *boot_get_kernel(cmd_tbl_t *cmdtp, int flag, int argc, break; #if defined(CONFIG_FIT) case IMAGE_FORMAT_FIT: - fit_hdr = buf; - printf("## Booting kernel from FIT Image at %08lx ...\n", - img_addr); - - if (!fit_check_format(fit_hdr)) { - puts("Bad FIT kernel image format!\n"); - bootstage_error(BOOTSTAGE_ID_FIT_FORMAT); + os_noffset = fit_image_load(images, FIT_KERNEL_PROP, + img_addr, + &fit_uname_kernel, fit_uname_config, + IH_ARCH_DEFAULT, IH_TYPE_KERNEL, + BOOTSTAGE_ID_FIT_KERNEL_START, + FIT_LOAD_IGNORED, os_data, os_len); + if (os_noffset < 0) return NULL; - } - bootstage_mark(BOOTSTAGE_ID_FIT_FORMAT); - - if (!fit_uname_kernel) { - /* - * no kernel image node unit name, try to get config - * node first. If config unit node name is NULL - * fit_conf_get_node() will try to find default config - * node - */ - bootstage_mark(BOOTSTAGE_ID_FIT_NO_UNIT_NAME); -#ifdef CONFIG_FIT_BEST_MATCH - if (fit_uname_config) - cfg_noffset = - fit_conf_get_node(fit_hdr, - fit_uname_config); - else - cfg_noffset = - fit_conf_find_compat(fit_hdr, - gd->fdt_blob); -#else - cfg_noffset = fit_conf_get_node(fit_hdr, - fit_uname_config); -#endif - if (cfg_noffset < 0) { - bootstage_error(BOOTSTAGE_ID_FIT_NO_UNIT_NAME); - return NULL; - } - /* save configuration uname provided in the first - * bootm argument - */ - images->fit_uname_cfg = fdt_get_name(fit_hdr, - cfg_noffset, - NULL); - printf(" Using '%s' configuration\n", - images->fit_uname_cfg); - if (IMAGE_ENABLE_VERIFY && images->verify) { - puts(" Verifying Hash Integrity ... "); - if (!fit_config_verify(fit_hdr, - cfg_noffset)) { - puts("Bad Data Hash\n"); - bootstage_error( - BOOTSTAGE_ID_FIT_CHECK_HASH); - return NULL; - } - puts("OK\n"); - } - - bootstage_mark(BOOTSTAGE_ID_FIT_CONFIG); - - os_noffset = fit_conf_get_kernel_node(fit_hdr, - cfg_noffset); - fit_uname_kernel = fit_get_name(fit_hdr, os_noffset, - NULL); - } else { - /* get kernel component image node offset */ - bootstage_mark(BOOTSTAGE_ID_FIT_UNIT_NAME); - os_noffset = fit_image_get_node(fit_hdr, - fit_uname_kernel); - } - if (os_noffset < 0) { - bootstage_error(BOOTSTAGE_ID_FIT_CONFIG); - return NULL; - } - - printf(" Trying '%s' kernel subimage\n", fit_uname_kernel); - - bootstage_mark(BOOTSTAGE_ID_FIT_CHECK_SUBIMAGE); - if (!fit_check_kernel(fit_hdr, os_noffset, images->verify)) - return NULL; - - /* get kernel image data address and length */ - if (fit_image_get_data(fit_hdr, os_noffset, &data, &len)) { - puts("Could not find kernel subimage data!\n"); - bootstage_error(BOOTSTAGE_ID_FIT_KERNEL_INFO_ERR); - return NULL; - } - bootstage_mark(BOOTSTAGE_ID_FIT_KERNEL_INFO); - *os_len = len; - *os_data = (ulong)data; - images->fit_hdr_os = (void *)fit_hdr; + images->fit_hdr_os = map_sysmem(img_addr, 0); images->fit_uname_os = fit_uname_kernel; images->fit_noffset_os = os_noffset; break; diff --git a/common/image-fit.c b/common/image-fit.c index 5d07861..ef21112 100644 --- a/common/image-fit.c +++ b/common/image-fit.c @@ -1393,25 +1393,6 @@ int fit_conf_get_prop_node(const void *fit, int noffset, } /** - * fit_conf_get_kernel_node - get kernel image node offset that corresponds to - * a given configuration - * @fit: pointer to the FIT format image header - * @noffset: configuration node offset - * - * fit_conf_get_kernel_node() retrives kernel image node unit name from - * configuration FIT_KERNEL_PROP property and translates it to the node - * offset. - * - * returns: - * image node offset when found (>=0) - * negative number on failure (FDT_ERR_* code) - */ -int fit_conf_get_kernel_node(const void *fit, int noffset) -{ - return fit_conf_get_prop_node(fit, noffset, FIT_KERNEL_PROP); -} - -/** * fit_conf_print - prints out the FIT configuration details * @fit: pointer to the FIT format image header * @noffset: offset of the configuration node diff --git a/include/image.h b/include/image.h index e19a92d..e5f2f06 100644 --- a/include/image.h +++ b/include/image.h @@ -761,7 +761,6 @@ int fit_check_format(const void *fit); int fit_conf_find_compat(const void *fit, const void *fdt); int fit_conf_get_node(const void *fit, const char *conf_uname); -int fit_conf_get_kernel_node(const void *fit, int noffset); /** * fit_conf_get_prop_node() - Get node refered to by a configuration