diff mbox series

[2/2] hw/misc/grlib_ahb_apb_pnp: Fix 8-bit accesses

Message ID 20191025110114.27091-3-philmd@redhat.com
State New
Headers show
Series hw/sparc/leon3: Fixes for the AHB/APB bridge | expand

Commit Message

Philippe Mathieu-Daudé Oct. 25, 2019, 11:01 a.m. UTC
The Plug & Play region of the AHB/APB bridge can be accessed
by various word size, however the implementation is clearly
restricted to 32-bit:

  static uint64_t grlib_apb_pnp_read(void *opaque, hwaddr offset, unsigned size)
  {
      APBPnp *apb_pnp = GRLIB_APB_PNP(opaque);

      return apb_pnp->regs[offset >> 2];
  }

Set the MemoryRegionOps::impl min/max fields to 32-bit, so
memory.c::access_with_adjusted_size() can adjust when the
access is not 32-bit.

This is required to run RTEMS on leon3, the grlib scanning
functions do byte accesses.

Reported-by: Jiri Gaisler <jiri@gaisler.se>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 hw/misc/grlib_ahb_apb_pnp.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

KONRAD Frederic Oct. 25, 2019, 11:54 a.m. UTC | #1
Le 10/25/19 à 1:01 PM, Philippe Mathieu-Daudé a écrit :
> The Plug & Play region of the AHB/APB bridge can be accessed
> by various word size, however the implementation is clearly
> restricted to 32-bit:
> 
>    static uint64_t grlib_apb_pnp_read(void *opaque, hwaddr offset, unsigned size)
>    {
>        APBPnp *apb_pnp = GRLIB_APB_PNP(opaque);
> 
>        return apb_pnp->regs[offset >> 2];
>    }
> 
> Set the MemoryRegionOps::impl min/max fields to 32-bit, so
> memory.c::access_with_adjusted_size() can adjust when the
> access is not 32-bit.
> 
> This is required to run RTEMS on leon3, the grlib scanning
> functions do byte accesses.
> 
> Reported-by: Jiri Gaisler <jiri@gaisler.se>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
>   hw/misc/grlib_ahb_apb_pnp.c | 4 ++++
>   1 file changed, 4 insertions(+)
> 
> diff --git a/hw/misc/grlib_ahb_apb_pnp.c b/hw/misc/grlib_ahb_apb_pnp.c
> index f3c015d2c3..e230e25363 100644
> --- a/hw/misc/grlib_ahb_apb_pnp.c
> +++ b/hw/misc/grlib_ahb_apb_pnp.c
> @@ -242,6 +242,10 @@ static const MemoryRegionOps grlib_apb_pnp_ops = {
>       .read       = grlib_apb_pnp_read,
>       .write      = grlib_apb_pnp_write,
>       .endianness = DEVICE_BIG_ENDIAN,
> +    .impl = {
> +        .min_access_size = 4,
> +        .max_access_size = 4,
> +    },
>   };
>   
>   static void grlib_apb_pnp_realize(DeviceState *dev, Error **errp)
> 

Reviewed-by: KONRAD Frederic <frederic.konrad@adacore.com>

Thanks
Laurent Vivier Nov. 5, 2019, 2:02 p.m. UTC | #2
Le 25/10/2019 à 13:01, Philippe Mathieu-Daudé a écrit :
> The Plug & Play region of the AHB/APB bridge can be accessed
> by various word size, however the implementation is clearly
> restricted to 32-bit:
> 
>   static uint64_t grlib_apb_pnp_read(void *opaque, hwaddr offset, unsigned size)
>   {
>       APBPnp *apb_pnp = GRLIB_APB_PNP(opaque);
> 
>       return apb_pnp->regs[offset >> 2];
>   }
> 
> Set the MemoryRegionOps::impl min/max fields to 32-bit, so
> memory.c::access_with_adjusted_size() can adjust when the
> access is not 32-bit.
> 
> This is required to run RTEMS on leon3, the grlib scanning
> functions do byte accesses.
> 
> Reported-by: Jiri Gaisler <jiri@gaisler.se>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
>  hw/misc/grlib_ahb_apb_pnp.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/hw/misc/grlib_ahb_apb_pnp.c b/hw/misc/grlib_ahb_apb_pnp.c
> index f3c015d2c3..e230e25363 100644
> --- a/hw/misc/grlib_ahb_apb_pnp.c
> +++ b/hw/misc/grlib_ahb_apb_pnp.c
> @@ -242,6 +242,10 @@ static const MemoryRegionOps grlib_apb_pnp_ops = {
>      .read       = grlib_apb_pnp_read,
>      .write      = grlib_apb_pnp_write,
>      .endianness = DEVICE_BIG_ENDIAN,
> +    .impl = {
> +        .min_access_size = 4,
> +        .max_access_size = 4,
> +    },
>  };
>  
>  static void grlib_apb_pnp_realize(DeviceState *dev, Error **errp)
> 

Applied to my trivial-patches branch.

Thanks,
Laurent
diff mbox series

Patch

diff --git a/hw/misc/grlib_ahb_apb_pnp.c b/hw/misc/grlib_ahb_apb_pnp.c
index f3c015d2c3..e230e25363 100644
--- a/hw/misc/grlib_ahb_apb_pnp.c
+++ b/hw/misc/grlib_ahb_apb_pnp.c
@@ -242,6 +242,10 @@  static const MemoryRegionOps grlib_apb_pnp_ops = {
     .read       = grlib_apb_pnp_read,
     .write      = grlib_apb_pnp_write,
     .endianness = DEVICE_BIG_ENDIAN,
+    .impl = {
+        .min_access_size = 4,
+        .max_access_size = 4,
+    },
 };
 
 static void grlib_apb_pnp_realize(DeviceState *dev, Error **errp)