2 Reset System Library functions for OVMF
4 Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
11 #include <Library/BaseLib.h>
12 #include <Library/DebugLib.h>
13 #include <Library/IoLib.h>
14 #include <Library/PciLib.h>
15 #include <Library/TimerLib.h>
16 #include <OvmfPlatforms.h>
23 UINT16 AcpiPmBaseAddress
;
24 UINT16 HostBridgeDevId
;
26 ASSERT (SuspendType
< 6);
28 AcpiPmBaseAddress
= 0;
29 HostBridgeDevId
= PciRead16 (OVMF_HOSTBRIDGE_DID
);
30 switch (HostBridgeDevId
) {
31 case INTEL_82441_DEVICE_ID
:
32 AcpiPmBaseAddress
= PIIX4_PMBA_VALUE
;
34 case INTEL_Q35_MCH_DEVICE_ID
:
35 AcpiPmBaseAddress
= ICH9_PMBASE_VALUE
;
42 IoBitFieldWrite16 (AcpiPmBaseAddress
+ 4, 10, 13, (UINT16
) SuspendType
);
43 IoOr16 (AcpiPmBaseAddress
+ 4, BIT13
);
48 Calling this function causes a system-wide reset. This sets
49 all circuitry within the system to its initial state. This type of reset
50 is asynchronous to system operation and operates without regard to
53 System reset should not return, if it returns, it means the system does
54 not support cold reset.
62 IoWrite8 (0xCF9, BIT2
| BIT1
); // 1st choice: PIIX3 RCR, RCPU|SRST
63 MicroSecondDelay (50);
65 IoWrite8 (0x64, 0xfe); // 2nd choice: keyboard controller
70 Calling this function causes a system-wide initialization. The processors
71 are set to their initial state, and pending cycles are not corrupted.
73 System reset should not return, if it returns, it means the system does
74 not support warm reset.
82 IoWrite8 (0x64, 0xfe);
87 Calling this function causes the system to enter a power state equivalent
88 to the ACPI G2/S5 or G3 states.
90 System shutdown should not return, if it returns, it means the system does
91 not support shut down reset.
105 Calling this function causes the system to enter a power state for capsule
108 Reset update should not return, if it returns, it means the system does
109 not support capsule update.
114 EnterS3WithImmediateWake (
123 This function causes a systemwide reset. The exact type of the reset is
124 defined by the EFI_GUID that follows the Null-terminated Unicode string passed
125 into ResetData. If the platform does not recognize the EFI_GUID in ResetData
126 the platform must pick a supported reset type to perform.The platform may
127 optionally log the parameters from any non-normal reset that occurs.
129 @param[in] DataSize The size, in bytes, of ResetData.
130 @param[in] ResetData The data buffer starts with a Null-terminated string,
131 followed by the EFI_GUID.
135 ResetPlatformSpecific (
144 The ResetSystem function resets the entire platform.
146 @param[in] ResetType The type of reset to perform.
147 @param[in] ResetStatus The status code for the reset.
148 @param[in] DataSize The size, in bytes, of ResetData.
149 @param[in] ResetData For a ResetType of EfiResetCold, EfiResetWarm, or EfiResetShutdown
150 the data buffer starts with a Null-terminated string, optionally
151 followed by additional binary data. The string is a description
152 that the caller may use to further indicate the reason for the
158 IN EFI_RESET_TYPE ResetType
,
159 IN EFI_STATUS ResetStatus
,
161 IN VOID
*ResetData OPTIONAL
173 case EfiResetShutdown
:
177 case EfiResetPlatformSpecific
:
178 ResetPlatformSpecific (DataSize
, ResetData
);