/* Get pointer to CPU MP Data structure. For BSP, the pointer is retrieved from HOB. For AP, the structure is stored in the top of each AP's stack. */
CPU_MP_DATA* GetCpuMpData(VOID)
/* Get pointer to CPU MP Data structure. For BSP, the pointer is retrieved from HOB. For AP, the structure is stored in the top of each AP's stack. */
CPU_MP_DATA* GetCpuMpData(VOID)
{
  CPU_MP_DATA                  *CpuMpData;
  MSR_IA32_APIC_BASE_REGISTER  ApicBaseMsr;
  UINTN                        ApTopOfStack;
  AP_STACK_DATA                *ApStackData;
  ApicBaseMsr.Uint64 = AsmReadMsr64 (MSR_IA32_APIC_BASE);
  if (ApicBaseMsr.Bits.BSP == 1) {
    CpuMpData = GetCpuMpDataFromGuidedHob ();
    ASSERT (CpuMpData != NULL);
  } else {
    ApTopOfStack = ALIGN_VALUE ((UINTN)&ApTopOfStack, (UINTN)PcdGet32 (PcdCpuApStackSize));
    ApStackData  = (AP_STACK_DATA *)((UINTN)ApTopOfStack- sizeof (AP_STACK_DATA));
    CpuMpData    = (CPU_MP_DATA *)ApStackData->MpData;
  }
  return CpuMpData;
}