source: rtems/doc/bsp_howto/clock.t @ 1e78607

4.104.114.95
Last change on this file since 1e78607 was 1e78607, checked in by Joel Sherrill <joel.sherrill@…>, on 09/05/08 at 22:04:42

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

  • bsp_howto/clock.t: 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: 3.4 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 uint32_t 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{rtems_configuration_get_microseconds_per_tick()}. Sometimes
63the periodic interval timer can use a prescaler so you have to look
64carefully at your user's manual 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
107Prior to RTEMS 4.9, the Shared Memory MPCI Driver required a special
108IOCTL in the Clock Driver.  This is no longer required and the Clock
109Driver does not have to provide an IOCTL method at all.
110
Note: See TracBrowser for help on using the repository browser.