source: rtems/c/src/lib/libbsp/no_cpu/no_bsp/clock/ckinit.c @ 34ef6c7

4.104.114.95
Last change on this file since 34ef6c7 was 34ef6c7, checked in by Joel Sherrill <joel.sherrill@…>, on Sep 5, 2008 at 10:06:51 PM

2008-09-05 Joel Sherrill <joel.sherrill@…>

  • clock/ckinit.c: The Shared Memory Driver no longer requires the special IOCTL in Clock_control. This was a hack which has existed since before the Classic API Timer Manager was implemented. All implementations of and references to Clock_control were removed.
  • Property mode set to 100644
File size: 2.9 KB
Line 
1/*  ckinit.c
2 *
3 *  This file provides a template for the clock device driver initialization.
4 *
5 *  COPYRIGHT (c) 1989-1999.
6 *  On-Line Applications Research Corporation (OAR).
7 *
8 *  The license and distribution terms for this file may be
9 *  found in the file LICENSE in this distribution or at
10 *  http://www.rtems.com/license/LICENSE.
11 *
12 *  $Id$
13 */
14
15#include <stdlib.h>
16
17#include <rtems.h>
18#include <rtems/libio.h>
19#include <bsp.h>
20
21void Clock_exit( void );
22rtems_isr Clock_isr( rtems_vector_number vector );
23
24/*
25 *  The interrupt vector number associated with the clock tick device
26 *  driver.
27 */
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 */
35
36volatile uint32_t         Clock_driver_ticks;
37
38/*
39 *  Clock_isrs is the number of clock ISRs until the next invocation of
40 *  the RTEMS clock tick routine.  The clock tick device driver
41 *  gets an interrupt once a millisecond and counts down until the
42 *  length of time between the user configured microseconds per tick
43 *  has passed.
44 */
45
46uint32_t         Clock_isrs;              /* ISRs until next tick */
47
48/*
49 * These are set by clock driver during its init
50 */
51
52rtems_device_major_number rtems_clock_major = ~0;
53rtems_device_minor_number rtems_clock_minor;
54
55/*
56 *  The previous ISR on this clock tick interrupt vector.
57 */
58
59rtems_isr_entry  Old_ticker;
60
61void Clock_exit( void );
62
63/*
64 *  Isr Handler
65 */
66
67rtems_isr Clock_isr(
68  rtems_vector_number vector
69)
70{
71/*
72 * bump the number of clock driver ticks since initialization
73 *
74 * determine if it is time to announce the passing of tick as configured
75 * to RTEMS through the rtems_clock_tick directive
76 *
77 * perform any timer dependent tasks
78 */
79}
80
81/*
82 *  Install_clock
83 *
84 *  Install a clock tick handler and reprograms the chip.  This
85 *  is used to initially establish the clock tick.
86 */
87
88void Install_clock(
89  rtems_isr_entry clock_isr
90)
91{
92  /*
93   *  Initialize the clock tick device driver variables
94   */
95
96  Clock_driver_ticks = 0;
97  Clock_isrs = rtems_configuration_get_microseconds_per_tick() / 1000;
98
99  Old_ticker = (rtems_isr_entry) set_vector( clock_isr, CLOCK_VECTOR, 1 );
100  /*
101   *  Hardware specific initialize goes here
102   */
103
104  /* XXX */
105
106  /*
107   *  Schedule the clock cleanup routine to execute if the application exits.
108   */
109
110  atexit( Clock_exit );
111}
112
113/*
114 *  Clean up before the application exits
115 */
116
117void Clock_exit( void )
118{
119  /* XXX: turn off the timer interrupts */
120
121  /* XXX: If necessary, restore the old vector */
122}
123
124/*
125 *  Clock_initialize
126 *
127 *  Device driver entry point for clock tick driver initialization.
128 */
129
130rtems_device_driver Clock_initialize(
131  rtems_device_major_number major,
132  rtems_device_minor_number minor,
133  void *pargp
134)
135{
136  Install_clock( Clock_isr );
137
138  /*
139   * make major/minor avail to others such as shared memory driver
140   */
141
142  rtems_clock_major = major;
143  rtems_clock_minor = minor;
144
145  return RTEMS_SUCCESSFUL;
146}
147
Note: See TracBrowser for help on using the repository browser.