Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1O4IUZ-00006y-CS for qemu-devel@nongnu.org; Tue, 20 Apr 2010 14:48:15 -0400 Received: from [140.186.70.92] (port=48531 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O4IUX-00006p-2N for qemu-devel@nongnu.org; Tue, 20 Apr 2010 14:48:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1O4IUU-0003ua-Tg for qemu-devel@nongnu.org; Tue, 20 Apr 2010 14:48:12 -0400 Received: from delta.zq1.de ([78.46.32.14]:35823) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O4IUU-0003tk-Oo for qemu-devel@nongnu.org; Tue, 20 Apr 2010 14:48:10 -0400 Received: from delta.zq1.de (localhost [127.0.0.1]) by delta.zq1.de (Postfix) with ESMTP id 1522117352E for ; Tue, 20 Apr 2010 20:48:07 +0200 (CEST) Received: from vm12ag.zq1.de (uml12a.zq1.de [192.168.234.46]) by delta.zq1.de (Postfix) with ESMTP for ; Tue, 20 Apr 2010 20:48:07 +0200 (CEST) From: "Bernhard M. Wiedemann" Date: Tue, 20 Apr 2010 20:48:06 +0200 Message-Id: <1271789286-10749-1-git-send-email-qemudevbmw@lsmod.de> In-Reply-To: References: Subject: [Qemu-devel] [PATCH] hw: better i440 emulation List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: "Bernhard M. Wiedemann" updated version of an old patch http://xenon.stanford.edu/~eswierk/misc/qemu-linuxbios/qemu-piix-ram-size.patch that together with http://www.mail-archive.com/linuxbios@linuxbios.org/msg02390.html (which is already in coreboot trunk) allows coreboot to autodetect the amount of RAM within qemu/kvm from a register in i440 northbridge. The message on the old patch states: Unfortunately the current version of qemu does not set these registers, but I have patched qemu so that it emulates the i440 more faithfully in this regard. Signed-off-by: Bernhard M. Wiedemann --- hw/pc.c | 2 +- hw/pc.h | 2 +- hw/piix_pci.c | 7 ++++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/hw/pc.c b/hw/pc.c index b797f21..eec0864 100644 --- a/hw/pc.c +++ b/hw/pc.c @@ -926,7 +926,7 @@ static void pc_init1(ram_addr_t ram_size, isa_irq = qemu_allocate_irqs(isa_irq_handler, isa_irq_state, 24); if (pci_enabled) { - pci_bus = i440fx_init(&i440fx_state, &piix3_devfn, isa_irq); + pci_bus = i440fx_init(&i440fx_state, &piix3_devfn, isa_irq, ram_size); } else { pci_bus = NULL; isa_bus_new(NULL); diff --git a/hw/pc.h b/hw/pc.h index 5f86b37..d11a576 100644 --- a/hw/pc.h +++ b/hw/pc.h @@ -107,7 +107,7 @@ int pcspk_audio_init(qemu_irq *pic); struct PCII440FXState; typedef struct PCII440FXState PCII440FXState; -PCIBus *i440fx_init(PCII440FXState **pi440fx_state, int *piix_devfn, qemu_irq *pic); +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); diff --git a/hw/piix_pci.c b/hw/piix_pci.c index cd12212..97519db 100644 --- a/hw/piix_pci.c +++ b/hw/piix_pci.c @@ -213,7 +213,7 @@ static int i440fx_initfn(PCIDevice *dev) return 0; } -PCIBus *i440fx_init(PCII440FXState **pi440fx_state, int *piix3_devfn, qemu_irq *pic) +PCIBus *i440fx_init(PCII440FXState **pi440fx_state, int *piix3_devfn, qemu_irq *pic, int ram_size) { DeviceState *dev; PCIBus *b; @@ -238,6 +238,11 @@ PCIBus *i440fx_init(PCII440FXState **pi440fx_state, int *piix3_devfn, qemu_irq * *piix3_devfn = piix3->dev.devfn; + ram_size = ram_size / 8 / 1024 / 1024; + if (ram_size > 255) + ram_size = 255; + (*pi440fx_state)->dev.config[0x57]=ram_size; + return b; } -- 1.5.6.5