source: rtems/bsps/no_cpu/no_bsp/clock/ckinit.c @ cc466a5

5
Last change on this file since cc466a5 was bb99cd0d, checked in by Sebastian Huber <sebastian.huber@…>, on 12/05/19 at 18:22:33

clock: Simplify driver initialization

Use a system initialization handler instead of a legacy IO driver.

Update #3834.

  • Property mode set to 100644
File size: 2.5 KB
Line 
1/*
2 *  This file provides a template for the clock device driver initialization.
3 *
4 *  If possible, please use the dev/clock/clockimpl.h method for instantiating
5 *  a clock driver.
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-2014.
10 *  On-Line Applications Research Corporation (OAR).
11 *
12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
14 *  http://www.rtems.org/license/LICENSE.
15 */
16
17#include <stdlib.h>
18
19#include <rtems.h>
20#include <bsp.h>
21
22void Clock_exit( void );
23rtems_isr Clock_isr( rtems_vector_number vector );
24
25/*
26 *  The interrupt vector number associated with the clock tick device
27 *  driver.
28 */
29#define CLOCK_VECTOR    4
30
31/*
32 *  Clock_driver_ticks is a monotonically increasing counter of the
33 *  number of clock ticks since the driver was initialized.
34 */
35volatile uint32_t         Clock_driver_ticks;
36
37/*
38 *  Clock_isrs is the number of clock ISRs until the next invocation of
39 *  the RTEMS clock tick routine.  The clock tick device driver
40 *  gets an interrupt once a millisecond and counts down until the
41 *  length of time between the user configured microseconds per tick
42 *  has passed.
43 */
44uint32_t         Clock_isrs;              /* ISRs until next tick */
45
46/*
47 *  The previous ISR on this clock tick interrupt vector.
48 */
49rtems_isr_entry  Old_ticker;
50
51static void Clock_exit( void );
52
53/*
54 *  Isr Handler
55 */
56static rtems_isr Clock_isr(
57  rtems_vector_number vector
58)
59{
60  /*
61   * bump the number of clock driver ticks since initialization
62   *
63   * determine if it is time to announce the passing of tick as configured
64   * to RTEMS through the rtems_clock_tick directive
65   *
66   * perform any timer dependent tasks
67   */
68}
69
70/*
71 *  Install_clock
72 *
73 *  Install a clock tick handler and reprograms the chip.  This
74 *  is used to initially establish the clock tick.
75 */
76void Install_clock(
77  rtems_isr_entry clock_isr
78)
79{
80  /*
81   *  Initialize the clock tick device driver variables
82   */
83
84  Clock_driver_ticks = 0;
85  Clock_isrs = rtems_configuration_get_microseconds_per_tick() / 1000;
86
87  Old_ticker = (rtems_isr_entry) set_vector( clock_isr, CLOCK_VECTOR, 1 );
88  /*
89   *  Hardware specific initialize goes here
90   */
91
92  /* XXX */
93
94  /*
95   *  Schedule the clock cleanup routine to execute if the application exits.
96   */
97
98  atexit( Clock_exit );
99}
100
101/*
102 *  Clean up before the application exits
103 */
104
105void Clock_exit( void )
106{
107  /* XXX: turn off the timer interrupts */
108
109  /* XXX: If necessary, restore the old vector */
110}
111
112void _Clock_Initialize( void )
113{
114  Install_clock( Clock_isr );
115}
Note: See TracBrowser for help on using the repository browser.