[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 07/61] pc, i440fx: Make smm enable/disable function
From: |
Isaku Yamahata |
Subject: |
[Qemu-devel] [PATCH 07/61] pc, i440fx: Make smm enable/disable function i440fx independent. |
Date: |
Wed, 30 Sep 2009 19:17:43 +0900 |
make cpu_smm_update() generic to be independent on i440fx by
registering a callback.
Signed-off-by: Isaku Yamahata <address@hidden>
---
hw/pc.c | 18 +++++++++++++++---
hw/pc.h | 8 +++++++-
hw/piix_pci.c | 6 ++++--
3 files changed, 26 insertions(+), 6 deletions(-)
diff --git a/hw/pc.c b/hw/pc.c
index 0d85914..232f6a7 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -64,7 +64,6 @@
static fdctrl_t *floppy_controller;
static RTCState *rtc_state;
static PITState *pit;
-static PCII440FXState *i440fx_state;
typedef struct rom_reset_data {
uint8_t *data;
@@ -130,10 +129,22 @@ uint64_t cpu_get_tsc(CPUX86State *env)
}
/* SMM support */
+
+static cpu_set_smm_t smm_set;
+static void *smm_arg;
+
+void cpu_smm_register(cpu_set_smm_t callback, void *arg)
+{
+ assert(smm_set == NULL);
+ assert(smm_arg == NULL);
+ smm_set = callback;
+ smm_arg = arg;
+}
+
void cpu_smm_update(CPUState *env)
{
- if (i440fx_state && env == first_cpu)
- i440fx_set_smm(i440fx_state, (env->hflags >> HF_SMM_SHIFT) & 1);
+ if (smm_set && smm_arg && env == first_cpu)
+ smm_set(!!(env->hflags & HF_SMM_MASK), smm_arg);
}
@@ -1128,6 +1139,7 @@ static void pc_init1(ram_addr_t ram_size,
int bios_size, isa_bios_size, oprom_area_size;
PCIBus *pci_bus;
ISADevice *isa_dev;
+ PCII440FXState *i440fx_state;
int piix3_devfn = -1;
CPUState *env;
qemu_irq *cpu_irq;
diff --git a/hw/pc.h b/hw/pc.h
index c9cdd4a..818323e 100644
--- a/hw/pc.h
+++ b/hw/pc.h
@@ -94,6 +94,13 @@ extern int fd_bootchk;
void ioport_set_a20(int enable);
int ioport_get_a20(void);
+typedef void (*cpu_set_smm_t)(int smm, void *arg);
+#if defined(TARGET_I386)
+void cpu_smm_register(cpu_set_smm_t callback, void *arg);
+#else
+static inline void cpu_smm_register(cpu_set_smm_t callback, void *arg) { };
+#endif
+
/* acpi.c */
extern int acpi_enabled;
extern char *acpi_tables;
@@ -120,7 +127,6 @@ struct PCII440FXState;
typedef struct PCII440FXState PCII440FXState;
PCIBus *i440fx_init(PCII440FXState **pi440fx_state, int *piix_devfn, qemu_irq
*pic);
-void i440fx_set_smm(PCII440FXState *d, int val);
void i440fx_init_memory_mappings(PCII440FXState *d);
/* piix4.c */
diff --git a/hw/piix_pci.c b/hw/piix_pci.c
index edd6df0..7447663 100644
--- a/hw/piix_pci.c
+++ b/hw/piix_pci.c
@@ -122,8 +122,10 @@ static void i440fx_update_memory_mappings(PCII440FXState
*d)
}
}
-void i440fx_set_smm(PCII440FXState *d, int val)
+static void i440fx_set_smm(int val, void *arg)
{
+ PCII440FXState *d = arg;
+
val = (val != 0);
if (d->smm_enabled != val) {
d->smm_enabled = val;
@@ -131,7 +133,6 @@ void i440fx_set_smm(PCII440FXState *d, int val)
}
}
-
/* XXX: suppress when better memory API. We make the assumption that
no device (in particular the VGA) changes the memory mappings in
the 0xa0000-0x100000 range */
@@ -223,6 +224,7 @@ static int i440fx_initfn(PCIDevice *dev)
d->dev.config[0x72] = 0x02; /* SMRAM */
vmstate_register(0, &vmstate_i440fx, d);
+ cpu_smm_register(&i440fx_set_smm, d);
return 0;
}
--
1.6.0.2
- [Qemu-devel] [PATCH 00/61] Q35 chip set and stuff., Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 07/61] pc, i440fx: Make smm enable/disable function i440fx independent.,
Isaku Yamahata <=
- [Qemu-devel] [PATCH 05/61] acpi_piix4: remove unused variable in get_pmsts()., Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 32/61] pci: helper functions to access PCIDevice::config, Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 50/61] pci hotadd, acpi_piix4: remove global variables., Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 27/61] pci: clean up of pci_update_mappings(), Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 06/61] pc: fix file stream leak in multiboot loader., Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 20/61] pci: fix PCI_DPRINTF() wrt variadic macro., Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 19/61] pc_piix: initialize ioapic before use., Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 31/61] pci: pcie host and mmcfg support., Isaku Yamahata, 2009/09/30
- [Qemu-devel] [PATCH 02/61] acpi: split out apm register emulation from acpi.c, Isaku Yamahata, 2009/09/30