From patchwork Fri Feb 28 21:06:12 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Nelson X-Patchwork-Id: 325348 X-Patchwork-Delegate: trini@ti.com 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 1266F2C0096 for ; Sat, 1 Mar 2014 08:06:39 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 995E84B59D; Fri, 28 Feb 2014 22:06:36 +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 Rqwd+B3SKetV; Fri, 28 Feb 2014 22:06:36 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id E28444B4E9; Fri, 28 Feb 2014 22:06:30 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 868614B4E9 for ; Fri, 28 Feb 2014 22:06:29 +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 Hg5skpICo4gV for ; Fri, 28 Feb 2014 22:06:26 +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-pa0-f44.google.com (mail-pa0-f44.google.com [209.85.220.44]) by theia.denx.de (Postfix) with ESMTPS id 0DFEB4B372 for ; Fri, 28 Feb 2014 22:06:21 +0100 (CET) Received: by mail-pa0-f44.google.com with SMTP id bj1so1257971pad.17 for ; Fri, 28 Feb 2014 13:06:19 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=PWWviIUH41qWTiaj9qoCdnJZxkORSJPQgUIjFirpc20=; b=EcFs1t7/qO5LfKkaYYfOOc5HHovQnHT8Yr9e58eP6bs/ofFgkq2oiEf6aeqTiIbX8X CCjT4LyqQYMSnUKc/27KCa6yGwE9YQnwh73AUd1OhS1QMX6flKygzAGtxa3WLNwLzyPz oybZvz9gkjIOTMMk99joSNwrJCFySMm1XkhjqGhbo9Y2Ra4x5aJb+9hM33Ysv1RzRAcf +f16EqQ4okF1YZj9DQ3muLQQQ9HUBFoxMu1N9NH8rmXF81FWi4BIfW6Gr+NI3No4n+bn 3NfcOspWHr5C0GJskSflQrZd8k78GOnvwfJ8OWsIFS20GB2xfRAZkU+55mqwWnolUox6 0tmA== X-Gm-Message-State: ALoCoQlit658tkofKO+2Hqo6RjuTyXrLq1r7h+nTGk4UhFcf6BQywZPaTIQvRhsbYjfbCMxd1gj2 X-Received: by 10.66.216.129 with SMTP id oq1mr5714986pac.75.1393621579482; Fri, 28 Feb 2014 13:06:19 -0800 (PST) Received: from ericsam.boundarydevices.com ([63.226.49.26]) by mx.google.com with ESMTPSA id ja8sm9336273pbd.3.2014.02.28.13.06.17 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 28 Feb 2014 13:06:18 -0800 (PST) From: Eric Nelson To: u-boot@lists.denx.de Date: Fri, 28 Feb 2014 14:06:12 -0700 Message-Id: <1393621572-10306-1-git-send-email-eric.nelson@boundarydevices.com> X-Mailer: git-send-email 1.8.3.2 Subject: [U-Boot] [PATCH V2] cfb_console: force natural alignment of 32-bit fields in gzipped .bmp files 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 .bmp files contain 32-bit integers aligned at offsets of +2, +6, et cetera within the bmp_header structure (see include/bmp_layout.h). Support for gzip-compressed .bmp files is present in the cfb_console display subsystem by uncompressing them prior to use. This patch forces the in-memory header to be aligned properly for these compressed images by extracting them to a 2-byte offset in the memory returned by malloc. Since malloc will always return a 4-byte aligned value, this forces the .bmp header fields to be naturally aligned on 4-byte addresses. Refer to these files for more details: doc/README.displaying-bmps doc/README.arm-unaligned-accesses Signed-off-by: Eric Nelson --- drivers/video/cfb_console.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/video/cfb_console.c b/drivers/video/cfb_console.c index 6db4073..2209148 100644 --- a/drivers/video/cfb_console.c +++ b/drivers/video/cfb_console.c @@ -1473,7 +1473,10 @@ int video_display_bitmap(ulong bmp_image, int x, int y) printf("Error: malloc in gunzip failed!\n"); return 1; } - if (gunzip(dst, CONFIG_SYS_VIDEO_LOGO_MAX_SIZE, + /* NB: we need to force offset of +2 + * See doc/README.displaying-bmps + */ + if (gunzip(dst+2, CONFIG_SYS_VIDEO_LOGO_MAX_SIZE-2, (uchar *) bmp_image, &len) != 0) { printf("Error: no valid bmp or bmp.gz image at %lx\n", @@ -1489,7 +1492,7 @@ int video_display_bitmap(ulong bmp_image, int x, int y) /* * Set addr to decompressed image */ - bmp = (bmp_image_t *) dst; + bmp = (bmp_image_t *)(dst+2); if (!((bmp->header.signature[0] == 'B') && (bmp->header.signature[1] == 'M'))) {