/* If Buffer is NULL, then ASSERT(). If Buffer is not aligned on a 16-bit boundary, then ASSERT(). If Length is not aligned on a 16-bit boundary, then ASSERT(). If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). */
UINT16 EFIAPI CalculateSum16(IN CONST UINT16 *Buffer, IN UINTN Length)
/* If Buffer is NULL, then ASSERT(). If Buffer is not aligned on a 16-bit boundary, then ASSERT(). If Length is not aligned on a 16-bit boundary, then ASSERT(). If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). */
UINT16 EFIAPI CalculateSum16(IN CONST UINT16 *Buffer, IN UINTN Length)
{
  UINT16  Sum;
  UINTN   Count;
  UINTN   Total;
  ASSERT (Buffer != NULL);
  ASSERT (((UINTN)Buffer & 0x1) == 0);
  ASSERT ((Length & 0x1) == 0);
  ASSERT (Length <= (MAX_ADDRESS - ((UINTN)Buffer) + 1));
  Total = Length / sizeof (*Buffer);
  for (Sum = 0, Count = 0; Count < Total; Count++) {
    Sum = (UINT16)(Sum + *(Buffer + Count));
  }
  return Sum;
}