TianoCore EDK2 master
Loading...
Searching...
No Matches
EfiMpServiceProtocolUnitTest.c
Go to the documentation of this file.
1
10#include <PiDxe.h>
13
14#define UNIT_TEST_NAME "EfiMpServiceProtocol Unit Test"
15#define UNIT_TEST_VERSION "0.1"
16
27 OUT MP_SERVICES *MpServices
28 )
29{
30 return gBS->LocateProtocol (&gEfiMpServiceProtocolGuid, NULL, (VOID **)&MpServices->Protocol);
31}
32
47 IN MP_SERVICES MpServices,
48 OUT UINTN *NumberOfProcessors,
49 OUT UINTN *NumberOfEnabledProcessors
50 )
51{
52 return MpServices.Protocol->GetNumberOfProcessors (MpServices.Protocol, NumberOfProcessors, NumberOfEnabledProcessors);
53}
54
67 IN MP_SERVICES MpServices,
68 IN UINTN ProcessorNumber,
69 OUT EFI_PROCESSOR_INFORMATION *ProcessorInfoBuffer
70 )
71{
72 return MpServices.Protocol->GetProcessorInfo (MpServices.Protocol, ProcessorNumber, ProcessorInfoBuffer);
73}
74
93 IN MP_SERVICES MpServices,
94 IN EFI_AP_PROCEDURE Procedure,
95 IN BOOLEAN SingleThread,
96 IN UINTN TimeoutInMicroSeconds,
97 IN VOID *ProcedureArgument
98 )
99{
100 return MpServices.Protocol->StartupAllAPs (MpServices.Protocol, Procedure, SingleThread, NULL, TimeoutInMicroSeconds, ProcedureArgument, NULL);
101}
102
119 IN MP_SERVICES MpServices,
120 IN EFI_AP_PROCEDURE Procedure,
121 IN UINTN ProcessorNumber,
122 IN UINTN TimeoutInMicroSeconds,
123 IN VOID *ProcedureArgument
124 )
125{
126 return MpServices.Protocol->StartupThisAP (MpServices.Protocol, Procedure, ProcessorNumber, NULL, TimeoutInMicroSeconds, ProcedureArgument, NULL);
127}
128
141 IN MP_SERVICES MpServices,
142 IN UINTN ProcessorNumber,
143 IN BOOLEAN EnableOldBSP
144 )
145{
146 return MpServices.Protocol->SwitchBSP (MpServices.Protocol, ProcessorNumber, EnableOldBSP);
147}
148
162 IN MP_SERVICES MpServices,
163 IN UINTN ProcessorNumber,
164 IN BOOLEAN EnableAP,
165 IN UINT32 *HealthFlag
166 )
167{
168 return MpServices.Protocol->EnableDisableAP (MpServices.Protocol, ProcessorNumber, EnableAP, HealthFlag);
169}
170
182 IN MP_SERVICES MpServices,
183 OUT UINTN *ProcessorNumber
184 )
185{
186 return MpServices.Protocol->WhoAmI (MpServices.Protocol, ProcessorNumber);
187}
188
197EFIAPI
199 VOID
200 )
201{
202 EFI_STATUS Status;
203 UNIT_TEST_FRAMEWORK_HANDLE Framework;
204 MP_SERVICE_UT_CONTEXT Context;
205
206 Framework = NULL;
207 Context.MpServices.Ppi = NULL;
208 Context.CommonBuffer = NULL;
209 Context.DisabledApNumber = NULL;
210
211 DEBUG ((DEBUG_INFO, "%a v%a\n", UNIT_TEST_NAME, UNIT_TEST_VERSION));
212
213 //
214 // Start setting up the test framework for running the tests.
215 //
216 Status = InitUnitTestFramework (&Framework, UNIT_TEST_NAME, gEfiCallerBaseName, UNIT_TEST_VERSION);
217 if (EFI_ERROR (Status)) {
218 DEBUG ((DEBUG_ERROR, "Failed in InitUnitTestFramework. Status = %r\n", Status));
219 goto EXIT;
220 }
221
222 //
223 // Create test suite and unit tests for both EdkiiPeiMpServices2Ppi and EfiMpServiceProtocol.
224 //
225 Status = AddCommonTestCase (Framework, &Context);
226 if (EFI_ERROR (Status)) {
227 DEBUG ((DEBUG_ERROR, "Failed in AddCommonTestCase. Status = %r\n", Status));
228 goto EXIT;
229 }
230
231 //
232 // Execute the tests.
233 //
234 Status = RunAllTestSuites (Framework);
235
236EXIT:
237 if (Framework != NULL) {
238 FreeUnitTestFramework (Framework);
239 }
240
241 return Status;
242}
243
253EFIAPI
255 IN EFI_HANDLE ImageHandle,
256 IN EFI_SYSTEM_TABLE *SystemTable
257 )
258{
260}
UINT64 UINTN
EFI_STATUS AddCommonTestCase(IN UNIT_TEST_FRAMEWORK_HANDLE Framework)
EFI_STATUS MpServicesUnitTestWhoAmI(IN MP_SERVICES MpServices, OUT UINTN *ProcessorNumber)
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 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 EFIAPI DxeEntryPoint(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
EFI_STATUS MpServicesUnitTestSwitchBSP(IN MP_SERVICES MpServices, IN UINTN ProcessorNumber, IN BOOLEAN EnableOldBSP)
EFI_STATUS EFIAPI EfiMpServiceProtocolUnitTest(VOID)
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)
#define NULL
Definition: Base.h:319
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
#define DEBUG(Expression)
Definition: DebugLib.h:434
VOID(EFIAPI * EFI_AP_PROCEDURE)(IN OUT VOID *Buffer)
Definition: PiMultiPhase.h:198
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
VOID * EFI_HANDLE
Definition: UefiBaseType.h:33
EFI_BOOT_SERVICES * gBS
EFI_STATUS EFIAPI RunAllTestSuites(IN UNIT_TEST_FRAMEWORK_HANDLE FrameworkHandle)
Definition: RunTests.c:145
EFI_STATUS EFIAPI FreeUnitTestFramework(IN UNIT_TEST_FRAMEWORK_HANDLE FrameworkHandle)
Definition: UnitTestLib.c:150
EFI_STATUS EFIAPI InitUnitTestFramework(OUT UNIT_TEST_FRAMEWORK_HANDLE *FrameworkHandle, IN CHAR8 *Title, IN CHAR8 *ShortTitle, IN CHAR8 *VersionString)
Definition: UnitTestLib.c:204