]> git.proxmox.com Git - mirror_edk2.git/blobdiff - UefiCpuPkg/CpuDxe/CpuDxe.c
UefiCpuPkg/CpuDxe: Put CPU to sleep during Idle events
[mirror_edk2.git] / UefiCpuPkg / CpuDxe / CpuDxe.c
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