source: rtems/c/src/lib/libbsp/unix/posix/clock/clock.c @ bd84f81

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

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

  • clock/clock.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: 1.6 KB
Line 
1/*  Clock
2 *
3 *  This routine generates clock ticks using standard POSIX services.
4 *  The tick frequency is specified by the bsp.
5 *
6 *  COPYRIGHT (c) 1989-1999.
7 *  On-Line Applications Research Corporation (OAR).
8 *
9 *  The license and distribution terms for this file may be
10 *  found in the file LICENSE in this distribution or at
11 *  http://www.rtems.com/license/LICENSE.
12 *
13 *  $Id$
14 */
15
16#include <bsp.h>
17#include <rtems/libio.h>
18#include <stdlib.h>
19
20void Clock_exit(void);
21
22volatile uint32_t         Clock_driver_ticks;
23
24uint32_t         Clock_driver_vector;
25
26/*
27 * These are set by clock driver during its init
28 */
29
30rtems_device_major_number rtems_clock_major = ~0;
31rtems_device_minor_number rtems_clock_minor;
32
33void Install_clock(rtems_isr_entry clock_isr)
34{
35    Clock_driver_ticks = 0;
36
37    (void) set_vector( clock_isr, Clock_driver_vector, 1 );
38
39    _CPU_Start_clock( rtems_configuration_get_microseconds_per_tick() );
40
41    atexit(Clock_exit);
42}
43
44void Clock_isr(int vector)
45{
46    Clock_driver_ticks++;
47    rtems_clock_tick();
48}
49
50/*
51 * Called via atexit()
52 * Remove the clock signal
53 */
54
55void Clock_exit(void)
56{
57  _CPU_Stop_clock();
58
59  (void) set_vector( 0, Clock_driver_vector, 1 );
60}
61
62rtems_device_driver Clock_initialize(
63  rtems_device_major_number major,
64  rtems_device_minor_number minor,
65  void *pargp
66)
67{
68    Clock_driver_vector = _CPU_Get_clock_vector();
69
70    Install_clock((rtems_isr_entry) Clock_isr);
71
72    /*
73     * make major/minor avail to others such as shared memory driver
74     */
75    rtems_clock_major = major;
76    rtems_clock_minor = minor;
77
78    return RTEMS_SUCCESSFUL;
79}
Note: See TracBrowser for help on using the repository browser.