2 Reset System Library functions for bootloader
4 Copyright (c) 2014 - 2019, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
10 #include <Library/BaseLib.h>
11 #include <Library/DebugLib.h>
12 #include <Library/IoLib.h>
13 #include <Library/HobLib.h>
14 #include <Library/BaseMemoryLib.h>
15 #include <Guid/AcpiBoardInfoGuid.h>
17 ACPI_BOARD_INFO mAcpiBoardInfo
;
20 The constructor function to initialize mAcpiBoardInfo.
22 @retval EFI_SUCCESS The constructor always returns RETURN_SUCCESS.
27 ResetSystemLibConstructor (
31 EFI_HOB_GUID_TYPE
*GuidHob
;
32 ACPI_BOARD_INFO
*AcpiBoardInfoPtr
;
35 // Find the acpi board information guid hob
37 GuidHob
= GetFirstGuidHob (&gUefiAcpiBoardInfoGuid
);
38 ASSERT (GuidHob
!= NULL
);
40 AcpiBoardInfoPtr
= (ACPI_BOARD_INFO
*)GET_GUID_HOB_DATA (GuidHob
);
41 CopyMem (&mAcpiBoardInfo
, AcpiBoardInfoPtr
, sizeof (ACPI_BOARD_INFO
));
54 ASSERT (SuspendType
<= 7);
56 PmCtrlReg
= (UINTN
)mAcpiBoardInfo
.PmCtrlRegBase
;
57 IoAndThenOr16 (PmCtrlReg
, (UINT16
) ~0x3c00, (UINT16
) (SuspendType
<< 10));
58 IoOr16 (PmCtrlReg
, BIT13
);
63 Calling this function causes a system-wide reset. This sets
64 all circuitry within the system to its initial state. This type of reset
65 is asynchronous to system operation and operates without regard to
68 System reset should not return, if it returns, it means the system does
69 not support cold reset.
77 IoWrite8 ((UINTN
)mAcpiBoardInfo
.ResetRegAddress
, mAcpiBoardInfo
.ResetValue
);
82 Calling this function causes a system-wide initialization. The processors
83 are set to their initial state, and pending cycles are not corrupted.
85 System reset should not return, if it returns, it means the system does
86 not support warm reset.
94 IoWrite8 ((UINTN
)mAcpiBoardInfo
.ResetRegAddress
, mAcpiBoardInfo
.ResetValue
);
99 Calling this function causes the system to enter a power state equivalent
100 to the ACPI G2/S5 or G3 states.
102 System shutdown should not return, if it returns, it means the system does
103 not support shut down reset.
114 // GPE0_EN should be disabled to avoid any GPI waking up the system from S5
116 IoWrite16 ((UINTN
)mAcpiBoardInfo
.PmGpeEnBase
, 0);
119 // Clear Power Button Status
121 IoWrite16((UINTN
) mAcpiBoardInfo
.PmEvtBase
, BIT8
);
124 // Transform system into S5 sleep state
126 PmCtrlReg
= (UINTN
)mAcpiBoardInfo
.PmCtrlRegBase
;
127 IoAndThenOr16 (PmCtrlReg
, (UINT16
) ~0x3c00, (UINT16
) (7 << 10));
128 IoOr16 (PmCtrlReg
, BIT13
);
135 Calling this function causes the system to enter a power state for capsule
138 Reset update should not return, if it returns, it means the system does
139 not support capsule update.
144 EnterS3WithImmediateWake (
153 This function causes a systemwide reset. The exact type of the reset is
154 defined by the EFI_GUID that follows the Null-terminated Unicode string passed
155 into ResetData. If the platform does not recognize the EFI_GUID in ResetData
156 the platform must pick a supported reset type to perform.The platform may
157 optionally log the parameters from any non-normal reset that occurs.
159 @param[in] DataSize The size, in bytes, of ResetData.
160 @param[in] ResetData The data buffer starts with a Null-terminated string,
161 followed by the EFI_GUID.
165 ResetPlatformSpecific (