TianoCore EDK2 master
Loading...
Searching...
No Matches
BaseResetShutdownXen.c
Go to the documentation of this file.
1
11#include <Base.h> // BIT13
12
13#include <Library/BaseLib.h> // CpuDeadLoop()
14#include <Library/DebugLib.h> // ASSERT()
15#include <Library/IoLib.h> // IoOr16()
16#include <Library/PciLib.h> // PciRead16()
17#include <Library/ResetSystemLib.h> // ResetShutdown()
19#include <OvmfPlatforms.h> // OVMF_HOSTBRIDGE_DID
20
28VOID
29EFIAPI
31 VOID
32 )
33{
34 UINT16 AcpiPmBaseAddress;
35 UINT16 HostBridgeDevId;
36
37 AcpiPmBaseAddress = 0;
38 HostBridgeDevId = PciRead16 (OVMF_HOSTBRIDGE_DID);
39 switch (HostBridgeDevId) {
40 case INTEL_82441_DEVICE_ID:
41 AcpiPmBaseAddress = PIIX4_PMBA_VALUE;
42 break;
43 case INTEL_Q35_MCH_DEVICE_ID:
44 AcpiPmBaseAddress = ICH9_PMBASE_VALUE;
45 break;
46 default:
47 {
48 //
49 // Fallback to using hypercall.
50 // Necessary for PVH guest, but should work for HVM guest.
51 //
52 INTN ReturnCode;
53 XEN_SCHED_SHUTDOWN ShutdownOp = {
54 .Reason = XEN_SHED_SHUTDOWN_POWEROFF,
55 };
56 ReturnCode = XenHypercallSchedOp (XEN_SCHEDOP_SHUTDOWN, ShutdownOp);
57 ASSERT (ReturnCode == 0);
58 CpuDeadLoop ();
59 }
60 }
61
62 IoBitFieldWrite16 (AcpiPmBaseAddress + 4, 10, 13, 0);
63 IoOr16 (AcpiPmBaseAddress + 4, BIT13);
64 CpuDeadLoop ();
65}
INT64 INTN
VOID EFIAPI CpuDeadLoop(VOID)
Definition: CpuDeadLoop.c:25
VOID EFIAPI ResetShutdown(VOID)
UINT16 EFIAPI IoOr16(IN UINTN Port, IN UINT16 OrData)
Definition: IoHighLevel.c:325
UINT16 EFIAPI IoBitFieldWrite16(IN UINTN Port, IN UINTN StartBit, IN UINTN EndBit, IN UINT16 Value)
Definition: IoHighLevel.c:453
UINT16 EFIAPI PciRead16(IN UINTN Address)
Definition: PciLib.c:396