Skip to contentSkip to conversation

Misc MIPS fulong2e improvements

PATCH In review BALATON Zoltan 3 participants 8 messages Feb 18, 2019 – Mar 4, 2019

lore
Share & tools
lore
#0 lore raw

v2 cover Misc MIPS fulong2e improvements

v2 of
http://lists.nongnu.org/archive/html/qemu-devel/2019-02/msg02477.html
Addressed review comments and removed last patch (sending it separately) to make this series not depend on my ati-vga patch so it can be applied independently.

BALATON Zoltan (3):
hw/pci-host/bonito.c: Add PCI mem region mapped at the correct address
mips_fulong2e: Fix bios flash size
mips_fulong2e: Dynamically generate SPD EEPROM data

 hw/mips/mips_fulong2e.c | 40 +++++++++++++++++-----------------------
 hw/pci-host/bonito.c    |  7 ++++++-
 2 files changed, 23 insertions(+), 24 deletions(-)
Signature · 1 line
2.13.7
#1 lore raw

PATCH v2 1/3 hw/pci-host/bonito.c: Add PCI mem region mapped at the correct address

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.

---
v2: add mem region to BonitoState instead of allocating it

 hw/pci-host/bonito.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
hw/pci-host/bonito.c +6 -1
index 9f33582706..dde4437595 100644
@@ -217,6 +217,7 @@ struct BonitoState {
     PCIHostState parent_obj;
     qemu_irq *pic;
     PCIBonitoState *pci_dev;
+    MemoryRegion pci_mem;
 };
 
 #define TYPE_BONITO_PCI_HOST_BRIDGE "Bonito-pcihost"
@@ -598,11 +599,15 @@ static const VMStateDescription vmstate_bonito = {
 static void bonito_pcihost_realize(DeviceState *dev, Error **errp)
 {
     PCIHostState *phb = PCI_HOST_BRIDGE(dev);
+    BonitoState *bs = BONITO_PCI_HOST_BRIDGE(dev);
 
+    memory_region_init(&bs->pci_mem, OBJECT(dev), "pci.mem", BONITO_PCILO_SIZE);
     phb->bus = pci_register_root_bus(DEVICE(dev), "pci",
                                      pci_bonito_set_irq, pci_bonito_map_irq,
-                                     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);
 }
 
 static void bonito_realize(PCIDevice *dev, Error **errp)
Signature · 1 line
2.13.7
#2 lore raw

PATCH v2 2/3 mips_fulong2e: Fix bios flash size

In reply to BALATON Zoltan

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.

---
 hw/mips/mips_fulong2e.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
hw/mips/mips_fulong2e.c +4 -5
index 02549d5c7e..10e6ed585a 100644
@@ -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
 
+/* fulong 2e has a 512k flash: Winbond W39L040AP70Z */
+#define BIOS_SIZE (512 * KiB)
 #define MAX_IDE_BUS 2
 
 /*
@@ -307,12 +309,9 @@ static void mips_fulong2e_init(MachineState *machine)
     /* fulong 2e has 256M ram. */
     ram_size = 256 * MiB;
 
-    /* fulong 2e has a 1M flash.Winbond W39L040AP70Z */
-    bios_size = 1 * MiB;
-
     /* allocate RAM */
     memory_region_allocate_system_memory(ram, NULL, "fulong2e.ram", ram_size);
-    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);
 
Signature · 1 line
2.13.7
#3 lore raw

PATCH v2 3/3 mips_fulong2e: Dynamically generate SPD EEPROM data

In reply to BALATON Zoltan

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.

---
 hw/mips/mips_fulong2e.c | 31 +++++++++++++------------------
 1 file changed, 13 insertions(+), 18 deletions(-)
hw/mips/mips_fulong2e.c +13 -18
index 10e6ed585a..eec6fd02c8 100644
@@ -214,20 +214,6 @@ static void main_cpu_reset(void *opaque)
     }
 }
 
