@@ -5,19 +5,20 @@
#include "hw/hw.h"
#include "exec/memory.h"
-typedef void (*apm_ctrl_changed_t)(uint32_t val, void *arg);
+typedef void (*apm_reg_changed_t)(uint32_t val, void *arg);
typedef struct APMState {
uint8_t apmc;
uint8_t apms;
- apm_ctrl_changed_t callback;
+ apm_reg_changed_t cnt_callback;
+ apm_reg_changed_t sts_callback;
void *arg;
MemoryRegion io;
} APMState;
-void apm_init(PCIDevice *dev, APMState *s, apm_ctrl_changed_t callback,
- void *arg);
+void apm_init(PCIDevice *dev, APMState *s, apm_reg_changed_t cnt_callback,
+ apm_reg_changed_t sts_callback, void *arg);
extern const VMStateDescription vmstate_apm;
@@ -493,7 +493,7 @@ static void piix4_pm_realize(PCIDevice *dev, Error **errp)
pci_conf[0x3d] = 0x01; // interrupt pin 1
/* APM */
- apm_init(dev, &s->apm, apm_ctrl_changed, s);
+ apm_init(dev, &s->apm, apm_ctrl_changed, NULL, s);
if (!s->smm_enabled) {
/* Mark SMM as already inited to prevent SMM from running. KVM does not
@@ -47,11 +47,15 @@ static void apm_ioport_writeb(void *opaque, hwaddr addr, uint64_t val,
if (addr == 0) {
apm->apmc = val;
- if (apm->callback) {
- (apm->callback)(val, apm->arg);
+ if (apm->cnt_callback) {
+ apm->cnt_callback(val, apm->arg);
}
} else {
apm->apms = val;
+
+ if (apm->sts_callback) {
+ apm->sts_callback(val, apm->arg);
+ }
}
}
@@ -90,10 +94,11 @@ static const MemoryRegionOps apm_ops = {
},
};
-void apm_init(PCIDevice *dev, APMState *apm, apm_ctrl_changed_t callback,
- void *arg)
+void apm_init(PCIDevice *dev, APMState *apm, apm_reg_changed_t cnt_callback,
+ apm_reg_changed_t sts_callback, void *arg)
{
- apm->callback = callback;
+ apm->cnt_callback = cnt_callback;
+ apm->sts_callback = sts_callback;
apm->arg = arg;
/* ioport 0xb2, 0xb3 */
@@ -634,7 +634,7 @@ static void ich9_lpc_realize(PCIDevice *d, Error **errp)
lpc->isa_bus = isa_bus;
ich9_cc_init(lpc);
- apm_init(d, &lpc->apm, ich9_apm_ctrl_changed, lpc);
+ apm_init(d, &lpc->apm, ich9_apm_ctrl_changed, NULL, lpc);
lpc->machine_ready.notify = ich9_lpc_machine_ready;
qemu_add_machine_init_done_notifier(&lpc->machine_ready);
@@ -365,7 +365,7 @@ static void vt82c686b_pm_realize(PCIDevice *dev, Error **errp)
pm_smbus_init(&s->dev.qdev, &s->smb);
memory_region_add_subregion(get_system_io(), s->smb_io_base, &s->smb.io);
- apm_init(dev, &s->apm, NULL, s);
+ apm_init(dev, &s->apm, NULL, NULL, s);
memory_region_init(&s->io, OBJECT(dev), "vt82c686-pm", 64);
memory_region_set_enabled(&s->io, false);
In the following patches we'll add custom handling for when APM_STS_IOPORT is written. Introduce a dedicated callback similar to the one that is now called for APM_CNT_IOPORT writes. Cc: "Kevin O'Connor" <kevin@koconnor.net> Cc: "Michael S. Tsirkin" <mst@redhat.com> Cc: Gerd Hoffmann <kraxel@redhat.com> Cc: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Laszlo Ersek <lersek@redhat.com> --- Notes: v3: - feature negotiation is new in v3 [Paolo, Michael] include/hw/isa/apm.h | 9 +++++---- hw/acpi/piix4.c | 2 +- hw/isa/apm.c | 15 ++++++++++----- hw/isa/lpc_ich9.c | 2 +- hw/isa/vt82c686.c | 2 +- 5 files changed, 18 insertions(+), 12 deletions(-) -- 2.9.2