summaryrefslogtreecommitdiff
path: root/InOsEmuPkg/CpuRuntimeDxe
diff options
context:
space:
mode:
authorandrewfish <andrewfish@6f19259b-4bc3-4df7-8a09-765794883524>2011-06-17 18:21:16 +0000
committerandrewfish <andrewfish@6f19259b-4bc3-4df7-8a09-765794883524>2011-06-17 18:21:16 +0000
commit57c7d70ff9bcd4365d75b854046bbb390cb579c6 (patch)
treef55a5d5c20115d918df260ef03071015b36ee1d3 /InOsEmuPkg/CpuRuntimeDxe
parentd8387fa4af2abae05dc6ec502b27adea455cdaaa (diff)
downloadedk2-platforms-57c7d70ff9bcd4365d75b854046bbb390cb579c6.tar.xz
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
Diffstat (limited to 'InOsEmuPkg/CpuRuntimeDxe')
-rw-r--r--InOsEmuPkg/CpuRuntimeDxe/Cpu.c33
-rw-r--r--InOsEmuPkg/CpuRuntimeDxe/Cpu.inf3
-rw-r--r--InOsEmuPkg/CpuRuntimeDxe/CpuDriver.h1
3 files changed, 37 insertions, 0 deletions
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 <Protocol/CpuIo2.h>
#include <Guid/DataHubRecords.h>
+#include <Guid/IdleLoopEvent.h>
#include <Library/BaseLib.h>
#include <Library/DebugLib.h>