]> git.proxmox.com Git - mirror_edk2.git/blame - OvmfPkg/Library/ResetSystemLib/ResetSystemLib.c
CorebootPayloadPkg/ResetSystemLib: Implement ResetPlatformSpecific
[mirror_edk2.git] / OvmfPkg / Library / ResetSystemLib / ResetSystemLib.c
CommitLineData
7ca30a6a 1/** @file\r
2 Reset System Library functions for OVMF\r
3\r
d52c2868 4 Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>\r
7ca30a6a 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 <Base.h>\r
16\r
17#include <Library/BaseLib.h>\r
18#include <Library/DebugLib.h>\r
19#include <Library/IoLib.h>\r
fb2ae5fd 20#include <Library/TimerLib.h>\r
1466b76f 21#include <OvmfPlatforms.h>\r
7ca30a6a 22\r
b2f4da39
LE
23#include <OvmfPlatforms.h>\r
24\r
7ca30a6a 25VOID\r
26AcpiPmControl (\r
27 UINTN SuspendType\r
28 )\r
29{\r
1466b76f
LE
30 UINT16 AcpiPmBaseAddress;\r
31 UINT16 HostBridgeDevId;\r
32\r
7ca30a6a 33 ASSERT (SuspendType < 6);\r
34\r
1466b76f
LE
35 AcpiPmBaseAddress = 0;\r
36 HostBridgeDevId = PciRead16 (OVMF_HOSTBRIDGE_DID);\r
37 switch (HostBridgeDevId) {\r
38 case INTEL_82441_DEVICE_ID:\r
39 AcpiPmBaseAddress = PIIX4_PMBA_VALUE;\r
40 break;\r
41 case INTEL_Q35_MCH_DEVICE_ID:\r
42 AcpiPmBaseAddress = ICH9_PMBASE_VALUE;\r
43 break;\r
44 default:\r
45 ASSERT (FALSE);\r
46 CpuDeadLoop ();\r
47 }\r
48\r
49 IoBitFieldWrite16 (AcpiPmBaseAddress + 4, 10, 13, (UINT16) SuspendType);\r
50 IoOr16 (AcpiPmBaseAddress + 4, BIT13);\r
7ca30a6a 51 CpuDeadLoop ();\r
52}\r
53\r
54/**\r
55 Calling this function causes a system-wide reset. This sets\r
56 all circuitry within the system to its initial state. This type of reset\r
57 is asynchronous to system operation and operates without regard to\r
58 cycle boundaries.\r
59\r
60 System reset should not return, if it returns, it means the system does\r
61 not support cold reset.\r
62**/\r
63VOID\r
64EFIAPI\r
65ResetCold (\r
66 VOID\r
67 )\r
68{\r
cb7b12ee 69 IoWrite8 (0xCF9, BIT2 | BIT1); // 1st choice: PIIX3 RCR, RCPU|SRST\r
fb2ae5fd 70 MicroSecondDelay (50);\r
71\r
cb7b12ee 72 IoWrite8 (0x64, 0xfe); // 2nd choice: keyboard controller\r
fb2ae5fd 73 CpuDeadLoop ();\r
7ca30a6a 74}\r
75\r
76/**\r
77 Calling this function causes a system-wide initialization. The processors\r
78 are set to their initial state, and pending cycles are not corrupted.\r
79\r
80 System reset should not return, if it returns, it means the system does\r
81 not support warm reset.\r
82**/\r
83VOID\r
84EFIAPI\r
85ResetWarm (\r
86 VOID\r
87 )\r
88{\r
89 IoWrite8 (0x64, 0xfe);\r
fb2ae5fd 90 CpuDeadLoop ();\r
7ca30a6a 91}\r
92\r
93/**\r
94 Calling this function causes the system to enter a power state equivalent\r
95 to the ACPI G2/S5 or G3 states.\r
96\r
97 System shutdown should not return, if it returns, it means the system does\r
98 not support shut down reset.\r
99**/\r
100VOID\r
101EFIAPI\r
102ResetShutdown (\r
103 VOID\r
104 )\r
105{\r
106 AcpiPmControl (0);\r
107 ASSERT (FALSE);\r
108}\r
109\r
110\r
111/**\r
112 Calling this function causes the system to enter a power state for capsule\r
113 update.\r
114\r
115 Reset update should not return, if it returns, it means the system does\r
116 not support capsule update.\r
117\r
118**/\r
119VOID\r
120EFIAPI\r
121EnterS3WithImmediateWake (\r
122 VOID\r
123 )\r
124{\r
125 AcpiPmControl (1);\r
126 ASSERT (FALSE);\r
127}\r