TianoCore EDK2 master
|
#include <PiPei.h>
#include <Ppi/MpServices2.h>
#include <Protocol/MpService.h>
#include <Library/BaseLib.h>
#include <Library/DebugLib.h>
#include <Library/ReportStatusCodeLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/UnitTestLib.h>
Go to the source code of this file.
Data Structures | |
union | MP_SERVICES |
struct | MP_SERVICE_UT_CONTEXT |
Macros | |
#define | RUN_PROCEDURE_TIMEOUT_VALUE 100000 |
Common header file for EdkiiPeiMpServices2Ppi and EfiMpServiceProtocol unit test.
Copyright (c) 2022, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
Definition in file EfiMpServicesUnitTestCommom.h.
#define RUN_PROCEDURE_TIMEOUT_VALUE 100000 |
Definition at line 23 of file EfiMpServicesUnitTestCommom.h.
EFI_STATUS AddCommonTestCase | ( | IN UNIT_TEST_FRAMEWORK_HANDLE | Framework, |
IN MP_SERVICE_UT_CONTEXT * | Context | ||
) |
Create test suite and unit tests for both EdkiiPeiMpServices2Ppi and EfiMpServiceProtocol.
[in] | Framework | A pointer to the framework that is being persisted. |
[in] | Context | A pointer to the private data buffer. |
EFI_SUCCESS | Create test suite and unit tests successfully. |
Others | Create test suite and unit tests unsuccessfully. |
Definition at line 1661 of file EfiMpServicesUnitTestCommom.c.
VOID EFIAPI CheckUTContext | ( | IN UNIT_TEST_CONTEXT | Context | ) |
Cleanup routine for Unit test function. If any processor is disabled unexpectedly then reenable it.
[in] | Context | Context pointer for this test. |
Definition at line 117 of file EfiMpServicesUnitTestCommom.c.
Empty procedure to be run on specified CPU.
[in,out] | Buffer | The pointer to private data buffer. |
Definition at line 311 of file EfiMpServicesUnitTestCommom.c.
VOID EFIAPI FreeUTContext | ( | IN UNIT_TEST_CONTEXT | Context | ) |
Cleanup routine for Unit test function. It will be called by the last "AddTestCase" to restore AP state and free pointer.
[in] | Context | Context pointer for this test. |
Definition at line 187 of file EfiMpServicesUnitTestCommom.c.
UNIT_TEST_STATUS EFIAPI InitUTContext | ( | IN UNIT_TEST_CONTEXT | Context | ) |
Prep routine for Unit test function. To save the ProcessorNumber of disabled AP and temporarily enable it.
[in] | Context | Context pointer for this test. |
UNIT_TEST_PASSED | Prep routine runs successful. |
UNIT_TEST_ERROR_TEST_FAILED | Prep routine runs unsuccessful. |
Definition at line 23 of file EfiMpServicesUnitTestCommom.c.
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.
[in] | MpServices | MP_SERVICES structure. |
[in] | ProcessorNumber | The handle number of the AP. |
[in] | EnableAP | Specifies the new state for the processor for enabled, FALSE for disabled. |
[in] | HealthFlag | If not NULL, a pointer to a value that specifies the new health status of the AP. |
EFI_SUCCESS | Caller enables or disables an AP successfully. |
Others | Caller enables or disables an AP unsuccessfully. |
Definition at line 161 of file EdkiiPeiMpServices2PpiUnitTest.c.
EFI_STATUS MpServicesUnitTestGetMpServices | ( | OUT MP_SERVICES * | MpServices | ) |
Get EFI_MP_SERVICES_PROTOCOL pointer.
[out] | MpServices | Pointer to the buffer where EFI_MP_SERVICES_PROTOCOL is stored |
EFI_SUCCESS | EFI_MP_SERVICES_PROTOCOL interface is returned |
EFI_NOT_FOUND | EFI_MP_SERVICES_PROTOCOL interface is not found |
Get EDKII_PEI_MP_SERVICES2_PPI pointer.
[out] | MpServices | Pointer to the buffer where EDKII_PEI_MP_SERVICES2_PPI is stored. |
EFI_SUCCESS | EDKII_PEI_MP_SERVICES2_PPI interface is returned |
EFI_NOT_FOUND | EDKII_PEI_MP_SERVICES2_PPI interface is not found |
Definition at line 26 of file EdkiiPeiMpServices2PpiUnitTest.c.
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.
[in] | MpServices | MP_SERVICES structure. |
[out] | NumberOfProcessors | Pointer to the total number of logical processors in the system, including the BSP and disabled APs. |
[out] | NumberOfEnabledProcessors | Pointer to the number of processors in the system that are enabled. |
EFI_SUCCESS | Retrieve the number of logical processor successfully |
Others | Retrieve the number of logical processor unsuccessfully |
Definition at line 51 of file DxeCpuExceptionHandlerUnitTest.c.
EFI_STATUS MpServicesUnitTestGetProcessorInfo | ( | IN MP_SERVICES | MpServices, |
IN UINTN | ProcessorNumber, | ||
OUT EFI_PROCESSOR_INFORMATION * | ProcessorInfoBuffer | ||
) |
Get detailed information on the requested logical processor.
[in] | MpServices | MP_SERVICES structure. |
[in] | ProcessorNumber | The handle number of the processor. |
[out] | ProcessorInfoBuffer | Pointer to the buffer where the processor information is stored. |
EFI_SUCCESS | Get information on the requested logical processor successfully |
Others | Get information on the requested logical processor unsuccessfully |
Definition at line 66 of file EdkiiPeiMpServices2PpiUnitTest.c.
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.
[in] | MpServices | MP_SERVICES structure. |
[in] | Procedure | Pointer to the function to be run on enabled APs of the system. |
[in] | SingleThread | If 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] | TimeoutInMicroSeconds | Indicates the time limit in microseconds for APs to return from Procedure, for blocking mode only. Zero means infinity. |
[in] | ProcedureArgument | The parameter passed into Procedure for all APs. |
EFI_SUCCESS | Execute a caller provided function on all enabled APs successfully |
Others | Execute a caller provided function on all enabled APs unsuccessfully |
Definition at line 121 of file DxeCpuExceptionHandlerUnitTest.c.
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.
[in] | MpServices | MP_SERVICES structure. |
[in] | Procedure | Pointer to the function to be run on enabled APs of the system. |
[in] | ProcessorNumber | The handle number of the AP. |
[in] | TimeoutInMicroSeconds | Indicates the time limit in microseconds for APs to return from Procedure, for blocking mode only. Zero means infinity. |
[in] | ProcedureArgument | The parameter passed into Procedure for all APs. |
EFI_SUCCESS | Caller gets one enabled AP to execute a caller-provided function successfully |
Others | Caller gets one enabled AP to execute a caller-provided function unsuccessfully |
Definition at line 93 of file DxeCpuExceptionHandlerUnitTest.c.
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.
[in] | MpServices | MP_SERVICES structure. |
[in] | ProcessorNumber | The handle number of AP that is to become the new BSP. |
[in] | EnableOldBSP | If TRUE, the old BSP will be listed as an enabled AP. Otherwise, it will be disabled. |
EFI_SUCCESS | Switch the requested AP to be the BSP successfully |
Others | Switch the requested AP to be the BSP unsuccessfully |
Definition at line 140 of file EdkiiPeiMpServices2PpiUnitTest.c.
EFI_STATUS MpServicesUnitTestWhoAmI | ( | IN MP_SERVICES | MpServices, |
OUT UINTN * | ProcessorNumber | ||
) |
Get the handle number for the calling processor.
[in] | MpServices | MP_SERVICES structure. |
[out] | ProcessorNumber | The handle number for the calling processor. |
EFI_SUCCESS | Get the handle number for the calling processor successfully. |
Others | Get the handle number for the calling processor unsuccessfully. |
Definition at line 70 of file DxeCpuExceptionHandlerUnitTest.c.
Produce to store ProcessorNumber in CommonBuffer and be run on specified CPU.
[in,out] | Buffer | The pointer to private data buffer. |
Produce to store ProcessorNumber in the corresponding location of CommonBuffer.
[in,out] | Buffer | The pointer to private data buffer. |
Definition at line 234 of file EfiMpServicesUnitTestCommom.c.
UNIT_TEST_STATUS EFIAPI TestEnableDisableAP1 | ( | IN UNIT_TEST_CONTEXT | Context | ) |
Unit test of MP service EnableDisableAP. When called with BSP number, the return status should be EFI_INVALID_PARAMETER. When called with a nonexistent processor handle, the return status should be EFI_NOT_FOUND. The AP should be really Enable/Disabled.
[in] | Context | Context pointer for this test. |
UNIT_TEST_PASSED | The Unit test has completed and the test case was successful. |
UNIT_TEST_ERROR_TEST_FAILED | A test case assertion has failed. |
Definition at line 774 of file EfiMpServicesUnitTestCommom.c.
UNIT_TEST_STATUS EFIAPI TestEnableDisableAP2 | ( | IN UNIT_TEST_CONTEXT | Context | ) |
Unit test of MP service EnableDisableAP. When run this procedure on AP, the return status should be EFI_DEVICE_ERROR.
[in] | Context | Context pointer for this test. |
UNIT_TEST_PASSED | The Unit test has completed and the test case was successful. |
UNIT_TEST_ERROR_TEST_FAILED | A test case assertion has failed. |
Definition at line 842 of file EfiMpServicesUnitTestCommom.c.
UNIT_TEST_STATUS EFIAPI TestEnableDisableAP3 | ( | IN UNIT_TEST_CONTEXT | Context | ) |
Unit test of MP service EnableDisableAP. When run this procedure on AP, the return status should be EFI_DEVICE_ERROR.
[in] | Context | Context pointer for this test. |
UNIT_TEST_PASSED | The Unit test has completed and the test case was successful. |
UNIT_TEST_ERROR_TEST_FAILED | A test case assertion has failed. |
Definition at line 885 of file EfiMpServicesUnitTestCommom.c.
UNIT_TEST_STATUS EFIAPI TestGetNumberOfProcessors1 | ( | IN UNIT_TEST_CONTEXT | Context | ) |
Unit test of MP service GetNumberOfProcessors. NumberOfProcessors should be greater that 0 and not less than NumberOfEnabledProcessors.
[in] | Context | Context pointer for this test. |
UNIT_TEST_PASSED | The Unit test has completed and the test case was successful. |
UNIT_TEST_ERROR_TEST_FAILED | A test case assertion has failed. |
Definition at line 518 of file EfiMpServicesUnitTestCommom.c.
UNIT_TEST_STATUS EFIAPI TestGetNumberOfProcessors2 | ( | IN UNIT_TEST_CONTEXT | Context | ) |
Unit test of MP service GetNumberOfProcessors. When this service is called from an AP, the return status should be EFI_DEVICE_ERROR.
[in] | Context | Context pointer for this test. |
UNIT_TEST_PASSED | The Unit test has completed and the test case was successful. |
UNIT_TEST_ERROR_TEST_FAILED | A test case assertion has failed. |
Definition at line 552 of file EfiMpServicesUnitTestCommom.c.
UNIT_TEST_STATUS EFIAPI TestGetNumberOfProcessors3 | ( | IN UNIT_TEST_CONTEXT | Context | ) |
Unit test of MP service GetNumberOfProcessors. Call EnableDisableAP() to change the number of enabled AP.
[in] | Context | Context pointer for this test. |
UNIT_TEST_PASSED | The Unit test has completed and the test case was successful. |
UNIT_TEST_ERROR_TEST_FAILED | A test case assertion has failed. |
Definition at line 595 of file EfiMpServicesUnitTestCommom.c.
UNIT_TEST_STATUS EFIAPI TestGetProcessorInfo1 | ( | IN UNIT_TEST_CONTEXT | Context | ) |
Unit test of MP service GetProcessorInfo. When all the parameters are valid, all reserved bits of StatusFlag in ProcessorInfoBuffer should be set to zero. When all the parameters are valid, the StatusFlag should not have an invalid value (The BSP can never be in the disabled state.). When called with nonexistent processor handle, the return status should be EFI_NOT_FOUND.
[in] | Context | Context pointer for this test. |
UNIT_TEST_PASSED | The Unit test has completed and the test case was successful. |
UNIT_TEST_ERROR_TEST_FAILED | A test case assertion has failed. |
Definition at line 682 of file EfiMpServicesUnitTestCommom.c.
UNIT_TEST_STATUS EFIAPI TestGetProcessorInfo2 | ( | IN UNIT_TEST_CONTEXT | Context | ) |
Unit test of MP service GetProcessorInfo. When this service is called from an AP, the return status should be EFI_DEVICE_ERROR.
[in] | Context | Context pointer for this test. |
UNIT_TEST_PASSED | The Unit test has completed and the test case was successful. |
UNIT_TEST_ERROR_TEST_FAILED | A test case assertion has failed. |
Definition at line 729 of file EfiMpServicesUnitTestCommom.c.
UNIT_TEST_STATUS EFIAPI TestStartupAllAPs1 | ( | IN UNIT_TEST_CONTEXT | Context | ) |
Unit test of MP service StartupAllAPs. All APs should execute the Procedure when called by StartupAllAPs.
[in] | Context | Context pointer for this test. |
UNIT_TEST_PASSED | The Unit test has completed and the test case was successful. |
UNIT_TEST_ERROR_TEST_FAILED | A test case assertion has failed. |
Definition at line 1157 of file EfiMpServicesUnitTestCommom.c.
UNIT_TEST_STATUS EFIAPI TestStartupAllAPs2 | ( | IN UNIT_TEST_CONTEXT | Context | ) |
Unit test of MP service StartupAllAPs. When called in single thread, the return status should be EFI_SUCCESS and AP executes in ascending order of processor handle number.
[in] | Context | Context pointer for this test. |
UNIT_TEST_PASSED | The Unit test has completed and the test case was successful. |
UNIT_TEST_ERROR_TEST_FAILED | A test case assertion has failed. |
Definition at line 1200 of file EfiMpServicesUnitTestCommom.c.
UNIT_TEST_STATUS EFIAPI TestStartupAllAPs3 | ( | IN UNIT_TEST_CONTEXT | Context | ) |
Unit test of MP service StartupAllAPs. When this service is called from an AP, the return status should be EFI_DEVICE_ERROR.
[in] | Context | Context pointer for this test. |
UNIT_TEST_PASSED | The Unit test has completed and the test case was successful. |
UNIT_TEST_ERROR_TEST_FAILED | A test case assertion has failed. |
Definition at line 1246 of file EfiMpServicesUnitTestCommom.c.
UNIT_TEST_STATUS EFIAPI TestStartupAllAPs4 | ( | IN UNIT_TEST_CONTEXT | Context | ) |
Unit test of MP service StartupAllAPs. When called with all AP timeout, the return status should be EFI_TIMEOUT.
[in] | Context | Context pointer for this test. |
UNIT_TEST_PASSED | The Unit test has completed and the test case was successful. |
UNIT_TEST_ERROR_TEST_FAILED | A test case assertion has failed. |
Definition at line 1289 of file EfiMpServicesUnitTestCommom.c.
UNIT_TEST_STATUS EFIAPI TestStartupAllAPs5 | ( | IN UNIT_TEST_CONTEXT | Context | ) |
Unit test of MP service StartupAllAPs. When called with the empty Procedure on all disabled APs, the return status should be EFI_NOT_STARTED.
[in] | Context | Context pointer for this test. |
UNIT_TEST_PASSED | The Unit test has completed and the test case was successful. |
UNIT_TEST_ERROR_TEST_FAILED | A test case assertion has failed. |
Definition at line 1331 of file EfiMpServicesUnitTestCommom.c.
UNIT_TEST_STATUS EFIAPI TestStartupThisAP1 | ( | IN UNIT_TEST_CONTEXT | Context | ) |
Unit test of MP service StartupThisAP. When called to startup a BSP, the return status should be EFI_INVALID_PARAMETER. When called with a nonexistent processor handle, the return status should be EFI_NOT_FOUND. The requested AP should execute the Procedure when called by StartupThisAP.
[in] | Context | Context pointer for this test. |
UNIT_TEST_PASSED | The Unit test has completed and the test case was successful. |
UNIT_TEST_ERROR_TEST_FAILED | A test case assertion has failed. |
Definition at line 955 of file EfiMpServicesUnitTestCommom.c.
UNIT_TEST_STATUS EFIAPI TestStartupThisAP2 | ( | IN UNIT_TEST_CONTEXT | Context | ) |
Unit test of MP service StartupThisAP. When this service is called from an AP, the return status should be EFI_DEVICE_ERROR.
[in] | Context | Context pointer for this test. |
UNIT_TEST_PASSED | The Unit test has completed and the test case was successful. |
UNIT_TEST_ERROR_TEST_FAILED | A test case assertion has failed. |
Definition at line 1007 of file EfiMpServicesUnitTestCommom.c.
UNIT_TEST_STATUS EFIAPI TestStartupThisAP3 | ( | IN UNIT_TEST_CONTEXT | Context | ) |
Unit test of MP service StartupThisAP. When timeout expired before the requested AP has finished, the return status should be EFI_TIMEOUT.
[in] | Context | Context pointer for this test. |
UNIT_TEST_PASSED | The Unit test has completed and the test case was successful. |
UNIT_TEST_ERROR_TEST_FAILED | A test case assertion has failed. |
Definition at line 1050 of file EfiMpServicesUnitTestCommom.c.
UNIT_TEST_STATUS EFIAPI TestStartupThisAP4 | ( | IN UNIT_TEST_CONTEXT | Context | ) |
Unit test of MP service StartupThisAP. When called with disabled AP, the return status should be EFI_INVALID_PARAMETER.
[in] | Context | Context pointer for this test. |
UNIT_TEST_PASSED | The Unit test has completed and the test case was successful. |
UNIT_TEST_ERROR_TEST_FAILED | A test case assertion has failed. |
Definition at line 1091 of file EfiMpServicesUnitTestCommom.c.
UNIT_TEST_STATUS EFIAPI TestSwitchBSP1 | ( | IN UNIT_TEST_CONTEXT | Context | ) |
Unit test of MP service SwitchBSP. When switch current BSP to be BSP, the return status should be EFI_INVALID_PARAMETER. When switch nonexistent processor to be BSP, the return status should be EFI_NOT_FOUND. After switch BSP, all APs(includes new AP) should execute the Procedure when called by StartupAllAP.
[in] | Context | Context pointer for this test. |
UNIT_TEST_PASSED | The Unit test has completed and the test case was successful. |
UNIT_TEST_ERROR_TEST_FAILED | A test case assertion has failed. |
Definition at line 1397 of file EfiMpServicesUnitTestCommom.c.
UNIT_TEST_STATUS EFIAPI TestSwitchBSP2 | ( | IN UNIT_TEST_CONTEXT | Context | ) |
Unit test of MP service SwitchBSP. When run this procedure on AP, the return status should be EFI_DEVICE_ERROR.
[in] | Context | Context pointer for this test. |
UNIT_TEST_PASSED | The Unit test has completed and the test case was successful. |
UNIT_TEST_ERROR_TEST_FAILED | A test case assertion has failed. |
Definition at line 1463 of file EfiMpServicesUnitTestCommom.c.
UNIT_TEST_STATUS EFIAPI TestSwitchBSP3 | ( | IN UNIT_TEST_CONTEXT | Context | ) |
Unit test of MP service SwitchBSP. When switch a disabled AP to be BSP, the return status should be EFI_INVALID_PARAMETER.
[in] | Context | Context pointer for this test. |
UNIT_TEST_PASSED | The Unit test has completed and the test case was successful. |
UNIT_TEST_ERROR_TEST_FAILED | A test case assertion has failed. |
Definition at line 1506 of file EfiMpServicesUnitTestCommom.c.
UNIT_TEST_STATUS EFIAPI TestSwitchBSP4 | ( | IN UNIT_TEST_CONTEXT | Context | ) |
Unit test of MP service SwitchBSP. When SwitchBSP and EnableOldBSP is TRUE, the new BSP should be in the enabled state and the old BSP should be in the enabled state. When SwitchBSP and EnableOldBSP is False, the new BSP should be in the enabled state and the old BSP should be in the disabled state.
[in] | Context | Context pointer for this test. |
UNIT_TEST_PASSED | The Unit test has completed and the test case was successful. |
UNIT_TEST_ERROR_TEST_FAILED | A test case assertion has failed. |
Definition at line 1564 of file EfiMpServicesUnitTestCommom.c.
UNIT_TEST_STATUS EFIAPI TestWhoAmI1 | ( | IN UNIT_TEST_CONTEXT | Context | ) |
Unit test of MP service WhoAmI. The range of ProcessorNumber should be from 0 to NumberOfCPUs minus 1. The ProcessorNumbers of all CPUs are unique.
[in] | Context | Context pointer for this test. |
UNIT_TEST_PASSED | The Unit test has completed and the test case was successful. |
UNIT_TEST_ERROR_TEST_FAILED | A test case assertion has failed. |
Definition at line 464 of file EfiMpServicesUnitTestCommom.c.