From patchwork Wed Mar 14 03:31:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Gorinov X-Patchwork-Id: 885605 X-Patchwork-Delegate: agraf@suse.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=intel.com Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 401HZC2tWpz9sSt for ; Wed, 14 Mar 2018 14:41:05 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 5E30AC21DC1; Wed, 14 Mar 2018 03:41:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 356FBC21C2F; Wed, 14 Mar 2018 03:41:00 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id F047AC21C2F; Wed, 14 Mar 2018 03:38:55 +0000 (UTC) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lists.denx.de (Postfix) with ESMTPS id 2F6C0C21BE5 for ; Wed, 14 Mar 2018 03:38:55 +0000 (UTC) X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Mar 2018 20:38:53 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.47,468,1515484800"; d="scan'208";a="41811491" Received: from dph9ls1.fm.intel.com (HELO intel.com) ([10.80.209.182]) by orsmga002.jf.intel.com with ESMTP; 13 Mar 2018 20:38:52 -0700 Date: Tue, 13 Mar 2018 20:31:12 -0700 From: Ivan Gorinov To: u-boot@lists.denx.de Message-ID: <20180314033112.GA23386@intel.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) X-Mailman-Approved-At: Wed, 14 Mar 2018 03:40:58 +0000 Cc: Alexander Graf Subject: [U-Boot] [PATCH] efi_loader: Allow width smaller than buffer stride in efi_gop Blt() X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Current implementation of Blt() in EFI_GRAPHICS_OUTPUT_PROTOCOL assumes the memory buffer stride (number of bytes in a row) always matches the rectangle Width, ignoring non-zero Delta. Signed-off-by: Ivan Gorinov --- lib/efi_loader/efi_gop.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/efi_loader/efi_gop.c b/lib/efi_loader/efi_gop.c index 3caddd5..362065b 100644 --- a/lib/efi_loader/efi_gop.c +++ b/lib/efi_loader/efi_gop.c @@ -64,6 +64,7 @@ efi_status_t EFIAPI gop_blt(struct efi_gop *this, void *buffer, { struct efi_gop_obj *gopobj = container_of(this, struct efi_gop_obj, ops); int i, j, line_len16, line_len32; + int buffer_stride; void *fb; EFI_ENTRY("%p, %p, %u, %zu, %zu, %zu, %zu, %zu, %zu, %zu", this, @@ -72,6 +73,11 @@ efi_status_t EFIAPI gop_blt(struct efi_gop *this, void *buffer, if (operation != EFI_BLT_BUFFER_TO_VIDEO) return EFI_EXIT(EFI_INVALID_PARAMETER); + if (delta == 0) + buffer_stride = width * sizeof(u32); + else + buffer_stride = delta; + fb = gopobj->fb; line_len16 = gopobj->info.width * sizeof(u16); line_len32 = gopobj->info.width * sizeof(u32); @@ -87,7 +93,7 @@ efi_status_t EFIAPI gop_blt(struct efi_gop *this, void *buffer, for (i = 0; i < height; i++) { u32 *dest = fb + ((i + dy) * line_len32) + (dx * sizeof(u32)); - u32 *src = buffer + ((i + sy) * line_len32) + + u32 *src = buffer + ((i + sy) * buffer_stride) + (sx * sizeof(u32)); /* Same color format, just memcpy */ @@ -102,7 +108,7 @@ efi_status_t EFIAPI gop_blt(struct efi_gop *this, void *buffer, for (i = 0; i < height; i++) { u16 *dest = fb + ((i + dy) * line_len16) + (dx * sizeof(u16)); - u32 *src = buffer + ((i + sy) * line_len32) + + u32 *src = buffer + ((i + sy) * buffer_stride) + (sx * sizeof(u32)); /* Convert from rgb888 to rgb565 */