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
9 #include <Base.h> // BIT1
11 #include <Library/BaseLib.h> // CpuDeadLoop()
12 #include <Library/DebugLib.h> // ASSERT()
13 #include <Library/IoLib.h> // IoWrite8()
14 #include <Library/PciLib.h> // PciRead16()
15 #include <Library/ResetSystemLib.h> // ResetCold()
16 #include <Library/TimerLib.h> // MicroSecondDelay()
17 #include <OvmfPlatforms.h> // OVMF_HOSTBRIDGE_DID
24 UINT16 AcpiPmBaseAddress
;
25 UINT16 HostBridgeDevId
;
27 ASSERT (SuspendType
< 6);
29 AcpiPmBaseAddress
= 0;
30 HostBridgeDevId
= PciRead16 (OVMF_HOSTBRIDGE_DID
);
31 switch (HostBridgeDevId
) {
32 case INTEL_82441_DEVICE_ID
:
33 AcpiPmBaseAddress
= PIIX4_PMBA_VALUE
;
35 case INTEL_Q35_MCH_DEVICE_ID
:
36 AcpiPmBaseAddress
= ICH9_PMBASE_VALUE
;
43 IoBitFieldWrite16 (AcpiPmBaseAddress
+ 4, 10, 13, (UINT16
) SuspendType
);
44 IoOr16 (AcpiPmBaseAddress
+ 4, BIT13
);
49 Calling this function causes a system-wide reset. This sets
50 all circuitry within the system to its initial state. This type of reset
51 is asynchronous to system operation and operates without regard to
54 System reset should not return, if it returns, it means the system does
55 not support cold reset.
63 IoWrite8 (0xCF9, BIT2
| BIT1
); // 1st choice: PIIX3 RCR, RCPU|SRST
64 MicroSecondDelay (50);
66 IoWrite8 (0x64, 0xfe); // 2nd choice: keyboard controller
71 Calling this function causes a system-wide initialization. The processors
72 are set to their initial state, and pending cycles are not corrupted.
74 System reset should not return, if it returns, it means the system does
75 not support warm reset.
83 IoWrite8 (0x64, 0xfe);
88 Calling this function causes the system to enter a power state equivalent
89 to the ACPI G2/S5 or G3 states.
91 System shutdown should not return, if it returns, it means the system does
92 not support shut down reset.
106 This function causes a systemwide reset. The exact type of the reset is
107 defined by the EFI_GUID that follows the Null-terminated Unicode string
108 passed into ResetData. If the platform does not recognize the EFI_GUID in
109 ResetData the platform must pick a supported reset type to perform.The
110 platform may optionally log the parameters from any non-normal reset that
113 @param[in] DataSize The size, in bytes, of ResetData.
114 @param[in] ResetData The data buffer starts with a Null-terminated string,
115 followed by the EFI_GUID.
119 ResetPlatformSpecific (
128 The ResetSystem function resets the entire platform.
130 @param[in] ResetType The type of reset to perform.
131 @param[in] ResetStatus The status code for the reset.
132 @param[in] DataSize The size, in bytes, of ResetData.
133 @param[in] ResetData For a ResetType of EfiResetCold, EfiResetWarm, or
134 EfiResetShutdown the data buffer starts with a
135 Null-terminated string, optionally followed by
136 additional binary data. The string is a description
137 that the caller may use to further indicate the
138 reason for the system reset.
143 IN EFI_RESET_TYPE ResetType
,
144 IN EFI_STATUS ResetStatus
,
146 IN VOID
*ResetData OPTIONAL
158 case EfiResetShutdown
:
162 case EfiResetPlatformSpecific
:
163 ResetPlatformSpecific (DataSize
, ResetData
);