source: rtems/c/src/lib/libbsp/no_cpu/no_bsp/clock/ckinit.c @ 0b6d4de8

4.104.115
Last change on this file since 0b6d4de8 was 0b6d4de8, checked in by Joel Sherrill <joel.sherrill@…>, on 09/16/08 at 19:09:53

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

  • clock/ckinit.c: Remove unnecessary includes of rtems/libcsupport.h and rtems/libio.h.
  • 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 <bsp.h>
19
20void Clock_exit( void );
21rtems_isr Clock_isr( rtems_vector_number vector );
22
23/*
24 *  The interrupt vector number associated with the clock tick device
25 *  driver.
26 */
27
28#define CLOCK_VECTOR    4
29
30/*
31 *  Clock_driver_ticks is a monotonically increasing counter of the
32 *  number of clock ticks since the driver was initialized.
33 */
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 */
44
45uint32_t         Clock_isrs;              /* ISRs until next tick */
46
47/*
48 * These are set by clock driver during its init
49 */
50
51rtems_device_major_number rtems_clock_major = ~0;
52rtems_device_minor_number rtems_clock_minor;
53
54/*
55 *  The previous ISR on this clock tick interrupt vector.
56 */
57
58rtems_isr_entry  Old_ticker;
59
60void Clock_exit( void );
61
62/*
63 *  Isr Handler
64 */
65
66rtems_isr Clock_isr(
67  rtems_vector_number vector
68)
69{
70/*
71 * bump the number of clock driver ticks since initialization
72 *
73 * determine if it is time to announce the passing of tick as configured
74 * to RTEMS through the rtems_clock_tick directive
75 *
76 * perform any timer dependent tasks
77 */
78}
79
80/*
81 *  Install_clock
82 *
83 *  Install a clock tick handler and reprograms the chip.  This
84 *  is used to initially establish the clock tick.
85 */
86
87void Install_clock(
88  rtems_isr_entry clock_isr
89)
90{
91  /*
92   *  Initialize the clock tick device driver variables
93   */
94
95  Clock_driver_ticks = 0;
96  Clock_isrs = rtems_configuration_get_microseconds_per_tick() / 1000;
97
98  Old_ticker = (rtems_isr_entry) set_vector( clock_isr, CLOCK_VECTOR, 1 );
99  /*
100   *  Hardware specific initialize goes here
101   */
102
103  /* XXX */
104
105  /*
106   *  Schedule the clock cleanup routine to execute if the application exits.
107   */
108
109  atexit( Clock_exit );
110}
111
112/*
113 *  Clean up before the application exits
114 */
115
116void Clock_exit( void )
117{
118  /* XXX: turn off the timer interrupts */
119
120  /* XXX: If necessary, restore the old vector */
121}
122
123/*
124 *  Clock_initialize
125 *
126 *  Device driver entry point for clock tick driver initialization.
127 */
128
129rtems_device_driver Clock_initialize(
130  rtems_device_major_number major,
131  rtems_device_minor_number minor,
132  void *pargp
133)
134{
135  Install_clock( Clock_isr );
136
137  /*
138   * make major/minor avail to others such as shared memory driver
139   */
140
141  rtems_clock_major = major;
142  rtems_clock_minor = minor;
143
144  return RTEMS_SUCCESSFUL;
145}
146
Note: See TracBrowser for help on using the repository browser.