]> git.proxmox.com Git - mirror_edk2.git/blame - OvmfPkg/Library/ResetSystemLib/ResetSystemLib.c
OvmfPkg ResetSystemLib: Fix shutdown via UEFI runtime services
[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
d52c2868 20#include <Library/PcdLib.h>\r
fb2ae5fd 21#include <Library/TimerLib.h>\r
7ca30a6a 22\r
23VOID\r
24AcpiPmControl (\r
25 UINTN SuspendType\r
26 )\r
27{\r
28 ASSERT (SuspendType < 6);\r
29\r
d52c2868
JJ
30 IoBitFieldWrite16 (PcdGet16 (PcdAcpiPmBaseAddress) + 4, 10, 13, SuspendType);\r
31 IoOr16 (PcdGet16 (PcdAcpiPmBaseAddress) + 4, BIT13);\r
7ca30a6a 32 CpuDeadLoop ();\r
33}\r
34\r
35/**\r
36 Calling this function causes a system-wide reset. This sets\r
37 all circuitry within the system to its initial state. This type of reset\r
38 is asynchronous to system operation and operates without regard to\r
39 cycle boundaries.\r
40\r
41 System reset should not return, if it returns, it means the system does\r
42 not support cold reset.\r
43**/\r
44VOID\r
45EFIAPI\r
46ResetCold (\r
47 VOID\r
48 )\r
49{\r
cb7b12ee 50 IoWrite8 (0xCF9, BIT2 | BIT1); // 1st choice: PIIX3 RCR, RCPU|SRST\r
fb2ae5fd 51 MicroSecondDelay (50);\r
52\r
cb7b12ee 53 IoWrite8 (0x64, 0xfe); // 2nd choice: keyboard controller\r
fb2ae5fd 54 CpuDeadLoop ();\r
7ca30a6a 55}\r
56\r
57/**\r
58 Calling this function causes a system-wide initialization. The processors\r
59 are set to their initial state, and pending cycles are not corrupted.\r
60\r
61 System reset should not return, if it returns, it means the system does\r
62 not support warm reset.\r
63**/\r
64VOID\r
65EFIAPI\r
66ResetWarm (\r
67 VOID\r
68 )\r
69{\r
70 IoWrite8 (0x64, 0xfe);\r
fb2ae5fd 71 CpuDeadLoop ();\r
7ca30a6a 72}\r
73\r
74/**\r
75 Calling this function causes the system to enter a power state equivalent\r
76 to the ACPI G2/S5 or G3 states.\r
77\r
78 System shutdown should not return, if it returns, it means the system does\r
79 not support shut down reset.\r
80**/\r
81VOID\r
82EFIAPI\r
83ResetShutdown (\r
84 VOID\r
85 )\r
86{\r
87 AcpiPmControl (0);\r
88 ASSERT (FALSE);\r
89}\r
90\r
91\r
92/**\r
93 Calling this function causes the system to enter a power state for capsule\r
94 update.\r
95\r
96 Reset update should not return, if it returns, it means the system does\r
97 not support capsule update.\r
98\r
99**/\r
100VOID\r
101EFIAPI\r
102EnterS3WithImmediateWake (\r
103 VOID\r
104 )\r
105{\r
106 AcpiPmControl (1);\r
107 ASSERT (FALSE);\r
108}\r