From patchwork Mon Jul 12 11:47:49 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Isaku Yamahata X-Patchwork-Id: 58606 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 6B6C5B6F14 for ; Mon, 12 Jul 2010 22:29:37 +1000 (EST) Received: from localhost ([127.0.0.1]:48180 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OYHYV-0008MK-5p for incoming@patchwork.ozlabs.org; Mon, 12 Jul 2010 07:52:15 -0400 Received: from [140.186.70.92] (port=50905 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OYHUL-0006mH-JO for qemu-devel@nongnu.org; Mon, 12 Jul 2010 07:47:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OYHUI-0007uK-PH for qemu-devel@nongnu.org; Mon, 12 Jul 2010 07:47:57 -0400 Received: from mail.valinux.co.jp ([210.128.90.3]:44779) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OYHUI-0007tg-AI for qemu-devel@nongnu.org; Mon, 12 Jul 2010 07:47:54 -0400 Received: from ps.local.valinux.co.jp (vagw.valinux.co.jp [210.128.90.14]) by mail.valinux.co.jp (Postfix) with SMTP id 2F386107761; Mon, 12 Jul 2010 20:47:50 +0900 (JST) Received: (nullmailer pid 2650 invoked by uid 1000); Mon, 12 Jul 2010 11:47:52 -0000 From: Isaku Yamahata To: seabios@seabios.org Date: Mon, 12 Jul 2010 20:47:49 +0900 Message-Id: X-Mailer: git-send-email 1.7.1.1 In-Reply-To: References: In-Reply-To: References: X-Virus-Scanned: clamav-milter 0.95.2 at va-mail.local.valinux.co.jp X-Virus-Status: Clean X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) Cc: yamahata@valinux.co.jp, qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH 4/7] seabios: smm_init: move out i440fx smram operation into dev-i440fx.c 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 move out i440fx smram operation into dev-i440fx.c. Signed-off-by: Isaku Yamahata --- src/dev-i440fx.c | 8 ++++++++ src/dev-i440fx.h | 1 + src/post.h | 5 +++++ src/smm.c | 17 ++++++++++++----- 4 files changed, 26 insertions(+), 5 deletions(-) diff --git a/src/dev-i440fx.c b/src/dev-i440fx.c index 17d42ce..c9e0c3e 100644 --- a/src/dev-i440fx.c +++ b/src/dev-i440fx.c @@ -26,6 +26,14 @@ void i440fx_shadow_detected(u16 bdf, void *arg) pam_regs->pam0 = I440FX_PAM0; } +#define I440FX_SMRAM 0x72 + +void i440fx_smram_detected(u16 bdf, void *arg) +{ + struct smram_regs *smram_regs = arg; + smram_regs->smram = I440FX_SMRAM; +} + /* PIIX3/PIIX4 PCI to ISA bridge */ void piix_isa_bridge_init(u16 bdf, void *arg) { diff --git a/src/dev-i440fx.h b/src/dev-i440fx.h index 934e7f2..6250c5e 100644 --- a/src/dev-i440fx.h +++ b/src/dev-i440fx.h @@ -4,6 +4,7 @@ #include "types.h" // u16 void i440fx_shadow_detected(u16 bdf, void *arg); +void i440fx_smram_detected(u16 bdf, void *arg); void piix_isa_bridge_init(u16 bdf, void *arg); void piix_ide_init(u16 bdf, void *arg); void piix4_pm_init(u16 bdf, void *arg); diff --git a/src/post.h b/src/post.h index 2996878..c82ee8f 100644 --- a/src/post.h +++ b/src/post.h @@ -16,4 +16,9 @@ struct apmc_ops void (*enable)(u16 bdf); }; +struct smram_regs +{ + u32 smram; +}; + #endif /* __POST_H */ diff --git a/src/smm.c b/src/smm.c index baa272f..4518d95 100644 --- a/src/smm.c +++ b/src/smm.c @@ -81,6 +81,13 @@ static const struct pci_device_id apmc_ops_tbl[] = { PCI_DEVICE_END, }; +static const struct pci_device_id smram_tbl[] = { + PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82441, + i440fx_smram_detected), + + PCI_DEVICE_END, +}; + void smm_init(void) { @@ -98,9 +105,9 @@ smm_init(void) if (bdf < 0) // Device not found return; - int i440_bdf = pci_find_device(PCI_VENDOR_ID_INTEL - , PCI_DEVICE_ID_INTEL_82441); - if (i440_bdf < 0) + struct smram_regs smram_regs; + int smram_bdf = pci_find_init_device(smram_tbl, &smram_regs); + if (smram_bdf < 0) return; /* check if SMM init is already done */ @@ -108,7 +115,7 @@ smm_init(void) return; /* enable the SMM memory window */ - pci_config_writeb(i440_bdf, 0x72, 0x02 | 0x48); + pci_config_writeb(smram_bdf, smram_regs.smram, 0x02 | 0x48); /* save original memory content */ memcpy((void *)BUILD_SMM_ADDR, (void *)BUILD_SMM_INIT_ADDR, BUILD_SMM_SIZE); @@ -139,5 +146,5 @@ smm_init(void) wbinvd(); /* close the SMM memory window and enable normal SMM */ - pci_config_writeb(i440_bdf, 0x72, 0x02 | 0x08); + pci_config_writeb(smram_bdf, smram_regs.smram, 0x02 | 0x08); }