From nobody Sun May 5 15:15:58 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1501564631499771.3100604419507; Mon, 31 Jul 2017 22:17:11 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 25FC421CF951F; Mon, 31 Jul 2017 22:15:00 -0700 (PDT) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 9427E21CF9511 for ; Mon, 31 Jul 2017 22:14:58 -0700 (PDT) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga105.fm.intel.com with ESMTP; 31 Jul 2017 22:17:07 -0700 Received: from ray-dev.ccr.corp.intel.com ([10.239.9.23]) by fmsmga006.fm.intel.com with ESMTP; 31 Jul 2017 22:17:06 -0700 X-Original-To: edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.41,305,1498546800"; d="scan'208";a="134365312" From: Ruiyu Ni To: edk2-devel@lists.01.org Date: Tue, 1 Aug 2017 13:17:04 +0800 Message-Id: <20170801051704.163104-1-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.12.2.windows.2 Subject: [edk2] [PATCH] ShellPkg/dblk: Honor the BlockIo alignment requirement. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: HuajingLi MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: HuajingLi Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Huajing Li Reviewed-by: Ruiyu Ni --- ShellPkg/Library/UefiShellDebug1CommandsLib/Dblk.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/ShellPkg/Library/UefiShellDebug1CommandsLib/Dblk.c b/ShellPkg/= Library/UefiShellDebug1CommandsLib/Dblk.c index 32e5917523..3632ca8a7a 100644 --- a/ShellPkg/Library/UefiShellDebug1CommandsLib/Dblk.c +++ b/ShellPkg/Library/UefiShellDebug1CommandsLib/Dblk.c @@ -2,7 +2,7 @@ Main file for Dblk shell Debug1 function. =20 (C) Copyright 2015 Hewlett-Packard Development Company, L.P.
- Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved.
+ Copyright (c) 2005 - 2017, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BS= D License which accompanies this distribution. The full text of the license may b= e found at @@ -37,6 +37,7 @@ DisplayTheBlocks( EFI_STATUS Status; SHELL_STATUS ShellStatus; UINT8 *Buffer; + UINT8 *OriginalBuffer; UINTN BufferSize; =20 ShellStatus =3D SHELL_SUCCESS; @@ -52,11 +53,17 @@ DisplayTheBlocks( } =20 BufferSize =3D BlockIo->Media->BlockSize * BlockCount; + if(BlockIo->Media->IoAlign =3D=3D 0) { + BlockIo->Media->IoAlign =3D 1; + } + if (BufferSize > 0) { - Buffer =3D AllocateZeroPool(BufferSize); + OriginalBuffer =3D AllocateZeroPool(BufferSize + BlockIo->Media->IoAli= gn); + Buffer =3D ALIGN_POINTER (OriginalBuffer,BlockIo->Media->IoAli= gn); } else { ShellPrintEx(-1,-1,L" BlockSize: 0x%08x, BlockCount: 0x%08x\r\n", Blo= ckIo->Media->BlockSize, BlockCount); - Buffer =3D NULL; + OriginalBuffer =3D NULL; + Buffer =3D NULL; } =20 Status =3D BlockIo->ReadBlocks(BlockIo, BlockIo->Media->MediaId, Lba, Bu= fferSize, Buffer); @@ -78,8 +85,8 @@ DisplayTheBlocks( ShellStatus =3D SHELL_DEVICE_ERROR; } =20 - if (Buffer !=3D NULL) { - FreePool(Buffer); + if (OriginalBuffer !=3D NULL) { + FreePool (OriginalBuffer); } =20 gBS->CloseProtocol(BlockIoHandle, &gEfiBlockIoProtocolGuid, gImageHandle= , NULL); --=20 2.12.2.windows.2 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel