Skip to content

Commit 986c9a3

Browse files
committed
PeiMp2UnitTest: Add test case for EnableDisableAP.
Signed-off-by: Eric Dong <[email protected]>
1 parent 936303b commit 986c9a3

File tree

1 file changed

+124
-30
lines changed

1 file changed

+124
-30
lines changed

PeiMp2UnitTest/PeiMp2UnitTest.c

+124-30
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,6 @@ Sleep (
172172
}
173173
}
174174

175-
176175
VOID
177176
Procedure (
178177
IN VOID *ProcedureArgument
@@ -203,42 +202,99 @@ Procedure (
203202
}
204203
}
205204

206-
/**
207-
Module's entry function.
208-
This routine will install EFI_PEI_PCI_CFG2_PPI.
209-
210-
@param FileHandle Handle of the file being invoked.
211-
@param PeiServices Describes the list of possible PEI Services.
212-
213-
@return Whether success to install service.
214-
**/
215-
EFI_STATUS
216-
EFIAPI
217-
PeiMp2UnitTest (
218-
IN EFI_PEI_FILE_HANDLE FileHandle,
219-
IN CONST EFI_PEI_SERVICES **PeiServices
205+
VOID
206+
TestAPIEnableDisableAP (
207+
VOID
220208
)
221209
{
222-
EFI_STATUS Status;
210+
UINTN NumberOfProcessors;
211+
UINTN NumberOfEnabledProcessors;
212+
EFI_STATUS Status;
213+
PEI_MP2_PROCEDURE_PARAM ProcParam;
214+
215+
DEBUG((DEBUG_INFO, "1.Test EnableDisableAP begin!\n"));
216+
Status = mCpuMp2Ppi->GetNumberOfProcessors (
217+
mCpuMp2Ppi,
218+
&NumberOfProcessors,
219+
&NumberOfEnabledProcessors);
220+
if (EFI_ERROR (Status)) {
221+
///
222+
/// If unable to retrieve the Number of Processors - assert.
223+
///
224+
DEBUG((DEBUG_INFO, "GetNumberOfProcessors return failure!\n"));
225+
return;
226+
}
227+
DEBUG((DEBUG_INFO, "Before disable one AP, NumOfProc = 0x%x, NumOfEnableProc = 0x%x!\n", NumberOfProcessors, NumberOfEnabledProcessors));
228+
229+
Status = mCpuMp2Ppi->EnableDisableAP (
230+
mCpuMp2Ppi,
231+
NumberOfProcessors - 1,
232+
FALSE,
233+
NULL
234+
);
235+
if (EFI_ERROR (Status)) {
236+
///
237+
/// If unable to retrieve the Number of Processors - assert.
238+
///
239+
DEBUG((DEBUG_INFO, "EnableDisableAP return failure!\n"));
240+
return;
241+
}
223242

224-
PEI_MP2_PROCEDURE_PARAM ProcParam;
243+
Status = mCpuMp2Ppi->GetNumberOfProcessors (
244+
mCpuMp2Ppi,
245+
&NumberOfProcessors,
246+
&NumberOfEnabledProcessors);
247+
ASSERT_EFI_ERROR (Status);
248+
DEBUG((DEBUG_INFO, "After disable one AP, NumOfProc = 0x%x, NumOfEnableProc = 0x%x!\n", NumberOfProcessors, NumberOfEnabledProcessors));
249+
250+
Status = mCpuMp2Ppi->EnableDisableAP (
251+
mCpuMp2Ppi,
252+
NumberOfProcessors - 1,
253+
TRUE,
254+
NULL
255+
);
256+
ASSERT_EFI_ERROR (Status);
225257

226-
InitializeSpinLock((SPIN_LOCK*) &mConsoleLock);
258+
Status = mCpuMp2Ppi->GetNumberOfProcessors (
259+
mCpuMp2Ppi,
260+
&NumberOfProcessors,
261+
&NumberOfEnabledProcessors);
262+
ASSERT_EFI_ERROR (Status);
263+
264+
DEBUG((DEBUG_INFO, "After enable one AP, NumOfProc = 0x%x, NumOfEnableProc = 0x%x!\n", NumberOfProcessors, NumberOfEnabledProcessors));
227265

228266
//
229-
// Get MP Services2 Ppi
267+
// Add below code here to test an regression issue fix below bugz:
268+
// https://bugzilla.tianocore.org/show_bug.cgi?id=2474
230269
//
231-
Status = PeiServicesLocatePpi (
232-
&gEdkiiPeiMpServices2PpiGuid,
233-
0,
234-
NULL,
235-
(VOID **)&mCpuMp2Ppi
236-
);
237-
ASSERT_EFI_ERROR (Status);
270+
ProcParam.SleepTime = 0x30;
271+
DEBUG((DEBUG_INFO, "Trig StartupAllCPUs with SleepTime = 0x%x\n", ProcParam.SleepTime));
272+
Status = mCpuMp2Ppi->StartupAllCPUs (
273+
mCpuMp2Ppi,
274+
Procedure,
275+
0x20,
276+
&ProcParam
277+
);
278+
if (EFI_ERROR (Status)) {
279+
//
280+
// StartAllCPUs will let APs to run the procedure first, then BSP
281+
// itself will run the procedure, at last BSP will check the APs
282+
// result. So the timeout value not works here because Bsp run
283+
// procedure also needs time.
284+
//
285+
DEBUG((DEBUG_INFO, "Trig StartupAllCPUs returns Fail !\n"));
286+
} else {
287+
DEBUG((DEBUG_INFO, "Trig StartupAllCPUs returns Pass !\n"));
288+
}
289+
}
238290

239-
DEBUG((DEBUG_INFO, "=========================================\n"));
240-
DEBUG((DEBUG_INFO, "=========================================\n"));
241-
DEBUG((DEBUG_INFO, "Begin do Edkii Pei Mp Services2 Ppi test!\n"));
291+
VOID
292+
TestAPIStartAllCPU (
293+
VOID
294+
)
295+
{
296+
EFI_STATUS Status;
297+
PEI_MP2_PROCEDURE_PARAM ProcParam;
242298

243299
ProcParam.SleepTime = 0;
244300
DEBUG((DEBUG_INFO, "1.Test StartupAllCPUs begin, SleepTime = 0x%x\n", ProcParam.SleepTime));
@@ -273,9 +329,47 @@ PeiMp2UnitTest (
273329
} else {
274330
DEBUG((DEBUG_INFO, "2. Test StartupAllCPUs End ==== Pass !\n"));
275331
}
332+
}
333+
334+
/**
335+
Module's entry function.
336+
This routine will install EFI_PEI_PCI_CFG2_PPI.
337+
338+
@param FileHandle Handle of the file being invoked.
339+
@param PeiServices Describes the list of possible PEI Services.
340+
341+
@return Whether success to install service.
342+
**/
343+
EFI_STATUS
344+
EFIAPI
345+
PeiMp2UnitTest (
346+
IN EFI_PEI_FILE_HANDLE FileHandle,
347+
IN CONST EFI_PEI_SERVICES **PeiServices
348+
)
349+
{
350+
EFI_STATUS Status;
351+
352+
InitializeSpinLock((SPIN_LOCK*) &mConsoleLock);
353+
354+
//
355+
// Get MP Services2 Ppi
356+
//
357+
Status = PeiServicesLocatePpi (
358+
&gEdkiiPeiMpServices2PpiGuid,
359+
0,
360+
NULL,
361+
(VOID **)&mCpuMp2Ppi
362+
);
363+
ASSERT_EFI_ERROR (Status);
276364

277-
DEBUG((DEBUG_INFO, "Edkii Pei Mp Services2 Ppi test End!\n"));
278365
DEBUG((DEBUG_INFO, "=========================================\n"));
366+
DEBUG((DEBUG_INFO, "Begin do Edkii Pei Mp Services2 Ppi test!\n"));
367+
368+
TestAPIStartAllCPU ();
369+
370+
TestAPIEnableDisableAP ();
371+
372+
DEBUG((DEBUG_INFO, "Edkii Pei Mp Services2 Ppi test End!\n"));
279373
DEBUG((DEBUG_INFO, "=========================================\n"));
280374

281375
return EFI_SUCCESS;

0 commit comments

Comments
 (0)