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