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
));
47 Calling this function causes a system-wide reset. This sets
48 all circuitry within the system to its initial state. This type of reset
49 is asynchronous to system operation and operates without regard to
52 System reset should not return, if it returns, it means the system does
53 not support cold reset.
61 IoWrite8 ((UINTN
)mAcpiBoardInfo
.ResetRegAddress
, mAcpiBoardInfo
.ResetValue
);
66 Calling this function causes a system-wide initialization. The processors
67 are set to their initial state, and pending cycles are not corrupted.
69 System reset should not return, if it returns, it means the system does
70 not support warm reset.
78 IoWrite8 ((UINTN
)mAcpiBoardInfo
.ResetRegAddress
, mAcpiBoardInfo
.ResetValue
);
83 Calling this function causes the system to enter a power state equivalent
84 to the ACPI G2/S5 or G3 states.
86 System shutdown should not return, if it returns, it means the system does
87 not support shut down reset.
98 // GPE0_EN should be disabled to avoid any GPI waking up the system from S5
100 IoWrite16 ((UINTN
)mAcpiBoardInfo
.PmGpeEnBase
, 0);
103 // Clear Power Button Status
105 IoWrite16((UINTN
) mAcpiBoardInfo
.PmEvtBase
, BIT8
);
108 // Transform system into S5 sleep state
110 PmCtrlReg
= (UINTN
)mAcpiBoardInfo
.PmCtrlRegBase
;
111 IoAndThenOr16 (PmCtrlReg
, (UINT16
) ~0x3c00, (UINT16
) (7 << 10));
112 IoOr16 (PmCtrlReg
, BIT13
);
119 This function causes a systemwide reset. The exact type of the reset is
120 defined by the EFI_GUID that follows the Null-terminated Unicode string passed
121 into ResetData. If the platform does not recognize the EFI_GUID in ResetData
122 the platform must pick a supported reset type to perform.The platform may
123 optionally log the parameters from any non-normal reset that occurs.
125 @param[in] DataSize The size, in bytes, of ResetData.
126 @param[in] ResetData The data buffer starts with a Null-terminated string,
127 followed by the EFI_GUID.
131 ResetPlatformSpecific (