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