Commit | Line | Data |
---|---|---|
b6d542e9 | 1 | /** @file\r |
d70cdcf0 | 2 | Base Reset System Library Shutdown API implementation for OVMF.\r |
b6d542e9 LE |
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/PciLib.h> // PciRead16()\r | |
15 | #include <Library/ResetSystemLib.h> // ResetShutdown()\r | |
16 | #include <OvmfPlatforms.h> // OVMF_HOSTBRIDGE_DID\r | |
17 | \r | |
18 | /**\r | |
19 | Calling this function causes the system to enter a power state equivalent\r | |
20 | to the ACPI G2/S5 or G3 states.\r | |
21 | \r | |
22 | System shutdown should not return, if it returns, it means the system does\r | |
23 | not support shut down reset.\r | |
24 | **/\r | |
25 | VOID\r | |
26 | EFIAPI\r | |
27 | ResetShutdown (\r | |
28 | VOID\r | |
29 | )\r | |
30 | {\r | |
31 | UINT16 AcpiPmBaseAddress;\r | |
32 | UINT16 HostBridgeDevId;\r | |
33 | \r | |
34 | AcpiPmBaseAddress = 0;\r | |
35 | HostBridgeDevId = PciRead16 (OVMF_HOSTBRIDGE_DID);\r | |
36 | switch (HostBridgeDevId) {\r | |
37 | case INTEL_82441_DEVICE_ID:\r | |
38 | AcpiPmBaseAddress = PIIX4_PMBA_VALUE;\r | |
39 | break;\r | |
40 | case INTEL_Q35_MCH_DEVICE_ID:\r | |
41 | AcpiPmBaseAddress = ICH9_PMBASE_VALUE;\r | |
42 | break;\r | |
43 | default:\r | |
44 | ASSERT (FALSE);\r | |
45 | CpuDeadLoop ();\r | |
46 | }\r | |
47 | \r | |
48 | IoBitFieldWrite16 (AcpiPmBaseAddress + 4, 10, 13, 0);\r | |
49 | IoOr16 (AcpiPmBaseAddress + 4, BIT13);\r | |
50 | CpuDeadLoop ();\r | |
51 | }\r |