]>
git.proxmox.com Git - mirror_edk2.git/blob - CorebootPayloadPkg/Library/ResetSystemLib/ResetSystemLib.c
1fb914240819fd5193fd00f3df08e490eb3279c4
2 Reset System Library functions for coreboot
4 Copyright (c) 2014 - 2016, 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>
15 #include <Guid/AcpiBoardInfoGuid.h>
22 EFI_HOB_GUID_TYPE
*GuidHob
;
23 ACPI_BOARD_INFO
*pAcpiBoardInfo
;
26 ASSERT (SuspendType
<= 7);
28 // Find the acpi board information guid hob
30 GuidHob
= GetFirstGuidHob (&gUefiAcpiBoardInfoGuid
);
31 ASSERT (GuidHob
!= NULL
);
32 pAcpiBoardInfo
= (ACPI_BOARD_INFO
*)GET_GUID_HOB_DATA (GuidHob
);
34 PmCtrlReg
= (UINTN
)pAcpiBoardInfo
->PmCtrlRegBase
;
35 IoAndThenOr16 (PmCtrlReg
, (UINT16
) ~0x3c00, (UINT16
) (SuspendType
<< 10));
36 IoOr16 (PmCtrlReg
, BIT13
);
41 Calling this function causes a system-wide reset. This sets
42 all circuitry within the system to its initial state. This type of reset
43 is asynchronous to system operation and operates without regard to
46 System reset should not return, if it returns, it means the system does
47 not support cold reset.
55 EFI_HOB_GUID_TYPE
*GuidHob
;
56 ACPI_BOARD_INFO
*pAcpiBoardInfo
;
59 // Find the acpi board information guid hob
61 GuidHob
= GetFirstGuidHob (&gUefiAcpiBoardInfoGuid
);
62 ASSERT (GuidHob
!= NULL
);
63 pAcpiBoardInfo
= (ACPI_BOARD_INFO
*)GET_GUID_HOB_DATA (GuidHob
);
65 IoWrite8 ((UINTN
)pAcpiBoardInfo
->ResetRegAddress
, pAcpiBoardInfo
->ResetValue
);
70 Calling this function causes a system-wide initialization. The processors
71 are set to their initial state, and pending cycles are not corrupted.
73 System reset should not return, if it returns, it means the system does
74 not support warm reset.
82 EFI_HOB_GUID_TYPE
*GuidHob
;
83 ACPI_BOARD_INFO
*pAcpiBoardInfo
;
86 // Find the acpi board information guid hob
88 GuidHob
= GetFirstGuidHob (&gUefiAcpiBoardInfoGuid
);
89 ASSERT (GuidHob
!= NULL
);
90 pAcpiBoardInfo
= (ACPI_BOARD_INFO
*)GET_GUID_HOB_DATA (GuidHob
);
92 IoWrite8 ((UINTN
)pAcpiBoardInfo
->ResetRegAddress
, pAcpiBoardInfo
->ResetValue
);
97 Calling this function causes the system to enter a power state equivalent
98 to the ACPI G2/S5 or G3 states.
100 System shutdown should not return, if it returns, it means the system does
101 not support shut down reset.
109 EFI_HOB_GUID_TYPE
*GuidHob
;
110 ACPI_BOARD_INFO
*pAcpiBoardInfo
;
114 // Find the acpi board information guid hob
116 GuidHob
= GetFirstGuidHob (&gUefiAcpiBoardInfoGuid
);
117 ASSERT (GuidHob
!= NULL
);
118 pAcpiBoardInfo
= (ACPI_BOARD_INFO
*)GET_GUID_HOB_DATA (GuidHob
);
121 // GPE0_EN should be disabled to avoid any GPI waking up the system from S5
123 IoWrite16 ((UINTN
)pAcpiBoardInfo
->PmGpeEnBase
, 0);
126 // Clear Power Button Status
128 IoWrite16((UINTN
) pAcpiBoardInfo
->PmEvtBase
, BIT8
);
131 // Transform system into S5 sleep state
133 PmCtrlReg
= (UINTN
)pAcpiBoardInfo
->PmCtrlRegBase
;
134 IoAndThenOr16 (PmCtrlReg
, (UINT16
) ~0x3c00, (UINT16
) (7 << 10));
135 IoOr16 (PmCtrlReg
, BIT13
);
142 Calling this function causes the system to enter a power state for capsule
145 Reset update should not return, if it returns, it means the system does
146 not support capsule update.
151 EnterS3WithImmediateWake (
160 This function causes a systemwide reset. The exact type of the reset is
161 defined by the EFI_GUID that follows the Null-terminated Unicode string passed
162 into ResetData. If the platform does not recognize the EFI_GUID in ResetData
163 the platform must pick a supported reset type to perform.The platform may
164 optionally log the parameters from any non-normal reset that occurs.
166 @param[in] DataSize The size, in bytes, of ResetData.
167 @param[in] ResetData The data buffer starts with a Null-terminated string,
168 followed by the EFI_GUID.
172 ResetPlatformSpecific (