ResetSystemLib.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /** @file
  2. Reset System Library functions for Simics ICH10
  3. Copyright (c) 2006 - 2019 Intel Corporation. All rights reserved. <BR>
  4. SPDX-License-Identifier: BSD-2-Clause-Patent
  5. **/
  6. #include <Base.h>
  7. #include <Library/BaseLib.h>
  8. #include <Library/DebugLib.h>
  9. #include <Library/IoLib.h>
  10. #include <Library/TimerLib.h>
  11. #include <Register/X58Ich10.h>
  12. VOID
  13. AcpiPmControl (
  14. UINTN SuspendType
  15. )
  16. {
  17. ASSERT (SuspendType < 6);
  18. DEBUG((EFI_D_ERROR, "SuspendType = 0x%x\n", SuspendType));
  19. IoBitFieldWrite16 (ICH10_PMBASE_IO + 4, 10, 13, (UINT16) SuspendType);
  20. IoOr16 (ICH10_PMBASE_IO + 0x04, BIT13);
  21. CpuDeadLoop ();
  22. }
  23. /**
  24. Calling this function causes a system-wide reset. This sets
  25. all circuitry within the system to its initial state. This type of reset
  26. is asynchronous to system operation and operates without regard to
  27. cycle boundaries.
  28. System reset should not return, if it returns, it means the system does
  29. not support cold reset.
  30. **/
  31. VOID
  32. EFIAPI
  33. ResetCold (
  34. VOID
  35. )
  36. {
  37. DEBUG((EFI_D_ERROR, "ResetCold_CF9\n"));
  38. IoWrite8 (0xCF9, BIT3 | BIT2 | BIT1); // 1st choice: PIIX3 RCR, RCPU|SRST
  39. MicroSecondDelay (50);
  40. DEBUG((EFI_D_ERROR, "ResetCold_Port64\n"));
  41. IoWrite8 (0x64, 0xfe); // 2nd choice: keyboard controller
  42. CpuDeadLoop ();
  43. }
  44. /**
  45. Calling this function causes a system-wide initialization. The processors
  46. are set to their initial state, and pending cycles are not corrupted.
  47. System reset should not return, if it returns, it means the system does
  48. not support warm reset.
  49. **/
  50. VOID
  51. EFIAPI
  52. ResetWarm (
  53. VOID
  54. )
  55. {
  56. DEBUG((EFI_D_ERROR, "ResetWarm\n"));
  57. //
  58. //BUGBUG workaround for warm reset
  59. //
  60. IoWrite8(0xCF9, BIT2 | BIT1);
  61. MicroSecondDelay(50);
  62. IoWrite8 (0x64, 0xfe);
  63. CpuDeadLoop ();
  64. }
  65. /**
  66. Calling this function causes the system to enter a power state equivalent
  67. to the ACPI G2/S5 or G3 states.
  68. System shutdown should not return, if it returns, it means the system does
  69. not support shut down reset.
  70. **/
  71. VOID
  72. EFIAPI
  73. ResetShutdown (
  74. VOID
  75. )
  76. {
  77. DEBUG((EFI_D_ERROR, "ResetShutdown\n"));
  78. AcpiPmControl (0);
  79. ASSERT (FALSE);
  80. }
  81. /**
  82. Calling this function causes the system to enter a power state for capsule
  83. update.
  84. Reset update should not return, if it returns, it means the system does
  85. not support capsule update.
  86. **/
  87. VOID
  88. EFIAPI
  89. EnterS3WithImmediateWake (
  90. VOID
  91. )
  92. {
  93. DEBUG((EFI_D_ERROR, "EnterS3WithImmediateWake\n"));
  94. AcpiPmControl (1);
  95. ASSERT (FALSE);
  96. }
  97. /**
  98. This function causes a systemwide reset. The exact type of the reset is
  99. defined by the EFI_GUID that follows the Null-terminated Unicode string passed
  100. into ResetData. If the platform does not recognize the EFI_GUID in ResetData
  101. the platform must pick a supported reset type to perform.The platform may
  102. optionally log the parameters from any non-normal reset that occurs.
  103. @param[in] DataSize The size, in bytes, of ResetData.
  104. @param[in] ResetData The data buffer starts with a Null-terminated string,
  105. followed by the EFI_GUID.
  106. **/
  107. VOID
  108. EFIAPI
  109. ResetPlatformSpecific (
  110. IN UINTN DataSize,
  111. IN VOID *ResetData
  112. )
  113. {
  114. DEBUG((EFI_D_ERROR, "ResetPlatformSpecific\n"));
  115. ResetCold ();
  116. }