14#define UNIT_TEST_NAME "EdkiiPeiMpServices2Ppi Unit Test"
15#define UNIT_TEST_VERSION "0.1"
52 return MpServices.Ppi->GetNumberOfProcessors (MpServices.Ppi, NumberOfProcessors, NumberOfEnabledProcessors);
72 return MpServices.Ppi->GetProcessorInfo (MpServices.Ppi, ProcessorNumber, ProcessorInfoBuffer);
95 IN BOOLEAN SingleThread,
97 IN VOID *ProcedureArgument
100 return MpServices.Ppi->StartupAllAPs (MpServices.Ppi, Procedure, SingleThread, TimeoutInMicroSeconds, ProcedureArgument);
122 IN UINTN TimeoutInMicroSeconds,
123 IN VOID *ProcedureArgument
126 return MpServices.Ppi->StartupThisAP (MpServices.Ppi, Procedure, ProcessorNumber, TimeoutInMicroSeconds, ProcedureArgument);
143 IN BOOLEAN EnableOldBSP
146 return MpServices.Ppi->SwitchBSP (MpServices.Ppi, ProcessorNumber, EnableOldBSP);
165 IN UINT32 *HealthFlag
168 return MpServices.Ppi->EnableDisableAP (MpServices.Ppi, ProcessorNumber, EnableAP, HealthFlag);
186 return MpServices.Ppi->WhoAmI (MpServices.Ppi, ProcessorNumber);
205 IN UINTN TimeoutInMicroSeconds,
206 IN VOID *ProcedureArgument
209 return MpServices.Ppi->StartupAllCPUs (MpServices.Ppi, Procedure, TimeoutInMicroSeconds, ProcedureArgument);
223 UINTN ProcessorNumber;
224 volatile BOOLEAN InfiniteLoop;
232 if (ProcessorNumber == LocalContext->BspNumber) {
233 InfiniteLoop =
FALSE;
238 while (InfiniteLoop) {
257 LocalContext->MpServices,
281 UINTN ProcessorIndex;
286 SetMem (LocalContext->CommonBuffer, LocalContext->NumberOfProcessors * sizeof (*LocalContext->CommonBuffer), 0xFF);
288 LocalContext->MpServices,
295 for (ProcessorIndex = 0; ProcessorIndex < LocalContext->NumberOfProcessors; ProcessorIndex++) {
296 UT_ASSERT_TRUE (LocalContext->CommonBuffer[ProcessorIndex] == ProcessorIndex);
299 return UNIT_TEST_PASSED;
324 for (ApNumber = 0; ApNumber < LocalContext->NumberOfProcessors; ApNumber++) {
325 LocalContext->ApNumber = ApNumber;
327 LocalContext->MpServices,
334 if (ApNumber == LocalContext->BspNumber) {
342 return UNIT_TEST_PASSED;
367 LocalContext->MpServices,
369 RUN_PROCEDURE_TIMEOUT_VALUE,
374 return UNIT_TEST_PASSED;
388 IN UNIT_TEST_FRAMEWORK_HANDLE Framework,
393 UNIT_TEST_SUITE_HANDLE MpServiceStartupAllCPUsTestSuite;
395 MpServiceStartupAllCPUsTestSuite =
NULL;
400 Status =
CreateUnitTestSuite (&MpServiceStartupAllCPUsTestSuite, Framework,
"Execute a caller provided function on all enabled CPUs",
"MpServices.StartupAllCPUs",
NULL,
NULL);
401 if (EFI_ERROR (Status)) {
402 DEBUG ((DEBUG_ERROR,
"Failed in CreateUnitTestSuite for MpServiceStartupAllCPUs Test Suite\n"));
429 UNIT_TEST_FRAMEWORK_HANDLE Framework;
433 Context.MpServices.Ppi =
NULL;
434 Context.CommonBuffer =
NULL;
435 Context.DisabledApNumber =
NULL;
437 DEBUG ((DEBUG_INFO,
"%a v%a\n", UNIT_TEST_NAME, UNIT_TEST_VERSION));
443 if (EFI_ERROR (Status)) {
444 DEBUG ((DEBUG_ERROR,
"Failed in InitUnitTestFramework. Status = %r\n", Status));
452 if (EFI_ERROR (Status)) {
453 DEBUG ((DEBUG_ERROR,
"Failed in AddTestCaseOnlyForEdkiiPeiMpServices2Ppi. Status = %r\n", Status));
461 if (EFI_ERROR (Status)) {
462 DEBUG ((DEBUG_ERROR,
"Failed in AddCommonTestCase. Status = %r\n", Status));
472 if (Framework !=
NULL) {
VOID *EFIAPI SetMem(OUT VOID *Buffer, IN UINTN Length, IN UINT8 Value)
EFI_STATUS AddCommonTestCase(IN UNIT_TEST_FRAMEWORK_HANDLE Framework)
EFI_STATUS MpServicesUnitTestWhoAmI(IN MP_SERVICES MpServices, OUT UINTN *ProcessorNumber)
UNIT_TEST_STATUS EFIAPI TestStartupAllCPUs1(IN UNIT_TEST_CONTEXT Context)
EFI_STATUS MpServicesUnitTestGetProcessorInfo(IN MP_SERVICES MpServices, IN UINTN ProcessorNumber, OUT EFI_PROCESSOR_INFORMATION *ProcessorInfoBuffer)
VOID RunMpServiceStartupAllCPUsOnAp(IN OUT VOID *Buffer)
EFI_STATUS MpServicesUnitTestStartupAllAPs(IN MP_SERVICES MpServices, IN EFI_AP_PROCEDURE Procedure, IN BOOLEAN SingleThread, IN UINTN TimeoutInMicroSeconds, IN VOID *ProcedureArgument)
VOID ApInfiniteLoopProcedure(IN OUT VOID *Buffer)
EFI_STATUS MpServicesUnitTestGetNumberOfProcessors(IN MP_SERVICES MpServices, OUT UINTN *NumberOfProcessors, OUT UINTN *NumberOfEnabledProcessors)
EFI_STATUS MpServicesUnitTestEnableDisableAP(IN MP_SERVICES MpServices, IN UINTN ProcessorNumber, IN BOOLEAN EnableAP, IN UINT32 *HealthFlag)
EFI_STATUS AddTestCaseOnlyForEdkiiPeiMpServices2Ppi(IN UNIT_TEST_FRAMEWORK_HANDLE Framework, IN MP_SERVICE_UT_CONTEXT *Context)
UNIT_TEST_STATUS EFIAPI TestStartupAllCPUs3(IN UNIT_TEST_CONTEXT Context)
EFI_STATUS MpServicesUnitTestStartupAllCPUs(IN MP_SERVICES MpServices, IN EFI_AP_PROCEDURE Procedure, IN UINTN TimeoutInMicroSeconds, IN VOID *ProcedureArgument)
EFI_STATUS EFIAPI PeiEntryPoint(IN EFI_PEI_FILE_HANDLE FileHandle, IN CONST EFI_PEI_SERVICES **PeiServices)
EFI_STATUS MpServicesUnitTestSwitchBSP(IN MP_SERVICES MpServices, IN UINTN ProcessorNumber, IN BOOLEAN EnableOldBSP)
UNIT_TEST_STATUS EFIAPI TestStartupAllCPUs2(IN UNIT_TEST_CONTEXT Context)
EFI_STATUS MpServicesUnitTestStartupThisAP(IN MP_SERVICES MpServices, IN EFI_AP_PROCEDURE Procedure, IN UINTN ProcessorNumber, IN UINTN TimeoutInMicroSeconds, IN VOID *ProcedureArgument)
EFI_STATUS MpServicesUnitTestGetMpServices(OUT MP_SERVICES *MpServices)
VOID StoreCpuNumbers(IN OUT VOID *Buffer)
VOID EFIAPI CheckUTContext(IN UNIT_TEST_CONTEXT Context)
UNIT_TEST_STATUS EFIAPI InitUTContext(IN UNIT_TEST_CONTEXT Context)
VOID EmptyProcedure(IN OUT VOID *Buffer)
EFI_STATUS EFIAPI PeiServicesLocatePpi(IN CONST EFI_GUID *Guid, IN UINTN Instance, IN OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor, IN OUT VOID **Ppi)
#define ASSERT_EFI_ERROR(StatusParameter)
#define DEBUG(Expression)
VOID(EFIAPI * EFI_AP_PROCEDURE)(IN OUT VOID *Buffer)
VOID * EFI_PEI_FILE_HANDLE
EFI_STATUS EFIAPI RunAllTestSuites(IN UNIT_TEST_FRAMEWORK_HANDLE FrameworkHandle)
#define UT_ASSERT_TRUE(Expression)
#define UT_ASSERT_STATUS_EQUAL(Status, Expected)
EFI_STATUS EFIAPI CreateUnitTestSuite(OUT UNIT_TEST_SUITE_HANDLE *SuiteHandle, IN UNIT_TEST_FRAMEWORK_HANDLE FrameworkHandle, IN CHAR8 *Title, IN CHAR8 *Name, IN UNIT_TEST_SUITE_SETUP Setup OPTIONAL, IN UNIT_TEST_SUITE_TEARDOWN Teardown OPTIONAL)
EFI_STATUS EFIAPI FreeUnitTestFramework(IN UNIT_TEST_FRAMEWORK_HANDLE FrameworkHandle)
EFI_STATUS EFIAPI AddTestCase(IN UNIT_TEST_SUITE_HANDLE SuiteHandle, IN CHAR8 *Description, IN CHAR8 *Name, IN UNIT_TEST_FUNCTION Function, IN UNIT_TEST_PREREQUISITE Prerequisite OPTIONAL, IN UNIT_TEST_CLEANUP CleanUp OPTIONAL, IN UNIT_TEST_CONTEXT Context OPTIONAL)
EFI_STATUS EFIAPI InitUnitTestFramework(OUT UNIT_TEST_FRAMEWORK_HANDLE *FrameworkHandle, IN CHAR8 *Title, IN CHAR8 *ShortTitle, IN CHAR8 *VersionString)
#define UT_ASSERT_NOT_EFI_ERROR(Status)