]> git.proxmox.com Git - mirror_edk2.git/blob - OvmfPkg/Library/ResetSystemLib/ResetSystemLib.c
308a6002149dcb05884f46890c46c102ce47d972
[mirror_edk2.git] / OvmfPkg / Library / ResetSystemLib / ResetSystemLib.c
1 /** @file
2 Reset System Library functions for OVMF
3
4 Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 **/
14
15 #include <Base.h>
16
17 #include <Library/BaseLib.h>
18 #include <Library/DebugLib.h>
19 #include <Library/IoLib.h>
20 #include <Library/TimerLib.h>
21
22 #include <OvmfPlatforms.h>
23
24 VOID
25 AcpiPmControl (
26 UINTN SuspendType
27 )
28 {
29 ASSERT (SuspendType < 6);
30
31 IoBitFieldWrite16 (PIIX4_PMBA_VALUE + 4, 10, 13, (UINT16) SuspendType);
32 IoOr16 (PIIX4_PMBA_VALUE + 4, BIT13);
33 CpuDeadLoop ();
34 }
35
36 /**
37 Calling this function causes a system-wide reset. This sets
38 all circuitry within the system to its initial state. This type of reset
39 is asynchronous to system operation and operates without regard to
40 cycle boundaries.
41
42 System reset should not return, if it returns, it means the system does
43 not support cold reset.
44 **/
45 VOID
46 EFIAPI
47 ResetCold (
48 VOID
49 )
50 {
51 IoWrite8 (0xCF9, BIT2 | BIT1); // 1st choice: PIIX3 RCR, RCPU|SRST
52 MicroSecondDelay (50);
53
54 IoWrite8 (0x64, 0xfe); // 2nd choice: keyboard controller
55 CpuDeadLoop ();
56 }
57
58 /**
59 Calling this function causes a system-wide initialization. The processors
60 are set to their initial state, and pending cycles are not corrupted.
61
62 System reset should not return, if it returns, it means the system does
63 not support warm reset.
64 **/
65 VOID
66 EFIAPI
67 ResetWarm (
68 VOID
69 )
70 {
71 IoWrite8 (0x64, 0xfe);
72 CpuDeadLoop ();
73 }
74
75 /**
76 Calling this function causes the system to enter a power state equivalent
77 to the ACPI G2/S5 or G3 states.
78
79 System shutdown should not return, if it returns, it means the system does
80 not support shut down reset.
81 **/
82 VOID
83 EFIAPI
84 ResetShutdown (
85 VOID
86 )
87 {
88 AcpiPmControl (0);
89 ASSERT (FALSE);
90 }
91
92
93 /**
94 Calling this function causes the system to enter a power state for capsule
95 update.
96
97 Reset update should not return, if it returns, it means the system does
98 not support capsule update.
99
100 **/
101 VOID
102 EFIAPI
103 EnterS3WithImmediateWake (
104 VOID
105 )
106 {
107 AcpiPmControl (1);
108 ASSERT (FALSE);
109 }