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

4.115
Last change on this file since 24bf11e was 24bf11e, checked in by Sebastian Huber <sebastian.huber@…>, on 02/12/14 at 09:31:38

score: Add CPU counter support

Add a CPU counter interface to allow access to a free-running counter.
It is useful to measure short time intervals. This can be used for
example to enable profiling of critical low-level functions.

Add two busy wait functions rtems_counter_delay_ticks() and
rtems_counter_delay_nanoseconds() implemented via the CPU counter.

  • Property mode set to 100644
File size: 2.1 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-2013.
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
19#include <bsp.h>
20#include <leon.h>
21#include <rtems/bspIo.h>
22#include <bsp/bootcard.h>
23
24/*
25 * Tells us if data cache snooping is available
26 */
27int CPU_SPARC_HAS_SNOOPING;
28
29/* Index of CPU, in an AMP system CPU-index may be non-zero */
30int LEON3_Cpu_Index = 0;
31
32extern void amba_initialize(void);
33
34/*
35 * set_snooping
36 *
37 * Read the data cache configuration register to determine if
38 * bus snooping is available and enabled. This is needed for some
39 * drivers so that they can select the most efficient copy routines.
40 *
41 */
42
43static inline int set_snooping(void)
44{
45  int tmp;
46  __asm__ (" lda [%%g0] 2, %0 "
47      : "=r"(tmp)
48      :
49  );
50  return (tmp >> 23) & 1;
51}
52
53/* ASM-function used to get the CPU-Index on calling LEON3 CPUs */
54static inline unsigned int get_asr17(void)
55{
56  unsigned int reg;
57  __asm__ (" mov %%asr17, %0 " : "=r"(reg) :);
58  return reg;
59}
60
61/*
62 *  bsp_start
63 *
64 *  This routine does the bulk of the system initialization.
65 */
66void bsp_start( void )
67{
68  CPU_SPARC_HAS_SNOOPING = set_snooping();
69
70  /* Get the LEON3 CPU index, normally 0, but for MP systems we do
71   * _not_ assume that this is CPU0. One may run another OS on CPU0
72   * and RTEMS on this CPU, and AMP system with mixed operating
73   * systems
74   */
75  LEON3_Cpu_Index = (get_asr17() >> 28) & 3;
76
77  /* Scan AMBA Plug&Play and parse it into a RAM description (ambapp_plb),
78   * find GPTIMER for bus frequency, find IRQ Controller and initialize
79   * interrupt support
80   */
81  amba_initialize();
82  leon3_cpu_counter_initialize();
83
84  /* find debug UART for printk() */
85  bsp_debug_uart_init();
86}
Note: See TracBrowser for help on using the repository browser.