Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C8C22C0032E for ; Sat, 28 Oct 2023 17:42:44 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qwnJq-0004LU-Vo; Sat, 28 Oct 2023 13:41:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qwnJm-0004LF-Kf for qemu-devel@nongnu.org; Sat, 28 Oct 2023 13:41:50 -0400 Received: from zero.eik.bme.hu ([2001:738:2001:2001::2001]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qwnJk-0001ov-4H for qemu-devel@nongnu.org; Sat, 28 Oct 2023 13:41:50 -0400 Received: from zero.eik.bme.hu (blah.eik.bme.hu [152.66.115.182]) by localhost (Postfix) with SMTP id 212A3756078; Sat, 28 Oct 2023 19:41:46 +0200 (CEST) Received: by zero.eik.bme.hu (Postfix, from userid 432) id 16D897456A7; Sat, 28 Oct 2023 19:41:45 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by zero.eik.bme.hu (Postfix) with ESMTP id 13162745681; Sat, 28 Oct 2023 19:41:45 +0200 (CEST) Date: Sat, 28 Oct 2023 19:41:45 +0200 (CEST) From: BALATON Zoltan To: Bernhard Beschow cc: qemu-devel@nongnu.org, Jiaxun Yang , =?ISO-8859-15?Q?Philippe_Mathieu-Daud=E9?= Subject: Re: [PATCH v5 5/5] hw/isa/vt82c686: Implement software-based SMI triggering In-Reply-To: <02D892F2-0778-40EF-A583-A4728B119EF8@gmail.com> Message-ID: References: <20231028091606.23700-1-shentey@gmail.com> <20231028091606.23700-6-shentey@gmail.com> <95144ce6-b340-11bf-354b-e73c2fbc795e@eik.bme.hu> <02D892F2-0778-40EF-A583-A4728B119EF8@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Received-SPF: pass client-ip=2001:738:2001:2001::2001; envelope-from=balaton@eik.bme.hu; helo=zero.eik.bme.hu X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org On Sat, 28 Oct 2023, Bernhard Beschow wrote: > Am 28. Oktober 2023 13:03:41 UTC schrieb BALATON Zoltan : >> On Sat, 28 Oct 2023, Bernhard Beschow wrote: >>> If enabled, SMIs can be triggered via software by writing to an IO-mapped port. >>> SMIs usually trigger execution of BIOS code. If appropriate values are written >>> to the port, the BIOS transitions the system into or out of ACPI mode. >>> >>> Note that APMState implements Intel-specific behavior where there are two IO >>> ports which are mapped at fixed addresses. In VIA, there is only one such port >>> which is located inside a relocatable IO-mapped region. Hence, there is no point >>> in reusing APMState. >>> >>> Signed-off-by: Bernhard Beschow >>> --- >>> hw/isa/vt82c686.c | 95 +++++++++++++++++++++++++++++++++++++++++++---- >>> 1 file changed, 87 insertions(+), 8 deletions(-) >>> >>> diff --git a/hw/isa/vt82c686.c b/hw/isa/vt82c686.c >>> index e8ec63dea9..361b3bed0a 100644 >>> --- a/hw/isa/vt82c686.c >>> +++ b/hw/isa/vt82c686.c >>> @@ -27,7 +27,6 @@ >>> #include "hw/timer/i8254.h" >>> #include "hw/rtc/mc146818rtc.h" >>> #include "migration/vmstate.h" >>> -#include "hw/isa/apm.h" >>> #include "hw/acpi/acpi.h" >>> #include "hw/i2c/pm_smbus.h" >>> #include "qapi/error.h" >>> @@ -42,6 +41,16 @@ >>> #define TYPE_VIA_PM "via-pm" >>> OBJECT_DECLARE_SIMPLE_TYPE(ViaPMState, VIA_PM) >>> >>> +#define VIA_PM_IO_GBLEN 0x2a >>> +#define VIA_PM_IO_GBLEN_SW_SMI_EN (1 << 6) >>> + >>> +#define VIA_PM_IO_GBLCTL 0x2c >>> +#define VIA_PM_IO_GBLCTL_SMI_EN 1 >>> +#define VIA_PM_IO_GBLCTL_SMIIG (1 << 4) >>> +#define VIA_PM_IO_GBLCTL_INSMI (1 << 8) >>> + >>> +#define VIA_PM_IO_SMI_CMD 0x2f >>> + >>> #define VIA_PM_GPE_LEN 4 >>> >>> #define VIA_PM_SCI_SELECT_OFS 0x42 >> >> If we'll make a copy of the data sheet in form of #defines could these be in the header to less clutter the source? > > Last time I did that I was asked to move the defines back into the > source file. I can't find the link right now, otherwise I'd have placed > it here. Yeah, the public header is probably not a good place for these either. Maybe add a local vt82c686_regs,h or similar private header in hw/isa next to the .c file for these? I'd just say we could use the constant values directly as reviewing them will need to look up the data sheet anyway but Philippe was in favour of adding defines for constants. This isn't a big deal though. Regards, BALATON Zoltan