]>
git.proxmox.com Git - mirror_edk2.git/blob - CorebootPayloadPkg/Library/ResetSystemLib/ResetSystemLib.c
2 Reset System Library functions for coreboot
4 Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 #include <Library/BaseLib.h>
17 #include <Library/DebugLib.h>
18 #include <Library/IoLib.h>
19 #include <Library/HobLib.h>
21 #include <Guid/AcpiBoardInfoGuid.h>
28 EFI_HOB_GUID_TYPE
*GuidHob
;
29 ACPI_BOARD_INFO
*pAcpiBoardInfo
;
32 ASSERT (SuspendType
<= 7);
34 // Find the acpi board information guid hob
36 GuidHob
= GetFirstGuidHob (&gUefiAcpiBoardInfoGuid
);
37 ASSERT (GuidHob
!= NULL
);
38 pAcpiBoardInfo
= (ACPI_BOARD_INFO
*)GET_GUID_HOB_DATA (GuidHob
);
40 PmCtrlReg
= (UINTN
)pAcpiBoardInfo
->PmCtrlRegBase
;
41 IoAndThenOr16 (PmCtrlReg
, (UINT16
) ~0x3c00, (UINT16
) (SuspendType
<< 10));
42 IoOr16 (PmCtrlReg
, BIT13
);
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 EFI_HOB_GUID_TYPE
*GuidHob
;
62 ACPI_BOARD_INFO
*pAcpiBoardInfo
;
65 // Find the acpi board information guid hob
67 GuidHob
= GetFirstGuidHob (&gUefiAcpiBoardInfoGuid
);
68 ASSERT (GuidHob
!= NULL
);
69 pAcpiBoardInfo
= (ACPI_BOARD_INFO
*)GET_GUID_HOB_DATA (GuidHob
);
71 IoWrite8 ((UINTN
)pAcpiBoardInfo
->ResetRegAddress
, pAcpiBoardInfo
->ResetValue
);
76 Calling this function causes a system-wide initialization. The processors
77 are set to their initial state, and pending cycles are not corrupted.
79 System reset should not return, if it returns, it means the system does
80 not support warm reset.
88 EFI_HOB_GUID_TYPE
*GuidHob
;
89 ACPI_BOARD_INFO
*pAcpiBoardInfo
;
92 // Find the acpi board information guid hob
94 GuidHob
= GetFirstGuidHob (&gUefiAcpiBoardInfoGuid
);
95 ASSERT (GuidHob
!= NULL
);
96 pAcpiBoardInfo
= (ACPI_BOARD_INFO
*)GET_GUID_HOB_DATA (GuidHob
);
98 IoWrite8 ((UINTN
)pAcpiBoardInfo
->ResetRegAddress
, pAcpiBoardInfo
->ResetValue
);
103 Calling this function causes the system to enter a power state equivalent
104 to the ACPI G2/S5 or G3 states.
106 System shutdown should not return, if it returns, it means the system does
107 not support shut down reset.
115 EFI_HOB_GUID_TYPE
*GuidHob
;
116 ACPI_BOARD_INFO
*pAcpiBoardInfo
;
120 // Find the acpi board information guid hob
122 GuidHob
= GetFirstGuidHob (&gUefiAcpiBoardInfoGuid
);
123 ASSERT (GuidHob
!= NULL
);
124 pAcpiBoardInfo
= (ACPI_BOARD_INFO
*)GET_GUID_HOB_DATA (GuidHob
);
127 // GPE0_EN should be disabled to avoid any GPI waking up the system from S5
129 IoWrite16 ((UINTN
)pAcpiBoardInfo
->PmGpeEnBase
, 0);
132 // Clear Power Button Status
134 IoWrite16((UINTN
) pAcpiBoardInfo
->PmEvtBase
, BIT8
);
137 // Transform system into S5 sleep state
139 PmCtrlReg
= (UINTN
)pAcpiBoardInfo
->PmCtrlRegBase
;
140 IoAndThenOr16 (PmCtrlReg
, (UINT16
) ~0x3c00, (UINT16
) (7 << 10));
141 IoOr16 (PmCtrlReg
, BIT13
);
148 Calling this function causes the system to enter a power state for capsule
151 Reset update should not return, if it returns, it means the system does
152 not support capsule update.
157 EnterS3WithImmediateWake (