source: rtems/c/src/lib/libbsp/sparc/leon3/startup/bspstart.c @ 9591970

4.10
Last change on this file since 9591970 was 9591970, checked in by Daniel Hellstrom <daniel@…>, on Feb 2, 2012 at 2:46:27 PM

LEON3: change d-cache snoop detect implementation

PR 2010/bsps

The previous code only checked if d-cache snooping was implemented,
however snooping may be available but not enabled which may lead
to driver bugs.

Signed-off-by: Daniel Hellstrom <daniel@…>

  • Property mode set to 100644
File size: 1.8 KB
Line 
1/*
2 *  This set of routines starts the application.  It includes application,
3 *  board, and monitor specific initialization and configuration.
4 *  The generic CPU dependent initialization has been performed
5 *  before any of these are invoked.
6 *
7 *  COPYRIGHT (c) 1989-2007.
8 *  On-Line Applications Research Corporation (OAR).
9 *
10 *  Modified for LEON3 BSP.
11 *  COPYRIGHT (c) 2004.
12 *  Gaisler Research.
13 *
14 *  The license and distribution terms for this file may be
15 *  found in the file LICENSE in this distribution or at
16 *  http://www.rtems.com/license/LICENSE.
17 *
18 *  $Id$
19 */
20
21
22#include <bsp.h>
23#include <rtems/bspIo.h>
24
25/*
26 * Tells us if data cache snooping is available
27 */
28int CPU_SPARC_HAS_SNOOPING;
29
30/* Index of CPU, in an AMP system CPU-index may be non-zero */
31int LEON3_Cpu_Index = 0;
32
33extern void amba_initialize(void);
34
35/*
36 * set_snooping
37 *
38 * Read the data cache configuration register to determine if
39 * bus snooping is available and enabled. This is needed for some
40 * drivers so that they can select the most efficient copy routines.
41 */
42static inline int set_snooping(void)
43{
44  int tmp;
45  __asm__ (" lda [%%g0] 2, %0 "
46      : "=r"(tmp)
47      :
48  );
49  return (tmp >> 23) & 1;
50}
51
52/* ASM-function used to get the CPU-Index on calling LEON3 CPUs */
53static inline unsigned int get_asr17(void)
54{
55  unsigned int reg;
56  __asm__ (" mov %%asr17, %0 " : "=r"(reg) :);
57  return reg;
58}
59
60/*
61 *  bsp_start
62 *
63 *  This routine does the bulk of the system initialization.
64 */
65void bsp_start( void )
66{
67  CPU_SPARC_HAS_SNOOPING = set_snooping();
68
69  /* Get the LEON3 CPU index, normally 0, but for MP systems we do
70   * _not_ assume that this is CPU0. One may run another OS on CPU0
71   * and RTEMS on this CPU, and AMP system with mixed operating
72   * systems
73   */
74  LEON3_Cpu_Index = (get_asr17() >> 28) & 3;
75
76  /* Find UARTs */
77  amba_initialize();
78}
Note: See TracBrowser for help on using the repository browser.