TianoCore EDK2 master
Loading...
Searching...
No Matches
EdkiiPeiMpServices2PpiUnitTest.c File Reference

Go to the source code of this file.

Macros

#define UNIT_TEST_NAME   "EdkiiPeiMpServices2Ppi Unit Test"
 
#define UNIT_TEST_VERSION   "0.1"
 

Functions

EFI_STATUS MpServicesUnitTestGetMpServices (OUT MP_SERVICES *MpServices)
 
EFI_STATUS MpServicesUnitTestGetNumberOfProcessors (IN MP_SERVICES MpServices, OUT UINTN *NumberOfProcessors, OUT UINTN *NumberOfEnabledProcessors)
 
EFI_STATUS MpServicesUnitTestGetProcessorInfo (IN MP_SERVICES MpServices, IN UINTN ProcessorNumber, OUT EFI_PROCESSOR_INFORMATION *ProcessorInfoBuffer)
 
EFI_STATUS MpServicesUnitTestStartupAllAPs (IN MP_SERVICES MpServices, IN EFI_AP_PROCEDURE Procedure, IN BOOLEAN SingleThread, IN UINTN TimeoutInMicroSeconds, IN VOID *ProcedureArgument)
 
EFI_STATUS MpServicesUnitTestStartupThisAP (IN MP_SERVICES MpServices, IN EFI_AP_PROCEDURE Procedure, IN UINTN ProcessorNumber, IN UINTN TimeoutInMicroSeconds, IN VOID *ProcedureArgument)
 
EFI_STATUS MpServicesUnitTestSwitchBSP (IN MP_SERVICES MpServices, IN UINTN ProcessorNumber, IN BOOLEAN EnableOldBSP)
 
EFI_STATUS MpServicesUnitTestEnableDisableAP (IN MP_SERVICES MpServices, IN UINTN ProcessorNumber, IN BOOLEAN EnableAP, IN UINT32 *HealthFlag)
 
EFI_STATUS MpServicesUnitTestWhoAmI (IN MP_SERVICES MpServices, OUT UINTN *ProcessorNumber)
 
EFI_STATUS MpServicesUnitTestStartupAllCPUs (IN MP_SERVICES MpServices, IN EFI_AP_PROCEDURE Procedure, IN UINTN TimeoutInMicroSeconds, IN VOID *ProcedureArgument)
 
VOID ApInfiniteLoopProcedure (IN OUT VOID *Buffer)
 
VOID RunMpServiceStartupAllCPUsOnAp (IN OUT VOID *Buffer)
 
UNIT_TEST_STATUS EFIAPI TestStartupAllCPUs1 (IN UNIT_TEST_CONTEXT Context)
 
UNIT_TEST_STATUS EFIAPI TestStartupAllCPUs2 (IN UNIT_TEST_CONTEXT Context)
 
UNIT_TEST_STATUS EFIAPI TestStartupAllCPUs3 (IN UNIT_TEST_CONTEXT Context)
 
EFI_STATUS AddTestCaseOnlyForEdkiiPeiMpServices2Ppi (IN UNIT_TEST_FRAMEWORK_HANDLE Framework, IN MP_SERVICE_UT_CONTEXT *Context)
 
EFI_STATUS EFIAPI PeiEntryPoint (IN EFI_PEI_FILE_HANDLE FileHandle, IN CONST EFI_PEI_SERVICES **PeiServices)
 

Detailed Description

PEI Module to test APIs defined in EdkiiPeiMpServices2Ppi.

Copyright (c) 2022, Intel Corporation. All rights reserved.

SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file EdkiiPeiMpServices2PpiUnitTest.c.

Macro Definition Documentation

◆ UNIT_TEST_NAME

#define UNIT_TEST_NAME   "EdkiiPeiMpServices2Ppi Unit Test"

Definition at line 14 of file EdkiiPeiMpServices2PpiUnitTest.c.

◆ UNIT_TEST_VERSION

#define UNIT_TEST_VERSION   "0.1"

