/* Internal Function. Free a pool by specified PoolIndex. */
EFI_STATUS InternalFreePoolByIndex(IN FREE_POOL_HEADER *FreePoolHdr, IN POOL_TAIL *PoolTail)
/* Internal Function. Free a pool by specified PoolIndex. */
EFI_STATUS InternalFreePoolByIndex(IN FREE_POOL_HEADER *FreePoolHdr, IN POOL_TAIL *PoolTail)
{
  UINTN          PoolIndex;
  SMM_POOL_TYPE  SmmPoolType;
  ASSERT ((FreePoolHdr->Header.Size & (FreePoolHdr->Header.Size - 1)) == 0);
  ASSERT (((UINTN)FreePoolHdr & (FreePoolHdr->Header.Size - 1)) == 0);
  ASSERT (FreePoolHdr->Header.Size >= MIN_POOL_SIZE);
  SmmPoolType = UefiMemoryTypeToSmmPoolType (FreePoolHdr->Header.Type);
  PoolIndex                     = (UINTN)(HighBitSet32 ((UINT32)FreePoolHdr->Header.Size) - MIN_POOL_SHIFT);
  FreePoolHdr->Header.Signature = 0;
  FreePoolHdr->Header.Available = TRUE;
  FreePoolHdr->Header.Type      = 0;
  PoolTail->Signature           = 0;
  PoolTail->Size                = 0;
  ASSERT (PoolIndex < MAX_POOL_INDEX);
  InsertHeadList (&mSmmPoolLists[SmmPoolType][PoolIndex], &FreePoolHdr->Link);
  return EFI_SUCCESS;
}