source: rtems/c/src/lib/libbsp/sparc/shared/bspstart.c @ 3d0d969

4.104.114.84.95
Last change on this file since 3d0d969 was 3d0d969, checked in by Joel Sherrill <joel.sherrill@…>, on Sep 6, 2007 at 12:03:18 AM

2007-09-05 Daniel Hellstrom <daniel@…>

  • shared/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...)
  • Property mode set to 100644
File size: 3.5 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-2006.
8 *  On-Line Applications Research Corporation (OAR).
9 *
10 *  The license and distribution terms for this file may be
11 *  found in the file LICENSE in this distribution or at
12 *  http://www.rtems.com/license/LICENSE.
13 *
14 *  Ported to ERC32 implementation of the SPARC by On-Line Applications
15 *  Research Corporation (OAR) under contract to the European Space
16 *  Agency (ESA).
17 *
18 *  ERC32 modifications of respective RTEMS file: COPYRIGHT (c) 1995.
19 *  European Space Agency.
20 *
21 *  $Id$
22 */
23
24/* must be identical to STACK_SIZE in start.S */
25#define STACK_SIZE 16 * 1024
26
27#include <string.h>
28
29#include <bsp.h>
30#include <rtems/libio.h>
31#include <rtems/libcsupport.h>
32#include <rtems/bspIo.h>
33
34/*
35 *  The original table from the application and our copy of it with
36 *  some changes.
37 */
38
39extern rtems_configuration_table  Configuration;
40rtems_configuration_table         BSP_Configuration;
41
42rtems_cpu_table Cpu_table;
43
44/*
45 *  Tells us where to put the workspace in case remote debugger is present.
46 */
47
48extern uint32_t rdb_start;
49
50#ifdef LEON2
51/*
52 * Tells us if data cache snooping is available
53 */ 
54
55int CPU_SPARC_HAS_SNOOPING;
56#endif
57
58/*
59 *  Use the shared implementations of the following routines
60 */
61
62void bsp_postdriver_hook(void);
63void bsp_libc_init( void *, uint32_t, int );
64extern void bsp_spurious_initialize();
65
66#ifdef LEON2
67/*
68 * set_snooping
69 *
70 * Read the data cache configuration register to determine if
71 * bus snooping is available. This is needed for some drivers so
72 * that they can select the most efficient copy routines. 
73 *
74 */
75
76static inline int set_snooping(void) 
77{
78        unsigned int tmp = *(unsigned int *)0x80000014; /* Cache control register */
79        return ((tmp>>23) & 1); /* Data cache snooping enabled */
80}
81#endif
82
83/*
84 *  bsp_pretasking_hook
85 *
86 *  BSP pretasking hook.  Called just before drivers are initialized.
87 *  Used to setup libc and install any BSP extensions.
88 */
89
90void bsp_pretasking_hook(void)
91{
92  extern int end;
93  uint32_t heap_start;
94  uint32_t heap_size;
95
96  heap_start = (uint32_t) &end;
97  if (heap_start & (CPU_ALIGNMENT-1))
98    heap_start = (heap_start + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1);
99
100  heap_size = BSP_Configuration.work_space_start - (void *)&end - STACK_SIZE;
101  heap_size &= 0xfffffff0;  /* keep it as a multiple of 16 bytes */
102
103  bsp_libc_init((void *) heap_start, heap_size, 0);
104
105#ifdef RTEMS_DEBUG
106  rtems_debug_enable( RTEMS_DEBUG_ALL_MASK );
107#endif
108
109  bsp_spurious_initialize();
110}
111
112/*
113 *  bsp_start
114 *
115 *  This routine does the bulk of the system initialization.
116 */
117
118void bsp_start( void )
119{
120  unsigned char *work_space_start;
121
122  /*
123   * Set up our hooks
124   * Make sure libc_init is done before drivers initialized so that
125   * they can use atexit()
126   */
127
128  Cpu_table.pretasking_hook = bsp_pretasking_hook;    /* init libc, etc. */
129  Cpu_table.postdriver_hook = bsp_postdriver_hook;
130
131  /*
132   *  This should be enough interrupt stack.
133   */
134
135  Cpu_table.interrupt_stack_size = CONFIGURE_INTERRUPT_STACK_MEMORY;
136
137  work_space_start =
138    (unsigned char *)rdb_start - BSP_Configuration.work_space_size;
139
140  if ( work_space_start <= (unsigned char *)&end ) {
141    printk( "bspstart: Not enough RAM!!!\n" );
142    BSP_fatal_return();
143  }
144
145  BSP_Configuration.work_space_start = work_space_start;
146 
147  #ifdef LEON2
148  CPU_SPARC_HAS_SNOOPING = set_snooping();
149  #endif
150}
Note: See TracBrowser for help on using the repository browser.