NOTE: this patches is for testing temporary. So it should be ignore when adding to main tree.
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Chen Fan <chen.fan.f...@cn.fujitsu.com> --- UefiCpuPkg/CpuDxe/CpuDxe.c | 2 + UefiCpuPkg/CpuDxe/CpuDxe.inf | 1 + UefiCpuPkg/CpuDxe/CpuMp.h | 9 ++++ UefiCpuPkg/CpuDxe/CpuMpTest.c | 97 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 109 insertions(+) create mode 100644 UefiCpuPkg/CpuDxe/CpuMpTest.c diff --git a/UefiCpuPkg/CpuDxe/CpuDxe.c b/UefiCpuPkg/CpuDxe/CpuDxe.c index c9df4e1..16e6bcc 100644 --- a/UefiCpuPkg/CpuDxe/CpuDxe.c +++ b/UefiCpuPkg/CpuDxe/CpuDxe.c @@ -900,6 +900,8 @@ InitializeCpu ( InitializeMpSupport (); + AddTestMpService (); + return Status; } diff --git a/UefiCpuPkg/CpuDxe/CpuDxe.inf b/UefiCpuPkg/CpuDxe/CpuDxe.inf index 6761e91..6983e62 100644 --- a/UefiCpuPkg/CpuDxe/CpuDxe.inf +++ b/UefiCpuPkg/CpuDxe/CpuDxe.inf @@ -52,6 +52,7 @@ CpuGdt.h CpuMp.c CpuMp.h + CpuMpTest.c [Sources.IA32] Ia32/CpuAsm.asm | MSFT diff --git a/UefiCpuPkg/CpuDxe/CpuMp.h b/UefiCpuPkg/CpuDxe/CpuMp.h index 10c67b8..5bb7c31 100644 --- a/UefiCpuPkg/CpuDxe/CpuMp.h +++ b/UefiCpuPkg/CpuDxe/CpuMp.h @@ -637,5 +637,14 @@ ResetApStackless ( IN UINT32 ProcessorId ); +/** + Initialize Mp Service Testing. + +**/ +VOID +AddTestMpService ( + VOID + ); + #endif // _CPU_MP_H_ diff --git a/UefiCpuPkg/CpuDxe/CpuMpTest.c b/UefiCpuPkg/CpuDxe/CpuMpTest.c new file mode 100644 index 0000000..9d65b1c --- /dev/null +++ b/UefiCpuPkg/CpuDxe/CpuMpTest.c @@ -0,0 +1,97 @@ +#include "CpuDxe.h" +#include "CpuMp.h" + +VOID +EFIAPI +CheckTaskComplete ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + DEBUG ((DEBUG_INFO, "All Client Task finished.\n")); +} + +VOID +EFIAPI +ClientTask( + IN VOID* parameter + ) +{ + DEBUG ((DEBUG_INFO, "I am Client Task!!!\n")); +} + +VOID +EFIAPI +ClientTask1( + IN VOID* parameter + ) +{ + DEBUG ((DEBUG_INFO, "I am Client Task with timeout!!!\n")); + while (1); +} + + +/** + Initialize Mp Service Testing + +**/ +VOID +AddTestMpService ( + VOID + ) +{ + EFI_STATUS Status; + EFI_MP_SERVICES_PROTOCOL *MpService; + UINTN WhoAmI; + UINTN NumberOfProcessors; + UINTN NumberOfEnabledProcessors; + EFI_EVENT WaitEvent; + + Status = gBS->LocateProtocol(&gEfiMpServiceProtocolGuid, + NULL, + (void **) &MpService); + if (EFI_ERROR(Status)) { + DEBUG ((DEBUG_ERROR, "Install Mp Service fails\n")); + return; + } + + Status = MpService->WhoAmI(MpService, &WhoAmI); + if (!EFI_ERROR(Status)) { + DEBUG ((DEBUG_INFO, "WhoAmI is : %d\n", WhoAmI)); + } + + Status = MpService->GetNumberOfProcessors (MpService, + &NumberOfProcessors, + &NumberOfEnabledProcessors + ); + if (!EFI_ERROR(Status)) { + DEBUG ((DEBUG_INFO, "GetNumberOfProcessors : %d enabled: %d\n", + NumberOfProcessors, NumberOfEnabledProcessors)); + } + + gBS->CreateEvent ( + EVT_NOTIFY_SIGNAL, + TPL_CALLBACK, + CheckTaskComplete, + NULL, + &WaitEvent + ); + + Status = MpService->StartupThisAP (MpService, ClientTask1, 1, NULL, + 1000000, NULL, NULL); + if (EFI_ERROR(Status)) { + DEBUG ((DEBUG_ERROR, "FAILED: %r\n", Status)); + } + + /* + do { + Status = gBS->CheckEvent(WaitEvent); + } while (EFI_ERROR(Status)); + + Status = MpService->StartupAllAPs (MpService, ClientTask, TRUE, WaitEvent, + 0, NULL, NULL); + if (EFI_ERROR(Status)) { + DEBUG ((DEBUG_ERROR, "FAILED.\n")); + }*/ + +} -- 1.9.3 ------------------------------------------------------------------------------ _______________________________________________ edk2-devel mailing list edk2-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/edk2-devel