]>
Commit | Line | Data |
---|---|---|
7ca30a6a | 1 | /** @file\r |
2 | Reset System Library functions for OVMF\r | |
3 | \r | |
84c0b80d | 4 | Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>\r |
b26f0cf9 | 5 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
7ca30a6a | 6 | \r |
7 | **/\r | |
8 | \r | |
9 | #include <Base.h>\r | |
10 | \r | |
11 | #include <Library/BaseLib.h>\r | |
12 | #include <Library/DebugLib.h>\r | |
13 | #include <Library/IoLib.h>\r | |
fb2ae5fd | 14 | #include <Library/TimerLib.h>\r |
1466b76f | 15 | #include <OvmfPlatforms.h>\r |
7ca30a6a | 16 | \r |
b2f4da39 LE |
17 | #include <OvmfPlatforms.h>\r |
18 | \r | |
7ca30a6a | 19 | VOID\r |
20 | AcpiPmControl (\r | |
21 | UINTN SuspendType\r | |
22 | )\r | |
23 | {\r | |
1466b76f LE |
24 | UINT16 AcpiPmBaseAddress;\r |
25 | UINT16 HostBridgeDevId;\r | |
26 | \r | |
7ca30a6a | 27 | ASSERT (SuspendType < 6);\r |
28 | \r | |
1466b76f LE |
29 | AcpiPmBaseAddress = 0;\r |
30 | HostBridgeDevId = PciRead16 (OVMF_HOSTBRIDGE_DID);\r | |
31 | switch (HostBridgeDevId) {\r | |
32 | case INTEL_82441_DEVICE_ID:\r | |
33 | AcpiPmBaseAddress = PIIX4_PMBA_VALUE;\r | |
34 | break;\r | |
35 | case INTEL_Q35_MCH_DEVICE_ID:\r | |
36 | AcpiPmBaseAddress = ICH9_PMBASE_VALUE;\r | |
37 | break;\r | |
38 | default:\r | |
39 | ASSERT (FALSE);\r | |
40 | CpuDeadLoop ();\r | |
41 | }\r | |
42 | \r | |
43 | IoBitFieldWrite16 (AcpiPmBaseAddress + 4, 10, 13, (UINT16) SuspendType);\r | |
44 | IoOr16 (AcpiPmBaseAddress + 4, BIT13);\r | |
7ca30a6a | 45 | CpuDeadLoop ();\r |
46 | }\r | |
47 | \r | |
48 | /**\r | |
49 | Calling this function causes a system-wide reset. This sets\r | |
50 | all circuitry within the system to its initial state. This type of reset\r | |
51 | is asynchronous to system operation and operates without regard to\r | |
52 | cycle boundaries.\r | |
53 | \r | |
54 | System reset should not return, if it returns, it means the system does\r | |
55 | not support cold reset.\r | |
56 | **/\r | |
57 | VOID\r | |
58 | EFIAPI\r | |
59 | ResetCold (\r | |
60 | VOID\r | |
61 | )\r | |
62 | {\r | |
cb7b12ee | 63 | IoWrite8 (0xCF9, BIT2 | BIT1); // 1st choice: PIIX3 RCR, RCPU|SRST\r |
fb2ae5fd | 64 | MicroSecondDelay (50);\r |
65 | \r | |
cb7b12ee | 66 | IoWrite8 (0x64, 0xfe); // 2nd choice: keyboard controller\r |
fb2ae5fd | 67 | CpuDeadLoop ();\r |
7ca30a6a | 68 | }\r |
69 | \r | |
70 | /**\r | |
71 | Calling this function causes a system-wide initialization. The processors\r | |
72 | are set to their initial state, and pending cycles are not corrupted.\r | |
73 | \r | |
74 | System reset should not return, if it returns, it means the system does\r | |
75 | not support warm reset.\r | |
76 | **/\r | |
77 | VOID\r | |
78 | EFIAPI\r | |
79 | ResetWarm (\r | |
80 | VOID\r | |
81 | )\r | |
82 | {\r | |
83 | IoWrite8 (0x64, 0xfe);\r | |
fb2ae5fd | 84 | CpuDeadLoop ();\r |
7ca30a6a | 85 | }\r |
86 | \r | |
87 | /**\r | |
88 | Calling this function causes the system to enter a power state equivalent\r | |
89 | to the ACPI G2/S5 or G3 states.\r | |
90 | \r | |
91 | System shutdown should not return, if it returns, it means the system does\r | |
92 | not support shut down reset.\r | |
93 | **/\r | |
94 | VOID\r | |
95 | EFIAPI\r | |
96 | ResetShutdown (\r | |
97 | VOID\r | |
98 | )\r | |
99 | {\r | |
100 | AcpiPmControl (0);\r | |
101 | ASSERT (FALSE);\r | |
102 | }\r | |
103 | \r | |
104 | \r | |
105 | /**\r | |
106 | Calling this function causes the system to enter a power state for capsule\r | |
107 | update.\r | |
108 | \r | |
109 | Reset update should not return, if it returns, it means the system does\r | |
110 | not support capsule update.\r | |
111 | \r | |
112 | **/\r | |
113 | VOID\r | |
114 | EFIAPI\r | |
115 | EnterS3WithImmediateWake (\r | |
116 | VOID\r | |
117 | )\r | |
118 | {\r | |
119 | AcpiPmControl (1);\r | |
120 | ASSERT (FALSE);\r | |
121 | }\r | |
2b9020f0 RN |
122 | \r |
123 | /**\r | |
124 | This function causes a systemwide reset. The exact type of the reset is\r | |
125 | defined by the EFI_GUID that follows the Null-terminated Unicode string passed\r | |
126 | into ResetData. If the platform does not recognize the EFI_GUID in ResetData\r | |
127 | the platform must pick a supported reset type to perform.The platform may\r | |
128 | optionally log the parameters from any non-normal reset that occurs.\r | |
129 | \r | |
130 | @param[in] DataSize The size, in bytes, of ResetData.\r | |
131 | @param[in] ResetData The data buffer starts with a Null-terminated string,\r | |
132 | followed by the EFI_GUID.\r | |
133 | **/\r | |
134 | VOID\r | |
135 | EFIAPI\r | |
136 | ResetPlatformSpecific (\r | |
137 | IN UINTN DataSize,\r | |
138 | IN VOID *ResetData\r | |
139 | )\r | |
140 | {\r | |
141 | ResetCold ();\r | |
142 | }\r | |
84c0b80d ZG |
143 | \r |
144 | /**\r | |
145 | The ResetSystem function resets the entire platform.\r | |
146 | \r | |
147 | @param[in] ResetType The type of reset to perform.\r | |
148 | @param[in] ResetStatus The status code for the reset.\r | |
149 | @param[in] DataSize The size, in bytes, of ResetData.\r | |
150 | @param[in] ResetData For a ResetType of EfiResetCold, EfiResetWarm, or EfiResetShutdown\r | |
151 | the data buffer starts with a Null-terminated string, optionally\r | |
152 | followed by additional binary data. The string is a description\r | |
153 | that the caller may use to further indicate the reason for the\r | |
154 | system reset.\r | |
155 | **/\r | |
156 | VOID\r | |
157 | EFIAPI\r | |
158 | ResetSystem (\r | |
159 | IN EFI_RESET_TYPE ResetType,\r | |
160 | IN EFI_STATUS ResetStatus,\r | |
161 | IN UINTN DataSize,\r | |
162 | IN VOID *ResetData OPTIONAL\r | |
163 | )\r | |
164 | {\r | |
165 | switch (ResetType) {\r | |
166 | case EfiResetWarm:\r | |
167 | ResetWarm ();\r | |
168 | break;\r | |
169 | \r | |
170 | case EfiResetCold:\r | |
171 | ResetCold ();\r | |
172 | break;\r | |
173 | \r | |
174 | case EfiResetShutdown:\r | |
175 | ResetShutdown ();\r | |
176 | return;\r | |
177 | \r | |
178 | case EfiResetPlatformSpecific:\r | |
179 | ResetPlatformSpecific (DataSize, ResetData);\r | |
180 | return;\r | |
181 | \r | |
182 | default:\r | |
183 | return;\r | |
184 | }\r | |
185 | }\r |