On 04/16/20 01:09, Rebecca Cran wrote:
> Update ResetSystemLib to support powering off bhyve guests instead of
> having them enter the CpuDeadLoop.
> 
> On bhyve, the Power Management 1 Control Register is located at 0x404;
> a write with SLP_TYP set to 5 will power off the guest.
> 
> Signed-off-by: Rebecca Cran <rebe...@bsdio.com>
> ---
>  OvmfPkg/Include/IndustryStandard/Bhyve.h        | 4 ++++
>  OvmfPkg/Library/ResetSystemLib/ResetSystemLib.c | 6 ++++++
>  2 files changed, 10 insertions(+)
> 
> diff --git a/OvmfPkg/Include/IndustryStandard/Bhyve.h 
> b/OvmfPkg/Include/IndustryStandard/Bhyve.h
> index 950f87048b..ceabc54d59 100644
> --- a/OvmfPkg/Include/IndustryStandard/Bhyve.h
> +++ b/OvmfPkg/Include/IndustryStandard/Bhyve.h
> @@ -18,4 +18,8 @@
>  
>  #define BHYVE_ACPI_TIMER_IO_ADDR 0x408
>  
> +#define BHYVE_PMBASE_VALUE 0x400
> +
> +#define BHYVE_PCI_DEVICE_ID 0x1275 // NetApp vendor ID
> +
>  #endif // __BHYVE_H__
> diff --git a/OvmfPkg/Library/ResetSystemLib/ResetSystemLib.c 
> b/OvmfPkg/Library/ResetSystemLib/ResetSystemLib.c
> index 2f2e1293a3..8d9b9dfcf5 100644
> --- a/OvmfPkg/Library/ResetSystemLib/ResetSystemLib.c
> +++ b/OvmfPkg/Library/ResetSystemLib/ResetSystemLib.c
> @@ -28,6 +28,12 @@ AcpiPmControl (
>    AcpiPmBaseAddress = 0;
>    HostBridgeDevId = PciRead16 (OVMF_HOSTBRIDGE_DID);
>    switch (HostBridgeDevId) {
> +  case BHYVE_PCI_DEVICE_ID:
> +    AcpiPmBaseAddress = BHYVE_PMBASE_VALUE;
> +    // Bhyve needs a value of 5 to enter S5 (power off)
> +    if (SuspendType == 0)
> +      SuspendType = 5;
> +    break;
>    case INTEL_82441_DEVICE_ID:
>      AcpiPmBaseAddress = PIIX4_PMBA_VALUE;
>      break;
> 

In this patch, we should follow the pattern seen in patch#1 -- new,
bhyve-specific library instance.

However, this library has hugely bit-rotted, and it needs some serious
scrubbing before we can do that. Let me look into a patch series for
that. I'll continue to review of this series after that. I hope that
works for you.

Thanks
Laszlo


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#57504): https://edk2.groups.io/g/devel/message/57504
Mute This Topic: https://groups.io/mt/73045196/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to