qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 06/17] pc.c: Make smm enable/disable function i440fx


From: Isaku Yamahata
Subject: [Qemu-devel] [PATCH 06/17] pc.c: Make smm enable/disable function i440fx independent.
Date: Tue, 7 Jul 2009 15:35:49 +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       |    4 +++-
 hw/piix_pci.c |    8 +++++---
 3 files changed, 23 insertions(+), 7 deletions(-)

diff --git a/hw/pc.c b/hw/pc.c
index 553ba5c..bc1c8cf 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -61,7 +61,6 @@ static fdctrl_t *floppy_controller;
 static RTCState *rtc_state;
 static PITState *pit;
 static IOAPICState *ioapic;
-static PCIDevice *i440fx_state;
 
 typedef struct rom_reset_data {
     uint8_t *data;
@@ -121,10 +120,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);
 }
 
 
@@ -1095,6 +1106,7 @@ static void pc_init1(ram_addr_t ram_size,
     int bios_size, isa_bios_size, oprom_area_size;
     PCIBus *pci_bus;
     PCIDevice *pci_dev;
+    PCIDevice *i440fx_state;
     int piix3_devfn = -1;
     CPUState *env;
     qemu_irq *cpu_irq;
diff --git a/hw/pc.h b/hw/pc.h
index 9fbae20..bd711ce 100644
--- a/hw/pc.h
+++ b/hw/pc.h
@@ -103,6 +103,9 @@ 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);
+void cpu_smm_register(cpu_set_smm_t callback, void *arg);
+
 /* acpi.c */
 extern int acpi_enabled;
 extern char *acpi_tables;
@@ -126,7 +129,6 @@ int pcspk_audio_init(qemu_irq *pic);
 
 /* piix_pci.c */
 PCIBus *i440fx_init(PCIDevice **pi440fx_state, qemu_irq *pic);
-void i440fx_set_smm(PCIDevice *d, int val);
 int piix3_init(PCIBus *bus, int devfn);
 void i440fx_init_memory_mappings(PCIDevice *d);
 
diff --git a/hw/piix_pci.c b/hw/piix_pci.c
index fce01d4..15f2d5e 100644
--- a/hw/piix_pci.c
+++ b/hw/piix_pci.c
@@ -107,16 +107,16 @@ static void i440fx_update_memory_mappings(PCIDevice *d)
     }
 }
 
-void i440fx_set_smm(PCIDevice *d, int val)
+static void i440fx_set_smm(int smm, void *arg)
 {
-    val = (val != 0);
+    int val = (smm != 0);
+    PCIDevice *d = (PCIDevice*)arg;
     if (smm_enabled != val) {
         smm_enabled = val;
         i440fx_update_memory_mappings(d);
     }
 }
 
-
 /* 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 */
@@ -202,6 +202,8 @@ PCIBus *i440fx_init(PCIDevice **pi440fx_state, qemu_irq 
*pic)
     d->config[0x72] = 0x02; /* SMRAM */
 
     register_savevm("I440FX", 0, 2, i440fx_save, i440fx_load, d);
+    cpu_smm_register(&i440fx_set_smm, d);
+
     *pi440fx_state = d;
     return b;
 }
-- 
1.6.0.2





reply via email to

[Prev in Thread] Current Thread [Next in Thread]