From: Ruiyu Ni <ruiyu.ni@intel.com>
To: edk2-devel@lists.01.org
Cc: HuajingLi <huajing.li@intel.com>
Subject: [PATCH] ShellPkg/dblk: Honor the BlockIo alignment requirement.
Date: Tue, 1 Aug 2017 13:17:04 +0800 [thread overview]
Message-ID: <20170801051704.163104-1-ruiyu.ni@intel.com> (raw)
From: HuajingLi <huajing.li@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Huajing Li <huajing.li@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
---
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.
(C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>
- Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2005 - 2017, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -37,6 +37,7 @@ DisplayTheBlocks(
EFI_STATUS Status;
SHELL_STATUS ShellStatus;
UINT8 *Buffer;
+ UINT8 *OriginalBuffer;
UINTN BufferSize;
ShellStatus = SHELL_SUCCESS;
@@ -52,11 +53,17 @@ DisplayTheBlocks(
}
BufferSize = BlockIo->Media->BlockSize * BlockCount;
+ if(BlockIo->Media->IoAlign == 0) {
+ BlockIo->Media->IoAlign = 1;
+ }
+
if (BufferSize > 0) {
- Buffer = AllocateZeroPool(BufferSize);
+ OriginalBuffer = AllocateZeroPool(BufferSize + BlockIo->Media->IoAlign);
+ Buffer = ALIGN_POINTER (OriginalBuffer,BlockIo->Media->IoAlign);
} else {
ShellPrintEx(-1,-1,L" BlockSize: 0x%08x, BlockCount: 0x%08x\r\n", BlockIo->Media->BlockSize, BlockCount);
- Buffer = NULL;
+ OriginalBuffer = NULL;
+ Buffer = NULL;
}
Status = BlockIo->ReadBlocks(BlockIo, BlockIo->Media->MediaId, Lba, BufferSize, Buffer);
@@ -78,8 +85,8 @@ DisplayTheBlocks(
ShellStatus = SHELL_DEVICE_ERROR;
}
- if (Buffer != NULL) {
- FreePool(Buffer);
+ if (OriginalBuffer != NULL) {
+ FreePool (OriginalBuffer);
}
gBS->CloseProtocol(BlockIoHandle, &gEfiBlockIoProtocolGuid, gImageHandle, NULL);
--
2.12.2.windows.2
reply other threads:[~2017-08-01 5:14 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170801051704.163104-1-ruiyu.ni@intel.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox