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 This function causes a systemwide reset. The exact type of the reset is
106 defined by the EFI_GUID that follows the Null-terminated Unicode string passed
107 into ResetData. If the platform does not recognize the EFI_GUID in ResetData
108 the platform must pick a supported reset type to perform.The platform may
109 optionally log the parameters from any non-normal reset that occurs.
111 @param[in] DataSize The size, in bytes, of ResetData.
112 @param[in] ResetData The data buffer starts with a Null-terminated string,
113 followed by the EFI_GUID.
117 ResetPlatformSpecific (
126 The ResetSystem function resets the entire platform.
128 @param[in] ResetType The type of reset to perform.
129 @param[in] ResetStatus The status code for the reset.
130 @param[in] DataSize The size, in bytes, of ResetData.
131 @param[in] ResetData For a ResetType of EfiResetCold, EfiResetWarm, or EfiResetShutdown
132 the data buffer starts with a Null-terminated string, optionally
133 followed by additional binary data. The string is a description
134 that the caller may use to further indicate the reason for the
140 IN EFI_RESET_TYPE ResetType
,
141 IN EFI_STATUS ResetStatus
,
143 IN VOID
*ResetData OPTIONAL
155 case EfiResetShutdown
:
159 case EfiResetPlatformSpecific
:
160 ResetPlatformSpecific (DataSize
, ResetData
);