]> git.proxmox.com Git - mirror_edk2.git/blame - OvmfPkg/Library/ResetSystemLib/ResetSystemLib.c
OvmfPkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / OvmfPkg / Library / ResetSystemLib / ResetSystemLib.c
CommitLineData
7ca30a6a 1/** @file\r
2 Reset System Library functions for OVMF\r
3\r
2b9020f0 4 Copyright (c) 2006 - 2016, 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 19VOID\r
20AcpiPmControl (\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
57VOID\r
58EFIAPI\r
59ResetCold (\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
77VOID\r
78EFIAPI\r
79ResetWarm (\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
94VOID\r
95EFIAPI\r
96ResetShutdown (\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
113VOID\r
114EFIAPI\r
115EnterS3WithImmediateWake (\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
134VOID\r
135EFIAPI\r
136ResetPlatformSpecific (\r
137 IN UINTN DataSize,\r
138 IN VOID *ResetData\r
139 )\r
140{\r
141 ResetCold ();\r
142}\r