[Top][All Lists]
[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
- [Qemu-devel] [PATCH 04/17] acpi: add acpi constants from linux header files and use them., (continued)
- [Qemu-devel] [PATCH 04/17] acpi: add acpi constants from linux header files and use them., Isaku Yamahata, 2009/07/07
- [Qemu-devel] [PATCH 17/17] pc.c: split out piix specific part from pc.c into pc_piix.c, Isaku Yamahata, 2009/07/07
- [Qemu-devel] [PATCH 07/17] pc.c: remove unnecessary global variables, pit and ioapic.., Isaku Yamahata, 2009/07/07
- [Qemu-devel] [PATCH 02/17] acpi.c: split out apm register emulation., Isaku Yamahata, 2009/07/07
- [Qemu-devel] [PATCH 11/17] pc.c: make pc_init1() not refer ferr_irq directly., Isaku Yamahata, 2009/07/07
- [Qemu-devel] [PATCH 03/17] acpi.c: make qemu_system_powerdown() piix independent., Isaku Yamahata, 2009/07/07
- [Qemu-devel] [PATCH 13/17] pc.c: split out memory allocation from pc_init1() into pc_memory_init(), Isaku Yamahata, 2009/07/07
- [Qemu-devel] [PATCH 09/17] pc.c: remove a global variable, RTCState *rtc_state., Isaku Yamahata, 2009/07/07
- [Qemu-devel] [PATCH 14/17] pc.c: split out vga initialization from pc_init1() into pc_vga_init()., Isaku Yamahata, 2009/07/07
- [Qemu-devel] [PATCH 06/17] pc.c: Make smm enable/disable function i440fx independent.,
Isaku Yamahata <=
- [Qemu-devel] [PATCH 05/17] acpi.c: split acpi.c into the common part and the piix4 part., Isaku Yamahata, 2009/07/07
- [Qemu-devel] [PATCH 08/17] pc.c: remove a global variable, floppy_controller., Isaku Yamahata, 2009/07/07
- [Qemu-devel] [PATCH 12/17] pc.c: split out cpu initialization from pc_init1() into pc_cpus_init()., Isaku Yamahata, 2009/07/07
- [Qemu-devel] [PATCH 10/17] pc.c: introduce a function to allocate cpu irq., Isaku Yamahata, 2009/07/07
- [Qemu-devel] [PATCH 15/17] pc.c: split out basic device init from pc_init1() into pc_basic_device_init(), Isaku Yamahata, 2009/07/07
- [Qemu-devel] [PATCH 16/17] pc.c: split out pci device init from pc_init1() into pc_pci_device_init(), Isaku Yamahata, 2009/07/07
- [Qemu-devel] [PATCH 00/17] split out piix specific part from pc emulator. v3, Isaku Yamahata, 2009/07/09