TianoCore EDK2 master
Loading...
Searching...
No Matches
DxeResetShutdownXen.c
Go to the documentation of this file.
1
9#include <Base.h> // BIT13
10
11#include <IndustryStandard/Xen/sched.h>
12#include <Library/BaseLib.h> // CpuDeadLoop()
13#include <Library/DebugLib.h> // ASSERT()
14#include <Library/IoLib.h> // IoOr16()
15#include <Library/PcdLib.h> // PcdGet16()
16#include <Library/ResetSystemLib.h> // ResetShutdown()
18#include <OvmfPlatforms.h> // PIIX4_PMBA_VALUE
19
20STATIC UINT16 mAcpiPmBaseAddress;
21
23EFIAPI
24DxeResetInit (
25 IN EFI_HANDLE ImageHandle,
26 IN EFI_SYSTEM_TABLE *SystemTable
27 )
28{
29 UINT16 HostBridgeDevId;
30
31 HostBridgeDevId = PcdGet16 (PcdOvmfHostBridgePciDevId);
32 switch (HostBridgeDevId) {
33 case INTEL_82441_DEVICE_ID:
34 mAcpiPmBaseAddress = PIIX4_PMBA_VALUE;
35 break;
36 case INTEL_Q35_MCH_DEVICE_ID:
37 mAcpiPmBaseAddress = ICH9_PMBASE_VALUE;
38 break;
39 default:
40 //
41 // Fallback to using hypercall.
42 // Necessary for PVH guest, but should work for HVM guest.
43 //
44 mAcpiPmBaseAddress = 0xffff;
45 break;
46 }
47
48 return EFI_SUCCESS;
49}
50
58VOID
59EFIAPI
61 VOID
62 )
63{
64 if (mAcpiPmBaseAddress != 0xffff) {
65 IoBitFieldWrite16 (mAcpiPmBaseAddress + 4, 10, 13, 0);
66 IoOr16 (mAcpiPmBaseAddress + 4, BIT13);
67 } else {
68 INTN ReturnCode;
69 XEN_SCHED_SHUTDOWN ShutdownOp = {
70 .Reason = XEN_SHED_SHUTDOWN_POWEROFF,
71 };
72 ReturnCode = XenHypercallSchedOp (XEN_SCHEDOP_SHUTDOWN, &ShutdownOp);
73 ASSERT (ReturnCode == 0);
74 }
75
76 CpuDeadLoop ();
77}
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
#define STATIC
Definition: Base.h:264
#define IN
Definition: Base.h:279
#define PcdGet16(TokenName)
Definition: PcdLib.h:349
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
VOID * EFI_HANDLE
Definition: UefiBaseType.h:33
#define EFI_SUCCESS
Definition: UefiBaseType.h:112