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

4.115
Last change on this file since e3be6915 was e3be6915, checked in by Sebastian Huber <sebastian.huber@…>, on 05/27/13 at 15:31:46

score: Remove idle field of Per_CPU_Control

This field is unused except for special case simulator clock drivers.
In these places use an alternative. Add and use
_Thread_Set_global_exit_status() and _Thread_Get_global_exit_status().

  • Property mode set to 100644
File size: 3.8 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 (
77      _Thread_Heir == _Thread_Executing
78        && _Thread_Executing->Start.entry_point
79          == rtems_configuration_get_idle_task()
80    );
81
82    Clock_driver_support_at_tick();
83    return;
84  #else
85    /*
86     *  Do the hardware specific per-tick action.
87     *
88     *  The counter/timer may or may not be set to automatically reload.
89     */
90    Clock_driver_support_at_tick();
91
92    #ifdef CLOCK_DRIVER_ISRS_PER_TICK
93      /*
94       *  The driver is multiple ISRs per clock tick.
95       */
96      if ( !Clock_driver_isrs ) {
97        rtems_clock_tick();
98
99        Clock_driver_isrs = CLOCK_DRIVER_ISRS_PER_TICK;
100      }
101      Clock_driver_isrs--;
102    #else
103      /*
104       *  The driver is one ISR per clock tick.
105       */
106      rtems_clock_tick();
107    #endif
108  #endif
109}
110
111/*
112 *  Clock_exit
113 *
114 *  This routine allows the clock driver to exit by masking the interrupt and
115 *  disabling the clock's counter.
116 *
117 *  Input parameters:   NONE
118 *
119 *  Output parameters:  NONE
120 *
121 *  Return values:      NONE
122 *
123 */
124
125void Clock_exit( void )
126{
127  Clock_driver_support_shutdown_hardware();
128
129  /* do not restore old vector */
130}
131
132/*
133 *  Clock_initialize
134 *
135 *  This routine initializes the clock driver.
136 *
137 *  Input parameters:
138 *    major - clock device major number
139 *    minor - clock device minor number
140 *    parg  - pointer to optional device driver arguments
141 *
142 *  Output parameters:  NONE
143 *
144 *  Return values:
145 *    rtems_device_driver status code
146 */
147
148rtems_device_driver Clock_initialize(
149  rtems_device_major_number major,
150  rtems_device_minor_number minor,
151  void *pargp
152)
153{
154  rtems_isr_entry  Old_ticker;
155
156  Clock_driver_ticks = 0;
157
158  /*
159   *  Find timer -- some BSPs search buses for hardware timer
160   */
161  Clock_driver_support_find_timer();
162
163  /*
164   *  Install vector
165   */
166  (void) Old_ticker;
167  Clock_driver_support_install_isr( Clock_isr, Old_ticker );
168
169  #if defined(Clock_driver_nanoseconds_since_last_tick)
170    rtems_clock_set_nanoseconds_extension(
171      Clock_driver_nanoseconds_since_last_tick
172    );
173  #endif
174
175  /*
176   *  Now initialize the hardware that is the source of the tick ISR.
177   */
178  Clock_driver_support_initialize_hardware();
179
180  atexit( Clock_exit );
181
182  /*
183   *  If we are counting ISRs per tick, then initialize the counter.
184   */
185  #ifdef CLOCK_DRIVER_ISRS_PER_TICK
186    Clock_driver_isrs = CLOCK_DRIVER_ISRS_PER_TICK;
187  #endif
188
189  return RTEMS_SUCCESSFUL;
190}
Note: See TracBrowser for help on using the repository browser.