TianoCore EDK2 master
Loading...
Searching...
No Matches
ResetSystemLibMicrovm.c
Go to the documentation of this file.
1
9#include <Base.h> // BIT1
10
11#include <Library/BaseLib.h> // CpuDeadLoop()
12#include <Library/DebugLib.h> // ASSERT()
13#include <Library/IoLib.h> // IoWrite8()
14#include <Library/ResetSystemLib.h> // ResetCold()
15#include <Library/TimerLib.h> // MicroSecondDelay()
16#include <Library/UefiRuntimeLib.h> // EfiGoneVirtual()
17#include <OvmfPlatforms.h> // PIIX4_PMBA_VALUE
18
19static UINTN
20MicrovmGedBase (
21 VOID
22 )
23{
24 VOID *Address = (VOID *)(UINTN)MICROVM_GED_MMIO_BASE_REGS;
25
26 if (EfiGoneVirtual ()) {
27 EfiConvertPointer (0, &Address);
28 DEBUG ((DEBUG_INFO, "%a: virtual -> 0x%x\n", __func__, Address));
29 } else {
30 DEBUG ((DEBUG_INFO, "%a: physical -> 0x%x\n", __func__, Address));
31 }
32
33 return (UINTN)Address;
34}
35
36static VOID
37MicrovmReset (
38 VOID
39 )
40{
41 UINTN Address = MicrovmGedBase ();
42
43 DEBUG ((DEBUG_INFO, "%a: microvm reset via ged\n", __func__));
45 Address + MICROVM_ACPI_GED_REG_RESET,
46 MICROVM_ACPI_GED_RESET_VALUE
47 );
48 CpuDeadLoop ();
49}
50
51static VOID
52MicrovmShutdown (
53 VOID
54 )
55{
56 UINTN Address = MicrovmGedBase ();
57
58 DEBUG ((DEBUG_INFO, "%a: microvm poweroff via ged\n", __func__));
60 Address + MICROVM_ACPI_GED_REG_SLEEP_CTL,
61 (1 << 5) /* enable bit */ |
62 (5 << 2) /* typ == S5 */
63 );
64 CpuDeadLoop ();
65}
66
67VOID EFIAPI
69 VOID
70 )
71{
72 MicrovmReset ();
73}
74
75VOID EFIAPI
77 VOID
78 )
79{
80 MicrovmReset ();
81}
82
83VOID
84EFIAPI
86 IN UINTN DataSize,
87 IN VOID *ResetData
88 )
89{
90 MicrovmReset ();
91}
92
93VOID
94EFIAPI
96 IN EFI_RESET_TYPE ResetType,
97 IN EFI_STATUS ResetStatus,
98 IN UINTN DataSize,
99 IN VOID *ResetData OPTIONAL
100 )
101{
102 MicrovmReset ();
103}
104
105VOID EFIAPI
107 VOID
108 )
109{
110 MicrovmShutdown ();
111}
UINT64 UINTN
VOID EFIAPI CpuDeadLoop(VOID)
Definition: CpuDeadLoop.c:25
UINT8 EFIAPI MmioWrite8(IN UINTN Address, IN UINT8 Value)
Definition: IoLib.c:126
#define IN
Definition: Base.h:279
#define DEBUG(Expression)
Definition: DebugLib.h:434
VOID EFIAPI ResetWarm(VOID)
VOID EFIAPI ResetShutdown(VOID)
VOID EFIAPI ResetSystem(IN EFI_RESET_TYPE ResetType, IN EFI_STATUS ResetStatus, IN UINTN DataSize, IN VOID *ResetData OPTIONAL)
VOID EFIAPI ResetPlatformSpecific(IN UINTN DataSize, IN VOID *ResetData)
VOID EFIAPI ResetCold(VOID)
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
EFI_RESET_TYPE
EFI_STATUS EFIAPI EfiConvertPointer(IN UINTN DebugDisposition, IN OUT VOID **Address)
Definition: RuntimeLib.c:561
BOOLEAN EFIAPI EfiGoneVirtual(VOID)
Definition: RuntimeLib.c:188