ResetSystemLib.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. /** @file
  2. Reset System Library functions for PCAT platforms
  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 <Uefi/UefiBaseType.h>
  8. #include <Uefi/UefiMultiPhase.h>
  9. #include <Library/DebugLib.h>
  10. #include <Library/IoLib.h>
  11. /**
  12. Calling this function causes a system-wide reset. This sets
  13. all circuitry within the system to its initial state. This type of reset
  14. is asynchronous to system operation and operates without regard to
  15. cycle boundaries.
  16. System reset should not return, if it returns, it means the system does
  17. not support cold reset.
  18. **/
  19. VOID
  20. EFIAPI
  21. ResetCold (
  22. VOID
  23. )
  24. {
  25. IoWrite8 ((UINTN) PcdGet64 (PcdResetControlRegister), PcdGet8 (PcdResetControlValueColdReset));
  26. }
  27. /**
  28. Calling this function causes a system-wide initialization. The processors
  29. are set to their initial state, and pending cycles are not corrupted.
  30. System reset should not return, if it returns, it means the system does
  31. not support warm reset.
  32. **/
  33. VOID
  34. EFIAPI
  35. ResetWarm (
  36. VOID
  37. )
  38. {
  39. IoWrite8 ((UINTN) PcdGet64 (PcdResetControlRegister), PcdGet8 (PcdResetControlValueColdReset));
  40. }
  41. /**
  42. Calling this function causes the system to enter a power state equivalent
  43. to the ACPI G2/S5 or G3 states.
  44. System shutdown should not return, if it returns, it means the system does
  45. not support shut down reset.
  46. **/
  47. VOID
  48. EFIAPI
  49. ResetShutdown (
  50. VOID
  51. )
  52. {
  53. ASSERT (FALSE);
  54. }
  55. /**
  56. Calling this function causes the system to enter a power state for capsule
  57. update.
  58. Reset update should not return, if it returns, it means the system does
  59. not support capsule update.
  60. **/
  61. VOID
  62. EFIAPI
  63. EnterS3WithImmediateWake (
  64. VOID
  65. )
  66. {
  67. ASSERT (FALSE);
  68. }
  69. /**
  70. This function causes a systemwide reset. The exact type of the reset is
  71. defined by the EFI_GUID that follows the Null-terminated Unicode string passed
  72. into ResetData. If the platform does not recognize the EFI_GUID in ResetData
  73. the platform must pick a supported reset type to perform.The platform may
  74. optionally log the parameters from any non-normal reset that occurs.
  75. @param[in] DataSize The size, in bytes, of ResetData.
  76. @param[in] ResetData The data buffer starts with a Null-terminated string,
  77. followed by the EFI_GUID.
  78. **/
  79. VOID
  80. EFIAPI
  81. ResetPlatformSpecific (
  82. IN UINTN DataSize,
  83. IN VOID *ResetData
  84. )
  85. {
  86. ResetCold ();
  87. }
  88. /**
  89. The ResetSystem function resets the entire platform.
  90. @param[in] ResetType The type of reset to perform.
  91. @param[in] ResetStatus The status code for the reset.
  92. @param[in] DataSize The size, in bytes, of ResetData.
  93. @param[in] ResetData For a ResetType of EfiResetCold, EfiResetWarm, or EfiResetShutdown
  94. the data buffer starts with a Null-terminated string, optionally
  95. followed by additional binary data. The string is a description
  96. that the caller may use to further indicate the reason for the
  97. system reset.
  98. **/
  99. VOID
  100. EFIAPI
  101. ResetSystem (
  102. IN EFI_RESET_TYPE ResetType,
  103. IN EFI_STATUS ResetStatus,
  104. IN UINTN DataSize,
  105. IN VOID *ResetData OPTIONAL
  106. )
  107. {
  108. switch (ResetType) {
  109. case EfiResetWarm:
  110. ResetWarm ();
  111. break;
  112. case EfiResetCold:
  113. ResetCold ();
  114. break;
  115. case EfiResetShutdown:
  116. ResetShutdown ();
  117. return;
  118. case EfiResetPlatformSpecific:
  119. ResetPlatformSpecific (DataSize, ResetData);
  120. return;
  121. default:
  122. return;
  123. }
  124. }