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
107 passed into ResetData. If the platform does not recognize the EFI_GUID in
108 ResetData the platform must pick a supported reset type to perform.The
109 platform may optionally log the parameters from any non-normal reset that
112 @param[in] DataSize The size, in bytes, of ResetData.
113 @param[in] ResetData The data buffer starts with a Null-terminated string,
114 followed by the EFI_GUID.
118 ResetPlatformSpecific (
127 The ResetSystem function resets the entire platform.
129 @param[in] ResetType The type of reset to perform.
130 @param[in] ResetStatus The status code for the reset.
131 @param[in] DataSize The size, in bytes, of ResetData.
132 @param[in] ResetData For a ResetType of EfiResetCold, EfiResetWarm, or
133 EfiResetShutdown the data buffer starts with a
134 Null-terminated string, optionally followed by
135 additional binary data. The string is a description
136 that the caller may use to further indicate the
137 reason for the system reset.
142 IN EFI_RESET_TYPE ResetType
,
143 IN EFI_STATUS ResetStatus
,
145 IN VOID
*ResetData OPTIONAL
157 case EfiResetShutdown
:
161 case EfiResetPlatformSpecific
:
162 ResetPlatformSpecific (DataSize
, ResetData
);