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