From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.81]) by mx.groups.io with SMTP id smtpd.web11.120.1587139527650378177 for ; Fri, 17 Apr 2020 09:05:27 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=dHefuItt; spf=pass (domain: redhat.com, ip: 207.211.31.81, mailfrom: philmd@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587139526; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pJRFvY+oSJbDt5tfFc9gRO7+vU9U1gdIg1wiTUbybJc=; b=dHefuIttyTqwwQMqtj+Ds+wVN5ARuqu1H3PvwMe+eaGo5mJEmbHhrbKyhuqWgngsbAMBJJ 3bSdy5K06VemnSZGKJWiq3b2Mw8I1Ljj8aA9gXZLbAlHO9Yh0uXTnA+jKZJ885O1lyKn83 43NkM6En/G32fR9nF6i4EzcoOKi1BVg= Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-485-001K-7mWNZaVOQPdon5r5A-1; Fri, 17 Apr 2020 12:05:25 -0400 X-MC-Unique: 001K-7mWNZaVOQPdon5r5A-1 Received: by mail-ej1-f71.google.com with SMTP id dx16so1256246ejb.10 for ; Fri, 17 Apr 2020 09:05:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=A+9ATAaU1Iq/DCPEOqobq/nXk4ZZY7EpVzpyeflCUDM=; b=BUmo9maJ6Is6OZ6jDwPR5+p6QETTYhoYXKZPefql3ZbHMNDyZqZ399o3+23xK7YFXU 594US9IEh3nkEnvZJmgZttgDxCykb3DqOr66XVKIKcEXPKXmzFh1QMdFConu38vqzwNY 1zdZHjta0UsySmTDaawLypAmrnmbqsyX4Fyjnn6okYYatcgjpjkUX4kz9B3oeRAHiF/F y9iipx+/ovfBMdbs56sjR3FD7xTCLl2pOGUWYnektt6KvdEtoOxvfENYmnyzgsOCTinO IncZmMnbMZrsGUGfvW0IAugjUkj+QkwGEvz2Z4yoh2K70sHCzRjbL2kOPdydHshjNR3D Pr2w== X-Gm-Message-State: AGi0PuZLFnOqb404Fu5M7ZSq7T+ySUoyimtgLuxNH0fYrOkdVW4Vkv/f NWec/YrkIgeP4P7uy8E7nIjXuWXj7mgFA+ae+s06h9ErT3K21JyCaZlBScXol5Gp5049WSecKnt TNGBpqk+qpCkmaw== X-Received: by 2002:a17:907:42d6:: with SMTP id ng6mr3647595ejb.265.1587139523564; Fri, 17 Apr 2020 09:05:23 -0700 (PDT) X-Google-Smtp-Source: APiQypJ8kA+HpbLpmioifbOUf9wpti0tJ3mSUg7YGHxtZ939TEV6mohQbbhd/LMoA/Yr2C2j6kkypw== X-Received: by 2002:a17:907:42d6:: with SMTP id ng6mr3647561ejb.265.1587139523247; Fri, 17 Apr 2020 09:05:23 -0700 (PDT) Return-Path: Received: from [192.168.1.39] (116.red-83-42-57.dynamicip.rima-tde.net. [83.42.57.116]) by smtp.gmail.com with ESMTPSA id k25sm2951777edf.37.2020.04.17.09.05.22 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 17 Apr 2020 09:05:22 -0700 (PDT) Subject: Re: [PATCH 4/6] OvmfPkg/ResetSystemLib: factor out ResetShutdown() To: Laszlo Ersek , edk2-devel-groups-io Cc: Ard Biesheuvel , Jordan Justen , Rebecca Cran References: <20200417153751.7110-1-lersek@redhat.com> <20200417153751.7110-5-lersek@redhat.com> From: =?UTF-8?B?UGhpbGlwcGUgTWF0aGlldS1EYXVkw6k=?= Message-ID: Date: Fri, 17 Apr 2020 18:05:20 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: <20200417153751.7110-5-lersek@redhat.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable On 4/17/20 5:37 PM, Laszlo Ersek wrote: > Move the ResetShutdown() definition to its own file. This will help us > introduce: >=20 > - a new library instance that is not broken in runtime modules (the > current library instance is broken in runtime modules), >=20 > - another new library instance for bhyve support. >=20 > While at it, squash AcpiPmControl() into ResetShutdown(), open-coding > SuspendType=3D0. This is justified because we've had no other callers for > AcpiPmControl() since commit 2d9950a2bff8 ("OvmfPkg: remove > EnterS3WithImmediateWake () from ResetSystemLib", 2020-01-10). >=20 > Tested with the "reset -s" UEFI shell command, on both i440fx and q35. >=20 > Cc: Ard Biesheuvel > Cc: Jordan Justen > Cc: Philippe Mathieu-Daud=C3=A9 > Cc: Rebecca Cran > Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2675 > Signed-off-by: Laszlo Ersek > --- > OvmfPkg/Library/ResetSystemLib/ResetSystemLib.inf | 1 + > OvmfPkg/Library/ResetSystemLib/ResetShutdown.c | 51 ++++++++++++++++= ++++ > OvmfPkg/Library/ResetSystemLib/ResetSystemLib.c | 49 ----------------= --- > 3 files changed, 52 insertions(+), 49 deletions(-) >=20 > diff --git a/OvmfPkg/Library/ResetSystemLib/ResetSystemLib.inf b/OvmfPkg/= Library/ResetSystemLib/ResetSystemLib.inf > index af20f516c035..9362f884f124 100644 > --- a/OvmfPkg/Library/ResetSystemLib/ResetSystemLib.inf > +++ b/OvmfPkg/Library/ResetSystemLib/ResetSystemLib.inf > @@ -22,6 +22,7 @@ [Defines] > # > =20 > [Sources] > + ResetShutdown.c > ResetSystemLib.c > =20 > [Packages] > diff --git a/OvmfPkg/Library/ResetSystemLib/ResetShutdown.c b/OvmfPkg/Lib= rary/ResetSystemLib/ResetShutdown.c > new file mode 100644 > index 000000000000..971d94fa5766 > --- /dev/null > +++ b/OvmfPkg/Library/ResetSystemLib/ResetShutdown.c > @@ -0,0 +1,51 @@ > +/** @file > + Reset System Library Shutdown API implementation for OVMF. > + > + Copyright (C) 2020, Red Hat, Inc. > + Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
> + SPDX-License-Identifier: BSD-2-Clause-Patent > +**/ > + > +#include // BIT13 > + > +#include // CpuDeadLoop() > +#include // ASSERT() > +#include // IoOr16() > +#include // PciRead16() > +#include // ResetShutdown() > +#include // OVMF_HOSTBRIDGE_DID > + > +/** > + Calling this function causes the system to enter a power state equival= ent > + to the ACPI G2/S5 or G3 states. > + > + System shutdown should not return, if it returns, it means the system = does > + not support shut down reset. > +**/ > +VOID > +EFIAPI > +ResetShutdown ( > + VOID > + ) > +{ > + UINT16 AcpiPmBaseAddress; > + UINT16 HostBridgeDevId; > + > + AcpiPmBaseAddress =3D 0; > + HostBridgeDevId =3D PciRead16 (OVMF_HOSTBRIDGE_DID); > + switch (HostBridgeDevId) { > + case INTEL_82441_DEVICE_ID: > + AcpiPmBaseAddress =3D PIIX4_PMBA_VALUE; > + break; > + case INTEL_Q35_MCH_DEVICE_ID: > + AcpiPmBaseAddress =3D ICH9_PMBASE_VALUE; > + break; > + default: > + ASSERT (FALSE); > + CpuDeadLoop (); > + } > + > + IoBitFieldWrite16 (AcpiPmBaseAddress + 4, 10, 13, 0); > + IoOr16 (AcpiPmBaseAddress + 4, BIT13); > + CpuDeadLoop (); > +} > diff --git a/OvmfPkg/Library/ResetSystemLib/ResetSystemLib.c b/OvmfPkg/Li= brary/ResetSystemLib/ResetSystemLib.c > index 0fc142325ece..fe51f53d1df2 100644 > --- a/OvmfPkg/Library/ResetSystemLib/ResetSystemLib.c > +++ b/OvmfPkg/Library/ResetSystemLib/ResetSystemLib.c > @@ -9,41 +9,9 @@ > #include // BIT1 > =20 > #include // CpuDeadLoop() > -#include // ASSERT() > #include // IoWrite8() > -#include // PciRead16() > #include // ResetCold() > #include // MicroSecondDelay() > -#include // OVMF_HOSTBRIDGE_DID > - > -VOID > -AcpiPmControl ( > - UINTN SuspendType > - ) > -{ > - UINT16 AcpiPmBaseAddress; > - UINT16 HostBridgeDevId; > - > - ASSERT (SuspendType < 6); > - > - AcpiPmBaseAddress =3D 0; > - HostBridgeDevId =3D PciRead16 (OVMF_HOSTBRIDGE_DID); > - switch (HostBridgeDevId) { > - case INTEL_82441_DEVICE_ID: > - AcpiPmBaseAddress =3D PIIX4_PMBA_VALUE; > - break; > - case INTEL_Q35_MCH_DEVICE_ID: > - AcpiPmBaseAddress =3D ICH9_PMBASE_VALUE; > - break; > - default: > - ASSERT (FALSE); > - CpuDeadLoop (); > - } > - > - IoBitFieldWrite16 (AcpiPmBaseAddress + 4, 10, 13, (UINT16) SuspendType= ); > - IoOr16 (AcpiPmBaseAddress + 4, BIT13); > - CpuDeadLoop (); > -} > =20 > /** > Calling this function causes a system-wide reset. This sets > @@ -84,23 +52,6 @@ ResetWarm ( > CpuDeadLoop (); > } > =20 > -/** > - Calling this function causes the system to enter a power state equival= ent > - to the ACPI G2/S5 or G3 states. > - > - System shutdown should not return, if it returns, it means the system = does > - not support shut down reset. > -**/ > -VOID > -EFIAPI > -ResetShutdown ( > - VOID > - ) > -{ > - AcpiPmControl (0); > - ASSERT (FALSE); > -} > - > =20 > /** > This function causes a systemwide reset. The exact type of the reset = is >=20 Reviewed-by: Philippe Mathieu-Daude