pc, i440fx: Make smm enable/disable function i440fx independent.

make cpu_smm_update() generic to be independent on i440fx by
registering a callback.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
This commit is contained in:
Isaku Yamahata 2010-05-14 16:29:04 +09:00 committed by Blue Swirl
parent b8d6f53986
commit f885f1eaa8
3 changed files with 22 additions and 5 deletions

18
hw/pc.c
View file

@ -68,7 +68,6 @@
static FDCtrl *floppy_controller; static FDCtrl *floppy_controller;
static RTCState *rtc_state; static RTCState *rtc_state;
static PITState *pit; static PITState *pit;
static PCII440FXState *i440fx_state;
#define E820_NR_ENTRIES 16 #define E820_NR_ENTRIES 16
@ -125,10 +124,22 @@ uint64_t cpu_get_tsc(CPUX86State *env)
} }
/* SMM support */ /* 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) void cpu_smm_update(CPUState *env)
{ {
if (i440fx_state && env == first_cpu) if (smm_set && smm_arg && env == first_cpu)
i440fx_set_smm(i440fx_state, (env->hflags >> HF_SMM_SHIFT) & 1); smm_set(!!(env->hflags & HF_SMM_MASK), smm_arg);
} }
@ -813,6 +824,7 @@ static void pc_init1(ram_addr_t ram_size,
ram_addr_t below_4g_mem_size, above_4g_mem_size = 0; ram_addr_t below_4g_mem_size, above_4g_mem_size = 0;
int bios_size, isa_bios_size; int bios_size, isa_bios_size;
PCIBus *pci_bus; PCIBus *pci_bus;
PCII440FXState *i440fx_state;
int piix3_devfn = -1; int piix3_devfn = -1;
qemu_irq *cpu_irq; qemu_irq *cpu_irq;
qemu_irq *isa_irq; qemu_irq *isa_irq;

View file

@ -80,6 +80,9 @@ extern int fd_bootchk;
void ioport_set_a20(int enable); void ioport_set_a20(int enable);
int ioport_get_a20(void); 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 */ /* acpi.c */
extern int acpi_enabled; extern int acpi_enabled;
extern char *acpi_tables; extern char *acpi_tables;
@ -108,7 +111,6 @@ struct PCII440FXState;
typedef struct PCII440FXState PCII440FXState; typedef struct PCII440FXState PCII440FXState;
PCIBus *i440fx_init(PCII440FXState **pi440fx_state, int *piix_devfn, qemu_irq *pic, int ram_size); PCIBus *i440fx_init(PCII440FXState **pi440fx_state, int *piix_devfn, qemu_irq *pic, int ram_size);
void i440fx_set_smm(PCII440FXState *d, int val);
void i440fx_init_memory_mappings(PCII440FXState *d); void i440fx_init_memory_mappings(PCII440FXState *d);
/* piix4.c */ /* piix4.c */

View file

@ -114,8 +114,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); val = (val != 0);
if (d->smm_enabled != val) { if (d->smm_enabled != val) {
d->smm_enabled = val; d->smm_enabled = val;
@ -210,6 +212,7 @@ static int i440fx_initfn(PCIDevice *dev)
d->dev.config[I440FX_SMRAM] = 0x02; d->dev.config[I440FX_SMRAM] = 0x02;
cpu_smm_register(&i440fx_set_smm, d);
return 0; return 0;
} }