From 57c7d70ff9bcd4365d75b854046bbb390cb579c6 Mon Sep 17 00:00:00 2001 From: andrewfish Date: Fri, 17 Jun 2011 18:21:16 +0000 Subject: InOsEmuPkg: Implement gIdleLoopEventGuid. Added a CpuSleep () API to the Emulator Thunk. We needed to do this as the Stall() works hard to not get broken by the timer tic (POSIX signal). nanosleep() gets interrupted by the timer signal so it is a good emulator of a CpuSleep(); I was also able to remove some stalls in the X11 keyboard and mouse checking events, now that the gIdleLoopEventGuid was added. Signed-off-by: andrewfish git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11846 6f19259b-4bc3-4df7-8a09-765794883524 --- InOsEmuPkg/CpuRuntimeDxe/Cpu.c | 33 +++++++++++++++++++++++++++++++++ InOsEmuPkg/CpuRuntimeDxe/Cpu.inf | 3 +++ InOsEmuPkg/CpuRuntimeDxe/CpuDriver.h | 1 + 3 files changed, 37 insertions(+) (limited to 'InOsEmuPkg/CpuRuntimeDxe') diff --git a/InOsEmuPkg/CpuRuntimeDxe/Cpu.c b/InOsEmuPkg/CpuRuntimeDxe/Cpu.c index 472b1c3b73..5ec315bea2 100644 --- a/InOsEmuPkg/CpuRuntimeDxe/Cpu.c +++ b/InOsEmuPkg/CpuRuntimeDxe/Cpu.c @@ -305,6 +305,27 @@ CpuUpdateSmbios ( FreePool (SmbiosRecord); } + + +/** + Callback function for idle events. + + @param Event Event whose notification function is being invoked. + @param Context The pointer to the notification function's context, + which is implementation-dependent. + +**/ +VOID +EFIAPI +IdleLoopEventCallback ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + gEmuThunk->CpuSleep (); +} + + EFI_STATUS EFIAPI InitializeCpu ( @@ -314,6 +335,7 @@ InitializeCpu ( { EFI_STATUS Status; UINT64 Frequency; + EFI_EVENT IdleLoopEvent; // // Retrieve the frequency of the performance counter in Hz. @@ -328,6 +350,17 @@ InitializeCpu ( CpuUpdateSmbios (); CpuMpServicesInit (); + + Status = gBS->CreateEventEx ( + EVT_NOTIFY_SIGNAL, + TPL_NOTIFY, + IdleLoopEventCallback, + NULL, + &gIdleLoopEventGuid, + &IdleLoopEvent + ); + ASSERT_EFI_ERROR (Status); + Status = gBS->InstallMultipleProtocolInterfaces ( &mCpuTemplate.Handle, diff --git a/InOsEmuPkg/CpuRuntimeDxe/Cpu.inf b/InOsEmuPkg/CpuRuntimeDxe/Cpu.inf index 6fc240c907..d548c8a41a 100644 --- a/InOsEmuPkg/CpuRuntimeDxe/Cpu.inf +++ b/InOsEmuPkg/CpuRuntimeDxe/Cpu.inf @@ -66,6 +66,9 @@ gEmuThreadThunkProtocolGuid gEfiMpServiceProtocolGuid +[Guids] + gIdleLoopEventGuid ## CONSUMES ## GUID + [Pcd] gInOsEmuPkgTokenSpaceGuid.PcdEmuMpServicesPollingInterval diff --git a/InOsEmuPkg/CpuRuntimeDxe/CpuDriver.h b/InOsEmuPkg/CpuRuntimeDxe/CpuDriver.h index 3ef251101f..69505ff0e4 100644 --- a/InOsEmuPkg/CpuRuntimeDxe/CpuDriver.h +++ b/InOsEmuPkg/CpuRuntimeDxe/CpuDriver.h @@ -28,6 +28,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include #include +#include #include #include -- cgit v1.2.3