From: Patrick Rudolph <patrick.rudolph@9elements.com>
To: qemu-devel@nongnu.org
Cc: pbonzini@redhat.com, mst@redhat.com, imammedo@redhat.com,
anisinha@redhat.com, marcel.apfelbaum@gmail.com,
Patrick Rudolph <patrick.rudolph@9elements.com>
Subject: [PATCH 2/3] hw/isa/lpc_ich9: Implement SMI_STS for APMC
Date: Wed, 18 Oct 2023 13:52:30 +0200 [thread overview]
Message-ID: <20231018115231.3547102-3-patrick.rudolph@9elements.com> (raw)
In-Reply-To: <20231018115231.3547102-1-patrick.rudolph@9elements.com>
The guest SMI handler wants to know the cause for the SMI, thus properly
emulate the RWC APMC and TCO bit in the SMI_STS register.
TEST: coreboot generic ICH9 SMI handler is able to determine
the source for the SMI and will invoke the APM callback.
Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
---
hw/acpi/ich9.c | 5 +++++
hw/acpi/ich9_tco.c | 5 +++++
hw/isa/lpc_ich9.c | 1 +
include/hw/southbridge/ich9.h | 2 ++
4 files changed, 13 insertions(+)
diff --git a/hw/acpi/ich9.c b/hw/acpi/ich9.c
index 25e2c7243e..74d1824595 100644
--- a/hw/acpi/ich9.c
+++ b/hw/acpi/ich9.c
@@ -98,6 +98,7 @@ static void ich9_smi_writel(void *opaque, hwaddr addr, uint64_t val,
ICH9LPCPMRegs *pm = opaque;
TCOIORegs *tr = &pm->tco_regs;
uint64_t tco_en;
+ uint32_t mask;
switch (addr) {
case 0:
@@ -109,6 +110,10 @@ static void ich9_smi_writel(void *opaque, hwaddr addr, uint64_t val,
pm->smi_en &= ~pm->smi_en_wmask;
pm->smi_en |= (val & pm->smi_en_wmask);
break;
+ case 4:
+ mask = pm->smi_sts & ~val;
+ pm->smi_sts &= ~(ICH9_PMIO_SMI_STS_TCO | ICH9_PMIO_SMI_STS_APMC);
+ pm->smi_sts |= mask & (ICH9_PMIO_SMI_STS_TCO | ICH9_PMIO_SMI_STS_APMC);
}
}
diff --git a/hw/acpi/ich9_tco.c b/hw/acpi/ich9_tco.c
index 1540f4fd46..0f1cb19864 100644
--- a/hw/acpi/ich9_tco.c
+++ b/hw/acpi/ich9_tco.c
@@ -71,6 +71,7 @@ static void tco_timer_expired(void *opaque)
}
if (pm->smi_en & ICH9_PMIO_SMI_EN_TCO_EN) {
+ lpc->pm.smi_sts |= ICH9_PMIO_SMI_STS_TCO;
ich9_generate_smi();
}
tr->tco.rld = tr->tco.tmr;
@@ -139,6 +140,9 @@ static uint32_t tco_ioport_readw(TCOIORegs *tr, uint32_t addr)
static void tco_ioport_writew(TCOIORegs *tr, uint32_t addr, uint32_t val)
{
+ ICH9LPCPMRegs *pm = container_of(tr, ICH9LPCPMRegs, tco_regs);
+ ICH9LPCState *lpc = container_of(pm, ICH9LPCState, pm);
+
trace_tco_io_write(addr, val);
switch (addr) {
case TCO_RLD:
@@ -153,6 +157,7 @@ static void tco_ioport_writew(TCOIORegs *tr, uint32_t addr, uint32_t val)
case TCO_DAT_IN:
tr->tco.din = val;
tr->tco.sts1 |= SW_TCO_SMI;
+ lpc->pm.smi_sts |= ICH9_PMIO_SMI_STS_TCO;
ich9_generate_smi();
break;
case TCO_DAT_OUT:
diff --git a/hw/isa/lpc_ich9.c b/hw/isa/lpc_ich9.c
index 01d6a46c3d..eb25e6429e 100644
--- a/hw/isa/lpc_ich9.c
+++ b/hw/isa/lpc_ich9.c
@@ -471,6 +471,7 @@ static void ich9_apm_ctrl_changed(uint32_t val, void *arg)
/* SMI_EN = PMBASE + 30. SMI control and enable register */
if (lpc->pm.smi_en & ICH9_PMIO_SMI_EN_APMC_EN) {
+ lpc->pm.smi_sts |= ICH9_PMIO_SMI_STS_APMC;
if (lpc->smi_negotiated_features &
(UINT64_C(1) << ICH9_LPC_SMI_F_BROADCAST_BIT)) {
CPUState *cs;
diff --git a/include/hw/southbridge/ich9.h b/include/hw/southbridge/ich9.h
index 1281eb654c..4f5d6cefaa 100644
--- a/include/hw/southbridge/ich9.h
+++ b/include/hw/southbridge/ich9.h
@@ -202,6 +202,8 @@ struct ICH9LPCState {
#define ICH9_PMIO_SMI_EN_APMC_EN (1 << 5)
#define ICH9_PMIO_SMI_EN_TCO_EN (1 << 13)
#define ICH9_PMIO_SMI_STS 0x34
+#define ICH9_PMIO_SMI_STS_APMC (1 << 5)
+#define ICH9_PMIO_SMI_STS_TCO (1 << 13)
#define ICH9_PMIO_TCO_RLD 0x60
#define ICH9_PMIO_TCO_LEN 32
--
2.41.0
next prev parent reply other threads:[~2023-10-18 12:48 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-18 11:52 [PATCH 0/3] hw/i386: Add MTD controller on ICH9 Patrick Rudolph
2023-10-18 11:52 ` [PATCH 1/3] hw/isa/ich9: Add SPI controller Patrick Rudolph
2023-10-18 11:52 ` Patrick Rudolph [this message]
2023-10-18 11:52 ` [PATCH 3/3] hw/i386/pc_sysfw: Do not create BIOS region if MTD is present Patrick Rudolph
2023-10-18 13:47 ` [PATCH 0/3] hw/i386: Add MTD controller on ICH9 Michael S. Tsirkin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231018115231.3547102-3-patrick.rudolph@9elements.com \
--to=patrick.rudolph@9elements.com \
--cc=anisinha@redhat.com \
--cc=imammedo@redhat.com \
--cc=marcel.apfelbaum@gmail.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).