On 12/24/20 4:17 AM, Jiaxun Yang wrote:
> The original mapping had wrong base address.

TBO this rational is a bit scarce ;)

I sent a patch implementing the REMAP register:
https://www.mail-archive.com/qemu-devel@nongnu.org/msg769751.html

If this isn't enough with a Linux kernel because it expects
the the Bonito being configured by the bootloader, then we
need to do the mapping in write_bootloader().

> 
> Signed-off-by: Jiaxun Yang <jiaxun.y...@flygoat.com>
> ---
>  hw/pci-host/bonito.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/hw/pci-host/bonito.c b/hw/pci-host/bonito.c
> index 3fad470fc6..737ee131e1 100644
> --- a/hw/pci-host/bonito.c
> +++ b/hw/pci-host/bonito.c
> @@ -85,9 +85,8 @@
>  #define BONITO_PCILO_BASE_VA    0xb0000000
>  #define BONITO_PCILO_SIZE       0x0c000000
>  #define BONITO_PCILO_TOP        (BONITO_PCILO_BASE + BONITO_PCILO_SIZE - 1)
> -#define BONITO_PCILO0_BASE      0x10000000
> -#define BONITO_PCILO1_BASE      0x14000000
> -#define BONITO_PCILO2_BASE      0x18000000
> +#define BONITO_PCILOx_BASE(x)   (BONITO_PCILO_BASE + BONITO_PCILOx_SIZE * x)
> +#define BONITO_PCILOx_SIZE      0x04000000
>  #define BONITO_PCIHI_BASE       0x20000000
>  #define BONITO_PCIHI_SIZE       0x60000000
>  #define BONITO_PCIHI_TOP        (BONITO_PCIHI_BASE + BONITO_PCIHI_SIZE - 1)
> @@ -610,7 +609,7 @@ static void bonito_pcihost_realize(DeviceState *dev, 
> Error **errp)
>  {
>      PCIHostState *phb = PCI_HOST_BRIDGE(dev);
>      BonitoState *bs = BONITO_PCI_HOST_BRIDGE(dev);
> -    MemoryRegion *pcimem_lo_alias = g_new(MemoryRegion, 3);
> +    MemoryRegion *pcimem_lo_alias = g_new(MemoryRegion, 1);
>  
>      memory_region_init(&bs->pci_mem, OBJECT(dev), "pci.mem", 
> BONITO_PCIHI_SIZE);
>      phb->bus = pci_register_root_bus(dev, "pci",
> @@ -622,9 +621,10 @@ static void bonito_pcihost_realize(DeviceState *dev, 
> Error **errp)
>          char *name = g_strdup_printf("pci.lomem%zu", i);
>  
>          memory_region_init_alias(&pcimem_lo_alias[i], NULL, name,
> -                                 &bs->pci_mem, i * 64 * MiB, 64 * MiB);
> +                                 &bs->pci_mem, BONITO_PCILOx_BASE(i),
> +                                 BONITO_PCILOx_SIZE);
>          memory_region_add_subregion(get_system_memory(),
> -                                    BONITO_PCILO_BASE + i * 64 * MiB,
> +                                    BONITO_PCILOx_BASE(i),
>                                      &pcimem_lo_alias[i]);
>          g_free(name);
>      }
> 

Reply via email to