]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ArmPkg/Drivers/CpuDxe/CpuDxe.c
ArmPkg/CpuDxe: Register a callback for the gIdleLoopEventGuid event
[mirror_edk2.git] / ArmPkg / Drivers / CpuDxe / CpuDxe.c
index 7e863f39361c559871158bef93c2c7f31a0f6874..cea333f91d6a8c10b305ef3292032c54214773f1 100644 (file)
@@ -1,6 +1,7 @@
 /** @file\r
 \r
   Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
+  Copyright (c) 2011, ARM Limited. All rights reserved.\r
   \r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
@@ -14,6 +15,8 @@
 \r
 #include "CpuDxe.h"\r
 \r
+#include <Guid/IdleLoopEvent.h>\r
+\r
 BOOLEAN mInterruptState   = FALSE;\r
 \r
 \r
@@ -194,6 +197,23 @@ CpuGetTimerValue (
   return EFI_UNSUPPORTED;\r
 }\r
 \r
+/**\r
+  Callback function for idle events.\r
\r
+  @param  Event                 Event whose notification function is being invoked.\r
+  @param  Context               The pointer to the notification function's context,\r
+                                which is implementation-dependent.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+IdleLoopEventCallback (\r
+  IN EFI_EVENT                Event,\r
+  IN VOID                     *Context\r
+  )\r
+{\r
+  CpuSleep ();\r
+}\r
 \r
 //\r
 // Globals used to initialize the protocol\r
@@ -219,10 +239,10 @@ CpuDxeInitialize (
   )\r
 {\r
   EFI_STATUS  Status;\r
+  EFI_EVENT    IdleLoopEvent;\r
 \r
   InitializeExceptions (&mCpu);  \r
   \r
-  \r
   Status = gBS->InstallMultipleProtocolInterfaces (\r
                 &mCpuHandle, \r
                 &gEfiCpuArchProtocolGuid,           &mCpu, \r
@@ -237,6 +257,18 @@ CpuDxeInitialize (
   //\r
   SyncCacheConfig (&mCpu);\r
   \r
+  //\r
+  // Setup a callback for idle events\r
+  //\r
+  Status = gBS->CreateEventEx (\r
+                  EVT_NOTIFY_SIGNAL,\r
+                  TPL_NOTIFY,\r
+                  IdleLoopEventCallback,\r
+                  NULL,\r
+                  &gIdleLoopEventGuid,\r
+                  &IdleLoopEvent\r
+                  );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
   return Status;\r
 }\r
-\r