[PATCH v3 7/8] grlib: make memory coherency cpu-independent
Sebastian Huber
sebastian.huber at embedded-brains.de
Mon Jan 21 06:26:43 UTC 2019
On 18/01/2019 23:34, Jiri Gaisler wrote:
> ---
> bsps/shared/grlib/spw/grspw.c | 6 +++---
> bsps/sparc/leon2/include/bsp.h | 2 +-
> bsps/sparc/leon2/start/bspstart.c | 4 ++--
> bsps/sparc/leon3/include/bsp.h | 2 +-
> bsps/sparc/leon3/start/bspstart.c | 4 ++--
> 5 files changed, 9 insertions(+), 9 deletions(-)
>
> diff --git a/bsps/shared/grlib/spw/grspw.c b/bsps/shared/grlib/spw/grspw.c
> index fbaadd1e13..7d99831e71 100644
> --- a/bsps/shared/grlib/spw/grspw.c
> +++ b/bsps/shared/grlib/spw/grspw.c
> @@ -25,8 +25,8 @@
>
> #include <grlib/grlib_impl.h>
>
> -#ifndef CPU_SPARC_HAS_SNOOPING
> -#define CPU_SPARC_HAS_SNOOPING 1
> +#ifndef GRLIB_DMA_IS_CACHE_COHERENT
> +#define GRLIB_DMA_IS_CACHE_COHERENT 1
> #endif
>
> #define DBGSPW_IOCALLS 1
> @@ -1897,7 +1897,7 @@ static int grspw_hw_receive(GRSPW_DEV *pDev, char *b, int c) {
> if (rxlen > c) {
> rxlen = c;
> }
> - if (CPU_SPARC_HAS_SNOOPING) {
> + if (GRLIB_DMA_IS_CACHE_COHERENT) {
> /* if ( 1 ) {*/
> /*printf("RX_MEMCPY(0x%x, 0x%x, 0x%x)\n", (unsigned int)b, (unsigned int)(rxb+pDev->rxbufcur), (unsigned int)rxlen);*/
> memcpy(b, rxb+pDev->rxbufcur, rxlen);
> diff --git a/bsps/sparc/leon2/include/bsp.h b/bsps/sparc/leon2/include/bsp.h
> index e9b98492d7..fee50c055d 100644
> --- a/bsps/sparc/leon2/include/bsp.h
> +++ b/bsps/sparc/leon2/include/bsp.h
> @@ -83,7 +83,7 @@ extern int rtems_smc91111_driver_attach_leon2(
> * The synchronous trap is an arbitrarily chosen software trap.
> */
>
> -extern int CPU_SPARC_HAS_SNOOPING;
> +extern int GRLIB_DMA_IS_CACHE_COHERENT;
I would leave the SPARC BSPs as is. Maybe someone uses this
CPU_SPARC_HAS_SNOOPING in external drivers or whatever. I would use the
GRLIB_DMA_IS_CACHE_COHERENT only in the grlib and place something like
this in grlib_impl.h:
#include <bsp.h>
#ifdef __sparc__
#define GRLIB_DMA_IS_CACHE_COHERENT CPU_SPARC_HAS_SNOOPING
#else
#define GRLIB_DMA_IS_CACHE_COHERENT 1
#endif
>
> /* Constants */
>
> diff --git a/bsps/sparc/leon2/start/bspstart.c b/bsps/sparc/leon2/start/bspstart.c
> index f2ed8ae16c..763d03ddc4 100644
> --- a/bsps/sparc/leon2/start/bspstart.c
> +++ b/bsps/sparc/leon2/start/bspstart.c
> @@ -32,7 +32,7 @@
> /*
> * Tells us if data cache snooping is available
> */
> -int CPU_SPARC_HAS_SNOOPING;
> +int GRLIB_DMA_IS_CACHE_COHERENT;
>
> /*
> * set_snooping
> @@ -49,7 +49,7 @@ static inline int set_snooping(void)
>
> void bsp_start( void )
> {
> - CPU_SPARC_HAS_SNOOPING = set_snooping();
> + GRLIB_DMA_IS_CACHE_COHERENT = set_snooping();
> }
>
> /* If RTEMS_DRVMGR_STARTUP is defined extra code is added that
> diff --git a/bsps/sparc/leon3/include/bsp.h b/bsps/sparc/leon3/include/bsp.h
> index 3fda4edc66..42d23c5a6f 100644
> --- a/bsps/sparc/leon3/include/bsp.h
> +++ b/bsps/sparc/leon3/include/bsp.h
> @@ -101,7 +101,7 @@ extern int rtems_leon_greth_driver_attach(
> #define GRETH_SUPPORTED
> #define GRETH_MEM_LOAD(addr) leon_r32_no_cache((uintptr_t)addr)
>
> -extern int CPU_SPARC_HAS_SNOOPING;
> +extern int GRLIB_DMA_IS_CACHE_COHERENT;
>
> /* Constants */
>
> diff --git a/bsps/sparc/leon3/start/bspstart.c b/bsps/sparc/leon3/start/bspstart.c
> index 58fc7d0907..aeeb0a08fa 100644
> --- a/bsps/sparc/leon3/start/bspstart.c
> +++ b/bsps/sparc/leon3/start/bspstart.c
> @@ -35,7 +35,7 @@ const unsigned char LEON3_mp_irq __attribute__((weak)) = 14;
> /*
> * Tells us if data cache snooping is available
> */
> -int CPU_SPARC_HAS_SNOOPING;
> +int GRLIB_DMA_IS_CACHE_COHERENT;
>
> /* Index of CPU, in an AMP system CPU-index may be non-zero */
> uint32_t LEON3_Cpu_Index = 0;
> @@ -66,7 +66,7 @@ static inline int set_snooping(void)
> */
> void bsp_start( void )
> {
> - CPU_SPARC_HAS_SNOOPING = set_snooping();
> + GRLIB_DMA_IS_CACHE_COHERENT = set_snooping();
> }
>
> static void leon3_cpu_index_init(void)
--
Sebastian Huber, embedded brains GmbH
Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone : +49 89 189 47 41-16
Fax : +49 89 189 47 41-09
E-Mail : sebastian.huber at embedded-brains.de
PGP : Public key available on request.
Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.
More information about the devel
mailing list