public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Supreeth Venkatesh <supreeth.venkatesh@arm.com>
To: Eric Jin <eric.jin@intel.com>, edk2-devel@lists.01.org
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Subject: Re: [edk2-test][Patch] uefi-sct\SctPkg: Add not-granularity-aligned cases in Erase Block Protocol
Date: Fri, 12 Oct 2018 09:40:52 +0100	[thread overview]
Message-ID: <c6808f0e-500e-fed7-2919-275644d41b8a@arm.com> (raw)
In-Reply-To: <20181012022813.11700-1-eric.jin@intel.com>

Migrating over from 
https://github.com/UEFI/UEFI-SCT/commit/48265b5f6167b520d3c19f7fd72edbdd58be7d2f

Reviewed-by: Supreeth Venkatesh <supreeth.venkatesh@arm.com>

On 10/12/2018 03:28 AM, Eric Jin wrote:
> Add not-granularity-aligned cases
> Correct end of line
>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Eric Jin <eric.jin@intel.com>
> Cc: Supreeth Venkatesh <supreeth.venkatesh@arm.com>
> Cc: Jiaxin Wu <jiaxin.wu@intel.com>
> ---
>   .../EraseBlock/BlackBoxTest/EraseBlockBBTest.inf   |  114 +--
>   .../BlackBoxTest/EraseBlockBBTestConformance.c     |  546 +++++-----
>   .../BlackBoxTest/EraseBlockBBTestFunction.c        | 1074 ++++++++++++--------
>   .../EraseBlock/BlackBoxTest/EraseBlockBBTestMain.c |  872 ++++++++--------
>   .../EraseBlock/BlackBoxTest/EraseBlockBBTestMain.h |  252 ++---
>   .../EFI/Protocol/EraseBlock/BlackBoxTest/Guid.c    |   84 +-
>   .../EFI/Protocol/EraseBlock/BlackBoxTest/Guid.h    |  155 +--
>   7 files changed, 1652 insertions(+), 1445 deletions(-)
>
> diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/EraseBlock/BlackBoxTest/EraseBlockBBTest.inf b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/EraseBlock/BlackBoxTest/EraseBlockBBTest.inf
> index d5f4af4..3fb8e96 100644
> --- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/EraseBlock/BlackBoxTest/EraseBlockBBTest.inf
> +++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/EraseBlock/BlackBoxTest/EraseBlockBBTest.inf
> @@ -1,57 +1,57 @@
> -## @file
> -#
> -#  Copyright 2017 Unified EFI, Inc.<BR>
> -#  Copyright (c) 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
> -#  http://opensource.org/licenses/bsd-license.php
> -#
> -#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> -#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> -#
> -##
> -#/*++
> -#
> -# Module Name:
> -#
> -#   EraseBlockBBTest.inf
> -#
> -# Abstract:
> -#
> -#   Component description file for Erase Block Protocol Black-Box Test.
> -#
> -#--*/
> -
> -[defines]
> -  INF_VERSION          = 0x00010005
> -  BASE_NAME            = EraseBlockBBTest
> -  FILE_GUID            = D73A4E73-7727-40E6-B774-0DE2FA1A1D26
> -  MODULE_TYPE          = UEFI_DRIVER
> -  VERSION_STRING       = 1.0
> -  ENTRY_POINT          = InitializeEraseBlockBBTest
> -
> -[sources.common]
> -  EraseBlockBBTestConformance.c
> -  EraseBlockBBTestFunction.c
> -  EraseBlockBBTestMain.c
> -  Guid.c
> -
> -[Packages]
> -  MdePkg/MdePkg.dec
> -  SctPkg/SctPkg.dec
> -  SctPkg/UEFI/UEFI.dec
> -
> -[LibraryClasses]
> -  UefiDriverEntryPoint
> -  SctLib
> -  EfiTestLib
> -
> -[Protocols]
> -  gBlackBoxEfiEraseBlockProtocolGuid
> -  gBlackBoxEfiBlockIo2ProtocolGuid
> -  gBlackBoxEfiBlockIoProtocolGuid
> -
> -[Guids]
> -
> +## @file
> +#
> +#  Copyright 2017 Unified EFI, Inc.<BR>
> +#  Copyright (c) 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
> +#  http://opensource.org/licenses/bsd-license.php
> +#
> +#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> +#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> +#
> +##
> +#/*++
> +#
> +# Module Name:
> +#
> +#   EraseBlockBBTest.inf
> +#
> +# Abstract:
> +#
> +#   Component description file for Erase Block Protocol Black-Box Test.
> +#
> +#--*/
> +
> +[defines]
> +  INF_VERSION          = 0x00010005
> +  BASE_NAME            = EraseBlockBBTest
> +  FILE_GUID            = D73A4E73-7727-40E6-B774-0DE2FA1A1D26
> +  MODULE_TYPE          = UEFI_DRIVER
> +  VERSION_STRING       = 1.0
> +  ENTRY_POINT          = InitializeEraseBlockBBTest
> +
> +[sources.common]
> +  EraseBlockBBTestConformance.c
> +  EraseBlockBBTestFunction.c
> +  EraseBlockBBTestMain.c
> +  Guid.c
> +
> +[Packages]
> +  MdePkg/MdePkg.dec
> +  SctPkg/SctPkg.dec
> +  SctPkg/UEFI/UEFI.dec
> +
> +[LibraryClasses]
> +  UefiDriverEntryPoint
> +  SctLib
> +  EfiTestLib
> +
> +[Protocols]
> +  gBlackBoxEfiEraseBlockProtocolGuid
> +  gBlackBoxEfiBlockIo2ProtocolGuid
> +  gBlackBoxEfiBlockIoProtocolGuid
> +
> +[Guids]
> +
> diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/EraseBlock/BlackBoxTest/EraseBlockBBTestConformance.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/EraseBlock/BlackBoxTest/EraseBlockBBTestConformance.c
> index c3d9395..df057b2 100644
> --- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/EraseBlock/BlackBoxTest/EraseBlockBBTestConformance.c
> +++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/EraseBlock/BlackBoxTest/EraseBlockBBTestConformance.c
> @@ -1,273 +1,273 @@
> -/** @file
> -
> -  Copyright 2017 Unified EFI, Inc.<BR>
> -  Copyright (c) 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
> -  http://opensource.org/licenses/bsd-license.php
> -
> -  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> -  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> -
> -**/
> -/*++
> -
> -Module Name:
> -
> -    EraseBlockBBTestConformance.c
> -
> -Abstract:
> -
> -    for EFI Driver Erase Block Protocol's Conformance Test
> -
> ---*/
> -
> -#include "EraseBlockBBTestMain.h"
> -
> -EFI_STATUS
> -BBTestEraseBlocksConformanceTest (
> -  IN EFI_BB_TEST_PROTOCOL       *This,
> -  IN VOID                       *ClientInterface,
> -  IN EFI_TEST_LEVEL             TestLevel,
> -  IN EFI_HANDLE                 SupportHandle
> -  )
> -{
> -
> -  EFI_STANDARD_TEST_LIBRARY_PROTOCOL    *StandardLib;
> -  EFI_STATUS                            Status;
> -  EFI_ERASE_BLOCK_PROTOCOL              *EraseBlock;
> -  EFI_BLOCK_IO_PROTOCOL                 *BlockIo;
> -  EFI_BLOCK_IO2_PROTOCOL                *BlockIo2;
> -  EFI_TEST_ASSERTION                    AssertionType;
> -  EFI_BLOCK_IO_MEDIA                    *Media;
> -  UINT32                                MediaId;
> -  BOOLEAN                               RemovableMedia;
> -  BOOLEAN                               MediaPresent;
> -  BOOLEAN                               LogicalPartition;
> -  BOOLEAN                               ReadOnly;
> -  BOOLEAN                               WriteCaching;
> -  UINT32                                BlockSize;
> -  UINT32                                IoAlign;
> -  EFI_LBA                               LastBlock;
> -
> -  UINT32                                BlockNumber;
> -
> -  EFI_ERASE_BLOCK_TOKEN                 Token;
> -
> -  EraseBlock = (EFI_ERASE_BLOCK_PROTOCOL*)ClientInterface;
> -
> -
> -  //
> -  // Get the Standard Library Interface
> -  //
> -  Status = gtBS->HandleProtocol (
> -                   SupportHandle,
> -                   &gEfiStandardTestLibraryGuid,
> -                   (VOID **) &StandardLib
> -                   );
> -
> -  if ( EFI_ERROR(Status) ) {
> -    StandardLib->RecordAssertion (
> -                   StandardLib,
> -                   EFI_TEST_ASSERTION_FAILED,
> -                   gTestGenericFailureGuid,
> -                   L"BS.HandleProtocol - Handle standard test library",
> -                   L"%a:%d:Status - %r\n",
> -                   __FILE__,
> -                   (UINTN)__LINE__,
> -                   Status
> -                   );
> -    return Status;
> -  }
> -
> -  Status = LocateBlockIoFromEraseBlock(EraseBlock, &BlockIo, StandardLib);
> -  if (Status == EFI_SUCCESS) {
> -    Media = BlockIo->Media;
> -    AssertionType = EFI_TEST_ASSERTION_PASSED;
> -  } else {
> -    Status = LocateBlockIo2FromEraseBlock(EraseBlock, &BlockIo2, StandardLib);
> -    if (Status == EFI_SUCCESS) {
> -      Media = BlockIo2->Media;
> -      AssertionType = EFI_TEST_ASSERTION_PASSED;
> -    } else {
> -      AssertionType = EFI_TEST_ASSERTION_FAILED;
> -    }
> -  }
> -
> -  StandardLib->RecordAssertion (
> -                 StandardLib,
> -                 AssertionType,
> -                 gEraseBlockBBTestConformanceAssertionGuid001,
> -                 L"EFI_ERASE_BLOCK_PROTOCOL - It should be installed on the same handle as the EFI_BLOCK_IO_PROTOCOL or EFI_BLOCK_IO2_PROTOCOL.",
> -                 L"%a:%d:Status - %r\n",
> -                 __FILE__,
> -                 (UINTN)__LINE__,
> -                 Status
> -                 );
> -
> -  if (AssertionType == EFI_TEST_ASSERTION_FAILED)
> -    return EFI_SUCCESS;
> -
> -
> -  MediaId           = Media->MediaId;
> -  RemovableMedia    = Media->RemovableMedia;
> -  MediaPresent      = Media->MediaPresent;
> -  LogicalPartition  = Media->LogicalPartition;
> -  ReadOnly          = Media->ReadOnly;
> -  WriteCaching      = Media->WriteCaching;
> -  BlockSize         = Media->BlockSize;
> -  IoAlign           = Media->IoAlign;
> -  LastBlock         = Media->LastBlock;
> -
> -  BlockNumber       = (UINT32) MINIMUM(LastBlock, MAX_NUMBER_OF_READ_BLOCK_BUFFER);
> -
> -  if (MediaPresent == FALSE) {
> -    Status = EraseBlock->EraseBlocks(EraseBlock, MediaId, 0, &Token, BlockNumber);
> -    if (Status == EFI_NO_MEDIA)
> -      AssertionType = EFI_TEST_ASSERTION_PASSED;
> -    else
> -      AssertionType = EFI_TEST_ASSERTION_FAILED;
> -
> -      StandardLib->RecordAssertion (
> -                     StandardLib,
> -                     AssertionType,
> -                     gEraseBlockBBTestConformanceAssertionGuid002,
> -                     L"EFI_ERASE_BLOCK_PROTOCOL - EFI_NO_MEDIA should be returned if there is no media in the device.",
> -                     L"%a:%d:Status - %r\n",
> -                     __FILE__,
> -                     (UINTN)__LINE__,
> -                     Status
> -                     );
> -
> -    Status = EraseBlock->EraseBlocks(EraseBlock, MediaId, LastBlock + 1, &Token, BlockNumber);
> -    if (Status == EFI_NO_MEDIA)
> -      AssertionType = EFI_TEST_ASSERTION_PASSED;
> -    else
> -      AssertionType = EFI_TEST_ASSERTION_FAILED;
> -
> -      StandardLib->RecordAssertion (
> -                     StandardLib,
> -                     AssertionType,
> -                     gEraseBlockBBTestConformanceAssertionGuid003,
> -                     L"EFI_ERASE_BLOCK_PROTOCOL - EFI_NO_MEDIA should be returned even if LBA is invalid.",
> -                     L"%a:%d:Status - %r\n",
> -                     __FILE__,
> -                     (UINTN)__LINE__,
> -                     Status
> -                     );
> -
> -    Status = EraseBlock->EraseBlocks(EraseBlock, MediaId, LastBlock - 10, &Token, BlockNumber + 1);
> -    if (Status == EFI_NO_MEDIA)
> -      AssertionType = EFI_TEST_ASSERTION_PASSED;
> -    else
> -      AssertionType = EFI_TEST_ASSERTION_FAILED;
> -
> -      StandardLib->RecordAssertion (
> -                     StandardLib,
> -                     AssertionType,
> -                     gEraseBlockBBTestConformanceAssertionGuid004,
> -                     L"EFI_ERASE_BLOCK_PROTOCOL - EFI_NO_MEDIA should be returned even if Size is invalid.",
> -                     L"%a:%d:Status - %r\n",
> -                     __FILE__,
> -                     (UINTN)__LINE__,
> -                     Status
> -                     );
> -
> -  } else {
> -    if (ReadOnly == TRUE) {
> -      Status = EraseBlock->EraseBlocks(EraseBlock, MediaId, 0, &Token, BlockNumber);
> -      if (Status == EFI_WRITE_PROTECTED)
> -        AssertionType = EFI_TEST_ASSERTION_PASSED;
> -      else
> -        AssertionType = EFI_TEST_ASSERTION_FAILED;
> -
> -      StandardLib->RecordAssertion (
> -                     StandardLib,
> -                     AssertionType,
> -                     gEraseBlockBBTestConformanceAssertionGuid005,
> -                     L"EFI_ERASE_BLOCK_PROTOCOL - EFI_WRITE_PROTECTED should be returned if the device cannot be erased due to write protection.",
> -                     L"%a:%d:Status - %r\n",
> -                     __FILE__,
> -                     (UINTN)__LINE__,
> -                     Status
> -                     );
> -
> -    } else {
> -      Status = EraseBlock->EraseBlocks(EraseBlock, MediaId + 1, 0, &Token, BlockNumber);
> -      if (Status == EFI_MEDIA_CHANGED)
> -        AssertionType = EFI_TEST_ASSERTION_PASSED;
> -      else
> -        AssertionType = EFI_TEST_ASSERTION_FAILED;
> -
> -      StandardLib->RecordAssertion (
> -                     StandardLib,
> -                     AssertionType,
> -                     gEraseBlockBBTestConformanceAssertionGuid006,
> -                     L"EFI_ERASE_BLOCK_PROTOCOL - EFI_MEDIA_CHANGED should be returned if the MediaId is not for the current media.",
> -                     L"%a:%d:Status - %r\n",
> -                     __FILE__,
> -                     (UINTN)__LINE__,
> -                     Status
> -                     );
> -
> -      Status = EraseBlock->EraseBlocks(EraseBlock, MediaId + 1, LastBlock + 1, &Token, BlockNumber);
> -      if (Status == EFI_MEDIA_CHANGED)
> -        AssertionType = EFI_TEST_ASSERTION_PASSED;
> -      else
> -        AssertionType = EFI_TEST_ASSERTION_FAILED;
> -
> -      StandardLib->RecordAssertion (
> -                     StandardLib,
> -                     AssertionType,
> -                     gEraseBlockBBTestConformanceAssertionGuid007,
> -                     L"EFI_ERASE_BLOCK_PROTOCOL - EFI_MEDIA_CHANGED should be returned even if LBA is invalid.",
> -                     L"%a:%d:Status - %r\n",
> -                     __FILE__,
> -                     (UINTN)__LINE__,
> -                     Status
> -                     );
> -
> -      Status = EraseBlock->EraseBlocks(EraseBlock, MediaId + 1, LastBlock - 10, &Token, BlockNumber + 1);
> -      if (Status == EFI_MEDIA_CHANGED)
> -        AssertionType = EFI_TEST_ASSERTION_PASSED;
> -      else
> -        AssertionType = EFI_TEST_ASSERTION_FAILED;
> -
> -      StandardLib->RecordAssertion (
> -                     StandardLib,
> -                     AssertionType,
> -                     gEraseBlockBBTestConformanceAssertionGuid008,
> -                     L"EFI_ERASE_BLOCK_PROTOCOL - EFI_MEDIA_CHANGED should be returned even if Size is invalid.",
> -                     L"%a:%d:Status - %r\n",
> -                     __FILE__,
> -                     (UINTN)__LINE__,
> -                     Status
> -                     );
> -
> -      Status = EraseBlock->EraseBlocks(EraseBlock, MediaId, LastBlock + 1, &Token, BlockNumber);
> -      if (Status == EFI_INVALID_PARAMETER)
> -        AssertionType = EFI_TEST_ASSERTION_PASSED;
> -      else
> -        AssertionType = EFI_TEST_ASSERTION_FAILED;
> -
> -      StandardLib->RecordAssertion (
> -                     StandardLib,
> -                     AssertionType,
> -                     gEraseBlockBBTestConformanceAssertionGuid009,
> -                     L"EFI_ERASE_BLOCK_PROTOCOL - EFI_INVALID_PARAMETER should be returned if the erase request contains LBAs that are not valid.",
> -                     L"%a:%d:Status - %r\n",
> -                     __FILE__,
> -                     (UINTN)__LINE__,
> -                     Status
> -                     );
> -
> -
> -    }
> -  }
> -
> -  return EFI_SUCCESS;
> -}
> -
> -
> +/** @file
> +
> +  Copyright 2017 Unified EFI, Inc.<BR>
> +  Copyright (c) 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
> +  http://opensource.org/licenses/bsd-license.php
> +
> +  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> +  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> +
> +**/
> +/*++
> +
> +Module Name:
> +
> +    EraseBlockBBTestConformance.c
> +
> +Abstract:
> +
> +    for EFI Driver Erase Block Protocol's Conformance Test
> +
> +--*/
> +
> +#include "EraseBlockBBTestMain.h"
> +
> +EFI_STATUS
> +BBTestEraseBlocksConformanceTest (
> +  IN EFI_BB_TEST_PROTOCOL       *This,
> +  IN VOID                       *ClientInterface,
> +  IN EFI_TEST_LEVEL             TestLevel,
> +  IN EFI_HANDLE                 SupportHandle
> +  )
> +{
> +
> +  EFI_STANDARD_TEST_LIBRARY_PROTOCOL    *StandardLib;
> +  EFI_STATUS                            Status;
> +  EFI_ERASE_BLOCK_PROTOCOL              *EraseBlock;
> +  EFI_BLOCK_IO_PROTOCOL                 *BlockIo;
> +  EFI_BLOCK_IO2_PROTOCOL                *BlockIo2;
> +  EFI_TEST_ASSERTION                    AssertionType;
> +  EFI_BLOCK_IO_MEDIA                    *Media;
> +  UINT32                                MediaId;
> +  BOOLEAN                               RemovableMedia;
> +  BOOLEAN                               MediaPresent;
> +  BOOLEAN                               LogicalPartition;
> +  BOOLEAN                               ReadOnly;
> +  BOOLEAN                               WriteCaching;
> +  UINT32                                BlockSize;
> +  UINT32                                IoAlign;
> +  EFI_LBA                               LastBlock;
> +
> +  UINT32                                BlockNumber;
> +
> +  EFI_ERASE_BLOCK_TOKEN                 Token;
> +
> +  EraseBlock = (EFI_ERASE_BLOCK_PROTOCOL*)ClientInterface;
> +
> +
> +  //
> +  // Get the Standard Library Interface
> +  //
> +  Status = gtBS->HandleProtocol (
> +                   SupportHandle,
> +                   &gEfiStandardTestLibraryGuid,
> +                   (VOID **) &StandardLib
> +                   );
> +
> +  if ( EFI_ERROR(Status) ) {
> +    StandardLib->RecordAssertion (
> +                   StandardLib,
> +                   EFI_TEST_ASSERTION_FAILED,
> +                   gTestGenericFailureGuid,
> +                   L"BS.HandleProtocol - Handle standard test library",
> +                   L"%a:%d:Status - %r\n",
> +                   __FILE__,
> +                   (UINTN)__LINE__,
> +                   Status
> +                   );
> +    return Status;
> +  }
> +
> +  Status = LocateBlockIoFromEraseBlock(EraseBlock, &BlockIo, StandardLib);
> +  if (Status == EFI_SUCCESS) {
> +    Media = BlockIo->Media;
> +    AssertionType = EFI_TEST_ASSERTION_PASSED;
> +  } else {
> +    Status = LocateBlockIo2FromEraseBlock(EraseBlock, &BlockIo2, StandardLib);
> +    if (Status == EFI_SUCCESS) {
> +      Media = BlockIo2->Media;
> +      AssertionType = EFI_TEST_ASSERTION_PASSED;
> +    } else {
> +      AssertionType = EFI_TEST_ASSERTION_FAILED;
> +    }
> +  }
> +
> +  StandardLib->RecordAssertion (
> +                 StandardLib,
> +                 AssertionType,
> +                 gEraseBlockBBTestConformanceAssertionGuid001,
> +                 L"EFI_ERASE_BLOCK_PROTOCOL - It should be installed on the same handle as the EFI_BLOCK_IO_PROTOCOL or EFI_BLOCK_IO2_PROTOCOL.",
> +                 L"%a:%d:Status - %r\n",
> +                 __FILE__,
> +                 (UINTN)__LINE__,
> +                 Status
> +                 );
> +
> +  if (AssertionType == EFI_TEST_ASSERTION_FAILED)
> +    return EFI_SUCCESS;
> +
> +
> +  MediaId           = Media->MediaId;
> +  RemovableMedia    = Media->RemovableMedia;
> +  MediaPresent      = Media->MediaPresent;
> +  LogicalPartition  = Media->LogicalPartition;
> +  ReadOnly          = Media->ReadOnly;
> +  WriteCaching      = Media->WriteCaching;
> +  BlockSize         = Media->BlockSize;
> +  IoAlign           = Media->IoAlign;
> +  LastBlock         = Media->LastBlock;
> +
> +  BlockNumber       = (UINT32) MINIMUM(LastBlock, MAX_NUMBER_OF_READ_BLOCK_BUFFER);
> +
> +  if (MediaPresent == FALSE) {
> +    Status = EraseBlock->EraseBlocks(EraseBlock, MediaId, 0, &Token, BlockNumber);
> +    if (Status == EFI_NO_MEDIA)
> +      AssertionType = EFI_TEST_ASSERTION_PASSED;
> +    else
> +      AssertionType = EFI_TEST_ASSERTION_FAILED;
> +
> +      StandardLib->RecordAssertion (
> +                     StandardLib,
> +                     AssertionType,
> +                     gEraseBlockBBTestConformanceAssertionGuid002,
> +                     L"EFI_ERASE_BLOCK_PROTOCOL - EFI_NO_MEDIA should be returned if there is no media in the device.",
> +                     L"%a:%d:Status - %r\n",
> +                     __FILE__,
> +                     (UINTN)__LINE__,
> +                     Status
> +                     );
> +
> +    Status = EraseBlock->EraseBlocks(EraseBlock, MediaId, LastBlock + 1, &Token, BlockNumber);
> +    if (Status == EFI_NO_MEDIA)
> +      AssertionType = EFI_TEST_ASSERTION_PASSED;
> +    else
> +      AssertionType = EFI_TEST_ASSERTION_FAILED;
> +
> +      StandardLib->RecordAssertion (
> +                     StandardLib,
> +                     AssertionType,
> +                     gEraseBlockBBTestConformanceAssertionGuid003,
> +                     L"EFI_ERASE_BLOCK_PROTOCOL - EFI_NO_MEDIA should be returned even if LBA is invalid.",
> +                     L"%a:%d:Status - %r\n",
> +                     __FILE__,
> +                     (UINTN)__LINE__,
> +                     Status
> +                     );
> +
> +    Status = EraseBlock->EraseBlocks(EraseBlock, MediaId, LastBlock - 10, &Token, BlockNumber + 1);
> +    if (Status == EFI_NO_MEDIA)
> +      AssertionType = EFI_TEST_ASSERTION_PASSED;
> +    else
> +      AssertionType = EFI_TEST_ASSERTION_FAILED;
> +
> +      StandardLib->RecordAssertion (
> +                     StandardLib,
> +                     AssertionType,
> +                     gEraseBlockBBTestConformanceAssertionGuid004,
> +                     L"EFI_ERASE_BLOCK_PROTOCOL - EFI_NO_MEDIA should be returned even if Size is invalid.",
> +                     L"%a:%d:Status - %r\n",
> +                     __FILE__,
> +                     (UINTN)__LINE__,
> +                     Status
> +                     );
> +
> +  } else {
> +    if (ReadOnly == TRUE) {
> +      Status = EraseBlock->EraseBlocks(EraseBlock, MediaId, 0, &Token, BlockNumber);
> +      if (Status == EFI_WRITE_PROTECTED)
> +        AssertionType = EFI_TEST_ASSERTION_PASSED;
> +      else
> +        AssertionType = EFI_TEST_ASSERTION_FAILED;
> +
> +      StandardLib->RecordAssertion (
> +                     StandardLib,
> +                     AssertionType,
> +                     gEraseBlockBBTestConformanceAssertionGuid005,
> +                     L"EFI_ERASE_BLOCK_PROTOCOL - EFI_WRITE_PROTECTED should be returned if the device cannot be erased due to write protection.",
> +                     L"%a:%d:Status - %r\n",
> +                     __FILE__,
> +                     (UINTN)__LINE__,
> +                     Status
> +                     );
> +
> +    } else {
> +      Status = EraseBlock->EraseBlocks(EraseBlock, MediaId + 1, 0, &Token, BlockNumber);
> +      if (Status == EFI_MEDIA_CHANGED)
> +        AssertionType = EFI_TEST_ASSERTION_PASSED;
> +      else
> +        AssertionType = EFI_TEST_ASSERTION_FAILED;
> +
> +      StandardLib->RecordAssertion (
> +                     StandardLib,
> +                     AssertionType,
> +                     gEraseBlockBBTestConformanceAssertionGuid006,
> +                     L"EFI_ERASE_BLOCK_PROTOCOL - EFI_MEDIA_CHANGED should be returned if the MediaId is not for the current media.",
> +                     L"%a:%d:Status - %r\n",
> +                     __FILE__,
> +                     (UINTN)__LINE__,
> +                     Status
> +                     );
> +
> +      Status = EraseBlock->EraseBlocks(EraseBlock, MediaId + 1, LastBlock + 1, &Token, BlockNumber);
> +      if (Status == EFI_MEDIA_CHANGED)
> +        AssertionType = EFI_TEST_ASSERTION_PASSED;
> +      else
> +        AssertionType = EFI_TEST_ASSERTION_FAILED;
> +
> +      StandardLib->RecordAssertion (
> +                     StandardLib,
> +                     AssertionType,
> +                     gEraseBlockBBTestConformanceAssertionGuid007,
> +                     L"EFI_ERASE_BLOCK_PROTOCOL - EFI_MEDIA_CHANGED should be returned even if LBA is invalid.",
> +                     L"%a:%d:Status - %r\n",
> +                     __FILE__,
> +                     (UINTN)__LINE__,
> +                     Status
> +                     );
> +
> +      Status = EraseBlock->EraseBlocks(EraseBlock, MediaId + 1, LastBlock - 10, &Token, BlockNumber + 1);
> +      if (Status == EFI_MEDIA_CHANGED)
> +        AssertionType = EFI_TEST_ASSERTION_PASSED;
> +      else
> +        AssertionType = EFI_TEST_ASSERTION_FAILED;
> +
> +      StandardLib->RecordAssertion (
> +                     StandardLib,
> +                     AssertionType,
> +                     gEraseBlockBBTestConformanceAssertionGuid008,
> +                     L"EFI_ERASE_BLOCK_PROTOCOL - EFI_MEDIA_CHANGED should be returned even if Size is invalid.",
> +                     L"%a:%d:Status - %r\n",
> +                     __FILE__,
> +                     (UINTN)__LINE__,
> +                     Status
> +                     );
> +
> +      Status = EraseBlock->EraseBlocks(EraseBlock, MediaId, LastBlock + 1, &Token, BlockNumber);
> +      if (Status == EFI_INVALID_PARAMETER)
> +        AssertionType = EFI_TEST_ASSERTION_PASSED;
> +      else
> +        AssertionType = EFI_TEST_ASSERTION_FAILED;
> +
> +      StandardLib->RecordAssertion (
> +                     StandardLib,
> +                     AssertionType,
> +                     gEraseBlockBBTestConformanceAssertionGuid009,
> +                     L"EFI_ERASE_BLOCK_PROTOCOL - EFI_INVALID_PARAMETER should be returned if the erase request contains LBAs that are not valid.",
> +                     L"%a:%d:Status - %r\n",
> +                     __FILE__,
> +                     (UINTN)__LINE__,
> +                     Status
> +                     );
> +
> +
> +    }
> +  }
> +
> +  return EFI_SUCCESS;
> +}
> +
> +
> diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/EraseBlock/BlackBoxTest/EraseBlockBBTestFunction.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/EraseBlock/BlackBoxTest/EraseBlockBBTestFunction.c
> index e70de7d..bc16a47 100644
> --- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/EraseBlock/BlackBoxTest/EraseBlockBBTestFunction.c
> +++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/EraseBlock/BlackBoxTest/EraseBlockBBTestFunction.c
> @@ -1,439 +1,635 @@
> -/** @file
> -
> -  Copyright 2017 Unified EFI, Inc.<BR>
> -  Copyright (c) 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
> -  http://opensource.org/licenses/bsd-license.php
> -
> -  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> -  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> -
> -**/
> -/*++
> -
> -Module Name:
> -
> -    EraseBlockBBTestFunction.c
> -
> -Abstract:
> -
> -    for EFI Driver Erase Block Protocol's Function Test
> -
> ---*/
> -
> -#include "EraseBlockBBTestMain.h"
> -
> -extern UINT8 EnterEvent;
> -
> -EFI_STATUS
> -BBTestEraseBlocksFunctionTest (
> -  IN EFI_BB_TEST_PROTOCOL       *This,
> -  IN VOID                       *ClientInterface,
> -  IN EFI_TEST_LEVEL             TestLevel,
> -  IN EFI_HANDLE                 SupportHandle
> -  )
> -{
> -  EFI_STANDARD_TEST_LIBRARY_PROTOCOL    *StandardLib;
> -  EFI_STATUS                            Status;
> -  EFI_STATUS                            EraseStatus;
> -  EFI_STATUS                            ReadStatus;
> -  EFI_STATUS                            WriteStatus;
> -  EFI_STATUS                            FlushStatus;
> -  EFI_ERASE_BLOCK_PROTOCOL              *EraseBlock;
> -  EFI_BLOCK_IO_PROTOCOL                 *BlockIo;
> -  EFI_BLOCK_IO2_PROTOCOL                *BlockIo2;
> -  EFI_TEST_ASSERTION                    AssertionType;
> -  UINT32                                EraseLengthGranularity;
> -
> -  EFI_BLOCK_IO_MEDIA                    *Media;
> -  UINT32                                MediaId;
> -  BOOLEAN                               RemovableMedia;
> -  BOOLEAN                               MediaPresent;
> -  BOOLEAN                               LogicalPartition;
> -  BOOLEAN                               ReadOnly;
> -  BOOLEAN                               WriteCaching;
> -  UINT32                                BlockSize;
> -  UINT32                                IoAlign;
> -  EFI_LBA                               LastBlock;
> -  EFI_LBA                               Lba;
> -
> -  UINTN                                 BufferSize;
> -  UINT8                                 *Buffer1 = NULL;
> -  UINT8                                 *Buffer2 = NULL;
> -  BOOLEAN                               IsZero = TRUE;
> -
> -  UINT64                                Index;
> -  UINTN                                 Index1;
> -  UINTN                                 Remainder;
> -
> -  EFI_ERASE_BLOCK_TOKEN                 Token;
> -  EFI_BLOCK_IO2_TOKEN                   BlockIo2Token;
> -
> -  EraseBlock = (EFI_ERASE_BLOCK_PROTOCOL*)ClientInterface;
> -
> -  //
> -  // Get the Standard Library Interface
> -  //
> -  Status = gtBS->HandleProtocol (
> -                   SupportHandle,
> -                   &gEfiStandardTestLibraryGuid,
> -                   (VOID **) &StandardLib
> -                   );
> -
> -  if ( EFI_ERROR(Status) ) {
> -    StandardLib->RecordAssertion (
> -                   StandardLib,
> -                   EFI_TEST_ASSERTION_FAILED,
> -                   gTestGenericFailureGuid,
> -                   L"BS.HandleProtocol - Handle standard test library",
> -                   L"%a:%d:Status - %r\n",
> -                   __FILE__,
> -                   (UINTN)__LINE__,
> -                   Status
> -                   );
> -    return Status;
> -  }
> -
> -  EraseLengthGranularity = EraseBlock->EraseLengthGranularity;
> -
> -  Status = LocateBlockIoFromEraseBlock(EraseBlock, &BlockIo, StandardLib);
> -  if (Status == EFI_SUCCESS) {
> -    Media = BlockIo->Media;
> -
> -    MediaId           = Media->MediaId;
> -    RemovableMedia    = Media->RemovableMedia;
> -    MediaPresent      = Media->MediaPresent;
> -    LogicalPartition  = Media->LogicalPartition;
> -    ReadOnly          = Media->ReadOnly;
> -    WriteCaching      = Media->WriteCaching;
> -    BlockSize         = Media->BlockSize;
> -    IoAlign           = Media->IoAlign;
> -    LastBlock         = Media->LastBlock;
> -
> -    BufferSize        = (UINTN)SctMultU64x32 (EraseLengthGranularity, BlockSize);
> -    Index             = SctDivU64x32 (LastBlock, EraseLengthGranularity, &Remainder);
> -
> -    if (Index > MAX_NUMBER_OF_READ_BLOCK_BUFFER)
> -      Lba = SctMultU64x32 (EraseLengthGranularity, (MAX_NUMBER_OF_READ_BLOCK_BUFFER - 2));
> -    else
> -      Lba = 0;
> -
> -    //
> -    // allocate aligned buffer
> -    //
> -    Buffer1 = AllocateAlignedPool(
> -                EfiBootServicesData,
> -                BufferSize,
> -                IoAlign
> -                );
> -    if (Buffer1 == NULL) {
> -      StandardLib->RecordAssertion (
> -                     StandardLib,
> -                     EFI_TEST_ASSERTION_FAILED,
> -                     gTestGenericFailureGuid,
> -                     L"AllocateAlignedPool - Allocate aligned buffer for testing",
> -                     L"%a:%d:Status - %r",
> -                     __FILE__,
> -                     (UINTN)__LINE__,
> -                     EFI_OUT_OF_RESOURCES
> -                     );
> -      return EFI_OUT_OF_RESOURCES;
> -    }
> -
> -    Buffer2 = AllocateAlignedPool(
> -                EfiBootServicesData,
> -                BufferSize,
> -                IoAlign
> -                );
> -    if (Buffer2 == NULL) {
> -      StandardLib->RecordAssertion (
> -                     StandardLib,
> -                     EFI_TEST_ASSERTION_FAILED,
> -                     gTestGenericFailureGuid,
> -                     L"AllocateAlignedPool - Allocate aligned buffer for testing",
> -                     L"%a:%d:Status - %r",
> -                     __FILE__,
> -                     (UINTN)__LINE__,
> -                     EFI_OUT_OF_RESOURCES
> -                     );
> -      FreeAlignedPool(Buffer1);
> -      return EFI_OUT_OF_RESOURCES;
> -    }
> -
> -    if ((MediaPresent == TRUE) && (ReadOnly == FALSE) && (LastBlock != 0)) {
> -      //
> -      // Read the data at first with ReadBlocks
> -      //
> -      Status = BlockIo->ReadBlocks (BlockIo, MediaId, Lba, BufferSize, (VOID*)Buffer1);
> -      if (EFI_ERROR (Status)) {
> -        StandardLib->RecordAssertion (
> -                       StandardLib,
> -                       EFI_TEST_ASSERTION_FAILED,
> -                       gTestGenericFailureGuid,
> -                       L"ReadBlocks - ReadBlocks for testing fail",
> -                       L"%a:%d:Status - %r",
> -                       __FILE__,
> -                       (UINTN)__LINE__,
> -                       Status
> -                       );
> -
> -        FreeAlignedPool(Buffer1);
> -        FreeAlignedPool(Buffer2);
> -        goto BlockIo2;
> -      }
> -
> -      //
> -      // Erase Blocks
> -      //
> -      Token.Event = NULL;
> -      Token.TransactionStatus = EFI_NOT_READY;
> -      EraseStatus = EraseBlock->EraseBlocks (EraseBlock, MediaId, Lba, &Token, BufferSize);
> -
> -      //
> -      // Read the data with 0
> -      //
> -      ReadStatus = BlockIo->ReadBlocks (BlockIo, MediaId, Lba, BufferSize, (VOID*)Buffer2);
> -      for (Index1 = 0; Index1 < BufferSize; Index1++) {
> -        if (Buffer2[Index1] != 0) {
> -          IsZero = FALSE;
> -          break;
> -        }
> -      }
> -
> -      //
> -      // Restore the data with WriteBlocks and FlushBlocks
> -      //
> -      WriteStatus = BlockIo->WriteBlocks (BlockIo, MediaId, Lba, BufferSize, (VOID*)Buffer1);
> -      FlushStatus = EFI_SUCCESS;
> -      if (WriteCaching == TRUE)
> -        FlushStatus = BlockIo->FlushBlocks(BlockIo);
> -
> -      if ((EraseStatus == EFI_SUCCESS) && (IsZero == TRUE))
> -       	AssertionType = EFI_TEST_ASSERTION_PASSED;
> -      else
> -        AssertionType = EFI_TEST_ASSERTION_FAILED;
> -
> -      StandardLib->RecordAssertion (
> -                       StandardLib,
> -                       AssertionType,
> -                       gEraseBlockBBTestFunctionAssertionGuid001,
> -                       L"EraseBlocks - EraseBlocks for testing",
> -                       L"%a:%d:EraseBlocks Status - %r, IsZero - %d",
> -                       __FILE__,
> -                       (UINTN)__LINE__,
> -                       Status,
> -                       IsZero
> -                       );
> -
> -      if ((WriteStatus != EFI_SUCCESS) || (FlushStatus != EFI_SUCCESS))
> -        StandardLib->RecordAssertion (
> -                       StandardLib,
> -                       EFI_TEST_ASSERTION_FAILED,
> -                       gTestGenericFailureGuid,
> -                       L"WriteBlocks/FlushBlocks - Restore for testing fail",
> -                       L"%a:%d: WriteStatus - %r, FlushStatus - %r",
> -                       __FILE__,
> -                       (UINTN)__LINE__,
> -                       WriteStatus,
> -                       FlushStatus
> -                       );
> -
> -      FreeAlignedPool(Buffer1);
> -      FreeAlignedPool(Buffer2);
> -    }
> -  }
> -
> -BlockIo2:
> -
> -  Status = LocateBlockIo2FromEraseBlock(EraseBlock, &BlockIo2, StandardLib);
> -  if (Status == EFI_SUCCESS) {
> -    Media = BlockIo2->Media;
> -
> -    MediaId           = Media->MediaId;
> -    RemovableMedia    = Media->RemovableMedia;
> -    MediaPresent      = Media->MediaPresent;
> -    LogicalPartition  = Media->LogicalPartition;
> -    ReadOnly          = Media->ReadOnly;
> -    WriteCaching      = Media->WriteCaching;
> -    BlockSize         = Media->BlockSize;
> -    IoAlign           = Media->IoAlign;
> -    LastBlock         = Media->LastBlock;
> -
> -    BufferSize        = (UINTN)SctMultU64x32 (EraseLengthGranularity, BlockSize);
> -    Index             = SctDivU64x32 (LastBlock, EraseLengthGranularity, &Remainder);
> -
> -    if (Index > MAX_NUMBER_OF_READ_BLOCK_BUFFER)
> -      Lba = SctMultU64x32 (EraseLengthGranularity, (MAX_NUMBER_OF_READ_BLOCK_BUFFER - 2));
> -    else
> -      Lba = 0;
> -
> -    //
> -    // allocate aligned buffer
> -    //
> -    Buffer1 = AllocateAlignedPool(
> -                EfiBootServicesData,
> -                BufferSize,
> -                IoAlign
> -                );
> -    if (Buffer1 == NULL) {
> -      StandardLib->RecordAssertion (
> -                     StandardLib,
> -                     EFI_TEST_ASSERTION_FAILED,
> -                     gTestGenericFailureGuid,
> -                     L"AllocateAlignedPool - Allocate aligned buffer for testing",
> -                     L"%a:%d:Status - %r",
> -                     __FILE__,
> -                     (UINTN)__LINE__,
> -                     EFI_OUT_OF_RESOURCES
> -                     );
> -      return EFI_OUT_OF_RESOURCES;
> -    }
> -
> -    Buffer2 = AllocateAlignedPool(
> -                EfiBootServicesData,
> -                BufferSize,
> -                IoAlign
> -                );
> -    if (Buffer2 == NULL) {
> -      StandardLib->RecordAssertion (
> -                     StandardLib,
> -                     EFI_TEST_ASSERTION_FAILED,
> -                     gTestGenericFailureGuid,
> -                     L"AllocateAlignedPool - Allocate aligned buffer for testing",
> -                     L"%a:%d:Status - %r",
> -                     __FILE__,
> -                     (UINTN)__LINE__,
> -                     EFI_OUT_OF_RESOURCES
> -                     );
> -      FreeAlignedPool(Buffer1);
> -      return EFI_OUT_OF_RESOURCES;
> -    }
> -
> -    if ((MediaPresent == TRUE) && (ReadOnly == FALSE) && (LastBlock != 0)) {
> -      BlockIo2Token.Event = NULL;
> -      BlockIo2Token.TransactionStatus = EFI_NOT_READY;
> -
> -      //
> -      // Read the data at first with ReadBlocks
> -      //
> -      Status = BlockIo2->ReadBlocksEx (BlockIo2, MediaId, Lba, &BlockIo2Token, BufferSize, (VOID*)Buffer1);
> -      if (EFI_ERROR (Status)) {
> -        StandardLib->RecordAssertion (
> -                       StandardLib,
> -                       EFI_TEST_ASSERTION_FAILED,
> -                       gTestGenericFailureGuid,
> -                       L"ReadBlocks - ReadBlocks for testing fail",
> -                       L"%a:%d:Status - %r",
> -                       __FILE__,
> -                       (UINTN)__LINE__,
> -                       Status
> -                       );
> -
> -        FreeAlignedPool(Buffer1);
> -        FreeAlignedPool(Buffer2);
> -        goto End;
> -      }
> -
> -      //
> -      // Erase Blocks
> -      //
> -      Token.Event             = NULL;
> -      Token.TransactionStatus = EFI_NOT_READY;
> -
> -      EnterEvent = 0;
> -
> -      Status = gtBS->CreateEvent (
> -                   EVT_NOTIFY_SIGNAL,
> -                   TPL_CALLBACK,
> -                   (EFI_EVENT_NOTIFY) NotifyFunction,
> -                   NULL,
> -                   &Token.Event
> -                   );
> -
> -      if (EFI_ERROR (Status)) {
> -        StandardLib->RecordAssertion (
> -                       StandardLib,
> -                       EFI_TEST_ASSERTION_FAILED,
> -                       gTestGenericFailureGuid,
> -                       L"CreateEvent - CreateEvent for testing fail",
> -                       L"%a:%d:Status - %r",
> -                       __FILE__,
> -                       (UINTN)__LINE__,
> -                       Status
> -                       );
> -        FreeAlignedPool(Buffer1);
> -        FreeAlignedPool(Buffer2);
> -        goto End;
> -      }
> -
> -      EraseStatus = EraseBlock->EraseBlocks (EraseBlock, MediaId, Lba, &Token, BufferSize);
> -
> -      while(Token.TransactionStatus == EFI_NOT_READY);
> -
> -      //
> -      // Read the data with 0
> -      //
> -      ReadStatus = BlockIo2->ReadBlocksEx (BlockIo2, MediaId, Lba, &BlockIo2Token, BufferSize, (VOID*)Buffer2);
> -
> -      for (Index1 = 0; Index1 < BufferSize; Index1++) {
> -        if (Buffer2[Index1] != 0) {
> -          IsZero = FALSE;
> -          break;
> -        }
> -      }
> -
> -      //
> -      // Restore the data with WriteBlocks and FlushBlocks
> -      //
> -      WriteStatus = BlockIo2->WriteBlocksEx (BlockIo2, MediaId, Lba, &BlockIo2Token, BufferSize, (VOID*)Buffer1);
> -      FlushStatus = EFI_SUCCESS;
> -      if (WriteCaching == TRUE)
> -        FlushStatus = BlockIo2->FlushBlocksEx (BlockIo2, &BlockIo2Token);
> -
> -      if ((EraseStatus == EFI_SUCCESS) && (IsZero == TRUE) && (EnterEvent == 1))
> -       	AssertionType = EFI_TEST_ASSERTION_PASSED;
> -      else
> -        AssertionType = EFI_TEST_ASSERTION_FAILED;
> -
> -      StandardLib->RecordAssertion (
> -                       StandardLib,
> -                       AssertionType,
> -                       gEraseBlockBBTestFunctionAssertionGuid002,
> -                       L"EraseBlocks - EraseBlocks for testing",
> -                       L"%a:%d:EraseBlocks Status - %r, IsZero - %d, EnterEvent - %d",
> -                       __FILE__,
> -                       (UINTN)__LINE__,
> -                       Status,
> -                       IsZero,
> -                       EnterEvent
> -                       );
> -
> -      if ((WriteStatus != EFI_SUCCESS) || (FlushStatus != EFI_SUCCESS))
> -        StandardLib->RecordAssertion (
> -                       StandardLib,
> -                       EFI_TEST_ASSERTION_FAILED,
> -                       gTestGenericFailureGuid,
> -                       L"WriteBlocks/FlushBlocks - Restore for testing fail",
> -                       L"%a:%d: WriteStatus - %r, FlushStatus - %r",
> -                       __FILE__,
> -                       (UINTN)__LINE__,
> -                       WriteStatus,
> -                       FlushStatus
> -                       );
> -
> -      FreeAlignedPool(Buffer1);
> -      FreeAlignedPool(Buffer2);
> -    }
> -
> -End:
> -    if (Token.Event != NULL)
> -      gtBS->CloseEvent(Token.Event);
> -
> -  }
> -
> -   return EFI_SUCCESS;
> -}
> -
> +/** @file
> +
> +  Copyright 2017 Unified EFI, Inc.<BR>
> +  Copyright (c) 2017 - 2018, 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
> +  http://opensource.org/licenses/bsd-license.php
> +
> +  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> +  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> +
> +**/
> +/*++
> +
> +Module Name:
> +
> +    EraseBlockBBTestFunction.c
> +
> +Abstract:
> +
> +    for EFI Driver Erase Block Protocol's Function Test
> +
> +--*/
> +
> +#include "EraseBlockBBTestMain.h"
> +
> +extern UINT8 EnterEvent;
> +
> +EFI_STATUS
> +BBTestEraseBlocksFunctionTest (
> +  IN EFI_BB_TEST_PROTOCOL       *This,
> +  IN VOID                       *ClientInterface,
> +  IN EFI_TEST_LEVEL             TestLevel,
> +  IN EFI_HANDLE                 SupportHandle
> +  )
> +{
> +  EFI_STANDARD_TEST_LIBRARY_PROTOCOL    *StandardLib;
> +  EFI_STATUS                            Status;
> +  EFI_STATUS                            EraseStatus;
> +  EFI_STATUS                            ReadStatus;
> +  EFI_STATUS                            WriteStatus;
> +  EFI_STATUS                            FlushStatus;
> +  EFI_ERASE_BLOCK_PROTOCOL              *EraseBlock;
> +  EFI_BLOCK_IO_PROTOCOL                 *BlockIo;
> +  EFI_BLOCK_IO2_PROTOCOL                *BlockIo2;
> +  EFI_TEST_ASSERTION                    AssertionType;
> +  UINT32                                EraseLengthGranularity;
> +
> +  EFI_BLOCK_IO_MEDIA                    *Media;
> +  UINT32                                MediaId;
> +  BOOLEAN                               RemovableMedia;
> +  BOOLEAN                               MediaPresent;
> +  BOOLEAN                               LogicalPartition;
> +  BOOLEAN                               ReadOnly;
> +  BOOLEAN                               WriteCaching;
> +  UINT32                                BlockSize;
> +  UINT32                                IoAlign;
> +  EFI_LBA                               LastBlock;
> +  EFI_LBA                               Lba;
> +
> +  UINTN                                 BufferSize;
> +  UINT8                                 *Buffer1 = NULL;
> +  UINT8                                 *Buffer2 = NULL;
> +  BOOLEAN                               IsZero  = TRUE;
> +  BOOLEAN                               IsZero1 = TRUE;
> +  BOOLEAN                               IsZero2 = TRUE;
> +  BOOLEAN                               IsZero3 = TRUE;
> +
> +  UINT64                                Index;
> +  UINTN                                 Index1;
> +  UINTN                                 Remainder;
> +
> +  EFI_ERASE_BLOCK_TOKEN                 Token;
> +  EFI_BLOCK_IO2_TOKEN                   BlockIo2Token;
> +
> +  EraseBlock = (EFI_ERASE_BLOCK_PROTOCOL*)ClientInterface;
> +
> +  //
> +  // Get the Standard Library Interface
> +  //
> +  Status = gtBS->HandleProtocol (
> +                   SupportHandle,
> +                   &gEfiStandardTestLibraryGuid,
> +                   (VOID **) &StandardLib
> +                   );
> +
> +  if ( EFI_ERROR(Status) ) {
> +    StandardLib->RecordAssertion (
> +                   StandardLib,
> +                   EFI_TEST_ASSERTION_FAILED,
> +                   gTestGenericFailureGuid,
> +                   L"BS.HandleProtocol - Handle standard test library",
> +                   L"%a:%d:Status - %r\n",
> +                   __FILE__,
> +                   (UINTN)__LINE__,
> +                   Status
> +                   );
> +    return Status;
> +  }
> +
> +  EraseLengthGranularity = EraseBlock->EraseLengthGranularity;
> +
> +  Status = LocateBlockIoFromEraseBlock(EraseBlock, &BlockIo, StandardLib);
> +  if (Status == EFI_SUCCESS) {
> +    Media = BlockIo->Media;
> +
> +    MediaId           = Media->MediaId;
> +    RemovableMedia    = Media->RemovableMedia;
> +    MediaPresent      = Media->MediaPresent;
> +    LogicalPartition  = Media->LogicalPartition;
> +    ReadOnly          = Media->ReadOnly;
> +    WriteCaching      = Media->WriteCaching;
> +    BlockSize         = Media->BlockSize;
> +    IoAlign           = Media->IoAlign;
> +    LastBlock         = Media->LastBlock;
> +
> +    BufferSize        = (UINTN)SctMultU64x32 (EraseLengthGranularity, BlockSize);
> +    Index             = SctDivU64x32 (LastBlock, EraseLengthGranularity, &Remainder);
> +
> +    if (Index > MAX_NUMBER_OF_READ_BLOCK_BUFFER)
> +      Lba = SctMultU64x32 (EraseLengthGranularity, (MAX_NUMBER_OF_READ_BLOCK_BUFFER - 2));
> +    else
> +      Lba = 0;
> +
> +    //
> +    // allocate aligned buffer
> +    //
> +    Buffer1 = AllocateAlignedPool(
> +                EfiBootServicesData,
> +                BufferSize,
> +                IoAlign
> +                );
> +    if (Buffer1 == NULL) {
> +      StandardLib->RecordAssertion (
> +                     StandardLib,
> +                     EFI_TEST_ASSERTION_FAILED,
> +                     gTestGenericFailureGuid,
> +                     L"AllocateAlignedPool - Allocate aligned buffer for testing",
> +                     L"%a:%d:Status - %r",
> +                     __FILE__,
> +                     (UINTN)__LINE__,
> +                     EFI_OUT_OF_RESOURCES
> +                     );
> +      return EFI_OUT_OF_RESOURCES;
> +    }
> +
> +    Buffer2 = AllocateAlignedPool(
> +                EfiBootServicesData,
> +                BufferSize,
> +                IoAlign
> +                );
> +    if (Buffer2 == NULL) {
> +      StandardLib->RecordAssertion (
> +                     StandardLib,
> +                     EFI_TEST_ASSERTION_FAILED,
> +                     gTestGenericFailureGuid,
> +                     L"AllocateAlignedPool - Allocate aligned buffer for testing",
> +                     L"%a:%d:Status - %r",
> +                     __FILE__,
> +                     (UINTN)__LINE__,
> +                     EFI_OUT_OF_RESOURCES
> +                     );
> +      FreeAlignedPool(Buffer1);
> +      return EFI_OUT_OF_RESOURCES;
> +    }
> +
> +    if ((MediaPresent == TRUE) && (ReadOnly == FALSE) && (LastBlock != 0)) {
> +      //
> +      // Read the data at first with ReadBlocks
> +      //
> +      Status = BlockIo->ReadBlocks (BlockIo, MediaId, Lba, BufferSize, (VOID*)Buffer1);
> +      if (EFI_ERROR (Status)) {
> +        StandardLib->RecordAssertion (
> +                       StandardLib,
> +                       EFI_TEST_ASSERTION_FAILED,
> +                       gTestGenericFailureGuid,
> +                       L"ReadBlocks - ReadBlocks for testing fail",
> +                       L"%a:%d:Status - %r",
> +                       __FILE__,
> +                       (UINTN)__LINE__,
> +                       Status
> +                       );
> +
> +        FreeAlignedPool(Buffer1);
> +        FreeAlignedPool(Buffer2);
> +        goto BlockIo2;
> +      }
> +
> +      //
> +      // Write 1
> +      //
> +      for (Index1 = 0; Index1 < BufferSize; Index1++) {
> +      	 Buffer2[Index1] = 1;
> +      }
> +
> +      Status = BlockIo->WriteBlocks (BlockIo, MediaId, Lba, BufferSize, (VOID*)Buffer2);
> +      if (EFI_ERROR (Status)) {
> +        StandardLib->RecordAssertion (
> +                       StandardLib,
> +                       EFI_TEST_ASSERTION_FAILED,
> +                       gTestGenericFailureGuid,
> +                       L"WriteBlocks - WriteBlocks for testing fail",
> +                       L"%a:%d:Status - %r",
> +                       __FILE__,
> +                       (UINTN)__LINE__,
> +                       Status
> +                       );
> +
> +        FreeAlignedPool(Buffer1);
> +        FreeAlignedPool(Buffer2);
> +        goto BlockIo2;
> +      }
> +
> +      // Erase Blocks with non-EraseLengthGranularity blocks
> +      Token.Event = NULL;
> +      Token.TransactionStatus = EFI_NOT_READY;
> +      EraseStatus = EraseBlock->EraseBlocks (EraseBlock, MediaId, Lba+1, &Token, BufferSize - 2 * BlockSize);
> +
> +      // Read the data with 0, the first/last block should not be erased
> +      ReadStatus = BlockIo->ReadBlocks (BlockIo, MediaId, Lba, BufferSize, (VOID*)Buffer2);
> +      if (ReadStatus == EFI_SUCCESS) {
> +        for (Index1 = 0; Index1 < BlockSize; Index1++) {
> +          if (Buffer2[Index1] != 0) {
> +            IsZero1 = FALSE;
> +            break;
> +          }
> +        }
> +
> +        for (Index1 = BlockSize; Index1 < BufferSize - BlockSize; Index1++) {
> +          if (Buffer2[Index1] != 0) {
> +            IsZero2 = FALSE;
> +            break;
> +          }
> +        }
> +
> +        for (Index1 = BufferSize - BlockSize; Index1 < BufferSize; Index1++) {
> +          if (Buffer2[Index1] != 0) {
> +            IsZero3 = FALSE;
> +            break;
> +          }
> +        }
> +
> +        if ((EraseStatus == EFI_SUCCESS) && (IsZero1 == FALSE) && (IsZero2 == TRUE) && ((IsZero3 == FALSE)))
> +       	  AssertionType = EFI_TEST_ASSERTION_PASSED;
> +        else
> +          AssertionType = EFI_TEST_ASSERTION_FAILED;
> +
> +
> +        StandardLib->RecordAssertion (
> +                       StandardLib,
> +                       AssertionType,
> +                       gEraseBlockBBTestFunctionAssertionGuid003,
> +                       L"EraseBlocks - EraseBlocks for testing, the first/last block should not be erased",
> +                       L"%a:%d:EraseBlocks Status - %r, IsZero1 - %d, IsZero2 - %d, IsZero3 - %d",
> +                       __FILE__,
> +                       (UINTN)__LINE__,
> +                       Status,
> +                       IsZero1, IsZero2, IsZero3
> +                       );
> +
> +      }
> +
> +      //
> +      // Erase Blocks with the EraseLengthGranularity blocks
> +      //
> +      Token.Event = NULL;
> +      Token.TransactionStatus = EFI_NOT_READY;
> +      EraseStatus = EraseBlock->EraseBlocks (EraseBlock, MediaId, Lba, &Token, BufferSize);
> +
> +      //
> +      // Read the data with 0
> +      //
> +      ReadStatus = BlockIo->ReadBlocks (BlockIo, MediaId, Lba, BufferSize, (VOID*)Buffer2);
> +      if (ReadStatus == EFI_SUCCESS) {
> +
> +        for (Index1 = 0; Index1 < BufferSize; Index1++) {
> +          if (Buffer2[Index1] != 0) {
> +            IsZero = FALSE;
> +            break;
> +          }
> +        }
> +
> +        if ((EraseStatus == EFI_SUCCESS) && (IsZero == TRUE))
> +       	  AssertionType = EFI_TEST_ASSERTION_PASSED;
> +        else
> +          AssertionType = EFI_TEST_ASSERTION_FAILED;
> +
> +        StandardLib->RecordAssertion (
> +                       StandardLib,
> +                       AssertionType,
> +                       gEraseBlockBBTestFunctionAssertionGuid001,
> +                       L"EraseBlocks - EraseBlocks for testing",
> +                       L"%a:%d:EraseBlocks Status - %r, IsZero - %d",
> +                       __FILE__,
> +                       (UINTN)__LINE__,
> +                       Status,
> +                       IsZero
> +                       );
> +
> +
> +      }
> +
> +      //
> +      // Restore the data with WriteBlocks and FlushBlocks
> +      //
> +      WriteStatus = BlockIo->WriteBlocks (BlockIo, MediaId, Lba, BufferSize, (VOID*)Buffer1);
> +      FlushStatus = EFI_SUCCESS;
> +      if (WriteCaching == TRUE)
> +        FlushStatus = BlockIo->FlushBlocks(BlockIo);
> +
> +      if ((WriteStatus != EFI_SUCCESS) || (FlushStatus != EFI_SUCCESS))
> +        StandardLib->RecordAssertion (
> +                       StandardLib,
> +                       EFI_TEST_ASSERTION_FAILED,
> +                       gTestGenericFailureGuid,
> +                       L"WriteBlocks/FlushBlocks - Restore for testing fail",
> +                       L"%a:%d: WriteStatus - %r, FlushStatus - %r",
> +                       __FILE__,
> +                       (UINTN)__LINE__,
> +                       WriteStatus,
> +                       FlushStatus
> +                       );
> +
> +      FreeAlignedPool(Buffer1);
> +      FreeAlignedPool(Buffer2);
> +    }
> +  }
> +
> +BlockIo2:
> +
> +  IsZero  = TRUE;
> +  IsZero1 = TRUE;
> +  IsZero2 = TRUE;
> +  IsZero3 = TRUE;
> +
> +  Status = LocateBlockIo2FromEraseBlock(EraseBlock, &BlockIo2, StandardLib);
> +  if (Status == EFI_SUCCESS) {
> +    Media = BlockIo2->Media;
> +
> +    MediaId           = Media->MediaId;
> +    RemovableMedia    = Media->RemovableMedia;
> +    MediaPresent      = Media->MediaPresent;
> +    LogicalPartition  = Media->LogicalPartition;
> +    ReadOnly          = Media->ReadOnly;
> +    WriteCaching      = Media->WriteCaching;
> +    BlockSize         = Media->BlockSize;
> +    IoAlign           = Media->IoAlign;
> +    LastBlock         = Media->LastBlock;
> +
> +    BufferSize        = (UINTN)SctMultU64x32 (EraseLengthGranularity, BlockSize);
> +    Index             = SctDivU64x32 (LastBlock, EraseLengthGranularity, &Remainder);
> +
> +    if (Index > MAX_NUMBER_OF_READ_BLOCK_BUFFER)
> +      Lba = SctMultU64x32 (EraseLengthGranularity, (MAX_NUMBER_OF_READ_BLOCK_BUFFER - 2));
> +    else
> +      Lba = 0;
> +
> +    //
> +    // allocate aligned buffer
> +    //
> +    Buffer1 = AllocateAlignedPool(
> +                EfiBootServicesData,
> +                BufferSize,
> +                IoAlign
> +                );
> +    if (Buffer1 == NULL) {
> +      StandardLib->RecordAssertion (
> +                     StandardLib,
> +                     EFI_TEST_ASSERTION_FAILED,
> +                     gTestGenericFailureGuid,
> +                     L"AllocateAlignedPool - Allocate aligned buffer for testing",
> +                     L"%a:%d:Status - %r",
> +                     __FILE__,
> +                     (UINTN)__LINE__,
> +                     EFI_OUT_OF_RESOURCES
> +                     );
> +      return EFI_OUT_OF_RESOURCES;
> +    }
> +
> +    Buffer2 = AllocateAlignedPool(
> +                EfiBootServicesData,
> +                BufferSize,
> +                IoAlign
> +                );
> +    if (Buffer2 == NULL) {
> +      StandardLib->RecordAssertion (
> +                     StandardLib,
> +                     EFI_TEST_ASSERTION_FAILED,
> +                     gTestGenericFailureGuid,
> +                     L"AllocateAlignedPool - Allocate aligned buffer for testing",
> +                     L"%a:%d:Status - %r",
> +                     __FILE__,
> +                     (UINTN)__LINE__,
> +                     EFI_OUT_OF_RESOURCES
> +                     );
> +      FreeAlignedPool(Buffer1);
> +      return EFI_OUT_OF_RESOURCES;
> +    }
> +
> +    if ((MediaPresent == TRUE) && (ReadOnly == FALSE) && (LastBlock != 0)) {
> +      BlockIo2Token.Event = NULL;
> +      BlockIo2Token.TransactionStatus = EFI_NOT_READY;
> +
> +      //
> +      // Read the data at first with ReadBlocks
> +      //
> +      Status = BlockIo2->ReadBlocksEx (BlockIo2, MediaId, Lba, &BlockIo2Token, BufferSize, (VOID*)Buffer1);
> +      if (EFI_ERROR (Status)) {
> +        StandardLib->RecordAssertion (
> +                       StandardLib,
> +                       EFI_TEST_ASSERTION_FAILED,
> +                       gTestGenericFailureGuid,
> +                       L"ReadBlocks - ReadBlocks for testing fail",
> +                       L"%a:%d:Status - %r",
> +                       __FILE__,
> +                       (UINTN)__LINE__,
> +                       Status
> +                       );
> +
> +        FreeAlignedPool(Buffer1);
> +        FreeAlignedPool(Buffer2);
> +        goto End;
> +      }
> +
> +      //
> +      // Write 1
> +      //
> +
> +      for (Index1 = 0; Index1 < BufferSize; Index1++) {
> +        Buffer2[Index1] = 1;
> +      }
> +
> +      Status = BlockIo2->WriteBlocksEx (BlockIo2, MediaId, Lba, &BlockIo2Token, BufferSize, (VOID*)Buffer2);
> +      if (EFI_ERROR (Status)) {
> +        StandardLib->RecordAssertion (
> +                       StandardLib,
> +                       EFI_TEST_ASSERTION_FAILED,
> +                       gTestGenericFailureGuid,
> +                       L"WriteBlocks - WriteBlocks for testing fail",
> +                       L"%a:%d:Status - %r",
> +                       __FILE__,
> +                       (UINTN)__LINE__,
> +                       Status
> +                       );
> +
> +        FreeAlignedPool(Buffer1);
> +        FreeAlignedPool(Buffer2);
> +        goto End;
> +      }
> +
> +      //
> +      // Erase Blocks with non EraseLengthGranularity blocks
> +      //
> +
> +      Token.Event             = NULL;
> +      Token.TransactionStatus = EFI_NOT_READY;
> +
> +      EnterEvent = 0;
> +
> +      Status = gtBS->CreateEvent (
> +                   EVT_NOTIFY_SIGNAL,
> +                   TPL_CALLBACK,
> +                   (EFI_EVENT_NOTIFY) NotifyFunction,
> +                   NULL,
> +                   &Token.Event
> +                   );
> +
> +      if (EFI_ERROR (Status)) {
> +        StandardLib->RecordAssertion (
> +                       StandardLib,
> +                       EFI_TEST_ASSERTION_FAILED,
> +                       gTestGenericFailureGuid,
> +                       L"CreateEvent - CreateEvent for testing fail",
> +                       L"%a:%d:Status - %r",
> +                       __FILE__,
> +                       (UINTN)__LINE__,
> +                       Status
> +                       );
> +        FreeAlignedPool(Buffer1);
> +        FreeAlignedPool(Buffer2);
> +        goto End;
> +      }
> +
> +      EraseStatus = EraseBlock->EraseBlocks (EraseBlock, MediaId, Lba+1, &Token, BufferSize - 2 * BlockSize);
> +
> +      while(Token.TransactionStatus == EFI_NOT_READY);
> +
> +      // Read the data with 0, the first/last block should not be erased
> +      ReadStatus = BlockIo2->ReadBlocksEx (BlockIo2, MediaId, Lba, &BlockIo2Token, BufferSize, (VOID*)Buffer2);
> +      if (ReadStatus == EFI_SUCCESS) {
> +        for (Index1 = 0; Index1 < BlockSize; Index1++) {
> +          if (Buffer2[Index1] != 0) {
> +            IsZero1 = FALSE;
> +            break;
> +          }
> +        }
> +
> +        for (Index1 = BlockSize; Index1 < BufferSize - BlockSize; Index1++) {
> +          if (Buffer2[Index1] != 0) {
> +            IsZero2 = FALSE;
> +            break;
> +          }
> +        }
> +
> +        for (Index1 = BufferSize - BlockSize; Index1 < BufferSize; Index1++) {
> +          if (Buffer2[Index1] != 0) {
> +            IsZero3 = FALSE;
> +            break;
> +          }
> +        }
> +
> +        if ((EraseStatus == EFI_SUCCESS) && (IsZero1 == FALSE) && (IsZero2 == TRUE) && ((IsZero3 == FALSE)))
> +       	  AssertionType = EFI_TEST_ASSERTION_PASSED;
> +        else
> +          AssertionType = EFI_TEST_ASSERTION_FAILED;
> +
> +
> +        StandardLib->RecordAssertion (
> +                       StandardLib,
> +                       AssertionType,
> +                       gEraseBlockBBTestFunctionAssertionGuid004,
> +                       L"EraseBlocks - EraseBlocks for testing, the first/last block should not be erased",
> +                       L"%a:%d:EraseBlocks Status - %r, IsZero1 - %d, IsZero2 - %d, IsZero3 - %d",
> +                       __FILE__,
> +                       (UINTN)__LINE__,
> +                       Status,
> +                       IsZero1, IsZero2, IsZero3
> +                       );
> +
> +      }
> +
> +      //
> +      // Erase Blocks with the EraseLengthGranularity blocks
> +      //
> +      Token.Event             = NULL;
> +      Token.TransactionStatus = EFI_NOT_READY;
> +
> +      EnterEvent = 0;
> +
> +      Status = gtBS->CreateEvent (
> +                   EVT_NOTIFY_SIGNAL,
> +                   TPL_CALLBACK,
> +                   (EFI_EVENT_NOTIFY) NotifyFunction,
> +                   NULL,
> +                   &Token.Event
> +                   );
> +
> +      if (EFI_ERROR (Status)) {
> +        StandardLib->RecordAssertion (
> +                       StandardLib,
> +                       EFI_TEST_ASSERTION_FAILED,
> +                       gTestGenericFailureGuid,
> +                       L"CreateEvent - CreateEvent for testing fail",
> +                       L"%a:%d:Status - %r",
> +                       __FILE__,
> +                       (UINTN)__LINE__,
> +                       Status
> +                       );
> +        FreeAlignedPool(Buffer1);
> +        FreeAlignedPool(Buffer2);
> +        goto End;
> +      }
> +
> +      EraseStatus = EraseBlock->EraseBlocks (EraseBlock, MediaId, Lba, &Token, BufferSize);
> +
> +      while(Token.TransactionStatus == EFI_NOT_READY);
> +
> +      //
> +      // Read the data with 0
> +      //
> +      ReadStatus = BlockIo2->ReadBlocksEx (BlockIo2, MediaId, Lba, &BlockIo2Token, BufferSize, (VOID*)Buffer2);
> +      if (ReadStatus == EFI_SUCCESS) {
> +        for (Index1 = 0; Index1 < BufferSize; Index1++) {
> +          if (Buffer2[Index1] != 0) {
> +            IsZero = FALSE;
> +            break;
> +          }
> +        }
> +
> +        if ((EraseStatus == EFI_SUCCESS) && (IsZero == TRUE) && (EnterEvent == 1))
> +       	  AssertionType = EFI_TEST_ASSERTION_PASSED;
> +        else
> +          AssertionType = EFI_TEST_ASSERTION_FAILED;
> +
> +        StandardLib->RecordAssertion (
> +                       StandardLib,
> +                       AssertionType,
> +                       gEraseBlockBBTestFunctionAssertionGuid004,
> +                       L"EraseBlocks - EraseBlocks for testing",
> +                       L"%a:%d:EraseBlocks Status - %r, IsZero - %d, EnterEvent - %d",
> +                       __FILE__,
> +                       (UINTN)__LINE__,
> +                       Status,
> +                       IsZero,
> +                       EnterEvent
> +                       );
> +
> +      }
> +
> +      //
> +      // Restore the data with WriteBlocks and FlushBlocks
> +      //
> +      WriteStatus = BlockIo2->WriteBlocksEx (BlockIo2, MediaId, Lba, &BlockIo2Token, BufferSize, (VOID*)Buffer1);
> +      FlushStatus = EFI_SUCCESS;
> +      if (WriteCaching == TRUE)
> +        FlushStatus = BlockIo2->FlushBlocksEx (BlockIo2, &BlockIo2Token);
> +
> +      if ((WriteStatus != EFI_SUCCESS) || (FlushStatus != EFI_SUCCESS))
> +        StandardLib->RecordAssertion (
> +                       StandardLib,
> +                       EFI_TEST_ASSERTION_FAILED,
> +                       gTestGenericFailureGuid,
> +                       L"WriteBlocks/FlushBlocks - Restore for testing fail",
> +                       L"%a:%d: WriteStatus - %r, FlushStatus - %r",
> +                       __FILE__,
> +                       (UINTN)__LINE__,
> +                       WriteStatus,
> +                       FlushStatus
> +                       );
> +
> +      FreeAlignedPool(Buffer1);
> +      FreeAlignedPool(Buffer2);
> +    }
> +
> +End:
> +    if (Token.Event != NULL)
> +      gtBS->CloseEvent(Token.Event);
> +
> +  }
> +
> +   return EFI_SUCCESS;
> +}
> +
> diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/EraseBlock/BlackBoxTest/EraseBlockBBTestMain.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/EraseBlock/BlackBoxTest/EraseBlockBBTestMain.c
> index 122de2a..7953563 100644
> --- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/EraseBlock/BlackBoxTest/EraseBlockBBTestMain.c
> +++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/EraseBlock/BlackBoxTest/EraseBlockBBTestMain.c
> @@ -1,436 +1,436 @@
> -/** @file
> -
> -  Copyright 2017 Unified EFI, Inc.<BR>
> -  Copyright (c) 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
> -  http://opensource.org/licenses/bsd-license.php
> -
> -  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> -  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> -
> -**/
> -/*++
> -
> -Module Name:
> -
> -  EraseBlockBBTestMain.c
> -
> -Abstract:
> -
> -  Test Driver of Erase Block Protocol
> -
> ---*/
> -
> -
> -#include "EraseBlockBBTestMain.h"
> -
> -#define EFI_ERASE_BLOCK_TEST_GUID \
> -  {0x95A9A93E, 0xA86E, 0x4926, {0xaa, 0xef, 0x99, 0x18, 0xe7, 0x72, 0xd9, 0x87}}
> -
> -
> -//
> -// Global variables
> -//
> -EFI_HANDLE mImageHandle;
> -
> -UINT8      EnterEvent;
> -
> -
> -EFI_BB_TEST_PROTOCOL *gBBTestProtocolInterface;
> -
> -EFI_BB_TEST_PROTOCOL_FIELD gBBTestProtocolField = {
> -  EFI_ERASE_BLOCK_PROTOCOL_TEST_REVISION,
> -  EFI_ERASE_BLOCK_TEST_GUID,
> -  L"Erase Block Protocol Test",
> -  L"UEFI Erase Block Protocol Black-Box Test"
> -};
> -
> -EFI_GUID gSupportProtocolGuid[] = {
> -  EFI_STANDARD_TEST_LIBRARY_GUID,
> -  EFI_NULL_GUID
> -};
> -
> -EFI_BB_TEST_ENTRY_FIELD gBBTestEntryField[] = {
> -  {
> -    EFI_ERASE_BLOCK_PROTOCOL_TEST_ENTRY_GUID0101,
> -    L"EraseBlocksFunction",
> -    L"Function auto test for ERASE BLOCK Protocol EraseBlocks().",
> -    EFI_TEST_LEVEL_MINIMAL,
> -    gSupportProtocolGuid,
> -    EFI_TEST_CASE_AUTO,
> -    BBTestEraseBlocksFunctionTest
> -  },
> -	
> -  {
> -    EFI_ERASE_BLOCK_PROTOCOL_TEST_ENTRY_GUID0201,
> -    L"EraseBlocksConformance",
> -    L"Conformance auto test for ERASE BLOCK Protocol EraseBlocks().",
> -    EFI_TEST_LEVEL_MINIMAL,
> -    gSupportProtocolGuid,
> -    EFI_TEST_CASE_AUTO,
> -    BBTestEraseBlocksConformanceTest
> -  },
> - 0
> -};
> -
> -
> -EFI_STATUS
> -EFIAPI
> -InitializeEraseBlockBBTest (
> -  IN EFI_HANDLE                   ImageHandle,
> -  IN EFI_SYSTEM_TABLE             *SystemTable
> -  )
> -{
> -
> -  EfiInitializeTestLib (ImageHandle, SystemTable);
> -
> -  //
> -  // initialize test utility lib
> -  //
> -
> -  SctInitializeLib (ImageHandle, SystemTable);
> -
> -  mImageHandle = ImageHandle;
> -
> -  return EfiInitAndInstallBBTestInterface (
> -             &ImageHandle,
> -             &gBBTestProtocolField,
> -             gBBTestEntryField,
> -             UnloadEraseBlockBBTest,
> -             &gBBTestProtocolInterface
> -             );
> -
> -}
> -
> -
> -EFI_STATUS
> -EFIAPI
> -UnloadEraseBlockBBTest (
> -  IN EFI_HANDLE                   ImageHandle
> -  )
> -{
> -
> -  return EfiUninstallAndFreeBBTestInterface (
> -           ImageHandle,
> -           gBBTestProtocolInterface
> -           );
> -}
> -
> -
> -EFI_STATUS
> -LocateBlockIoFromEraseBlock (
> -  IN EFI_ERASE_BLOCK_PROTOCOL              *EraseBlock,
> -  IN OUT EFI_BLOCK_IO_PROTOCOL             **BlockIo,
> -  IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL    *StandardLib
> -  )
> -{
> -  EFI_STATUS                  Status;
> -  UINTN                       NoHandles, Index;
> -  EFI_HANDLE                  *HandleBuffer;
> -  EFI_ERASE_BLOCK_PROTOCOL    *OtherEraseBlock;
> -
> -  //
> -  // Locate the Handles that the EraseBlock interface is bound to
> -  //
> -  HandleBuffer = NULL;
> -  Status = gtBS->LocateHandleBuffer (
> -                   ByProtocol,
> -                   &gBlackBoxEfiEraseBlockProtocolGuid,
> -                   NULL,
> -                   &NoHandles,
> -                   &HandleBuffer
> -                   );
> -  if (EFI_ERROR (Status)) {
> -    StandardLib->RecordAssertion (
> -                   StandardLib,
> -                   EFI_TEST_ASSERTION_FAILED,
> -                   gTestGenericFailureGuid,
> -                   L"BS.LocateHandle - LocateHandle",
> -                   L"%a:%d:Status - %r",
> -                   __FILE__,
> -                   (UINTN)__LINE__,
> -                   Status
> -                   );
> -    return Status;
> -  }
> -
> -  if (NoHandles <= 0 || HandleBuffer == NULL) {
> -    StandardLib->RecordAssertion (
> -                   StandardLib,
> -                   EFI_TEST_ASSERTION_FAILED,
> -                   gTestGenericFailureGuid,
> -                   L"BS.LocateHandle - LocateHandle",
> -                   L"%a:%d:Device Error",
> -                   __FILE__,
> -                   (UINTN)__LINE__
> -                   );
> -    return EFI_DEVICE_ERROR;
> -  }
> -
> -  //
> -  // Find the exact handle that EraseBlock bound to
> -  //
> -  for (Index = 0; Index < NoHandles; Index++) {
> -      Status = gtBS->HandleProtocol (
> -                       HandleBuffer[Index],
> -                       &gBlackBoxEfiEraseBlockProtocolGuid,
> -                       (VOID **) &OtherEraseBlock
> -                       );
> -    if (EFI_ERROR (Status)) {
> -      StandardLib->RecordAssertion (
> -                     StandardLib,
> -                     EFI_TEST_ASSERTION_FAILED,
> -                     gTestGenericFailureGuid,
> -                     L"BS.HandleProtocol - HandleProtocol",
> -                     L"%a:%d:Status - %r",
> -                     __FILE__,
> -                     (UINTN)__LINE__,
> -                     Status
> -                     );
> -
> -      gtBS->FreePool (HandleBuffer);
> -      return Status;
> -      }
> -    if (OtherEraseBlock == EraseBlock) {
> -      break;
> -    }
> -  }
> -
> -  //
> -  // Locate the BlockIo Protocol bound to EraseBlock Protocol
> -  //
> -  if (Index >= NoHandles) {
> -    //
> -    // No Handle Found!!
> -    //
> -    gtBS->FreePool (HandleBuffer);
> -    return EFI_DEVICE_ERROR;
> -  }
> -
> -  Status = gtBS->HandleProtocol (
> -                   HandleBuffer[Index],
> -                   &gBlackBoxEfiBlockIoProtocolGuid,
> -                   (VOID **) BlockIo
> -                   );
> -
> -  gtBS->FreePool (HandleBuffer);
> -  return Status;
> -}
> -
> -
> -EFI_STATUS
> -LocateBlockIo2FromEraseBlock (
> -  IN EFI_ERASE_BLOCK_PROTOCOL              *EraseBlock,
> -  IN OUT EFI_BLOCK_IO2_PROTOCOL            **BlockIo2,
> -  IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL    *StandardLib
> -  )
> -{
> -  EFI_STATUS                  Status;
> -  UINTN                       NoHandles, Index;
> -  EFI_HANDLE                  *HandleBuffer;
> -  EFI_ERASE_BLOCK_PROTOCOL    *OtherEraseBlock;
> -
> -  //
> -  // Locate the Handles that the EraseBlock interface is bound to
> -  //
> -  HandleBuffer = NULL;
> -  Status = gtBS->LocateHandleBuffer (
> -                   ByProtocol,
> -                   &gBlackBoxEfiEraseBlockProtocolGuid,
> -                   NULL,
> -                   &NoHandles,
> -                   &HandleBuffer
> -                   );
> -  if (EFI_ERROR (Status)) {
> -    StandardLib->RecordAssertion (
> -                   StandardLib,
> -                   EFI_TEST_ASSERTION_FAILED,
> -                   gTestGenericFailureGuid,
> -                   L"BS.LocateHandle - LocateHandle",
> -                   L"%a:%d:Status - %r",
> -                   __FILE__,
> -                   (UINTN)__LINE__,
> -                   Status
> -                   );
> -    return Status;
> -  }
> -
> -  if (NoHandles <= 0 || HandleBuffer == NULL) {
> -    StandardLib->RecordAssertion (
> -                   StandardLib,
> -                   EFI_TEST_ASSERTION_FAILED,
> -                   gTestGenericFailureGuid,
> -                   L"BS.LocateHandle - LocateHandle",
> -                   L"%a:%d:Device Error",
> -                   __FILE__,
> -                   (UINTN)__LINE__
> -                   );
> -    return EFI_DEVICE_ERROR;
> -  }
> -
> -  //
> -  // Find the exact handle that EraseBlock bound to
> -  //
> -  for (Index = 0; Index < NoHandles; Index++) {
> -      Status = gtBS->HandleProtocol (
> -                       HandleBuffer[Index],
> -                       &gBlackBoxEfiEraseBlockProtocolGuid,
> -                       (VOID **) &OtherEraseBlock
> -                       );
> -    if (EFI_ERROR (Status)) {
> -      StandardLib->RecordAssertion (
> -                     StandardLib,
> -                     EFI_TEST_ASSERTION_FAILED,
> -                     gTestGenericFailureGuid,
> -                     L"BS.HandleProtocol - HandleProtocol",
> -                     L"%a:%d:Status - %r",
> -                     __FILE__,
> -                     (UINTN)__LINE__,
> -                     Status
> -                     );
> -
> -      gtBS->FreePool (HandleBuffer);
> -      return Status;
> -      }
> -    if (OtherEraseBlock == EraseBlock) {
> -      break;
> -    }
> -  }
> -
> -  //
> -  // Locate the BlockIo2 Protocol bound to EraseBlock Protocol
> -  //
> -  if (Index >= NoHandles) {
> -    //
> -    // No Handle Found!!
> -    //
> -    gtBS->FreePool (HandleBuffer);
> -    return EFI_DEVICE_ERROR;
> -  }
> -
> -  Status = gtBS->HandleProtocol (
> -                   HandleBuffer[Index],
> -                   &gBlackBoxEfiBlockIo2ProtocolGuid,
> -                   (VOID **) BlockIo2
> -                   );
> -
> -  gtBS->FreePool (HandleBuffer);
> -  return Status;
> -}
> -
> -
> -/**
> -  Allocates a buffer of a certain pool type at a specified alignment.
> -
> -  Allocates the number bytes specified by AllocationSize of a certain pool type with an alignment
> -  specified by Alignment.  The allocated buffer is returned.  If AllocationSize is 0, then a valid
> -  buffer of 0 size is returned.  If there is not enough memory at the specified alignment remaining
> -  to satisfy the request, then NULL is returned.
> -  If Alignment is not a power of two and Alignment is not zero, then ASSERT().
> -
> -  @param  PoolType              The type of pool to allocate.
> -  @param  AllocationSize        The number of bytes to allocate.
> -  @param  Alignment             The requested alignment of the allocation.  Must be a power of two.                            If Alignment is zero, then byte alignment is used.
> -                                If Alignment is zero, then byte alignment is used.
> -
> -  @return A pointer to the allocated buffer or NULL if allocation fails.
> -
> -**/
> -VOID *
> -AllocateAlignedPool (
> -  IN EFI_MEMORY_TYPE  PoolType,
> -  IN UINTN            AllocationSize,
> -  IN UINTN            Alignment
> -  )
> -{
> -  EFI_STATUS  Status;
> -  VOID        *RawAddress;
> -  UINTN       AlignedAddress;
> -  UINTN       AlignmentMask;
> -  UINTN       OverAllocationSize;
> -  UINTN       RealAllocationSize;
> -  VOID        **FreePointer;
> -
> -  //
> -  // Alignment must be a power of two or zero.
> -  //
> -  ASSERT ((Alignment & (Alignment - 1)) == 0);
> -
> -  if (Alignment == 0) {
> -    AlignmentMask = Alignment;
> -  } else {
> -    AlignmentMask = Alignment - 1;
> -  }
> -  //
> -  // Calculate the extra memory size, over-allocate memory pool and get the aligned memory address.
> -  //
> -  OverAllocationSize  = sizeof (RawAddress) + AlignmentMask;
> -  RealAllocationSize  = AllocationSize + OverAllocationSize;
> -  //
> -  // Make sure that AllocationSize plus OverAllocationSize does not overflow.
> -  //
> -  ASSERT (RealAllocationSize > AllocationSize);
> -
> -  Status = gtBS->AllocatePool (PoolType, RealAllocationSize, (VOID **) &RawAddress);
> -  if (EFI_ERROR (Status)) {
> -    return NULL;
> -  }
> -
> -  AlignedAddress      = ((UINTN) RawAddress + OverAllocationSize) & ~AlignmentMask;
> -  //
> -  // Save the original memory address just before the aligned address.
> -  //
> -  FreePointer         = (VOID **)(AlignedAddress - sizeof (RawAddress));
> -  *FreePointer        = RawAddress;
> -
> -  return (VOID *) AlignedAddress;
> -}
> -
> -
> -/**
> -  Frees a buffer that was previously allocated with one of the aligned pool allocation functions
> -  in the Memory Allocation Library.
> -
> -  Frees the buffer specified by Buffer.  Buffer must have been allocated on a previous call to the
> -  aligned pool allocation services of the Memory Allocation Library.
> -  If Buffer was not allocated with an aligned pool allocation function in the Memory Allocation
> -  Library, then ASSERT().
> -
> -  @param  Buffer                Pointer to the buffer to free.
> -
> -  @return free aligned pool function status
> -
> -**/
> -EFI_STATUS
> -FreeAlignedPool (
> -  IN VOID   *Buffer
> -  )
> -{
> -  VOID        *RawAddress;
> -  VOID        **FreePointer;
> -  EFI_STATUS  Status;
> -
> -  //
> -  // Get the pre-saved original address in the over-allocate pool.
> -  //
> -  FreePointer = (VOID **)((UINTN) Buffer - sizeof (RawAddress));
> -  RawAddress  = *FreePointer;
> -
> -  Status = gtBS->FreePool (RawAddress);
> -
> -  return Status;
> -}
> -
> -VOID
> -NotifyFunction (
> -  EFI_EVENT    Event,
> -  VOID         *Context
> -  )
> -{
> -  EnterEvent = 1;
> -  return;
> -}
> -
> +/** @file
> +
> +  Copyright 2017 Unified EFI, Inc.<BR>
> +  Copyright (c) 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
> +  http://opensource.org/licenses/bsd-license.php
> +
> +  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> +  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> +
> +**/
> +/*++
> +
> +Module Name:
> +
> +  EraseBlockBBTestMain.c
> +
> +Abstract:
> +
> +  Test Driver of Erase Block Protocol
> +
> +--*/
> +
> +
> +#include "EraseBlockBBTestMain.h"
> +
> +#define EFI_ERASE_BLOCK_TEST_GUID \
> +  {0x95A9A93E, 0xA86E, 0x4926, {0xaa, 0xef, 0x99, 0x18, 0xe7, 0x72, 0xd9, 0x87}}
> +
> +
> +//
> +// Global variables
> +//
> +EFI_HANDLE mImageHandle;
> +
> +UINT8      EnterEvent;
> +
> +
> +EFI_BB_TEST_PROTOCOL *gBBTestProtocolInterface;
> +
> +EFI_BB_TEST_PROTOCOL_FIELD gBBTestProtocolField = {
> +  EFI_ERASE_BLOCK_PROTOCOL_TEST_REVISION,
> +  EFI_ERASE_BLOCK_TEST_GUID,
> +  L"Erase Block Protocol Test",
> +  L"UEFI Erase Block Protocol Black-Box Test"
> +};
> +
> +EFI_GUID gSupportProtocolGuid[] = {
> +  EFI_STANDARD_TEST_LIBRARY_GUID,
> +  EFI_NULL_GUID
> +};
> +
> +EFI_BB_TEST_ENTRY_FIELD gBBTestEntryField[] = {
> +  {
> +    EFI_ERASE_BLOCK_PROTOCOL_TEST_ENTRY_GUID0101,
> +    L"EraseBlocksFunction",
> +    L"Function auto test for ERASE BLOCK Protocol EraseBlocks().",
> +    EFI_TEST_LEVEL_MINIMAL,
> +    gSupportProtocolGuid,
> +    EFI_TEST_CASE_AUTO,
> +    BBTestEraseBlocksFunctionTest
> +  },
> +	
> +  {
> +    EFI_ERASE_BLOCK_PROTOCOL_TEST_ENTRY_GUID0201,
> +    L"EraseBlocksConformance",
> +    L"Conformance auto test for ERASE BLOCK Protocol EraseBlocks().",
> +    EFI_TEST_LEVEL_MINIMAL,
> +    gSupportProtocolGuid,
> +    EFI_TEST_CASE_AUTO,
> +    BBTestEraseBlocksConformanceTest
> +  },
> + 0
> +};
> +
> +
> +EFI_STATUS
> +EFIAPI
> +InitializeEraseBlockBBTest (
> +  IN EFI_HANDLE                   ImageHandle,
> +  IN EFI_SYSTEM_TABLE             *SystemTable
> +  )
> +{
> +
> +  EfiInitializeTestLib (ImageHandle, SystemTable);
> +
> +  //
> +  // initialize test utility lib
> +  //
> +
> +  SctInitializeLib (ImageHandle, SystemTable);
> +
> +  mImageHandle = ImageHandle;
> +
> +  return EfiInitAndInstallBBTestInterface (
> +             &ImageHandle,
> +             &gBBTestProtocolField,
> +             gBBTestEntryField,
> +             UnloadEraseBlockBBTest,
> +             &gBBTestProtocolInterface
> +             );
> +
> +}
> +
> +
> +EFI_STATUS
> +EFIAPI
> +UnloadEraseBlockBBTest (
> +  IN EFI_HANDLE                   ImageHandle
> +  )
> +{
> +
> +  return EfiUninstallAndFreeBBTestInterface (
> +           ImageHandle,
> +           gBBTestProtocolInterface
> +           );
> +}
> +
> +
> +EFI_STATUS
> +LocateBlockIoFromEraseBlock (
> +  IN EFI_ERASE_BLOCK_PROTOCOL              *EraseBlock,
> +  IN OUT EFI_BLOCK_IO_PROTOCOL             **BlockIo,
> +  IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL    *StandardLib
> +  )
> +{
> +  EFI_STATUS                  Status;
> +  UINTN                       NoHandles, Index;
> +  EFI_HANDLE                  *HandleBuffer;
> +  EFI_ERASE_BLOCK_PROTOCOL    *OtherEraseBlock;
> +
> +  //
> +  // Locate the Handles that the EraseBlock interface is bound to
> +  //
> +  HandleBuffer = NULL;
> +  Status = gtBS->LocateHandleBuffer (
> +                   ByProtocol,
> +                   &gBlackBoxEfiEraseBlockProtocolGuid,
> +                   NULL,
> +                   &NoHandles,
> +                   &HandleBuffer
> +                   );
> +  if (EFI_ERROR (Status)) {
> +    StandardLib->RecordAssertion (
> +                   StandardLib,
> +                   EFI_TEST_ASSERTION_FAILED,
> +                   gTestGenericFailureGuid,
> +                   L"BS.LocateHandle - LocateHandle",
> +                   L"%a:%d:Status - %r",
> +                   __FILE__,
> +                   (UINTN)__LINE__,
> +                   Status
> +                   );
> +    return Status;
> +  }
> +
> +  if (NoHandles <= 0 || HandleBuffer == NULL) {
> +    StandardLib->RecordAssertion (
> +                   StandardLib,
> +                   EFI_TEST_ASSERTION_FAILED,
> +                   gTestGenericFailureGuid,
> +                   L"BS.LocateHandle - LocateHandle",
> +                   L"%a:%d:Device Error",
> +                   __FILE__,
> +                   (UINTN)__LINE__
> +                   );
> +    return EFI_DEVICE_ERROR;
> +  }
> +
> +  //
> +  // Find the exact handle that EraseBlock bound to
> +  //
> +  for (Index = 0; Index < NoHandles; Index++) {
> +      Status = gtBS->HandleProtocol (
> +                       HandleBuffer[Index],
> +                       &gBlackBoxEfiEraseBlockProtocolGuid,
> +                       (VOID **) &OtherEraseBlock
> +                       );
> +    if (EFI_ERROR (Status)) {
> +      StandardLib->RecordAssertion (
> +                     StandardLib,
> +                     EFI_TEST_ASSERTION_FAILED,
> +                     gTestGenericFailureGuid,
> +                     L"BS.HandleProtocol - HandleProtocol",
> +                     L"%a:%d:Status - %r",
> +                     __FILE__,
> +                     (UINTN)__LINE__,
> +                     Status
> +                     );
> +
> +      gtBS->FreePool (HandleBuffer);
> +      return Status;
> +      }
> +    if (OtherEraseBlock == EraseBlock) {
> +      break;
> +    }
> +  }
> +
> +  //
> +  // Locate the BlockIo Protocol bound to EraseBlock Protocol
> +  //
> +  if (Index >= NoHandles) {
> +    //
> +    // No Handle Found!!
> +    //
> +    gtBS->FreePool (HandleBuffer);
> +    return EFI_DEVICE_ERROR;
> +  }
> +
> +  Status = gtBS->HandleProtocol (
> +                   HandleBuffer[Index],
> +                   &gBlackBoxEfiBlockIoProtocolGuid,
> +                   (VOID **) BlockIo
> +                   );
> +
> +  gtBS->FreePool (HandleBuffer);
> +  return Status;
> +}
> +
> +
> +EFI_STATUS
> +LocateBlockIo2FromEraseBlock (
> +  IN EFI_ERASE_BLOCK_PROTOCOL              *EraseBlock,
> +  IN OUT EFI_BLOCK_IO2_PROTOCOL            **BlockIo2,
> +  IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL    *StandardLib
> +  )
> +{
> +  EFI_STATUS                  Status;
> +  UINTN                       NoHandles, Index;
> +  EFI_HANDLE                  *HandleBuffer;
> +  EFI_ERASE_BLOCK_PROTOCOL    *OtherEraseBlock;
> +
> +  //
> +  // Locate the Handles that the EraseBlock interface is bound to
> +  //
> +  HandleBuffer = NULL;
> +  Status = gtBS->LocateHandleBuffer (
> +                   ByProtocol,
> +                   &gBlackBoxEfiEraseBlockProtocolGuid,
> +                   NULL,
> +                   &NoHandles,
> +                   &HandleBuffer
> +                   );
> +  if (EFI_ERROR (Status)) {
> +    StandardLib->RecordAssertion (
> +                   StandardLib,
> +                   EFI_TEST_ASSERTION_FAILED,
> +                   gTestGenericFailureGuid,
> +                   L"BS.LocateHandle - LocateHandle",
> +                   L"%a:%d:Status - %r",
> +                   __FILE__,
> +                   (UINTN)__LINE__,
> +                   Status
> +                   );
> +    return Status;
> +  }
> +
> +  if (NoHandles <= 0 || HandleBuffer == NULL) {
> +    StandardLib->RecordAssertion (
> +                   StandardLib,
> +                   EFI_TEST_ASSERTION_FAILED,
> +                   gTestGenericFailureGuid,
> +                   L"BS.LocateHandle - LocateHandle",
> +                   L"%a:%d:Device Error",
> +                   __FILE__,
> +                   (UINTN)__LINE__
> +                   );
> +    return EFI_DEVICE_ERROR;
> +  }
> +
> +  //
> +  // Find the exact handle that EraseBlock bound to
> +  //
> +  for (Index = 0; Index < NoHandles; Index++) {
> +      Status = gtBS->HandleProtocol (
> +                       HandleBuffer[Index],
> +                       &gBlackBoxEfiEraseBlockProtocolGuid,
> +                       (VOID **) &OtherEraseBlock
> +                       );
> +    if (EFI_ERROR (Status)) {
> +      StandardLib->RecordAssertion (
> +                     StandardLib,
> +                     EFI_TEST_ASSERTION_FAILED,
> +                     gTestGenericFailureGuid,
> +                     L"BS.HandleProtocol - HandleProtocol",
> +                     L"%a:%d:Status - %r",
> +                     __FILE__,
> +                     (UINTN)__LINE__,
> +                     Status
> +                     );
> +
> +      gtBS->FreePool (HandleBuffer);
> +      return Status;
> +      }
> +    if (OtherEraseBlock == EraseBlock) {
> +      break;
> +    }
> +  }
> +
> +  //
> +  // Locate the BlockIo2 Protocol bound to EraseBlock Protocol
> +  //
> +  if (Index >= NoHandles) {
> +    //
> +    // No Handle Found!!
> +    //
> +    gtBS->FreePool (HandleBuffer);
> +    return EFI_DEVICE_ERROR;
> +  }
> +
> +  Status = gtBS->HandleProtocol (
> +                   HandleBuffer[Index],
> +                   &gBlackBoxEfiBlockIo2ProtocolGuid,
> +                   (VOID **) BlockIo2
> +                   );
> +
> +  gtBS->FreePool (HandleBuffer);
> +  return Status;
> +}
> +
> +
> +/**
> +  Allocates a buffer of a certain pool type at a specified alignment.
> +
> +  Allocates the number bytes specified by AllocationSize of a certain pool type with an alignment
> +  specified by Alignment.  The allocated buffer is returned.  If AllocationSize is 0, then a valid
> +  buffer of 0 size is returned.  If there is not enough memory at the specified alignment remaining
> +  to satisfy the request, then NULL is returned.
> +  If Alignment is not a power of two and Alignment is not zero, then ASSERT().
> +
> +  @param  PoolType              The type of pool to allocate.
> +  @param  AllocationSize        The number of bytes to allocate.
> +  @param  Alignment             The requested alignment of the allocation.  Must be a power of two.                            If Alignment is zero, then byte alignment is used.
> +                                If Alignment is zero, then byte alignment is used.
> +
> +  @return A pointer to the allocated buffer or NULL if allocation fails.
> +
> +**/
> +VOID *
> +AllocateAlignedPool (
> +  IN EFI_MEMORY_TYPE  PoolType,
> +  IN UINTN            AllocationSize,
> +  IN UINTN            Alignment
> +  )
> +{
> +  EFI_STATUS  Status;
> +  VOID        *RawAddress;
> +  UINTN       AlignedAddress;
> +  UINTN       AlignmentMask;
> +  UINTN       OverAllocationSize;
> +  UINTN       RealAllocationSize;
> +  VOID        **FreePointer;
> +
> +  //
> +  // Alignment must be a power of two or zero.
> +  //
> +  ASSERT ((Alignment & (Alignment - 1)) == 0);
> +
> +  if (Alignment == 0) {
> +    AlignmentMask = Alignment;
> +  } else {
> +    AlignmentMask = Alignment - 1;
> +  }
> +  //
> +  // Calculate the extra memory size, over-allocate memory pool and get the aligned memory address.
> +  //
> +  OverAllocationSize  = sizeof (RawAddress) + AlignmentMask;
> +  RealAllocationSize  = AllocationSize + OverAllocationSize;
> +  //
> +  // Make sure that AllocationSize plus OverAllocationSize does not overflow.
> +  //
> +  ASSERT (RealAllocationSize > AllocationSize);
> +
> +  Status = gtBS->AllocatePool (PoolType, RealAllocationSize, (VOID **) &RawAddress);
> +  if (EFI_ERROR (Status)) {
> +    return NULL;
> +  }
> +
> +  AlignedAddress      = ((UINTN) RawAddress + OverAllocationSize) & ~AlignmentMask;
> +  //
> +  // Save the original memory address just before the aligned address.
> +  //
> +  FreePointer         = (VOID **)(AlignedAddress - sizeof (RawAddress));
> +  *FreePointer        = RawAddress;
> +
> +  return (VOID *) AlignedAddress;
> +}
> +
> +
> +/**
> +  Frees a buffer that was previously allocated with one of the aligned pool allocation functions
> +  in the Memory Allocation Library.
> +
> +  Frees the buffer specified by Buffer.  Buffer must have been allocated on a previous call to the
> +  aligned pool allocation services of the Memory Allocation Library.
> +  If Buffer was not allocated with an aligned pool allocation function in the Memory Allocation
> +  Library, then ASSERT().
> +
> +  @param  Buffer                Pointer to the buffer to free.
> +
> +  @return free aligned pool function status
> +
> +**/
> +EFI_STATUS
> +FreeAlignedPool (
> +  IN VOID   *Buffer
> +  )
> +{
> +  VOID        *RawAddress;
> +  VOID        **FreePointer;
> +  EFI_STATUS  Status;
> +
> +  //
> +  // Get the pre-saved original address in the over-allocate pool.
> +  //
> +  FreePointer = (VOID **)((UINTN) Buffer - sizeof (RawAddress));
> +  RawAddress  = *FreePointer;
> +
> +  Status = gtBS->FreePool (RawAddress);
> +
> +  return Status;
> +}
> +
> +VOID
> +NotifyFunction (
> +  EFI_EVENT    Event,
> +  VOID         *Context
> +  )
> +{
> +  EnterEvent = 1;
> +  return;
> +}
> +
> diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/EraseBlock/BlackBoxTest/EraseBlockBBTestMain.h b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/EraseBlock/BlackBoxTest/EraseBlockBBTestMain.h
> index 28f79dd..4b569d3 100644
> --- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/EraseBlock/BlackBoxTest/EraseBlockBBTestMain.h
> +++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/EraseBlock/BlackBoxTest/EraseBlockBBTestMain.h
> @@ -1,126 +1,126 @@
> -/** @file
> -
> -  Copyright 2017 Unified EFI, Inc.<BR>
> -  Copyright (c) 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
> -  http://opensource.org/licenses/bsd-license.php
> -
> -  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> -  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> -
> -**/
> -/*++
> -
> -Module Name:
> -
> -  EraseBlockBBTestMain.h
> -
> -Abstract:
> -
> -  Test Driver of Erase Block Protocol header file
> -
> ---*/
> -
> -#ifndef _ERASE_BLOCK_BB_TEST_MAIN
> -#define _ERASE_BLOCK_BB_TEST_MAIN
> -
> -#include <Efi.h>
> -#include <Library/EfiTestLib.h>
> -#include <SctLib.h>
> -#include <UEFI/Protocol/EraseBlock.h>
> -#include <UEFI/Protocol/BlockIo.h>
> -#include <UEFI/Protocol/BlockIo2.h>
> -#include "Guid.h"
> -
> -
> -#define EFI_ERASE_BLOCK_PROTOCOL_TEST_REVISION    0x00010000
> -
> -//
> -// Entry GUIDs for Func Test
> -//
> -#define EFI_ERASE_BLOCK_PROTOCOL_TEST_ENTRY_GUID0101 \
> -{ 0x2e54c9ba, 0xf0e0, 0x4cef, { 0x8c, 0xe6, 0x18, 0x15, 0x79, 0xfe, 0x5f, 0xc }}
> -
> -//
> -// Entry GUIDs for Conf Test
> -//
> -#define EFI_ERASE_BLOCK_PROTOCOL_TEST_ENTRY_GUID0201 \
> -{ 0xd0a834d6, 0xad31, 0x43d2, { 0xa7, 0x6a, 0x9f, 0x1a, 0xd6, 0x9e, 0x6f, 0x15 }}
> -
> -
> -#define MINIMUM(a,b)                        ((a)<(b)?(a):(b))
> -#define MAX_NUMBER_OF_READ_BLOCK_BUFFER     20
> -
> -//
> -//
> -//
> -EFI_STATUS
> -EFIAPI
> -InitializeEraseBlockBBTest (
> -  IN EFI_HANDLE                   ImageHandle,
> -  IN EFI_SYSTEM_TABLE             *SystemTable
> -  );
> -
> -EFI_STATUS
> -EFIAPI
> -UnloadEraseBlockBBTest (
> -  IN EFI_HANDLE                   ImageHandle
> -  );
> -
> -//
> -//Test Cases
> -//
> -EFI_STATUS
> -BBTestEraseBlocksConformanceTest (
> -  IN EFI_BB_TEST_PROTOCOL       *This,
> -  IN VOID                       *ClientInterface,
> -  IN EFI_TEST_LEVEL             TestLevel,
> -  IN EFI_HANDLE                 SupportHandle
> -  );
> -
> -
> -EFI_STATUS
> -BBTestEraseBlocksFunctionTest (
> -  IN EFI_BB_TEST_PROTOCOL       *This,
> -  IN VOID                       *ClientInterface,
> -  IN EFI_TEST_LEVEL             TestLevel,
> -  IN EFI_HANDLE                 SupportHandle
> -  );
> -
> -EFI_STATUS
> -LocateBlockIoFromEraseBlock (
> -  IN EFI_ERASE_BLOCK_PROTOCOL              *EraseBlock,
> -  IN OUT EFI_BLOCK_IO_PROTOCOL             **BlockIo,
> -  IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL    *StandardLib
> -  );
> -
> -EFI_STATUS
> -LocateBlockIo2FromEraseBlock (
> -  IN EFI_ERASE_BLOCK_PROTOCOL              *EraseBlock,
> -  IN OUT EFI_BLOCK_IO2_PROTOCOL            **BlockIo2,
> -  IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL    *StandardLib
> -  );
> -
> -VOID
> -NotifyFunction (
> -  EFI_EVENT    Event,
> -  VOID         *Context
> -  );
> -
> -VOID *
> -AllocateAlignedPool (
> -  IN EFI_MEMORY_TYPE  PoolType,
> -  IN UINTN            AllocationSize,
> -  IN UINTN            Alignment
> -  );
> -
> -EFI_STATUS
> -FreeAlignedPool (
> -  IN VOID   *Buffer
> -  );
> -
> -#endif
> -
> +/** @file
> +
> +  Copyright 2017 Unified EFI, Inc.<BR>
> +  Copyright (c) 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
> +  http://opensource.org/licenses/bsd-license.php
> +
> +  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> +  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> +
> +**/
> +/*++
> +
> +Module Name:
> +
> +  EraseBlockBBTestMain.h
> +
> +Abstract:
> +
> +  Test Driver of Erase Block Protocol header file
> +
> +--*/
> +
> +#ifndef _ERASE_BLOCK_BB_TEST_MAIN
> +#define _ERASE_BLOCK_BB_TEST_MAIN
> +
> +#include <Efi.h>
> +#include <Library/EfiTestLib.h>
> +#include <SctLib.h>
> +#include <UEFI/Protocol/EraseBlock.h>
> +#include <UEFI/Protocol/BlockIo.h>
> +#include <UEFI/Protocol/BlockIo2.h>
> +#include "Guid.h"
> +
> +
> +#define EFI_ERASE_BLOCK_PROTOCOL_TEST_REVISION    0x00010000
> +
> +//
> +// Entry GUIDs for Func Test
> +//
> +#define EFI_ERASE_BLOCK_PROTOCOL_TEST_ENTRY_GUID0101 \
> +{ 0x2e54c9ba, 0xf0e0, 0x4cef, { 0x8c, 0xe6, 0x18, 0x15, 0x79, 0xfe, 0x5f, 0xc }}
> +
> +//
> +// Entry GUIDs for Conf Test
> +//
> +#define EFI_ERASE_BLOCK_PROTOCOL_TEST_ENTRY_GUID0201 \
> +{ 0xd0a834d6, 0xad31, 0x43d2, { 0xa7, 0x6a, 0x9f, 0x1a, 0xd6, 0x9e, 0x6f, 0x15 }}
> +
> +
> +#define MINIMUM(a,b)                        ((a)<(b)?(a):(b))
> +#define MAX_NUMBER_OF_READ_BLOCK_BUFFER     20
> +
> +//
> +//
> +//
> +EFI_STATUS
> +EFIAPI
> +InitializeEraseBlockBBTest (
> +  IN EFI_HANDLE                   ImageHandle,
> +  IN EFI_SYSTEM_TABLE             *SystemTable
> +  );
> +
> +EFI_STATUS
> +EFIAPI
> +UnloadEraseBlockBBTest (
> +  IN EFI_HANDLE                   ImageHandle
> +  );
> +
> +//
> +//Test Cases
> +//
> +EFI_STATUS
> +BBTestEraseBlocksConformanceTest (
> +  IN EFI_BB_TEST_PROTOCOL       *This,
> +  IN VOID                       *ClientInterface,
> +  IN EFI_TEST_LEVEL             TestLevel,
> +  IN EFI_HANDLE                 SupportHandle
> +  );
> +
> +
> +EFI_STATUS
> +BBTestEraseBlocksFunctionTest (
> +  IN EFI_BB_TEST_PROTOCOL       *This,
> +  IN VOID                       *ClientInterface,
> +  IN EFI_TEST_LEVEL             TestLevel,
> +  IN EFI_HANDLE                 SupportHandle
> +  );
> +
> +EFI_STATUS
> +LocateBlockIoFromEraseBlock (
> +  IN EFI_ERASE_BLOCK_PROTOCOL              *EraseBlock,
> +  IN OUT EFI_BLOCK_IO_PROTOCOL             **BlockIo,
> +  IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL    *StandardLib
> +  );
> +
> +EFI_STATUS
> +LocateBlockIo2FromEraseBlock (
> +  IN EFI_ERASE_BLOCK_PROTOCOL              *EraseBlock,
> +  IN OUT EFI_BLOCK_IO2_PROTOCOL            **BlockIo2,
> +  IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL    *StandardLib
> +  );
> +
> +VOID
> +NotifyFunction (
> +  EFI_EVENT    Event,
> +  VOID         *Context
> +  );
> +
> +VOID *
> +AllocateAlignedPool (
> +  IN EFI_MEMORY_TYPE  PoolType,
> +  IN UINTN            AllocationSize,
> +  IN UINTN            Alignment
> +  );
> +
> +EFI_STATUS
> +FreeAlignedPool (
> +  IN VOID   *Buffer
> +  );
> +
> +#endif
> +
> diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/EraseBlock/BlackBoxTest/Guid.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/EraseBlock/BlackBoxTest/Guid.c
> index 011c6ee..cfc3070 100644
> --- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/EraseBlock/BlackBoxTest/Guid.c
> +++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/EraseBlock/BlackBoxTest/Guid.c
> @@ -1,41 +1,43 @@
> -/** @file
> -
> -  Copyright 2017 Unified EFI, Inc.<BR>
> -  Copyright (c) 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
> -  http://opensource.org/licenses/bsd-license.php
> -
> -  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> -  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> -
> -**/
> -/*++
> -
> - Module Name:
> -
> -   Guid.c
> -
> - Abstract:
> -
> -   GUIDs auto-generated for EFI test assertion.
> -
> ---*/
> -
> -#include "EraseBlockBBTestMain.h"
> -
> -EFI_GUID gEraseBlockBBTestConformanceAssertionGuid001 = EFI_TEST_ERASEBLOCKBBTESTCONFORMANCE_ASSERTION_001_GUID;
> -EFI_GUID gEraseBlockBBTestConformanceAssertionGuid002 = EFI_TEST_ERASEBLOCKBBTESTCONFORMANCE_ASSERTION_002_GUID;
> -EFI_GUID gEraseBlockBBTestConformanceAssertionGuid003 = EFI_TEST_ERASEBLOCKBBTESTCONFORMANCE_ASSERTION_003_GUID;
> -EFI_GUID gEraseBlockBBTestConformanceAssertionGuid004 = EFI_TEST_ERASEBLOCKBBTESTCONFORMANCE_ASSERTION_004_GUID;
> -EFI_GUID gEraseBlockBBTestConformanceAssertionGuid005 = EFI_TEST_ERASEBLOCKBBTESTCONFORMANCE_ASSERTION_005_GUID;
> -EFI_GUID gEraseBlockBBTestConformanceAssertionGuid006 = EFI_TEST_ERASEBLOCKBBTESTCONFORMANCE_ASSERTION_006_GUID;
> -EFI_GUID gEraseBlockBBTestConformanceAssertionGuid007 = EFI_TEST_ERASEBLOCKBBTESTCONFORMANCE_ASSERTION_007_GUID;
> -EFI_GUID gEraseBlockBBTestConformanceAssertionGuid008 = EFI_TEST_ERASEBLOCKBBTESTCONFORMANCE_ASSERTION_008_GUID;
> -EFI_GUID gEraseBlockBBTestConformanceAssertionGuid009 = EFI_TEST_ERASEBLOCKBBTESTCONFORMANCE_ASSERTION_009_GUID;
> -
> -
> -EFI_GUID gEraseBlockBBTestFunctionAssertionGuid001 = EFI_TEST_ERASEBLOCKBBTESTFUNCTION_ASSERTION_001_GUID;
> -EFI_GUID gEraseBlockBBTestFunctionAssertionGuid002 = EFI_TEST_ERASEBLOCKBBTESTFUNCTION_ASSERTION_002_GUID;
> \ No newline at end of file
> +/** @file
> +
> +  Copyright 2017 Unified EFI, Inc.<BR>
> +  Copyright (c) 2017 - 2018, 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
> +  http://opensource.org/licenses/bsd-license.php
> +
> +  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> +  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> +
> +**/
> +/*++
> +
> + Module Name:
> +
> +   Guid.c
> +
> + Abstract:
> +
> +   GUIDs auto-generated for EFI test assertion.
> +
> +--*/
> +
> +#include "EraseBlockBBTestMain.h"
> +
> +EFI_GUID gEraseBlockBBTestConformanceAssertionGuid001 = EFI_TEST_ERASEBLOCKBBTESTCONFORMANCE_ASSERTION_001_GUID;
> +EFI_GUID gEraseBlockBBTestConformanceAssertionGuid002 = EFI_TEST_ERASEBLOCKBBTESTCONFORMANCE_ASSERTION_002_GUID;
> +EFI_GUID gEraseBlockBBTestConformanceAssertionGuid003 = EFI_TEST_ERASEBLOCKBBTESTCONFORMANCE_ASSERTION_003_GUID;
> +EFI_GUID gEraseBlockBBTestConformanceAssertionGuid004 = EFI_TEST_ERASEBLOCKBBTESTCONFORMANCE_ASSERTION_004_GUID;
> +EFI_GUID gEraseBlockBBTestConformanceAssertionGuid005 = EFI_TEST_ERASEBLOCKBBTESTCONFORMANCE_ASSERTION_005_GUID;
> +EFI_GUID gEraseBlockBBTestConformanceAssertionGuid006 = EFI_TEST_ERASEBLOCKBBTESTCONFORMANCE_ASSERTION_006_GUID;
> +EFI_GUID gEraseBlockBBTestConformanceAssertionGuid007 = EFI_TEST_ERASEBLOCKBBTESTCONFORMANCE_ASSERTION_007_GUID;
> +EFI_GUID gEraseBlockBBTestConformanceAssertionGuid008 = EFI_TEST_ERASEBLOCKBBTESTCONFORMANCE_ASSERTION_008_GUID;
> +EFI_GUID gEraseBlockBBTestConformanceAssertionGuid009 = EFI_TEST_ERASEBLOCKBBTESTCONFORMANCE_ASSERTION_009_GUID;
> +
> +
> +EFI_GUID gEraseBlockBBTestFunctionAssertionGuid001 = EFI_TEST_ERASEBLOCKBBTESTFUNCTION_ASSERTION_001_GUID;
> +EFI_GUID gEraseBlockBBTestFunctionAssertionGuid002 = EFI_TEST_ERASEBLOCKBBTESTFUNCTION_ASSERTION_002_GUID;
> +EFI_GUID gEraseBlockBBTestFunctionAssertionGuid003 = EFI_TEST_ERASEBLOCKBBTESTFUNCTION_ASSERTION_003_GUID;
> +EFI_GUID gEraseBlockBBTestFunctionAssertionGuid004 = EFI_TEST_ERASEBLOCKBBTESTFUNCTION_ASSERTION_004_GUID;
> \ No newline at end of file
> diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/EraseBlock/BlackBoxTest/Guid.h b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/EraseBlock/BlackBoxTest/Guid.h
> index b9cc3b3..34aa88c 100644
> --- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/EraseBlock/BlackBoxTest/Guid.h
> +++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/EraseBlock/BlackBoxTest/Guid.h
> @@ -1,73 +1,82 @@
> -/** @file
> -
> -  Copyright 2017 Unified EFI, Inc.<BR>
> -  Copyright (c) 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
> -  http://opensource.org/licenses/bsd-license.php
> -
> -  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> -  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> -
> -**/
> -/*++
> -
> - Module Name:
> -
> -   Guid.h
> -
> - Abstract:
> -
> -   GUIDs auto-generated for EFI test assertion.
> -
> ---*/
> -
> -
> -#define EFI_TEST_ERASEBLOCKBBTESTCONFORMANCE_ASSERTION_001_GUID \
> -{ 0xf62e99e3, 0xcda2, 0x4e44, { 0x89, 0xa2, 0x47, 0x3b, 0xd8, 0x61, 0x90, 0xf8 } }
> -extern EFI_GUID gEraseBlockBBTestConformanceAssertionGuid001;
> -
> -#define EFI_TEST_ERASEBLOCKBBTESTCONFORMANCE_ASSERTION_002_GUID \
> -{ 0x4cfed8bb, 0xb9b1, 0x4c21, { 0xb3, 0xb6, 0xa7, 0x5, 0x38, 0x6c, 0xf1, 0xe5 } }
> -extern EFI_GUID gEraseBlockBBTestConformanceAssertionGuid002;
> -
> -#define EFI_TEST_ERASEBLOCKBBTESTCONFORMANCE_ASSERTION_003_GUID \
> -{ 0x9877f323, 0x8812, 0x40bc, { 0xbd, 0x41, 0x71, 0xe, 0x8b, 0xbe, 0xb6, 0x69 } }
> -extern EFI_GUID gEraseBlockBBTestConformanceAssertionGuid003;
> -
> -#define EFI_TEST_ERASEBLOCKBBTESTCONFORMANCE_ASSERTION_004_GUID \
> -{ 0x9877cf0d, 0x3d1b, 0x4ac5, { 0x8a, 0x3f, 0x8c, 0xba, 0x95, 0x62, 0xb7, 0x53 } }
> -extern EFI_GUID gEraseBlockBBTestConformanceAssertionGuid004;
> -
> -#define EFI_TEST_ERASEBLOCKBBTESTCONFORMANCE_ASSERTION_005_GUID \
> -{ 0x61c0575e, 0x742f, 0x4094, { 0xa8, 0x73, 0x2, 0x11, 0x4, 0xdb, 0x45, 0x1d } }
> -extern EFI_GUID gEraseBlockBBTestConformanceAssertionGuid005;
> -
> -#define EFI_TEST_ERASEBLOCKBBTESTCONFORMANCE_ASSERTION_006_GUID \
> -{ 0x2176fd0d, 0xb211, 0x426d, { 0xbf, 0xc, 0x84, 0x65, 0x5f, 0x3e, 0x3c, 0xcd } }
> -extern EFI_GUID gEraseBlockBBTestConformanceAssertionGuid006;
> -
> -#define EFI_TEST_ERASEBLOCKBBTESTCONFORMANCE_ASSERTION_007_GUID \
> -{ 0x5d60ba1c, 0x42da, 0x4a50, { 0x82, 0xbc, 0xe5, 0xbe, 0xe2, 0x3f, 0x41, 0x4f } }
> -extern EFI_GUID gEraseBlockBBTestConformanceAssertionGuid007;
> -
> -#define EFI_TEST_ERASEBLOCKBBTESTCONFORMANCE_ASSERTION_008_GUID \
> -{ 0x702c5141, 0xc1a8, 0x42ee, { 0x8f, 0x9c, 0xe6, 0x8, 0x8e, 0x33, 0x2a, 0xe6 } }
> -extern EFI_GUID gEraseBlockBBTestConformanceAssertionGuid008;
> -
> -#define EFI_TEST_ERASEBLOCKBBTESTCONFORMANCE_ASSERTION_009_GUID \
> -{ 0x2864536a, 0x9aa4, 0x44ac, { 0xa9, 0x60, 0x3b, 0x6e, 0x4e, 0x93, 0x47, 0xb5 } }
> -extern EFI_GUID gEraseBlockBBTestConformanceAssertionGuid009;
> -
> -
> -
> -#define EFI_TEST_ERASEBLOCKBBTESTFUNCTION_ASSERTION_001_GUID \
> -{ 0xb9ec66f1, 0x41ae, 0x44dc, { 0xa6, 0xcc, 0x55, 0xde, 0x3b, 0x0, 0x37, 0xca } }
> -extern EFI_GUID gEraseBlockBBTestFunctionAssertionGuid001;
> -
> -#define EFI_TEST_ERASEBLOCKBBTESTFUNCTION_ASSERTION_002_GUID \
> -{ 0x2af1346c, 0xf3d8, 0x48d9, { 0x94, 0x61, 0x6e, 0xef, 0xf6, 0xb2, 0x48, 0x3c } }
> -extern EFI_GUID gEraseBlockBBTestFunctionAssertionGuid002;
> -
> +/** @file
> +
> +  Copyright 2017 Unified EFI, Inc.<BR>
> +  Copyright (c) 2017 - 2018, 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
> +  http://opensource.org/licenses/bsd-license.php
> +
> +  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
> +  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
> +
> +**/
> +/*++
> +
> + Module Name:
> +
> +   Guid.h
> +
> + Abstract:
> +
> +   GUIDs auto-generated for EFI test assertion.
> +
> +--*/
> +
> +
> +#define EFI_TEST_ERASEBLOCKBBTESTCONFORMANCE_ASSERTION_001_GUID \
> +{ 0xf62e99e3, 0xcda2, 0x4e44, { 0x89, 0xa2, 0x47, 0x3b, 0xd8, 0x61, 0x90, 0xf8 } }
> +extern EFI_GUID gEraseBlockBBTestConformanceAssertionGuid001;
> +
> +#define EFI_TEST_ERASEBLOCKBBTESTCONFORMANCE_ASSERTION_002_GUID \
> +{ 0x4cfed8bb, 0xb9b1, 0x4c21, { 0xb3, 0xb6, 0xa7, 0x5, 0x38, 0x6c, 0xf1, 0xe5 } }
> +extern EFI_GUID gEraseBlockBBTestConformanceAssertionGuid002;
> +
> +#define EFI_TEST_ERASEBLOCKBBTESTCONFORMANCE_ASSERTION_003_GUID \
> +{ 0x9877f323, 0x8812, 0x40bc, { 0xbd, 0x41, 0x71, 0xe, 0x8b, 0xbe, 0xb6, 0x69 } }
> +extern EFI_GUID gEraseBlockBBTestConformanceAssertionGuid003;
> +
> +#define EFI_TEST_ERASEBLOCKBBTESTCONFORMANCE_ASSERTION_004_GUID \
> +{ 0x9877cf0d, 0x3d1b, 0x4ac5, { 0x8a, 0x3f, 0x8c, 0xba, 0x95, 0x62, 0xb7, 0x53 } }
> +extern EFI_GUID gEraseBlockBBTestConformanceAssertionGuid004;
> +
> +#define EFI_TEST_ERASEBLOCKBBTESTCONFORMANCE_ASSERTION_005_GUID \
> +{ 0x61c0575e, 0x742f, 0x4094, { 0xa8, 0x73, 0x2, 0x11, 0x4, 0xdb, 0x45, 0x1d } }
> +extern EFI_GUID gEraseBlockBBTestConformanceAssertionGuid005;
> +
> +#define EFI_TEST_ERASEBLOCKBBTESTCONFORMANCE_ASSERTION_006_GUID \
> +{ 0x2176fd0d, 0xb211, 0x426d, { 0xbf, 0xc, 0x84, 0x65, 0x5f, 0x3e, 0x3c, 0xcd } }
> +extern EFI_GUID gEraseBlockBBTestConformanceAssertionGuid006;
> +
> +#define EFI_TEST_ERASEBLOCKBBTESTCONFORMANCE_ASSERTION_007_GUID \
> +{ 0x5d60ba1c, 0x42da, 0x4a50, { 0x82, 0xbc, 0xe5, 0xbe, 0xe2, 0x3f, 0x41, 0x4f } }
> +extern EFI_GUID gEraseBlockBBTestConformanceAssertionGuid007;
> +
> +#define EFI_TEST_ERASEBLOCKBBTESTCONFORMANCE_ASSERTION_008_GUID \
> +{ 0x702c5141, 0xc1a8, 0x42ee, { 0x8f, 0x9c, 0xe6, 0x8, 0x8e, 0x33, 0x2a, 0xe6 } }
> +extern EFI_GUID gEraseBlockBBTestConformanceAssertionGuid008;
> +
> +#define EFI_TEST_ERASEBLOCKBBTESTCONFORMANCE_ASSERTION_009_GUID \
> +{ 0x2864536a, 0x9aa4, 0x44ac, { 0xa9, 0x60, 0x3b, 0x6e, 0x4e, 0x93, 0x47, 0xb5 } }
> +extern EFI_GUID gEraseBlockBBTestConformanceAssertionGuid009;
> +
> +
> +
> +#define EFI_TEST_ERASEBLOCKBBTESTFUNCTION_ASSERTION_001_GUID \
> +{ 0xb9ec66f1, 0x41ae, 0x44dc, { 0xa6, 0xcc, 0x55, 0xde, 0x3b, 0x0, 0x37, 0xca } }
> +extern EFI_GUID gEraseBlockBBTestFunctionAssertionGuid001;
> +
> +#define EFI_TEST_ERASEBLOCKBBTESTFUNCTION_ASSERTION_002_GUID \
> +{ 0x2af1346c, 0xf3d8, 0x48d9, { 0x94, 0x61, 0x6e, 0xef, 0xf6, 0xb2, 0x48, 0x3c } }
> +extern EFI_GUID gEraseBlockBBTestFunctionAssertionGuid002;
> +
> +#define EFI_TEST_ERASEBLOCKBBTESTFUNCTION_ASSERTION_003_GUID \
> +{ 0x467c9548, 0x726, 0x45b5, { 0xb8, 0x59, 0xd1, 0x8c, 0x1c, 0xf7, 0xf3, 0x93 } }
> +extern EFI_GUID gEraseBlockBBTestFunctionAssertionGuid003;
> +
> +#define EFI_TEST_ERASEBLOCKBBTESTFUNCTION_ASSERTION_004_GUID \
> +{ 0x402a045e, 0xa67b, 0x4a3e, { 0x89, 0x9e, 0x2d, 0xe4, 0x71, 0x75, 0x6e, 0x16 } }
> +extern EFI_GUID gEraseBlockBBTestFunctionAssertionGuid004;
> +
> +



      reply	other threads:[~2018-10-12  8:40 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-12  2:28 [edk2-test][Patch] uefi-sct\SctPkg: Add not-granularity-aligned cases in Erase Block Protocol Eric Jin
2018-10-12  8:40 ` Supreeth Venkatesh [this message]

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=c6808f0e-500e-fed7-2919-275644d41b8a@arm.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