OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rtems-20020807/] [doc/] [bsp_howto/] [clock.t] - Diff between revs 1026 and 1765

Only display areas with differences | Details | Blame | View Log

Rev 1026 Rev 1765
@c
@c
@c  COPYRIGHT (c) 1988-2002.
@c  COPYRIGHT (c) 1988-2002.
@c  On-Line Applications Research Corporation (OAR).
@c  On-Line Applications Research Corporation (OAR).
@c  All rights reserved.
@c  All rights reserved.
@c
@c
@c  clock.t,v 1.9 2002/01/17 21:47:44 joel Exp
@c  clock.t,v 1.9 2002/01/17 21:47:44 joel Exp
@c
@c
@chapter Clock Driver
@chapter Clock Driver
@section Introduction
@section Introduction
The purpose of the clock driver is to provide a steady time
The purpose of the clock driver is to provide a steady time
basis to the kernel, so that the RTEMS primitives that need
basis to the kernel, so that the RTEMS primitives that need
a clock tick work properly.  See the @code{Clock Manager} chapter
a clock tick work properly.  See the @code{Clock Manager} chapter
of the @b{RTEMS Application C User's Guide} for more details.
of the @b{RTEMS Application C User's Guide} for more details.
The clock driver is located in the @code{clock} directory of the BSP.
The clock driver is located in the @code{clock} directory of the BSP.
@section Clock Driver Global Variables
@section Clock Driver Global Variables
This section describes the global variables expected to be provided by
This section describes the global variables expected to be provided by
this driver.
this driver.
@subsection Major and Minor Number
@subsection Major and Minor Number
The major and minor numbers of the clock driver are made available via
The major and minor numbers of the clock driver are made available via
the following variables.
the following variables.
@itemize @bullet
@itemize @bullet
@item rtems_device_major_number rtems_clock_major;
@item rtems_device_major_number rtems_clock_major;
@item rtems_device_minor_number rtems_clock_minor;
@item rtems_device_minor_number rtems_clock_minor;
@end itemize
@end itemize
The clock device driver is responsible for declaring and
The clock device driver is responsible for declaring and
initializing these variables.  These variables are used
initializing these variables.  These variables are used
by other RTEMS components -- notably the Shared Memory Driver.
by other RTEMS components -- notably the Shared Memory Driver.
@b{NOTE:} In a future RTEMS version, these variables may be replaced
@b{NOTE:} In a future RTEMS version, these variables may be replaced
with the clock device driver registering @b{/dev/clock}.
with the clock device driver registering @b{/dev/clock}.
@subsection Ticks Counter
@subsection Ticks Counter
Most of the clock device drivers provide a global variable
Most of the clock device drivers provide a global variable
that is simply a count of the number of clock driver interrupt service
that is simply a count of the number of clock driver interrupt service
routines that have occured.  This information is valuable when debugging
routines that have occured.  This information is valuable when debugging
a system.  This variable is declared as follows:
a system.  This variable is declared as follows:
@example
@example
volatile rtems_unsigned32 Clock_driver_ticks;
volatile rtems_unsigned32 Clock_driver_ticks;
@end example
@end example
@section Initialization
@section Initialization
The initialization routine is responsible for
The initialization routine is responsible for
programming the hardware that will periodically
programming the hardware that will periodically
generate an interrupt.  A programmable interval timer is commonly
generate an interrupt.  A programmable interval timer is commonly
used as the source of the clock tick.
used as the source of the clock tick.
The device should be programmed such that an interrupt is generated
The device should be programmed such that an interrupt is generated
every @i{m} microseconds, where @i{m} is equal to
every @i{m} microseconds, where @i{m} is equal to
@code{BSP_Configuration.microseconds_per_tick}. Sometimes the periodic interval
@code{BSP_Configuration.microseconds_per_tick}. Sometimes the periodic interval
timer can use a prescaler so you have to look carefully at your user's
timer can use a prescaler so you have to look carefully at your user's
manual to determine the correct value.
manual to determine the correct value.
You must use the RTEMS primitive @code{rtems_interrupt_catch} to install
You must use the RTEMS primitive @code{rtems_interrupt_catch} to install
your clock interrupt service routine:
your clock interrupt service routine:
@example
@example
rtems_interrupt_catch (Clock_ISR, CLOCK_VECTOR, &old_handler);
rtems_interrupt_catch (Clock_ISR, CLOCK_VECTOR, &old_handler);
@end example
@end example
Since there is currently not a driver entry point invoked at system
Since there is currently not a driver entry point invoked at system
shutdown, many clock device drivers use the @code{atexit} routine
shutdown, many clock device drivers use the @code{atexit} routine
to schedule their @code{Clock_exit} routine to execute when the
to schedule their @code{Clock_exit} routine to execute when the
system is shutdown.
system is shutdown.
By convention, many of the clock drivers do not install the clock
By convention, many of the clock drivers do not install the clock
tick if the @code{ticks_per_timeslice} field of the Configuration
tick if the @code{ticks_per_timeslice} field of the Configuration
Table is 0.
Table is 0.
@section System shutdown
@section System shutdown
Many drivers provide the routine @code{Clock_exit} that is scheduled
Many drivers provide the routine @code{Clock_exit} that is scheduled
to be run during system shutdown via the @code{atexit} routine.
to be run during system shutdown via the @code{atexit} routine.
The @code{Clock_exit} routine will disable the clock tick source
The @code{Clock_exit} routine will disable the clock tick source
if it was enabled.  This can be used to prevent clock ticks after the
if it was enabled.  This can be used to prevent clock ticks after the
system is shutdown.
system is shutdown.
@section Clock Interrupt Subroutine
@section Clock Interrupt Subroutine
It only has to inform the kernel that a ticker has elapsed, so call :
It only has to inform the kernel that a ticker has elapsed, so call :
@example
@example
@group
@group
rtems_isr Clock_isr( rtems_vector_number vector )
rtems_isr Clock_isr( rtems_vector_number vector )
@{
@{
  invoke the rtems_clock_tick() directive to announce the tick
  invoke the rtems_clock_tick() directive to announce the tick
  if necessary for this hardware
  if necessary for this hardware
    reload the programmable timer
    reload the programmable timer
@}
@}
@end group
@end group
@end example
@end example
@section IO Control
@section IO Control
The clock driver must supply a handler for the IO control device driver
The clock driver must supply a handler for the IO control device driver
entry point.  This functionality is used by other components -- notably
entry point.  This functionality is used by other components -- notably
the Shared Memory Driver to install a wrapper for the clock interrupt
the Shared Memory Driver to install a wrapper for the clock interrupt
service routine.  The following shows the functionality required:
service routine.  The following shows the functionality required:
@example
@example
@group
@group
rtems_device_driver Clock_control(
rtems_device_driver Clock_control(
  rtems_device_major_number major,
  rtems_device_major_number major,
  rtems_device_minor_number minor,
  rtems_device_minor_number minor,
  void *pargp
  void *pargp
)
)
@{
@{
  error check the argument pointer parameter
  error check the argument pointer parameter
  if the command is "ISR"
  if the command is "ISR"
    invoke the clock interrupt service routine
    invoke the clock interrupt service routine
  else if the command is "NEW"
  else if the command is "NEW"
    install the requested handler
    install the requested handler
@}
@}
@end group
@end group
@end example
@end example
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.