]> git.proxmox.com Git - mirror_edk2.git/blobdiff - DuetPkg/AcpiResetDxe/ResetEntry.c
Port AcpiResetDxe from EDK to EDKII to enable reset function on DUET above legacy...
[mirror_edk2.git] / DuetPkg / AcpiResetDxe / ResetEntry.c
diff --git a/DuetPkg/AcpiResetDxe/ResetEntry.c b/DuetPkg/AcpiResetDxe/ResetEntry.c
new file mode 100644 (file)
index 0000000..3da08a1
--- /dev/null
@@ -0,0 +1,88 @@
+/*++ @file\r
+  Entrypoint of AcpiResetDxe driver.\r
+\r
+Copyright (c) 2010, Intel Corporation                                                         \r
+All rights reserved. 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
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+--*/\r
+\r
+#include "Reset.h"\r
+\r
+EFI_ACPI_DESCRIPTION  mAcpiDescription;\r
+\r
+/**\r
+  Reset the system.\r
+\r
+  @param[in] ResetType       Warm or cold\r
+  @param[in] ResetStatus     Possible cause of reset\r
+  @param[in] DataSize        Size of ResetData in bytes\r
+  @param[in] ResetData       Optional Unicode string\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+EfiAcpiResetSystem (\r
+  IN EFI_RESET_TYPE   ResetType,\r
+  IN EFI_STATUS       ResetStatus,\r
+  IN UINTN            DataSize,\r
+  IN CHAR16           *ResetData OPTIONAL\r
+  )\r
+{\r
+  AcpiResetSystem (ResetType, ResetStatus, DataSize, ResetData, &mAcpiDescription);\r
+}\r
+\r
+/**\r
+  Initialize the state information for the Reset Architectural Protocol.\r
+\r
+  @param[in] ImageHandle  Image handle of the loaded driver\r
+  @param[in] SystemTable  Pointer to the System Table\r
+\r
+  @retval EFI_SUCCESS           Thread can be successfully created\r
+  @retval EFI_UNSUPPORTED       Cannot find the info to reset system\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+InitializeReset (\r
+  IN EFI_HANDLE        ImageHandle,\r
+  IN EFI_SYSTEM_TABLE  *SystemTable\r
+  )\r
+{\r
+  EFI_STATUS            Status;\r
+  EFI_HANDLE            Handle;\r
+  //\r
+  // Initialize AcpiDescription\r
+  //\r
+  if (!GetAcpiDescription (&mAcpiDescription)) {\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  //\r
+  // Make sure the Reset Architectural Protocol is not already installed in the system\r
+  //\r
+  ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiResetArchProtocolGuid);\r
+\r
+  //\r
+  // Hook the runtime service table\r
+  //\r
+  SystemTable->RuntimeServices->ResetSystem = EfiAcpiResetSystem;\r
+\r
+  //\r
+  // Now install the Reset RT AP on a new handle\r
+  //\r
+  Handle = NULL;\r
+  Status = gBS->InstallMultipleProtocolInterfaces (\r
+                  &Handle,\r
+                  &gEfiResetArchProtocolGuid,\r
+                  NULL,\r
+                  NULL\r
+                  );\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
+  return Status;\r
+}\r