From patchwork Thu Oct 4 01:47:09 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Troy Kisky X-Patchwork-Id: 188981 X-Patchwork-Delegate: sbabic@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 831142C032C for ; Thu, 4 Oct 2012 11:47:55 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 5E9D428232; Thu, 4 Oct 2012 03:47:52 +0200 (CEST) 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 10W819RUzWAQ; Thu, 4 Oct 2012 03:47:51 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 8473F281FE; Thu, 4 Oct 2012 03:47:42 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id F289A281DA for ; Thu, 4 Oct 2012 03:47:38 +0200 (CEST) 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 VlqNkq0f7YT4 for ; Thu, 4 Oct 2012 03:47:38 +0200 (CEST) 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-pa0-f44.google.com (mail-pa0-f44.google.com [209.85.220.44]) by theia.denx.de (Postfix) with ESMTPS id 7B1FD281DE for ; Thu, 4 Oct 2012 03:47:37 +0200 (CEST) Received: by padfb11 with SMTP id fb11so7087349pad.3 for ; Wed, 03 Oct 2012 18:47:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=tBAKrIxm9I3Txudr4N8UP4m9je8J5kztmubCxtbHKoI=; b=jDlMlMoODdTnDg1+esVQF42Canaju2KxnLwTuBZEf+UDCymVhqVBVyBeU3m5w7RBn0 2RIvDF250m+9/8tJG/lZJN35aDqZg0on8ml0361wGf2xvbZ1efyn5/WqrJGerGvHSgAc 0aqiE1i9a2vElPmxC4Iv7p51Z7sru/SGUMSodJLsbkdHPlUsplqA43uekvT+bgZdR62j bqKMt6SFvoD14J64AWem9qKMpQxLJxA2ODxK1frDlvdKYCme2tmHS9VNHgSCw2qo67oe mmnqQOVvSumd7i6AEcZ1OrCAE8WBgFgz8qfRqy5P5LT3isp7Oue7fma5vrZgSR1FAT8h M/dA== Received: by 10.68.203.164 with SMTP id kr4mr17608970pbc.46.1349315255781; Wed, 03 Oct 2012 18:47:35 -0700 (PDT) Received: from officeserver-2 ([70.96.116.236]) by mx.google.com with ESMTPS id py9sm3470111pbb.20.2012.10.03.18.47.32 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 03 Oct 2012 18:47:35 -0700 (PDT) Received: from tkisky by officeserver-2 with local (Exim 4.76) (envelope-from ) id 1TJaXc-0005WT-DQ; Wed, 03 Oct 2012 18:47:56 -0700 From: Troy Kisky To: sbabic@denx.de Date: Wed, 3 Oct 2012 18:47:09 -0700 Message-Id: <1349315254-21151-8-git-send-email-troy.kisky@boundarydevices.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1349315254-21151-1-git-send-email-troy.kisky@boundarydevices.com> References: <1348281558-19520-1-git-send-email-troy.kisky@boundarydevices.com> <1349315254-21151-1-git-send-email-troy.kisky@boundarydevices.com> X-Gm-Message-State: ALoCoQmJd2AmirOQgXpMMNn6BE4360fElfYf2E29Q8GH5MXvkhEa8+PoXH0c/cVv0nmIjJ4hVu3J Cc: u-boot@lists.denx.de Subject: [U-Boot] [PATCH V3 07/32] imximage: make set_imx_hdr_v1/v2 easier to read 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 Signed-off-by: Troy Kisky --- v3: split into own patch --- tools/imximage.c | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) diff --git a/tools/imximage.c b/tools/imximage.c index 87a6b59..63f88b6 100644 --- a/tools/imximage.c +++ b/tools/imximage.c @@ -201,25 +201,19 @@ static void set_imx_hdr_v1(struct imx_header *imxhdr, uint32_t dcd_len, imx_header_v1_t *hdr_v1 = &imxhdr->header.hdr_v1; flash_header_v1_t *fhdr_v1 = &hdr_v1->fhdr; dcd_v1_t *dcd_v1 = &hdr_v1->dcd_table; - uint32_t base_offset; + uint32_t hdr_base; uint32_t header_length = (((char *)&dcd_v1->addr_data[dcd_len].addr) - ((char *)imxhdr)); /* Set magic number */ fhdr_v1->app_code_barker = APP_CODE_BARKER; - fhdr_v1->app_dest_ptr = entry_point - flash_offset - - sizeof(struct imx_header); + hdr_base = entry_point - sizeof(struct imx_header); + fhdr_v1->app_dest_ptr = hdr_base - flash_offset; fhdr_v1->app_code_jump_vector = entry_point; - base_offset = fhdr_v1->app_dest_ptr + flash_offset; - fhdr_v1->dcd_ptr_ptr = - (uint32_t) (offsetof(flash_header_v1_t, dcd_ptr) - - offsetof(flash_header_v1_t, app_code_jump_vector) + - base_offset); - - fhdr_v1->dcd_ptr = base_offset + - offsetof(imx_header_v1_t, dcd_table); + fhdr_v1->dcd_ptr_ptr = hdr_base + offsetof(flash_header_v1_t, dcd_ptr); + fhdr_v1->dcd_ptr = hdr_base + offsetof(imx_header_v1_t, dcd_table); /* Security feature are not supported */ fhdr_v1->app_code_csf = 0; @@ -232,6 +226,7 @@ static void set_imx_hdr_v2(struct imx_header *imxhdr, uint32_t dcd_len, { imx_header_v2_t *hdr_v2 = &imxhdr->header.hdr_v2; flash_header_v2_t *fhdr_v2 = &hdr_v2->fhdr; + uint32_t hdr_base; /* Set magic number */ fhdr_v2->header.tag = IVT_HEADER_TAG; /* 0xD1 */ @@ -240,15 +235,12 @@ static void set_imx_hdr_v2(struct imx_header *imxhdr, uint32_t dcd_len, fhdr_v2->entry = entry_point; fhdr_v2->reserved1 = fhdr_v2->reserved2 = 0; - fhdr_v2->self = entry_point - sizeof(struct imx_header); - - fhdr_v2->dcd_ptr = fhdr_v2->self + - offsetof(imx_header_v2_t, dcd_table); - - fhdr_v2->boot_data_ptr = fhdr_v2->self + - offsetof(imx_header_v2_t, boot_data); + fhdr_v2->self = hdr_base = entry_point - sizeof(struct imx_header); - hdr_v2->boot_data.start = fhdr_v2->self - flash_offset; + fhdr_v2->dcd_ptr = hdr_base + offsetof(imx_header_v2_t, dcd_table); + fhdr_v2->boot_data_ptr = hdr_base + + offsetof(imx_header_v2_t, boot_data); + hdr_v2->boot_data.start = hdr_base - flash_offset; /* Security feature are not supported */ fhdr_v2->csf = 0;