/* Check if a block of buffer is erased. */
BOOLEAN IsBufferErased(IN UINT8 ErasePolarity, IN VOID *InBuffer, IN UINTN BufferSize)
/* Check if a block of buffer is erased. */
BOOLEAN IsBufferErased(IN UINT8 ErasePolarity, IN VOID *InBuffer, IN UINTN BufferSize)
{
  UINTN  Count;
  UINT8  EraseByte;
  UINT8  *Buffer;
  if (ErasePolarity == 1) {
    EraseByte = 0xFF;
  } else {
    EraseByte = 0;
  }
  Buffer = InBuffer;
  for (Count = 0; Count < BufferSize; Count++) {
    if (Buffer[Count] != EraseByte) {
      return FALSE;
    }
  }
  return TRUE;
}