]>
Commit | Line | Data |
---|---|---|
9c228fb0 MM |
1 | /** @file\r |
2 | Reset System Library functions for coreboot\r | |
3 | \r | |
adb6c39a | 4 | Copyright (c) 2014 - 2016, Intel Corporation. All rights reserved.<BR>\r |
d2e8b7e1 | 5 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
9c228fb0 MM |
6 | \r |
7 | **/\r | |
8 | \r | |
9 | #include <PiDxe.h>\r | |
10 | #include <Library/BaseLib.h>\r | |
11 | #include <Library/DebugLib.h>\r | |
12 | #include <Library/IoLib.h>\r | |
13 | #include <Library/HobLib.h>\r | |
14 | \r | |
15 | #include <Guid/AcpiBoardInfoGuid.h>\r | |
16 | \r | |
17 | VOID\r | |
18 | AcpiPmControl (\r | |
19 | UINTN SuspendType\r | |
20 | )\r | |
21 | {\r | |
22 | EFI_HOB_GUID_TYPE *GuidHob;\r | |
23 | ACPI_BOARD_INFO *pAcpiBoardInfo; \r | |
24 | UINTN PmCtrlReg = 0;\r | |
25 | \r | |
26 | ASSERT (SuspendType <= 7); \r | |
27 | //\r | |
28 | // Find the acpi board information guid hob\r | |
29 | //\r | |
30 | GuidHob = GetFirstGuidHob (&gUefiAcpiBoardInfoGuid);\r | |
31 | ASSERT (GuidHob != NULL);\r | |
32 | pAcpiBoardInfo = (ACPI_BOARD_INFO *)GET_GUID_HOB_DATA (GuidHob); \r | |
33 | \r | |
34 | PmCtrlReg = (UINTN)pAcpiBoardInfo->PmCtrlRegBase; \r | |
35 | IoAndThenOr16 (PmCtrlReg, (UINT16) ~0x3c00, (UINT16) (SuspendType << 10));\r | |
36 | IoOr16 (PmCtrlReg, BIT13);\r | |
37 | CpuDeadLoop ();\r | |
38 | }\r | |
39 | \r | |
40 | /**\r | |
41 | Calling this function causes a system-wide reset. This sets\r | |
42 | all circuitry within the system to its initial state. This type of reset\r | |
43 | is asynchronous to system operation and operates without regard to\r | |
44 | cycle boundaries.\r | |
45 | \r | |
46 | System reset should not return, if it returns, it means the system does\r | |
47 | not support cold reset.\r | |
48 | **/\r | |
49 | VOID\r | |
50 | EFIAPI\r | |
51 | ResetCold (\r | |
52 | VOID\r | |
53 | )\r | |
54 | {\r | |
55 | EFI_HOB_GUID_TYPE *GuidHob;\r | |
56 | ACPI_BOARD_INFO *pAcpiBoardInfo; \r | |
57 | \r | |
58 | //\r | |
59 | // Find the acpi board information guid hob\r | |
60 | //\r | |
61 | GuidHob = GetFirstGuidHob (&gUefiAcpiBoardInfoGuid);\r | |
62 | ASSERT (GuidHob != NULL);\r | |
63 | pAcpiBoardInfo = (ACPI_BOARD_INFO *)GET_GUID_HOB_DATA (GuidHob); \r | |
64 | \r | |
65 | IoWrite8 ((UINTN)pAcpiBoardInfo->ResetRegAddress, pAcpiBoardInfo->ResetValue);\r | |
66 | CpuDeadLoop ();\r | |
67 | }\r | |
68 | \r | |
69 | /**\r | |
70 | Calling this function causes a system-wide initialization. The processors\r | |
71 | are set to their initial state, and pending cycles are not corrupted.\r | |
72 | \r | |
73 | System reset should not return, if it returns, it means the system does\r | |
74 | not support warm reset.\r | |
75 | **/\r | |
76 | VOID\r | |
77 | EFIAPI\r | |
78 | ResetWarm (\r | |
79 | VOID\r | |
80 | )\r | |
81 | {\r | |
82 | EFI_HOB_GUID_TYPE *GuidHob;\r | |
83 | ACPI_BOARD_INFO *pAcpiBoardInfo; \r | |
84 | \r | |
85 | //\r | |
86 | // Find the acpi board information guid hob\r | |
87 | //\r | |
88 | GuidHob = GetFirstGuidHob (&gUefiAcpiBoardInfoGuid);\r | |
89 | ASSERT (GuidHob != NULL);\r | |
90 | pAcpiBoardInfo = (ACPI_BOARD_INFO *)GET_GUID_HOB_DATA (GuidHob); \r | |
91 | \r | |
92 | IoWrite8 ((UINTN)pAcpiBoardInfo->ResetRegAddress, pAcpiBoardInfo->ResetValue);\r | |
93 | CpuDeadLoop ();\r | |
94 | }\r | |
95 | \r | |
96 | /**\r | |
97 | Calling this function causes the system to enter a power state equivalent\r | |
98 | to the ACPI G2/S5 or G3 states.\r | |
99 | \r | |
100 | System shutdown should not return, if it returns, it means the system does\r | |
101 | not support shut down reset.\r | |
102 | **/\r | |
103 | VOID\r | |
104 | EFIAPI\r | |
105 | ResetShutdown (\r | |
106 | VOID\r | |
107 | )\r | |
108 | {\r | |
24467749 GD |
109 | EFI_HOB_GUID_TYPE *GuidHob;\r |
110 | ACPI_BOARD_INFO *pAcpiBoardInfo;\r | |
111 | UINTN PmCtrlReg;\r | |
112 | \r | |
113 | //\r | |
114 | // Find the acpi board information guid hob\r | |
115 | //\r | |
116 | GuidHob = GetFirstGuidHob (&gUefiAcpiBoardInfoGuid);\r | |
117 | ASSERT (GuidHob != NULL);\r | |
118 | pAcpiBoardInfo = (ACPI_BOARD_INFO *)GET_GUID_HOB_DATA (GuidHob); \r | |
119 | \r | |
120 | //\r | |
121 | // GPE0_EN should be disabled to avoid any GPI waking up the system from S5\r | |
122 | //\r | |
123 | IoWrite16 ((UINTN)pAcpiBoardInfo->PmGpeEnBase, 0);\r | |
124 | \r | |
125 | //\r | |
126 | // Clear Power Button Status\r | |
127 | //\r | |
128 | IoWrite16((UINTN) pAcpiBoardInfo->PmEvtBase, BIT8);\r | |
129 | \r | |
130 | //\r | |
131 | // Transform system into S5 sleep state\r | |
132 | //\r | |
133 | PmCtrlReg = (UINTN)pAcpiBoardInfo->PmCtrlRegBase; \r | |
134 | IoAndThenOr16 (PmCtrlReg, (UINT16) ~0x3c00, (UINT16) (7 << 10));\r | |
135 | IoOr16 (PmCtrlReg, BIT13);\r | |
136 | CpuDeadLoop ();\r | |
137 | \r | |
9c228fb0 MM |
138 | ASSERT (FALSE);\r |
139 | }\r | |
140 | \r | |
9c228fb0 MM |
141 | /**\r |
142 | Calling this function causes the system to enter a power state for capsule\r | |
143 | update.\r | |
144 | \r | |
145 | Reset update should not return, if it returns, it means the system does\r | |
146 | not support capsule update.\r | |
147 | \r | |
148 | **/\r | |
149 | VOID\r | |
150 | EFIAPI\r | |
151 | EnterS3WithImmediateWake (\r | |
152 | VOID\r | |
153 | )\r | |
154 | {\r | |
155 | AcpiPmControl (5);\r | |
156 | ASSERT (FALSE);\r | |
157 | }\r | |
adb6c39a RN |
158 | \r |
159 | /**\r | |
160 | This function causes a systemwide reset. The exact type of the reset is\r | |
161 | defined by the EFI_GUID that follows the Null-terminated Unicode string passed\r | |
162 | into ResetData. If the platform does not recognize the EFI_GUID in ResetData\r | |
163 | the platform must pick a supported reset type to perform.The platform may\r | |
164 | optionally log the parameters from any non-normal reset that occurs.\r | |
165 | \r | |
166 | @param[in] DataSize The size, in bytes, of ResetData.\r | |
167 | @param[in] ResetData The data buffer starts with a Null-terminated string,\r | |
168 | followed by the EFI_GUID.\r | |
169 | **/\r | |
170 | VOID\r | |
171 | EFIAPI\r | |
172 | ResetPlatformSpecific (\r | |
173 | IN UINTN DataSize,\r | |
174 | IN VOID *ResetData\r | |
175 | )\r | |
176 | {\r | |
177 | ResetCold ();\r | |
178 | }\r |