2 Base Reset System Library Shutdown API implementation for OVMF.
4 Copyright (C) 2020, Red Hat, Inc.
5 Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
9 #include <Base.h> // BIT13
11 #include <Library/BaseLib.h> // CpuDeadLoop()
12 #include <Library/DebugLib.h> // ASSERT()
13 #include <Library/IoLib.h> // IoOr16()
14 #include <Library/PciLib.h> // PciRead16()
15 #include <Library/ResetSystemLib.h> // ResetShutdown()
16 #include <OvmfPlatforms.h> // OVMF_HOSTBRIDGE_DID
19 Calling this function causes the system to enter a power state equivalent
20 to the ACPI G2/S5 or G3 states.
22 System shutdown should not return, if it returns, it means the system does
23 not support shut down reset.
31 UINT16 AcpiPmBaseAddress
;
32 UINT16 HostBridgeDevId
;
34 AcpiPmBaseAddress
= 0;
35 HostBridgeDevId
= PciRead16 (OVMF_HOSTBRIDGE_DID
);
36 switch (HostBridgeDevId
) {
37 case INTEL_82441_DEVICE_ID
:
38 AcpiPmBaseAddress
= PIIX4_PMBA_VALUE
;
40 case INTEL_Q35_MCH_DEVICE_ID
:
41 AcpiPmBaseAddress
= ICH9_PMBASE_VALUE
;
43 case CLOUDHV_DEVICE_ID
:
44 IoWrite8 (CLOUDHV_ACPI_SHUTDOWN_IO_ADDRESS
, 5 << 2 | 1 << 5);
51 IoBitFieldWrite16 (AcpiPmBaseAddress
+ 4, 10, 13, 0);
52 IoOr16 (AcpiPmBaseAddress
+ 4, BIT13
);