source: rtems/doc/bsp_howto/clock.t @ 99583c6

4.104.114.84.95
Last change on this file since 99583c6 was 6449498, checked in by Joel Sherrill <joel.sherrill@…>, on 01/17/02 at 21:47:47

2001-01-17 Joel Sherrill <joel@…>

  • SUPPORT, LICENSE: New files.
  • Numerous files touched as part of merging the 4.5 branch onto the mainline development trunk and ensuring that the script that cuts snapshots and releases works on the documentation.
  • Property mode set to 100644
File size: 3.9 KB
Line 
1@c
2@c  COPYRIGHT (c) 1988-2002.
3@c  On-Line Applications Research Corporation (OAR).
4@c  All rights reserved.
5@c
6@c  $Id$
7@c
8
9@chapter Clock Driver
10
11@section Introduction
12
13The purpose of the clock driver is to provide a steady time
14basis to the kernel, so that the RTEMS primitives that need
15a clock tick work properly.  See the @code{Clock Manager} chapter
16of the @b{RTEMS Application C User's Guide} for more details.
17
18The clock driver is located in the @code{clock} directory of the BSP.
19
20@section Clock Driver Global Variables
21
22This section describes the global variables expected to be provided by
23this driver.
24
25@subsection Major and Minor Number
26
27The major and minor numbers of the clock driver are made available via
28the following variables. 
29
30@itemize @bullet
31@item rtems_device_major_number rtems_clock_major;
32@item rtems_device_minor_number rtems_clock_minor;
33@end itemize
34
35The clock device driver is responsible for declaring and
36initializing these variables.  These variables are used
37by other RTEMS components -- notably the Shared Memory Driver.
38
39@b{NOTE:} In a future RTEMS version, these variables may be replaced
40with the clock device driver registering @b{/dev/clock}.
41
42@subsection Ticks Counter
43
44Most of the clock device drivers provide a global variable
45that is simply a count of the number of clock driver interrupt service
46routines that have occured.  This information is valuable when debugging
47a system.  This variable is declared as follows:
48
49@example
50volatile rtems_unsigned32 Clock_driver_ticks;
51@end example
52
53@section Initialization
54
55The initialization routine is responsible for
56programming the hardware that will periodically
57generate an interrupt.  A programmable interval timer is commonly
58used as the source of the clock tick.
59
60The device should be programmed such that an interrupt is generated
61every @i{m} microseconds, where @i{m} is equal to
62@code{BSP_Configuration.microseconds_per_tick}. Sometimes the periodic interval
63timer can use a prescaler so you have to look carefully at your user's
64manual to determine the correct value.
65
66You must use the RTEMS primitive @code{rtems_interrupt_catch} to install
67your clock interrupt service routine:
68
69@example
70rtems_interrupt_catch (Clock_ISR, CLOCK_VECTOR, &old_handler);
71@end example
72
73Since there is currently not a driver entry point invoked at system
74shutdown, many clock device drivers use the @code{atexit} routine
75to schedule their @code{Clock_exit} routine to execute when the
76system is shutdown.
77
78By convention, many of the clock drivers do not install the clock
79tick if the @code{ticks_per_timeslice} field of the Configuration
80Table is 0.
81
82@section System shutdown
83
84Many drivers provide the routine @code{Clock_exit} that is scheduled
85to be run during system shutdown via the @code{atexit} routine.
86The @code{Clock_exit} routine will disable the clock tick source
87if it was enabled.  This can be used to prevent clock ticks after the
88system is shutdown.
89
90@section Clock Interrupt Subroutine
91
92It only has to inform the kernel that a ticker has elapsed, so call :
93
94@example
95@group
96rtems_isr Clock_isr( rtems_vector_number vector )
97@{
98  invoke the rtems_clock_tick() directive to announce the tick
99  if necessary for this hardware
100    reload the programmable timer
101@}
102@end group
103@end example
104
105@section IO Control
106
107The clock driver must supply a handler for the IO control device driver
108entry point.  This functionality is used by other components -- notably
109the Shared Memory Driver to install a wrapper for the clock interrupt
110service routine.  The following shows the functionality required:
111
112@example
113@group
114rtems_device_driver Clock_control(
115  rtems_device_major_number major,
116  rtems_device_minor_number minor,
117  void *pargp
118)
119@{
120  error check the argument pointer parameter
121
122  if the command is "ISR"
123    invoke the clock interrupt service routine
124  else if the command is "NEW"
125    install the requested handler
126@}
127@end group
128@end example
129
130
131
132
Note: See TracBrowser for help on using the repository browser.