Definition at line 15 of file EdkiiPeiMpServices2PpiUnitTest.c.

Function Documentation

◆ AddTestCaseOnlyForEdkiiPeiMpServices2Ppi()

EFI_STATUS AddTestCaseOnlyForEdkiiPeiMpServices2Ppi ( IN UNIT_TEST_FRAMEWORK_HANDLE  Framework,
IN MP_SERVICE_UT_CONTEXT Context 
)

Create test suite and unit tests only for EdkiiPeiMpServices2Ppi.

Parameters
[in]FrameworkA pointer to the framework that is being persisted.
[in]ContextA pointer to the private data buffer.
Return values
EFI_SUCCESSCreate test suite and unit tests successfully.
OthersCreate test suite and unit tests unsuccessfully.

Definition at line 387 of file EdkiiPeiMpServices2PpiUnitTest.c.

◆ ApInfiniteLoopProcedure()

VOID ApInfiniteLoopProcedure ( IN OUT VOID *  Buffer)

Infinite loop procedure to be run on specified AP.

Parameters
[in,out]BufferThe pointer to private data buffer.

Definition at line 218 of file EdkiiPeiMpServices2PpiUnitTest.c.

◆ MpServicesUnitTestEnableDisableAP()

EFI_STATUS MpServicesUnitTestEnableDisableAP ( IN MP_SERVICES  MpServices,
IN UINTN  ProcessorNumber,
IN BOOLEAN  EnableAP,
IN UINT32 *  HealthFlag 
)

Caller enables or disables an AP from this point onward.

Parameters
[in]MpServicesMP_SERVICES structure.
[in]ProcessorNumberThe handle number of the AP.
[in]EnableAPSpecifies the new state for the processor for enabled, FALSE for disabled.
[in]HealthFlagIf not NULL, a pointer to a value that specifies the new health status of the AP.
Return values
EFI_SUCCESSCaller enables or disables an AP successfully.
OthersCaller enables or disables an AP unsuccessfully.

Definition at line 161 of file EdkiiPeiMpServices2PpiUnitTest.c.

◆ MpServicesUnitTestGetMpServices()

EFI_STATUS MpServicesUnitTestGetMpServices ( OUT MP_SERVICES MpServices)

Get EDKII_PEI_MP_SERVICES2_PPI pointer.

Parameters
[out]MpServicesPointer to the buffer where EDKII_PEI_MP_SERVICES2_PPI is stored.
Return values
EFI_SUCCESSEDKII_PEI_MP_SERVICES2_PPI interface is returned
EFI_NOT_FOUNDEDKII_PEI_MP_SERVICES2_PPI interface is not found

Definition at line 26 of file EdkiiPeiMpServices2PpiUnitTest.c.

◆ MpServicesUnitTestGetNumberOfProcessors()

EFI_STATUS MpServicesUnitTestGetNumberOfProcessors ( IN MP_SERVICES  MpServices,
OUT UINTN NumberOfProcessors,
OUT UINTN NumberOfEnabledProcessors 
)

Retrieve the number of logical processor in the platform and the number of those logical processors that are enabled on this boot.

Parameters
[in]MpServicesMP_SERVICES structure.
[out]NumberOfProcessorsPointer to the total number of logical processors in the system, including the BSP and disabled APs.
[out]NumberOfEnabledProcessorsPointer to the number of processors in the system that are enabled.
Return values
EFI_SUCCESSRetrieve the number of logical processor successfully
OthersRetrieve the number of logical processor unsuccessfully

Definition at line 46 of file EdkiiPeiMpServices2PpiUnitTest.c.

◆ MpServicesUnitTestGetProcessorInfo()

EFI_STATUS MpServicesUnitTestGetProcessorInfo ( IN MP_SERVICES  MpServices,
IN UINTN  ProcessorNumber,
OUT EFI_PROCESSOR_INFORMATION ProcessorInfoBuffer 
)

Get detailed information on the requested logical processor.

