]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmPkg/CpuDxe: Register a callback for the gIdleLoopEventGuid event
authoroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 20 Jun 2011 21:35:50 +0000 (21:35 +0000)
committeroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 20 Jun 2011 21:35:50 +0000 (21:35 +0000)
This gIdleLoopEventGuid event signals the Cpu that it should go into
the idle state waiting for any events.
CpuSleep() is used in this implementation to make the Cpu wait for
the next interrupt (WFI instruction).

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11863 6f19259b-4bc3-4df7-8a09-765794883524

ArmPkg/Drivers/CpuDxe/CpuDxe.c
ArmPkg/Drivers/CpuDxe/CpuDxe.inf

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
index 94e91c1ebd77e21f31092142fa5995f1173c30ae..3cf4036cfb42b72c2c4be40d60802d9a4ace4548 100644 (file)
@@ -3,6 +3,8 @@
 #  DXE CPU driver\r
 #  \r
 #  Copyright (c) 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
 #  which accompanies this distribution.  The full text of the license may be found at\r
@@ -45,6 +47,7 @@
   ArmPkg/ArmPkg.dec\r
   EmbeddedPkg/EmbeddedPkg.dec\r
   MdePkg/MdePkg.dec\r
+  MdeModulePkg/MdeModulePkg.dec\r
 \r
 [LibraryClasses]\r
   BaseMemoryLib\r
@@ -65,6 +68,7 @@
 \r
 [Guids]\r
   gEfiDebugImageInfoTableGuid\r
+  gIdleLoopEventGuid\r
 \r
 [Pcd.common]\r
   gArmTokenSpaceGuid.PcdVFPEnabled\r