source: rtems/c/src/lib/libbsp/shared/clockdrv_shell.h @ 79fee34

4.11
Last change on this file since 79fee34 was 79fee34, checked in by Joel Sherrill <joel.sherrill@…>, on May 10, 2012 at 12:59:49 PM

clockdrv_shell.h - Fix commment

  • Property mode set to 100644
File size: 3.7 KB
Line 
1/**
2 *  @file
3 * 
4 *  Clock Tick Device Driver Shell
5 */
6
7/*
8 *  COPYRIGHT (c) 1989-2012.
9 *  On-Line Applications Research Corporation (OAR).
10 *
11 *  The license and distribution terms for this file may be
12 *  found in the file LICENSE in this distribution or at
13 *  http://www.rtems.com/license/LICENSE.
14 *
15 *  $Id$
16 */
17
18#include <stdlib.h>
19
20#include <bsp.h>
21
22#if defined(CLOCK_DRIVER_USE_FAST_IDLE) && defined(CLOCK_DRIVER_ISRS_PER_TICK)
23#error "clockdrv_shell.h: Fast Idle PLUS n ISRs per tick is not supported"
24#endif
25
26/*
27 * This method is rarely used so default it.
28 */
29#ifndef Clock_driver_support_find_timer
30  #define Clock_driver_support_find_timer()
31#endif
32
33/*
34 *  ISRs until next clock tick
35 */
36#ifdef CLOCK_DRIVER_ISRS_PER_TICK
37  volatile uint32_t  Clock_driver_isrs;
38#endif
39
40/*
41 *  Clock ticks since initialization
42 */
43volatile uint32_t    Clock_driver_ticks;
44
45void Clock_exit( void );
46
47/*
48 *  Clock_isr
49 *
50 *  This is the clock tick interrupt handler.
51 *
52 *  Input parameters:
53 *    vector - vector number
54 *
55 *  Output parameters:  NONE
56 *
57 *  Return values:      NONE
58 */
59#if defined(BSP_FEATURE_IRQ_EXTENSION) || \
60    (CPU_SIMPLE_VECTORED_INTERRUPTS != TRUE)
61void Clock_isr(void *arg)
62{
63#else
64rtems_isr Clock_isr(rtems_vector_number vector);
65rtems_isr Clock_isr(
66  rtems_vector_number vector
67)
68{
69#endif
70  /*
71   *  Accurate count of ISRs
72   */
73  Clock_driver_ticks += 1;
74
75  #ifdef CLOCK_DRIVER_USE_FAST_IDLE
76    do {
77      rtems_clock_tick();
78    } while ( _Thread_Executing == _Thread_Idle &&
79            _Thread_Heir == _Thread_Executing);
80
81    Clock_driver_support_at_tick();
82    return;
83  #else
84    /*
85     *  Do the hardware specific per-tick action.
86     *
87     *  The counter/timer may or may not be set to automatically reload.
88     */
89    Clock_driver_support_at_tick();
90
91    #ifdef CLOCK_DRIVER_ISRS_PER_TICK
92      /*
93       *  The driver is multiple ISRs per clock tick.
94       */
95      if ( !Clock_driver_isrs ) {
96        rtems_clock_tick();
97
98        Clock_driver_isrs = CLOCK_DRIVER_ISRS_PER_TICK;
99      }
100      Clock_driver_isrs--;
101    #else
102      /*
103       *  The driver is one ISR per clock tick.
104       */
105      rtems_clock_tick();
106    #endif
107  #endif
108}
109
110/*
111 *  Clock_exit
112 *
113 *  This routine allows the clock driver to exit by masking the interrupt and
114 *  disabling the clock's counter.
115 *
116 *  Input parameters:   NONE
117 *
118 *  Output parameters:  NONE
119 *
120 *  Return values:      NONE
121 *
122 */
123
124void Clock_exit( void )
125{
126  Clock_driver_support_shutdown_hardware();
127
128  /* do not restore old vector */
129}
130
131/*
132 *  Clock_initialize
133 *
134 *  This routine initializes the clock driver.
135 *
136 *  Input parameters:
137 *    major - clock device major number
138 *    minor - clock device minor number
139 *    parg  - pointer to optional device driver arguments
140 *
141 *  Output parameters:  NONE
142 *
143 *  Return values:
144 *    rtems_device_driver status code
145 */
146
147rtems_device_driver Clock_initialize(
148  rtems_device_major_number major,
149  rtems_device_minor_number minor,
150  void *pargp
151)
152{
153  rtems_isr_entry  Old_ticker;
154
155  Clock_driver_ticks = 0;
156
157  /*
158   *  Find timer -- some BSPs search buses for hardware timer
159   */
160  Clock_driver_support_find_timer();
161
162  /*
163   *  Install vector
164   */
165  Clock_driver_support_install_isr( Clock_isr, Old_ticker );
166
167  #if defined(Clock_driver_nanoseconds_since_last_tick)
168    rtems_clock_set_nanoseconds_extension(
169      Clock_driver_nanoseconds_since_last_tick
170    );
171  #endif
172
173  /*
174   *  Now initialize the hardware that is the source of the tick ISR.
175   */
176  Clock_driver_support_initialize_hardware();
177
178  atexit( Clock_exit );
179
180  /*
181   *  If we are counting ISRs per tick, then initialize the counter.
182   */
183  #ifdef CLOCK_DRIVER_ISRS_PER_TICK
184    Clock_driver_isrs = CLOCK_DRIVER_ISRS_PER_TICK;
185  #endif
186
187  return RTEMS_SUCCESSFUL;
188}
Note: See TracBrowser for help on using the repository browser.