ResetSystemLib.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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. This function causes a systemwide reset. The exact type of the reset is
  57. defined by the EFI_GUID that follows the Null-terminated Unicode string passed
  58. into ResetData. If the platform does not recognize the EFI_GUID in ResetData
  59. the platform must pick a supported reset type to perform.The platform may
  60. optionally log the parameters from any non-normal reset that occurs.
  61. @param[in] DataSize The size, in bytes, of ResetData.
  62. @param[in] ResetData The data buffer starts with a Null-terminated string,
  63. followed by the EFI_GUID.
  64. **/
  65. VOID
  66. EFIAPI
  67. ResetPlatformSpecific (
  68. IN UINTN DataSize,
  69. IN VOID *ResetData
  70. )
  71. {
  72. ResetCold ();
  73. }
  74. /**
  75. The ResetSystem function resets the entire platform.
  76. @param[in] ResetType The type of reset to perform.
  77. @param[in] ResetStatus The status code for the reset.
  78. @param[in] DataSize The size, in bytes, of ResetData.
  79. @param[in] ResetData For a ResetType of EfiResetCold, EfiResetWarm, or EfiResetShutdown
  80. the data buffer starts with a Null-terminated string, optionally
  81. followed by additional binary data. The string is a description
  82. that the caller may use to further indicate the reason for the
  83. system reset.
  84. **/
  85. VOID
  86. EFIAPI
  87. ResetSystem (
  88. IN EFI_RESET_TYPE ResetType,
  89. IN EFI_STATUS ResetStatus,
  90. IN UINTN DataSize,
  91. IN VOID *ResetData OPTIONAL
  92. )
  93. {
  94. switch (ResetType) {
  95. case EfiResetWarm:
  96. ResetWarm ();
  97. break;
  98. case EfiResetCold:
  99. ResetCold ();
  100. break;
  101. case EfiResetShutdown:
  102. ResetShutdown ();
  103. return;
  104. case EfiResetPlatformSpecific:
  105. ResetPlatformSpecific (DataSize, ResetData);
  106. return;
  107. default:
  108. return;
  109. }
  110. }