diff --git a/c/src/lib/libbsp/sparc/leon3/ChangeLog b/c/src/lib/libbsp/sparc/leon3/ChangeLog index 6abc98391d..ad22325cf5 100644 --- a/c/src/lib/libbsp/sparc/leon3/ChangeLog +++ b/c/src/lib/libbsp/sparc/leon3/ChangeLog @@ -1,3 +1,11 @@ +2007-09-05 Daniel Hellstrom + + * include/bsp.h, startup/bspstart.c: LEON2 and LEON3 Data cache + snooping detection on startup, for drivers. (LEON2,3 are configurable + processors, they can be with or without DCache snooping. Caches + without snooping needs the drivers to flush cache or use the sparc + instruction lda to force cache miss...) + 2007-09-05 Daniel Hellstrom * Makefile.am, preinstall.am, amba/amba.c, include/amba.h, diff --git a/c/src/lib/libbsp/sparc/leon3/include/bsp.h b/c/src/lib/libbsp/sparc/leon3/include/bsp.h index 717395fad4..045b7c2f5a 100644 --- a/c/src/lib/libbsp/sparc/leon3/include/bsp.h +++ b/c/src/lib/libbsp/sparc/leon3/include/bsp.h @@ -83,6 +83,8 @@ extern int rtems_leon_greth_driver_attach( extern void Clock_delay(uint32_t microseconds); #define delay( microseconds ) Clock_delay(microseconds) +extern int CPU_SPARC_HAS_SNOOPING; + /* Constants */ diff --git a/c/src/lib/libbsp/sparc/leon3/startup/bspstart.c b/c/src/lib/libbsp/sparc/leon3/startup/bspstart.c index e863250614..baf1b1cbef 100644 --- a/c/src/lib/libbsp/sparc/leon3/startup/bspstart.c +++ b/c/src/lib/libbsp/sparc/leon3/startup/bspstart.c @@ -42,10 +42,35 @@ rtems_cpu_table Cpu_table; extern uint32_t rdb_start; +/* + * Tells us if data cache snooping is available + */ + +int CPU_SPARC_HAS_SNOOPING; + void bsp_postdriver_hook(void); void bsp_libc_init( void *, uint32_t, int ); extern void bsp_spurious_initialize(); +/* + * set_snooping + * + * Read the data cache configuration register to determine if + * bus snooping is available. This is needed for some drivers so + * that they can select the most efficient copy routines. + * + */ + +static inline int set_snooping(void) +{ + int tmp; + asm(" lda [%1] 2, %0 " + : "=r"(tmp) + : "r"(0xC) + ); + return (tmp >> 27) & 1; +} + /* * bsp_pretasking_hook * @@ -112,4 +137,6 @@ void bsp_start( void ) } BSP_Configuration.work_space_start = work_space_start; + + CPU_SPARC_HAS_SNOOPING = set_snooping(); }