/* This function is called by BSP and APs to accept memory. Note: The input PhysicalStart/PhysicalEnd indicates the whole memory region to be accepted. BSP or AP only accepts one piece in the whole memory region. */
STATIC EFI_STATUS EFIAPI BspApAcceptMemoryResourceRange(UINT32 CpuIndex, UINT32 CpusNum, EFI_PHYSICAL_ADDRESS PhysicalStart, EFI_PHYSICAL_ADDRESS PhysicalEnd)
/* This function is called by BSP and APs to accept memory. Note: The input PhysicalStart/PhysicalEnd indicates the whole memory region to be accepted. BSP or AP only accepts one piece in the whole memory region. */
STATIC EFI_STATUS EFIAPI BspApAcceptMemoryResourceRange(UINT32 CpuIndex, UINT32 CpusNum, EFI_PHYSICAL_ADDRESS PhysicalStart, EFI_PHYSICAL_ADDRESS PhysicalEnd)
{
  UINT64                Status;
  UINT64                Pages;
  UINT64                Stride;
  UINT64                AcceptPageSize;
  EFI_PHYSICAL_ADDRESS  PhysicalAddress;
  AcceptPageSize = (UINT64)(UINTN)FixedPcdGet32 (PcdTdxAcceptPageSize);
  Status          = EFI_SUCCESS;
  Stride          = (UINTN)CpusNum * ACCEPT_CHUNK_SIZE;
  PhysicalAddress = PhysicalStart + ACCEPT_CHUNK_SIZE * (UINTN)CpuIndex;
  while (!EFI_ERROR (Status) && PhysicalAddress < PhysicalEnd) {
    Pages  = MIN (ACCEPT_CHUNK_SIZE, PhysicalEnd - PhysicalAddress) / AcceptPageSize;
    Status = TdAcceptPages (PhysicalAddress, Pages, (UINT32)(UINTN)AcceptPageSize);
    ASSERT (!EFI_ERROR (Status));
    PhysicalAddress += Stride;
  }
  return EFI_SUCCESS;
}