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