]> git.proxmox.com Git - mirror_edk2.git/blob - OvmfPkg/Library/ResetSystemLib/DxeResetShutdown.c
OvmfPkg: Apply uncrustify changes
[mirror_edk2.git] / OvmfPkg / Library / ResetSystemLib / DxeResetShutdown.c
1 /** @file
2 DXE Reset System Library Shutdown API implementation for OVMF.
3
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
7 **/
8
9 #include <Base.h> // BIT13
10
11 #include <Library/BaseLib.h> // CpuDeadLoop()
12 #include <Library/DebugLib.h> // ASSERT()
13 #include <Library/IoLib.h> // IoOr16()
14 #include <Library/PcdLib.h> // PcdGet16()
15 #include <Library/ResetSystemLib.h> // ResetShutdown()
16 #include <OvmfPlatforms.h> // PIIX4_PMBA_VALUE
17
18 STATIC UINT16 mAcpiPmBaseAddress;
19
20 EFI_STATUS
21 EFIAPI
22 DxeResetInit (
23 IN EFI_HANDLE ImageHandle,
24 IN EFI_SYSTEM_TABLE *SystemTable
25 )
26 {
27 UINT16 HostBridgeDevId;
28
29 HostBridgeDevId = PcdGet16 (PcdOvmfHostBridgePciDevId);
30 switch (HostBridgeDevId) {
31 case INTEL_82441_DEVICE_ID:
32 mAcpiPmBaseAddress = PIIX4_PMBA_VALUE;
33 break;
34 case INTEL_Q35_MCH_DEVICE_ID:
35 mAcpiPmBaseAddress = ICH9_PMBASE_VALUE;
36 break;
37 default:
38 ASSERT (FALSE);
39 CpuDeadLoop ();
40 return EFI_UNSUPPORTED;
41 }
42
43 return EFI_SUCCESS;
44 }
45
46 /**
47 Calling this function causes the system to enter a power state equivalent
48 to the ACPI G2/S5 or G3 states.
49
50 System shutdown should not return, if it returns, it means the system does
51 not support shut down reset.
52 **/
53 VOID
54 EFIAPI
55 ResetShutdown (
56 VOID
57 )
58 {
59 IoBitFieldWrite16 (mAcpiPmBaseAddress + 4, 10, 13, 0);
60 IoOr16 (mAcpiPmBaseAddress + 4, BIT13);
61 CpuDeadLoop ();
62 }