source: rtems/c/src/lib/libbsp/sparc/leon3/clock/ckinit.c @ 12bd47e

4.104.114.95
Last change on this file since 12bd47e was 12bd47e, checked in by Joel Sherrill <joel.sherrill@…>, on 12/11/07 at 15:49:53

2007-12-11 Joel Sherrill <joel.sherrill@…>

  • clock/ckinit.c, include/bsp.h, startup/bspstart.c: Eliminate copies of the Configuration Table. Use the RTEMS provided accessor macros to obtain configuration fields.
  • Property mode set to 100644
File size: 2.5 KB
Line 
1/*
2 *  Clock Tick Device Driver
3 *
4 *  This routine initializes LEON timer 1 which used for the clock tick.
5 *
6 *  The tick frequency is directly programmed to the configured number of
7 *  microseconds per tick.
8 *
9 *  COPYRIGHT (c) 1989-2006.
10 *  On-Line Applications Research Corporation (OAR).
11 *
12 *  Modified for LEON3 BSP.
13 *  COPYRIGHT (c) 2004.
14 *  Gaisler Research.
15 *
16 *  The license and distribution terms for this file may be
17 *  found in the file LICENSE in this distribution or at
18 *  http://www.rtems.com/license/LICENSE.
19 *
20 *  $Id$
21 */
22
23#include <bsp.h>
24#include <bspopts.h>
25
26#if SIMSPARC_FAST_IDLE==1
27#define CLOCK_DRIVER_USE_FAST_IDLE
28#endif
29
30/*
31 *  The Real Time Clock Counter Timer uses this trap type.
32 */
33
34#if defined(RTEMS_MULTIPROCESSING)
35  #define LEON3_CLOCK_INDEX \
36    (rtems_configuration_get_user_multiprocessing_table() ? LEON3_Cpu_Index : 0)
37#else
38  #define LEON3_CLOCK_INDEX 0
39#endif
40
41
42volatile LEON3_Timer_Regs_Map *LEON3_Timer_Regs = 0;
43static int clkirq;
44
45#define CLOCK_VECTOR LEON_TRAP_TYPE( clkirq )
46
47#define Clock_driver_support_at_tick()
48
49#if defined(RTEMS_MULTIPROCESSING)
50  #define Adjust_clkirq_for_node() \
51    do { \
52      if (rtems_configuration_get_user_multiprocessing_table() != NULL) { \
53        clkirq += LEON3_Cpu_Index; \
54      } \
55    } while(0)
56#else
57  #define Adjust_clkirq_for_node()
58#endif
59
60#define Clock_driver_support_find_timer() \
61  do { \
62    int cnt; \
63    amba_apb_device dev; \
64    \
65    /* Find LEON3 GP Timer */ \
66    cnt = amba_find_apbslv(&amba_conf,VENDOR_GAISLER,GAISLER_GPTIMER,&dev); \
67    if ( cnt > 0 ){ \
68      /* Found APB GPTIMER Timer */ \
69      LEON3_Timer_Regs = (volatile LEON3_Timer_Regs_Map *) dev.start; \
70      clkirq = (LEON3_Timer_Regs->status & 0xfc) >> 3; \
71      \
72      Adjust_clkirq_for_node(); \
73    } \
74  } while (0)
75
76#define Clock_driver_support_install_isr( _new, _old ) \
77  do { \
78    _old = set_vector( _new, CLOCK_VECTOR, 1 ); \
79  } while(0)
80
81#define Clock_driver_support_initialize_hardware() \
82  do { \
83    LEON3_Timer_Regs->timer[LEON3_CLOCK_INDEX].reload = \
84      rtems_configuration_get_microseconds_per_tick() - 1; \
85    \
86    LEON3_Timer_Regs->timer[LEON3_CLOCK_INDEX].conf = \
87      LEON3_GPTIMER_EN | LEON3_GPTIMER_RL | \
88        LEON3_GPTIMER_LD | LEON3_GPTIMER_IRQEN; \
89  } while (0)
90
91#define Clock_driver_support_shutdown_hardware() \
92  do { \
93    LEON_Mask_interrupt(LEON_TRAP_TYPE(clkirq)); \
94    LEON3_Timer_Regs->timer[LEON3_CLOCK_INDEX].conf = 0; \
95  } while (0)
96
97#include "../../../shared/clockdrv_shell.c"
Note: See TracBrowser for help on using the repository browser.