]> git.proxmox.com Git - mirror_edk2.git/commitdiff
UefiCpuPkg/CpuDxe: Put CPU to sleep during Idle events
authorjljusten <jljusten@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 16 Jun 2011 23:28:16 +0000 (23:28 +0000)
committerjljusten <jljusten@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 16 Jun 2011 23:28:16 +0000 (23:28 +0000)
When the MdeModulePkg gCoreEventIdleGuid event is signaled,
CpuSleep is called.  This will cause the CPU to sleep until
the next interrupt occurs.

Signed-off-by: jljusten
Reviewed-by: mdkinney
Reviewed-by: rsun3
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11842 6f19259b-4bc3-4df7-8a09-765794883524

UefiCpuPkg/CpuDxe/CpuDxe.c
UefiCpuPkg/CpuDxe/CpuDxe.h
UefiCpuPkg/CpuDxe/CpuDxe.inf

index 04d76a5cebe886b361b3499604b626abc7c24c97..ad4599dab93c8674ecaa9303c54846fcd8cd0ee0 100644 (file)
@@ -1154,6 +1154,25 @@ InitInterruptDescriptorTable (
 }\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
 /**\r
   Initialize the state information for the CPU Architectural Protocol.\r
 \r
@@ -1173,6 +1192,7 @@ InitializeCpu (
   )\r
 {\r
   EFI_STATUS  Status;\r
+  EFI_EVENT   IdleLoopEvent;\r
 \r
   //\r
   // Make sure interrupts are disabled\r
@@ -1204,6 +1224,19 @@ InitializeCpu (
   //\r
   RefreshGcdMemoryAttributes ();\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 d42f82e0bda6ea9cc1939041f0f5a59bfa6840cf..e36cf1c82cf22f88bbf09fb92788ac952487380b 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   CPU DXE Module.\r
 \r
-  Copyright (c) 2008 - 2010, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2008 - 2011, Intel Corporation. All rights reserved.<BR>\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
@@ -28,6 +28,7 @@
 #include <Library/MemoryAllocationLib.h>\r
 #include <Library/DebugLib.h>\r
 #include <Library/MtrrLib.h>\r
+#include <Guid/IdleLoopEvent.h>\r
 \r
 //\r
 //\r
index 7790d3505ddd73ddbb2f7c33c0db3bd30e00ac60..0c70b3276d3bfc86a56717b2b138342dc909195e 100644 (file)
@@ -2,7 +2,7 @@
 #\r
 #    Component description file for simple CPU driver\r
 #\r
-#  Copyright (c) 2008 - 2010, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2008 - 2011, Intel Corporation. All rights reserved.<BR>\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
@@ -24,6 +24,7 @@
 \r
 [Packages]\r
   MdePkg/MdePkg.dec\r
+  MdeModulePkg/MdeModulePkg.dec\r
   UefiCpuPkg/UefiCpuPkg.dec\r
 \r
 [LibraryClasses]\r
@@ -59,6 +60,9 @@
 [Protocols]\r
   gEfiCpuArchProtocolGuid\r
 \r
+[Guids]\r
+  gIdleLoopEventGuid                            ## CONSUMES ## GUID\r
+\r
 [Depex]\r
   TRUE\r
 \r