/** Worker function to MP-related information on the requested processor at the instant this call is made. @param[in] ProcessorNumber The handle number of processor. @param[out] ProcessorInfoBuffer A pointer to the buffer where information for the requested processor is deposited. @return Status of MpServices->GetProcessorInfo(). **/ EFI_STATUS GetProcessorInformation ( IN UINTN ProcessorNumber, OUT EFI_PROCESSOR_INFORMATION *ProcessorInfoBuffer ) { EFI_PEI_MP_SERVICES_PPI *CpuMpPpi; EFI_STATUS Status; CpuMpPpi = GetMpPpi (); Status = CpuMpPpi->GetProcessorInfo ( GetPeiServicesTablePointer(), CpuMpPpi, ProcessorNumber, ProcessorInfoBuffer ); return Status; }
/** Worker function to MP-related information on the requested processor at the instant this call is made. @param[in] ProcessorNumber The handle number of processor. @param[out] ProcessorInfoBuffer A pointer to the buffer where information for the requested processor is deposited. @return Status of MpServices->GetProcessorInfo(). **/ EFI_STATUS GetProcessorInformation ( IN UINTN ProcessorNumber, OUT EFI_PROCESSOR_INFORMATION *ProcessorInfoBuffer ) { EFI_PEI_MP_SERVICES_PPI *CpuMpPpi; EFI_STATUS Status; CPU_FEATURES_DATA *CpuFeaturesData; CpuFeaturesData = GetCpuFeaturesData (); CpuMpPpi = CpuFeaturesData->MpService.Ppi; Status = CpuMpPpi->GetProcessorInfo ( GetPeiServicesTablePointer(), CpuMpPpi, ProcessorNumber, ProcessorInfoBuffer ); return Status; }
/** Allocates ACPI NVS memory to save ACPI_CPU_DATA. @return Pointer to allocated ACPI_CPU_DATA. **/ ACPI_CPU_DATA * AllocateAcpiCpuData ( VOID ) { EFI_STATUS Status; EFI_PEI_MP_SERVICES_PPI *CpuMpPpi; UINTN NumberOfCpus; UINTN NumberOfEnabledProcessors; ACPI_CPU_DATA *AcpiCpuData; EFI_PHYSICAL_ADDRESS Address; UINTN TableSize; CPU_REGISTER_TABLE *RegisterTable; UINTN Index; EFI_PROCESSOR_INFORMATION ProcessorInfoBuffer; Status = PeiServicesAllocatePages ( EfiACPIMemoryNVS, EFI_SIZE_TO_PAGES (sizeof (ACPI_CPU_DATA)), &Address ); ASSERT_EFI_ERROR (Status); AcpiCpuData = (ACPI_CPU_DATA *) (UINTN) Address; ASSERT (AcpiCpuData != NULL); // // Get MP Services Protocol // Status = PeiServicesLocatePpi ( &gEfiPeiMpServicesPpiGuid, 0, NULL, (VOID **)&CpuMpPpi ); ASSERT_EFI_ERROR (Status); // // Get the number of CPUs // Status = CpuMpPpi->GetNumberOfProcessors ( GetPeiServicesTablePointer (), CpuMpPpi, &NumberOfCpus, &NumberOfEnabledProcessors ); ASSERT_EFI_ERROR (Status); AcpiCpuData->NumberOfCpus = (UINT32)NumberOfCpus; // // Allocate buffer for empty RegisterTable and PreSmmInitRegisterTable for all CPUs // TableSize = 2 * NumberOfCpus * sizeof (CPU_REGISTER_TABLE); Status = PeiServicesAllocatePages ( EfiACPIMemoryNVS, EFI_SIZE_TO_PAGES (TableSize), &Address ); ASSERT_EFI_ERROR (Status); RegisterTable = (CPU_REGISTER_TABLE *) (UINTN) Address; for (Index = 0; Index < NumberOfCpus; Index++) { Status = CpuMpPpi->GetProcessorInfo ( GetPeiServicesTablePointer (), CpuMpPpi, Index, &ProcessorInfoBuffer ); ASSERT_EFI_ERROR (Status); RegisterTable[Index].InitialApicId = (UINT32)ProcessorInfoBuffer.ProcessorId; RegisterTable[Index].TableLength = 0; RegisterTable[Index].AllocatedSize = 0; RegisterTable[Index].RegisterTableEntry = 0; RegisterTable[NumberOfCpus + Index].InitialApicId = (UINT32)ProcessorInfoBuffer.ProcessorId; RegisterTable[NumberOfCpus + Index].TableLength = 0; RegisterTable[NumberOfCpus + Index].AllocatedSize = 0; RegisterTable[NumberOfCpus + Index].RegisterTableEntry = 0; } AcpiCpuData->RegisterTable = (EFI_PHYSICAL_ADDRESS)(UINTN)RegisterTable; AcpiCpuData->PreSmmInitRegisterTable = (EFI_PHYSICAL_ADDRESS)(UINTN)(RegisterTable + NumberOfCpus); return AcpiCpuData; }