From patchwork Tue Jan 5 06:27:30 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Isaku Yamahata X-Patchwork-Id: 42184 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id EF10EB6EF2 for ; Wed, 6 Jan 2010 08:10:58 +1100 (EST) Received: from localhost ([127.0.0.1]:44849 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NSGg4-0007F0-2w for incoming@patchwork.ozlabs.org; Tue, 05 Jan 2010 16:10:56 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NSFPs-0007US-D8 for qemu-devel@nongnu.org; Tue, 05 Jan 2010 14:50:09 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NSFPn-0007RQ-T8 for qemu-devel@nongnu.org; Tue, 05 Jan 2010 14:50:07 -0500 Received: from [199.232.76.173] (port=40915 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NSFPn-0007RB-Np for qemu-devel@nongnu.org; Tue, 05 Jan 2010 14:50:03 -0500 Received: from mx20.gnu.org ([199.232.41.8]:36255) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NSFPn-0003Ef-DH for qemu-devel@nongnu.org; Tue, 05 Jan 2010 14:50:03 -0500 Received: from mail.valinux.co.jp ([210.128.90.3]) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NS2uv-0003rm-Sd for qemu-devel@nongnu.org; Tue, 05 Jan 2010 01:29:22 -0500 Received: from ps.local.valinux.co.jp (vagw.valinux.co.jp [210.128.90.14]) by mail.valinux.co.jp (Postfix) with SMTP id 6352618294; Tue, 5 Jan 2010 15:27:45 +0900 (JST) Received: (nullmailer pid 22658 invoked by uid 1000); Tue, 05 Jan 2010 06:27:50 -0000 From: Isaku Yamahata To: qemu-devel@nongnu.org, kraxel@redhat.com Date: Tue, 5 Jan 2010 15:27:30 +0900 Message-Id: <1262672870-22607-8-git-send-email-yamahata@valinux.co.jp> X-Mailer: git-send-email 1.6.5.4 In-Reply-To: <1262672870-22607-1-git-send-email-yamahata@valinux.co.jp> References: <1262672870-22607-1-git-send-email-yamahata@valinux.co.jp> X-Virus-Scanned: clamav-milter 0.95.2 at va-mail.local.valinux.co.jp X-Virus-Status: Clean X-detected-operating-system: by mx20.gnu.org: GNU/Linux 2.6 (newer, 3) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) Cc: yamahata@valinux.co.jp Subject: [Qemu-devel] [PATCH V11 07/27] pc, i440fx: Make smm enable/disable function i440fx independent. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org make cpu_smm_update() generic to be independent on i440fx by registering a callback. Signed-off-by: Isaku Yamahata --- hw/pc.c | 18 +++++++++++++++--- hw/pc.h | 8 +++++++- hw/piix_pci.c | 5 ++++- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/hw/pc.c b/hw/pc.c index fbacc1e..cdd9de6 100644 --- a/hw/pc.c +++ b/hw/pc.c @@ -67,7 +67,6 @@ static fdctrl_t *floppy_controller; static RTCState *rtc_state; static PITState *pit; -static PCII440FXState *i440fx_state; typedef struct isa_irq_state { qemu_irq *i8259; @@ -109,10 +108,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); } @@ -996,6 +1007,7 @@ static void pc_init1(ram_addr_t ram_size, int bios_size, isa_bios_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 03ffc91..cbecc07 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 1b67475..ff689a3 100644 --- a/hw/piix_pci.c +++ b/hw/piix_pci.c @@ -104,8 +104,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; @@ -198,6 +200,7 @@ static int i440fx_initfn(PCIDevice *dev) d->dev.config[0x72] = 0x02; /* SMRAM */ + cpu_smm_register(&i440fx_set_smm, d); return 0; }