/** @file DXE Reset System Library Shutdown API implementation for OVMF. Copyright (C) 2020, Red Hat, Inc. Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent **/ #include // BIT13 #include // CpuDeadLoop() #include // ASSERT() #include // IoOr16() #include // PcdGet16() #include // ResetShutdown() #include // PIIX4_PMBA_VALUE STATIC UINT16 mAcpiPmBaseAddress; EFI_STATUS EFIAPI DxeResetInit ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) { UINT16 HostBridgeDevId; HostBridgeDevId = PcdGet16 (PcdOvmfHostBridgePciDevId); switch (HostBridgeDevId) { case INTEL_82441_DEVICE_ID: mAcpiPmBaseAddress = PIIX4_PMBA_VALUE; break; case INTEL_Q35_MCH_DEVICE_ID: mAcpiPmBaseAddress = ICH9_PMBASE_VALUE; break; default: ASSERT (FALSE); CpuDeadLoop (); return EFI_UNSUPPORTED; } return EFI_SUCCESS; } /** Calling this function causes the system to enter a power state equivalent to the ACPI G2/S5 or G3 states. System shutdown should not return, if it returns, it means the system does not support shut down reset. **/ VOID EFIAPI ResetShutdown ( VOID ) { IoBitFieldWrite16 (mAcpiPmBaseAddress + 4, 10, 13, 0); IoOr16 (mAcpiPmBaseAddress + 4, BIT13); CpuDeadLoop (); }