Parameters
[in]MpServicesMP_SERVICES structure.
[in]ProcessorNumberThe handle number of the processor.
[out]ProcessorInfoBufferPointer to the buffer where the processor information is stored.
Return values
EFI_SUCCESSGet information on the requested logical processor successfully
OthersGet information on the requested logical processor unsuccessfully

Definition at line 66 of file EdkiiPeiMpServices2PpiUnitTest.c.

◆ MpServicesUnitTestStartupAllAPs()

EFI_STATUS MpServicesUnitTestStartupAllAPs ( IN MP_SERVICES  MpServices,
IN EFI_AP_PROCEDURE  Procedure,
IN BOOLEAN  SingleThread,
IN UINTN  TimeoutInMicroSeconds,
IN VOID *  ProcedureArgument 
)

Execute a caller provided function on all enabled APs.

Parameters
[in]MpServicesMP_SERVICES structure.
[in]ProcedurePointer to the function to be run on enabled APs of the system.
[in]SingleThreadIf TRUE, then all the enabled APs execute the function specified by Procedure one by one, in ascending order of processor handle number. If FALSE, then all the enabled APs execute the function specified by Procedure simultaneously.
[in]TimeoutInMicroSecondsIndicates the time limit in microseconds for APs to return from Procedure, for blocking mode only. Zero means infinity.
[in]ProcedureArgumentThe parameter passed into Procedure for all APs.
Return values
EFI_SUCCESSExecute a caller provided function on all enabled APs successfully
OthersExecute a caller provided function on all enabled APs unsuccessfully

Definition at line 92 of file EdkiiPeiMpServices2PpiUnitTest.c.

◆ MpServicesUnitTestStartupAllCPUs()

EFI_STATUS MpServicesUnitTestStartupAllCPUs ( IN MP_SERVICES  MpServices,
IN EFI_AP_PROCEDURE  Procedure,
IN UINTN  TimeoutInMicroSeconds,
IN VOID *  ProcedureArgument 
)

Execute a caller provided function on all enabled CPUs.

Parameters
[in]MpServicesMP_SERVICES structure.
[in]ProcedurePointer to the function to be run on enabled CPUs of the system.
[in]TimeoutInMicroSecondsIndicates the time limit in microseconds for APs to return from Procedure, for blocking mode only. Zero means infinity.
[in]ProcedureArgumentThe parameter passed into Procedure for all enabled CPUs.
Return values
EFI_SUCCESSExecute a caller provided function on all enabled CPUs successfully
OthersExecute a caller provided function on all enabled CPUs unsuccessfully

Definition at line 202 of file EdkiiPeiMpServices2PpiUnitTest.c.

◆ MpServicesUnitTestStartupThisAP()

EFI_STATUS MpServicesUnitTestStartupThisAP ( IN MP_SERVICES  MpServices,
IN EFI_AP_PROCEDURE  Procedure,
IN UINTN  ProcessorNumber,
IN UINTN  TimeoutInMicroSeconds,
IN VOID *  ProcedureArgument 
)

Caller gets one enabled AP to execute a caller-provided function.

Parameters
[in]MpServicesMP_SERVICES structure.
[in]ProcedurePointer to the function to be run on enabled APs of the system.
[in]ProcessorNumberThe handle number of the AP.
[in]TimeoutInMicroSecondsIndicates the time limit in microseconds for APs to return from Procedure, for blocking mode only. Zero means infinity.
[in]ProcedureArgumentThe parameter passed into Procedure for all APs.
Return values
EFI_SUCCESSCaller gets one enabled AP to execute a caller-provided function successfully
OthersCaller gets one enabled AP to execute a caller-provided function unsuccessfully

Definition at line 118 of file EdkiiPeiMpServices2PpiUnitTest.c.

◆ MpServicesUnitTestSwitchBSP()

EFI_STATUS MpServicesUnitTestSwitchBSP ( IN MP_SERVICES  MpServices,
IN UINTN  ProcessorNumber,
IN BOOLEAN  EnableOldBSP 
)

