source: rtems/c/src/lib/libbsp/shared/clockdrv_shell.h @ 38c0b112

4.115
Last change on this file since 38c0b112 was 9b4422a2, checked in by Joel Sherrill <joel.sherrill@…>, on 05/03/12 at 15:09:24

Remove All CVS Id Strings Possible Using a Script

Script does what is expected and tries to do it as
smartly as possible.

+ remove occurrences of two blank comment lines

next to each other after Id string line removed.

+ remove entire comment blocks which only exited to

contain CVS Ids

+ If the processing left a blank line at the top of

a file, it was removed.

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