From nobody Sun May 5 05:38:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1550492260556166.89805970774432; Mon, 18 Feb 2019 04:17:40 -0800 (PST) Received: from localhost ([127.0.0.1]:57297 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gvhrd-0000Cv-JF for importer@patchew.org; Mon, 18 Feb 2019 07:17:37 -0500 Received: from eggs.gnu.org ([209.51.188.92]:34848) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gvhng-00062G-SC for qemu-devel@nongnu.org; Mon, 18 Feb 2019 07:13:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gvhne-0006ce-9g for qemu-devel@nongnu.org; Mon, 18 Feb 2019 07:13:32 -0500 Received: from zero.eik.bme.hu ([152.66.115.2]:27818) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gvhna-0006XS-2O for qemu-devel@nongnu.org; Mon, 18 Feb 2019 07:13:27 -0500 Received: from zero.eik.bme.hu (blah.eik.bme.hu [152.66.115.182]) by localhost (Postfix) with SMTP id 08F3E7456B9; Mon, 18 Feb 2019 13:13:23 +0100 (CET) Received: by zero.eik.bme.hu (Postfix, from userid 432) id D68A07456B3; Mon, 18 Feb 2019 13:13:22 +0100 (CET) Message-Id: In-Reply-To: References: From: BALATON Zoltan Date: Mon, 18 Feb 2019 13:01:41 +0100 To: qemu-devel@nongnu.org X-detected-operating-system: by eggs.gnu.org: FreeBSD 9.x [fuzzy] X-Received-From: 152.66.115.2 Subject: [Qemu-devel] [PATCH v2 1/3] hw/pci-host/bonito.c: Add PCI mem region mapped at the correct address X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Huacai Chen , philmd@redhat.com, Aleksandar Markovic , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Stop using system memory as PCI memory otherwise devices such as VGA that have regions mapped to PCI memory clash with RAM. Use a separate memory region for PCI memory and map it to the correct address in system memory which allows PCI mem regions to show at the correct address where clients expect them. Signed-off-by: BALATON Zoltan Reviewed-by: Philippe Mathieu-Daud\ufffd\ufffd Tested-by: Philippe Mathieu-Daud\ufffd\ufffd Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 --- v2: add mem region to BonitoState instead of allocating it hw/pci-host/bonito.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/hw/pci-host/bonito.c b/hw/pci-host/bonito.c index 9f33582706..dde4437595 100644 --- a/hw/pci-host/bonito.c +++ b/hw/pci-host/bonito.c @@ -217,6 +217,7 @@ struct BonitoState { PCIHostState parent_obj; qemu_irq *pic; PCIBonitoState *pci_dev; + MemoryRegion pci_mem; }; =20 #define TYPE_BONITO_PCI_HOST_BRIDGE "Bonito-pcihost" @@ -598,11 +599,15 @@ static const VMStateDescription vmstate_bonito =3D { static void bonito_pcihost_realize(DeviceState *dev, Error **errp) { PCIHostState *phb =3D PCI_HOST_BRIDGE(dev); + BonitoState *bs =3D BONITO_PCI_HOST_BRIDGE(dev); =20 + memory_region_init(&bs->pci_mem, OBJECT(dev), "pci.mem", BONITO_PCILO_= SIZE); phb->bus =3D pci_register_root_bus(DEVICE(dev), "pci", pci_bonito_set_irq, pci_bonito_map_ir= q, - dev, get_system_memory(), get_system_= io(), + dev, &bs->pci_mem, get_system_io(), 0x28, 32, TYPE_PCI_BUS); + memory_region_add_subregion(get_system_memory(), BONITO_PCILO_BASE, + &bs->pci_mem); } =20 static void bonito_realize(PCIDevice *dev, Error **errp) --=20 2.13.7 From nobody Sun May 5 05:38:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1550492257017446.00945484286854; Mon, 18 Feb 2019 04:17:37 -0800 (PST) Received: from localhost ([127.0.0.1]:57295 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gvhra-0000BN-1B for importer@patchew.org; Mon, 18 Feb 2019 07:17:34 -0500 Received: from eggs.gnu.org ([209.51.188.92]:34852) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gvhng-00062H-So for qemu-devel@nongnu.org; Mon, 18 Feb 2019 07:13:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gvhnf-0006dk-9k for qemu-devel@nongnu.org; Mon, 18 Feb 2019 07:13:32 -0500 Received: from zero.eik.bme.hu ([2001:738:2001:2001::2001]:27824) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gvhnb-0006Xd-G5 for qemu-devel@nongnu.org; Mon, 18 Feb 2019 07:13:29 -0500 Received: from zero.eik.bme.hu (blah.eik.bme.hu [152.66.115.182]) by localhost (Postfix) with SMTP id 624787456BC; Mon, 18 Feb 2019 13:13:23 +0100 (CET) Received: by zero.eik.bme.hu (Postfix, from userid 432) id DDF347456B2; Mon, 18 Feb 2019 13:13:22 +0100 (CET) Message-Id: In-Reply-To: References: From: BALATON Zoltan Date: Mon, 18 Feb 2019 13:01:41 +0100 To: qemu-devel@nongnu.org X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:738:2001:2001::2001 Subject: [Qemu-devel] [PATCH v2 2/3] mips_fulong2e: Fix bios flash size X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Huacai Chen , philmd@redhat.com, Aleksandar Markovic , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" According to both the specifications on linux-mips.org referenced in a comment at the beginning of the file and the flash chip part number the bios size should be 512k not 1M. Signed-off-by: BALATON Zoltan Reviewed-by: Philippe Mathieu-Daud\ufffd\ufffd Tested-by: Philippe Mathieu-Daud\ufffd\ufffd Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 --- hw/mips/mips_fulong2e.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/hw/mips/mips_fulong2e.c b/hw/mips/mips_fulong2e.c index 02549d5c7e..10e6ed585a 100644 --- a/hw/mips/mips_fulong2e.c +++ b/hw/mips/mips_fulong2e.c @@ -21,6 +21,7 @@ #include "qemu/osdep.h" #include "qemu/units.h" #include "qapi/error.h" +#include "cpu.h" #include "hw/hw.h" #include "hw/i386/pc.h" #include "hw/dma/i8257.h" @@ -35,7 +36,6 @@ #include "audio/audio.h" #include "qemu/log.h" #include "hw/loader.h" -#include "hw/mips/bios.h" #include "hw/ide.h" #include "elf.h" #include "hw/isa/vt82c686.h" @@ -51,6 +51,8 @@ #define ENVP_NB_ENTRIES 16 #define ENVP_ENTRY_SIZE 256 =20 +/* fulong 2e has a 512k flash: Winbond W39L040AP70Z */ +#define BIOS_SIZE (512 * KiB) #define MAX_IDE_BUS 2 =20 /* @@ -307,12 +309,9 @@ static void mips_fulong2e_init(MachineState *machine) /* fulong 2e has 256M ram. */ ram_size =3D 256 * MiB; =20 - /* fulong 2e has a 1M flash.Winbond W39L040AP70Z */ - bios_size =3D 1 * MiB; - /* allocate RAM */ memory_region_allocate_system_memory(ram, NULL, "fulong2e.ram", ram_si= ze); - memory_region_init_ram(bios, NULL, "fulong2e.bios", bios_size, + memory_region_init_ram(bios, NULL, "fulong2e.bios", BIOS_SIZE, &error_fatal); memory_region_set_readonly(bios, true); =20 --=20 2.13.7 From nobody Sun May 5 05:38:37 2024 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1550492128615677.1473947454781; Mon, 18 Feb 2019 04:15:28 -0800 (PST) Received: from localhost ([127.0.0.1]:57249 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gvhpM-0006zO-Tc for importer@patchew.org; Mon, 18 Feb 2019 07:15:16 -0500 Received: from eggs.gnu.org ([209.51.188.92]:34879) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gvhnj-00064F-V3 for qemu-devel@nongnu.org; Mon, 18 Feb 2019 07:13:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gvhne-0006cY-9g for qemu-devel@nongnu.org; Mon, 18 Feb 2019 07:13:35 -0500 Received: from zero.eik.bme.hu ([152.66.115.2]:27835) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gvhna-0006Xi-1X for qemu-devel@nongnu.org; Mon, 18 Feb 2019 07:13:27 -0500 Received: from zero.eik.bme.hu (blah.eik.bme.hu [152.66.115.182]) by localhost (Postfix) with SMTP id 8AB277456B2; Mon, 18 Feb 2019 13:13:23 +0100 (CET) Received: by zero.eik.bme.hu (Postfix, from userid 432) id 05FAB74569A; Mon, 18 Feb 2019 13:13:22 +0100 (CET) Message-Id: In-Reply-To: References: From: BALATON Zoltan Date: Mon, 18 Feb 2019 13:01:41 +0100 To: qemu-devel@nongnu.org X-detected-operating-system: by eggs.gnu.org: FreeBSD 9.x [fuzzy] X-Received-From: 152.66.115.2 Subject: [Qemu-devel] [PATCH v2 3/3] mips_fulong2e: Dynamically generate SPD EEPROM data X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Huacai Chen , philmd@redhat.com, Aleksandar Markovic , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The machine comes with 256M memory module by default but it's upgradable so it could have different memory size. There was a TODO comment to replace static SPD EEPROM data with dynamically generated one to support this. Now that we have a function for that, it's easy to do. Although this would allow larger RAM sizes, the peculiar memory map of the machine may need some special handling to map it as low and high memory. Because I don't know what the correct place would be for highmem, I've left memory size fixed at 256M for now and TODO is moved there instead. Signed-off-by: BALATON Zoltan Reviewed-by: Philippe Mathieu-Daud\ufffd\ufffd Tested-by: Philippe Mathieu-Daud\ufffd\ufffd Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 --- hw/mips/mips_fulong2e.c | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/hw/mips/mips_fulong2e.c b/hw/mips/mips_fulong2e.c index 10e6ed585a..eec6fd02c8 100644 --- a/hw/mips/mips_fulong2e.c +++ b/hw/mips/mips_fulong2e.c @@ -214,20 +214,6 @@ static void main_cpu_reset(void *opaque) } } =20 -static const uint8_t eeprom_spd[0x80] =3D { - 0x80,0x08,0x07,0x0d,0x09,0x02,0x40,0x00,0x04,0x70, - 0x70,0x00,0x82,0x10,0x00,0x01,0x0e,0x04,0x0c,0x01, - 0x02,0x20,0x80,0x75,0x70,0x00,0x00,0x50,0x3c,0x50, - 0x2d,0x20,0xb0,0xb0,0x50,0x50,0x00,0x00,0x00,0x00, - 0x00,0x41,0x48,0x3c,0x32,0x75,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x9c,0x7b,0x07,0x00,0x00,0x00,0x00, - 0x00,0x00,0x00,0x00,0x48,0x42,0x35,0x34,0x41,0x32, - 0x35,0x36,0x38,0x4b,0x4e,0x2d,0x41,0x37,0x35,0x42, - 0x20,0x30,0x20 -}; - static void vt82c686b_southbridge_init(PCIBus *pci_bus, int slot, qemu_irq= intc, I2CBus **i2c_bus, ISABus **p_isa_bu= s) { @@ -284,7 +270,6 @@ static void network_init (PCIBus *pci_bus) =20 static void mips_fulong2e_init(MachineState *machine) { - ram_addr_t ram_size =3D machine->ram_size; const char *kernel_filename =3D machine->kernel_filename; const char *kernel_cmdline =3D machine->kernel_cmdline; const char *initrd_filename =3D machine->initrd_filename; @@ -292,7 +277,10 @@ static void mips_fulong2e_init(MachineState *machine) MemoryRegion *address_space_mem =3D get_system_memory(); MemoryRegion *ram =3D g_new(MemoryRegion, 1); MemoryRegion *bios =3D g_new(MemoryRegion, 1); + ram_addr_t ram_size =3D machine->ram_size; long bios_size; + uint8_t *spd_data; + Error *err =3D NULL; int64_t kernel_entry; PCIBus *pci_bus; ISABus *isa_bus; @@ -306,7 +294,7 @@ static void mips_fulong2e_init(MachineState *machine) =20 qemu_register_reset(main_cpu_reset, cpu); =20 - /* fulong 2e has 256M ram. */ + /* TODO: support more than 256M RAM as highmem */ ram_size =3D 256 * MiB; =20 /* allocate RAM */ @@ -359,8 +347,14 @@ static void mips_fulong2e_init(MachineState *machine) vt82c686b_southbridge_init(pci_bus, FULONG2E_VIA_SLOT, env->irq[5], &smbus, &isa_bus); =20 - /* TODO: Populate SPD eeprom data. */ - smbus_eeprom_init(smbus, 1, eeprom_spd, sizeof(eeprom_spd)); + /* Populate SPD eeprom data */ + spd_data =3D spd_data_generate(DDR, ram_size, &err); + if (err) { + warn_report_err(err); + } + if (spd_data) { + smbus_eeprom_init_one(smbus, 0x50, spd_data); + } =20 mc146818_rtc_init(isa_bus, 2000, NULL); =20 @@ -374,6 +368,7 @@ static void mips_fulong2e_machine_init(MachineClass *mc) mc->init =3D mips_fulong2e_init; mc->block_default_type =3D IF_IDE; mc->default_cpu_type =3D MIPS_CPU_TYPE_NAME("Loongson-2E"); + mc->default_ram_size =3D 256 * MiB; } =20 DEFINE_MACHINE("fulong2e", mips_fulong2e_machine_init) --=20 2.13.7