]> git.proxmox.com Git - mirror_edk2.git/blame - CorebootPayloadPkg/Library/ResetSystemLib/ResetSystemLib.c
Pkg-Module: CorebootPayloadPkg
[mirror_edk2.git] / CorebootPayloadPkg / Library / ResetSystemLib / ResetSystemLib.c
CommitLineData
9c228fb0
MM
1/** @file\r
2 Reset System Library functions for coreboot\r
3\r
4 Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>\r
5 This program and the accompanying materials\r
6 are licensed and made available under the terms and conditions of the BSD License\r
7 which accompanies this distribution. The full text of the license may be found at\r
8 http://opensource.org/licenses/bsd-license.php\r
9\r
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13**/\r
14\r
15#include <PiDxe.h>\r
16#include <Library/BaseLib.h>\r
17#include <Library/DebugLib.h>\r
18#include <Library/IoLib.h>\r
19#include <Library/HobLib.h>\r
20\r
21#include <Guid/AcpiBoardInfoGuid.h>\r
22\r
23VOID\r
24AcpiPmControl (\r
25 UINTN SuspendType\r
26 )\r
27{\r
28 EFI_HOB_GUID_TYPE *GuidHob;\r
29 ACPI_BOARD_INFO *pAcpiBoardInfo; \r
30 UINTN PmCtrlReg = 0;\r
31 \r
32 ASSERT (SuspendType <= 7); \r
33 //\r
34 // Find the acpi board information guid hob\r
35 //\r
36 GuidHob = GetFirstGuidHob (&gUefiAcpiBoardInfoGuid);\r
37 ASSERT (GuidHob != NULL);\r
38 pAcpiBoardInfo = (ACPI_BOARD_INFO *)GET_GUID_HOB_DATA (GuidHob); \r
39 \r
40 PmCtrlReg = (UINTN)pAcpiBoardInfo->PmCtrlRegBase; \r
41 IoAndThenOr16 (PmCtrlReg, (UINT16) ~0x3c00, (UINT16) (SuspendType << 10));\r
42 IoOr16 (PmCtrlReg, BIT13);\r
43 CpuDeadLoop ();\r
44}\r
45\r
46/**\r
47 Calling this function causes a system-wide reset. This sets\r
48 all circuitry within the system to its initial state. This type of reset\r
49 is asynchronous to system operation and operates without regard to\r
50 cycle boundaries.\r
51\r
52 System reset should not return, if it returns, it means the system does\r
53 not support cold reset.\r
54**/\r
55VOID\r
56EFIAPI\r
57ResetCold (\r
58 VOID\r
59 )\r
60{\r
61 EFI_HOB_GUID_TYPE *GuidHob;\r
62 ACPI_BOARD_INFO *pAcpiBoardInfo; \r
63 \r
64 //\r
65 // Find the acpi board information guid hob\r
66 //\r
67 GuidHob = GetFirstGuidHob (&gUefiAcpiBoardInfoGuid);\r
68 ASSERT (GuidHob != NULL);\r
69 pAcpiBoardInfo = (ACPI_BOARD_INFO *)GET_GUID_HOB_DATA (GuidHob); \r
70 \r
71 IoWrite8 ((UINTN)pAcpiBoardInfo->ResetRegAddress, pAcpiBoardInfo->ResetValue);\r
72 CpuDeadLoop ();\r
73}\r
74\r
75/**\r
76 Calling this function causes a system-wide initialization. The processors\r
77 are set to their initial state, and pending cycles are not corrupted.\r
78\r
79 System reset should not return, if it returns, it means the system does\r
80 not support warm reset.\r
81**/\r
82VOID\r
83EFIAPI\r
84ResetWarm (\r
85 VOID\r
86 )\r
87{\r
88 EFI_HOB_GUID_TYPE *GuidHob;\r
89 ACPI_BOARD_INFO *pAcpiBoardInfo; \r
90 \r
91 //\r
92 // Find the acpi board information guid hob\r
93 //\r
94 GuidHob = GetFirstGuidHob (&gUefiAcpiBoardInfoGuid);\r
95 ASSERT (GuidHob != NULL);\r
96 pAcpiBoardInfo = (ACPI_BOARD_INFO *)GET_GUID_HOB_DATA (GuidHob); \r
97 \r
98 IoWrite8 ((UINTN)pAcpiBoardInfo->ResetRegAddress, pAcpiBoardInfo->ResetValue);\r
99 CpuDeadLoop ();\r
100}\r
101\r
102/**\r
103 Calling this function causes the system to enter a power state equivalent\r
104 to the ACPI G2/S5 or G3 states.\r
105\r
106 System shutdown should not return, if it returns, it means the system does\r
107 not support shut down reset.\r
108**/\r
109VOID\r
110EFIAPI\r
111ResetShutdown (\r
112 VOID\r
113 )\r
114{\r
115 AcpiPmControl (7);\r
116 ASSERT (FALSE);\r
117}\r
118\r
119\r
120/**\r
121 Calling this function causes the system to enter a power state for capsule\r
122 update.\r
123\r
124 Reset update should not return, if it returns, it means the system does\r
125 not support capsule update.\r
126\r
127**/\r
128VOID\r
129EFIAPI\r
130EnterS3WithImmediateWake (\r
131 VOID\r
132 )\r
133{\r
134 AcpiPmControl (5);\r
135 ASSERT (FALSE);\r
136}\r