-static const uint8_t eeprom_spd[0x80] = {
-    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_bus)
 {
@@ -284,7 +270,6 @@ static void network_init (PCIBus *pci_bus)
 
 static void mips_fulong2e_init(MachineState *machine)
 {
-    ram_addr_t ram_size = machine->ram_size;
     const char *kernel_filename = machine->kernel_filename;
     const char *kernel_cmdline = machine->kernel_cmdline;
     const char *initrd_filename = machine->initrd_filename;
@@ -292,7 +277,10 @@ static void mips_fulong2e_init(MachineState *machine)
     MemoryRegion *address_space_mem = get_system_memory();
     MemoryRegion *ram = g_new(MemoryRegion, 1);
     MemoryRegion *bios = g_new(MemoryRegion, 1);
+    ram_addr_t ram_size = machine->ram_size;
     long bios_size;
+    uint8_t *spd_data;
+    Error *err = NULL;
     int64_t kernel_entry;
     PCIBus *pci_bus;
     ISABus *isa_bus;
@@ -306,7 +294,7 @@ static void mips_fulong2e_init(MachineState *machine)
 
     qemu_register_reset(main_cpu_reset, cpu);
 
-    /* fulong 2e has 256M ram. */
+    /* TODO: support more than 256M RAM as highmem */
     ram_size = 256 * MiB;
 
     /* 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);
 
-    /* TODO: Populate SPD eeprom data.  */
-    smbus_eeprom_init(smbus, 1, eeprom_spd, sizeof(eeprom_spd));
+    /* Populate SPD eeprom data */
+    spd_data = spd_data_generate(DDR, ram_size, &err);
+    if (err) {
+        warn_report_err(err);
+    }
+    if (spd_data) {
+        smbus_eeprom_init_one(smbus, 0x50, spd_data);
+    }
 
     mc146818_rtc_init(isa_bus, 2000, NULL);
 
@@ -374,6 +368,7 @@ static void mips_fulong2e_machine_init(MachineClass *mc)
     mc->init = mips_fulong2e_init;
     mc->block_default_type = IF_IDE;
     mc->default_cpu_type = MIPS_CPU_TYPE_NAME("Loongson-2E");
+    mc->default_ram_size = 256 * MiB;
 }
 
 DEFINE_MACHINE("fulong2e", mips_fulong2e_machine_init)
Signature · 1 line
2.13.7
Reviewed-by Tested-by on the v2 series
#4 lore raw
In reply to BALATON Zoltan
Quoted 6 lines · BALATON Zoltan

v2 of
http://lists.nongnu.org/archive/html/qemu-devel/2019-02/msg02477.html
Addressed review comments and removed last patch (sending it separately) to make this series not depend on my ati-vga patch so it can be applied independently.

Quoted 8 lines

BALATON Zoltan (3):
hw/pci-host/bonito.c: Add PCI mem region mapped at the correct address
mips_fulong2e: Fix bios flash size
mips_fulong2e: Dynamically generate SPD EEPROM data

 hw/mips/mips_fulong2e.c | 40 +++++++++++++++++-----------------------
 hw/pci-host/bonito.c    |  7 ++++++-
 2 files changed, 23 insertions(+), 24 deletions(-)

For whoever who takes this series, please replace my mojibaked lastname with:

Thanks,

Phil.

#5 lore raw
In reply to BALATON Zoltan
Quoted 5 lines

From: BALATON Zoltan <[email protected]>
v2 of http://lists.nongnu.org/archive/html/qemu-devel/2019-02/msg02477.html
Addressed review comments and removed last patch (sending it separately) to make this series not depend on my ati-vga patch so it can be applied independently.

I plan to add bin file (that you mentioned) used for Fulong 2E tests into our tree (in pc-bios directory, with an appropriate comment in pc-bios/README). Please let me know if you this I should not do that, of if I should perhaps include more files, or different files, etc.

Regards,
Aleksandar

#6 lore raw
Quoted 10 lines · Aleksandar Markovic
Quoted 5 lines

From: BALATON Zoltan <[email protected]>
v2 of http://lists.nongnu.org/archive/html/qemu-devel/2019-02/msg02477.html
Addressed review comments and removed last patch (sending it separately) to make this series not depend on my ati-vga patch so it can be applied independently.

I plan to add bin file (that you mentioned) used for Fulong 2E tests into our tree (in pc-bios directory, with an appropriate comment in pc-bios/README). Please let me know if you this I should not do that, of if I should perhaps include more files, or different files, etc.

I think you cannot do that because distributing binary also requires to provide sources to comply with GPL. Therefore you should include source in roms and build binary from that like done for sam460ex for example (see: git log roms/u-boot-sam460ex). Problem is you have to figure out which sources and config was used to build that binary with the original lemote.com site mentioned in a comment in mips_fulong2e.c that used to host the source seemingly gone. So you probably will need to find a mirror and figure out how to build the pmon binary from that. The comment in source mentions that pmon is under BSD licence in which case it may be distributed without source but including random binaries may not be the best way even if it would be allowed by licence so building a firmware from source is the best way if possible.

Regards,
BALATON Zoltan

#7 lore raw
Quoted 15 lines

From: BALATON Zoltan <[email protected]>
Subject: Re: [PATCH v2 0/3] Misc MIPS fulong2e improvements

Quoted 10 lines · Aleksandar Markovic
Quoted 5 lines

From: BALATON Zoltan <[email protected]>
v2 of http://lists.nongnu.org/archive/html/qemu-devel/2019-02/msg02477.html
Addressed review comments and removed last patch (sending it separately) to make this series not depend on my ati-vga patch so it can be applied independently.

I plan to add bin file (that you mentioned) used for Fulong 2E tests into our tree (in pc-bios directory, with an appropriate comment in pc-bios/README). Please let me know if you this I should not do that, of if I should perhaps > include more files, or different files, etc.

Quoted 12 lines

I think you cannot do that because distributing binary also requires to provide sources to comply with GPL. Therefore you should include source in roms and build binary from that like done for sam460ex for example (see:
git log roms/u-boot-sam460ex). Problem is you have to figure out which sources and config was used to build that binary with the original lemote.com site mentioned in a comment in mips_fulong2e.c that used to host the source seemingly gone. So you probably will need to find a mirror and figure out how to build the pmon binary from that. The comment in source mentions that pmon is under BSD licence in which case it may be distributed without source but including random binaries may not be the best way even if it would be allowed by licence so building a firmware from source is the best way if possible.

OK, I will for now give up integrating the binary until all is clarified.

Thanks!
Aleksandar

________________________________________
From: BALATON Zoltan <[email protected]>
Sent: Monday, March 4, 2019 3:27:27 PM
To: Aleksandar Markovic
Cc: [email protected]; Aurelien Jarno; Huacai Chen; [email protected]
Subject: Re: [PATCH v2 0/3] Misc MIPS fulong2e improvements

Quoted 10 lines · Aleksandar Markovic
Quoted 5 lines

From: BALATON Zoltan <[email protected]>
v2 of http://lists.nongnu.org/archive/html/qemu-devel/2019-02/msg02477.html
Addressed review comments and removed last patch (sending it separately) to make this series not depend on my ati-vga patch so it can be applied independently.

I plan to add bin file (that you mentioned) used for Fulong 2E tests into our tree (in pc-bios directory, with an appropriate comment in pc-bios/README). Please let me know if you this I should not do that, of if I should perhaps include more files, or different files, etc.

I think you cannot do that because distributing binary also requires to provide sources to comply with GPL. Therefore you should include source in roms and build binary from that like done for sam460ex for example (see:
git log roms/u-boot-sam460ex). Problem is you have to figure out which sources and config was used to build that binary with the original lemote.com site mentioned in a comment in mips_fulong2e.c that used to host the source seemingly gone. So you probably will need to find a mirror and figure out how to build the pmon binary from that. The comment in source mentions that pmon is under BSD licence in which case it may be distributed without source but including random binaries may not be the best way even if it would be allowed by licence so building a firmware from source is the best way if possible.

Regards,
BALATON Zoltan