Switch the requested AP to be the BSP from that point onward.

Parameters
[in]MpServicesMP_SERVICES structure.
[in]ProcessorNumberThe handle number of AP that is to become the new BSP.
[in]EnableOldBSPIf TRUE, the old BSP will be listed as an enabled AP. Otherwise, it will be disabled.
Return values
EFI_SUCCESSSwitch the requested AP to be the BSP successfully
OthersSwitch the requested AP to be the BSP unsuccessfully

Definition at line 140 of file EdkiiPeiMpServices2PpiUnitTest.c.

◆ MpServicesUnitTestWhoAmI()

EFI_STATUS MpServicesUnitTestWhoAmI ( IN MP_SERVICES  MpServices,
OUT UINTN ProcessorNumber 
)

Get the handle number for the calling processor.

Parameters
[in]MpServicesMP_SERVICES structure.
[out]ProcessorNumberThe handle number for the calling processor.
Return values
EFI_SUCCESSGet the handle number for the calling processor successfully.
OthersGet the handle number for the calling processor unsuccessfully.

Definition at line 181 of file EdkiiPeiMpServices2PpiUnitTest.c.

◆ PeiEntryPoint()

EFI_STATUS EFIAPI PeiEntryPoint ( IN EFI_PEI_FILE_HANDLE  FileHandle,
IN CONST EFI_PEI_SERVICES **  PeiServices 
)

Standard PEIM entry point for unit test execution from PEI. Initialize the unit test framework, suite, and unit tests for the EdkiiPeiMpServices2Ppi and run the unit test.

Parameters
[in]FileHandleHandle of the file being invoked.
[in]PeiServicesPointer to PEI Services table.

Definition at line 423 of file EdkiiPeiMpServices2PpiUnitTest.c.

◆ RunMpServiceStartupAllCPUsOnAp()

VOID RunMpServiceStartupAllCPUsOnAp ( IN OUT VOID *  Buffer)

Procedure to run MP service StartupAllCPUs on AP.

Parameters
[in,out]BufferThe pointer to private data buffer.

Definition at line 248 of file EdkiiPeiMpServices2PpiUnitTest.c.

◆ TestStartupAllCPUs1()

UNIT_TEST_STATUS EFIAPI TestStartupAllCPUs1 ( IN UNIT_TEST_CONTEXT  Context)

Unit test of PEI MP service StartupAllCPU. All CPUs should execute the Procedure.

Parameters
[in]ContextContext pointer for this test.
Return values
UNIT_TEST_PASSEDThe Unit test has completed and the test case was successful.
UNIT_TEST_ERROR_TEST_FAILEDA test case assertion has failed.

Definition at line 276 of file EdkiiPeiMpServices2PpiUnitTest.c.

◆ TestStartupAllCPUs2()

UNIT_TEST_STATUS EFIAPI TestStartupAllCPUs2 ( IN UNIT_TEST_CONTEXT  Context)

Unit test of PEI MP service StartupAllCPU. When this service is called from an AP, the return status should be EFI_DEVICE_ERROR.

Parameters
[in]ContextContext pointer for this test.
Return values
UNIT_TEST_PASSEDThe Unit test has completed and the test case was successful.
UNIT_TEST_ERROR_TEST_FAILEDA test case assertion has failed.

Definition at line 314 of file EdkiiPeiMpServices2PpiUnitTest.c.

◆ TestStartupAllCPUs3()

UNIT_TEST_STATUS EFIAPI TestStartupAllCPUs3 ( IN UNIT_TEST_CONTEXT  Context)

Unit test of PEI MP service StartupAllCPU. When called with all CPUs timeout, the return status should be EFI_TIMEOUT.

Parameters
[in]ContextContext pointer for this test.
Return values
UNIT_TEST_PASSEDThe Unit test has completed and the test case was successful.
UNIT_TEST_ERROR_TEST_FAILEDA test case assertion has failed.

Definition at line 357 of file EdkiiPeiMpServices2PpiUnitTest.c.