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

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

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

  • clock/clock.c: Remove unnecessary includes of rtems/libcsupport.h and rtems/libio.h.
  • Property mode set to 100644
File size: 1.5 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 <stdlib.h>
18
19void Clock_exit(void);
20
21volatile uint32_t         Clock_driver_ticks;
22
23uint32_t         Clock_driver_vector;
24
25/*
26 * These are set by clock driver during its init
27 */
28
29rtems_device_major_number rtems_clock_major = ~0;
30rtems_device_minor_number rtems_clock_minor;
31
32void Install_clock(rtems_isr_entry clock_isr)
33{
34    Clock_driver_ticks = 0;
35
36    (void) set_vector( clock_isr, Clock_driver_vector, 1 );
37
38    _CPU_Start_clock( rtems_configuration_get_microseconds_per_tick() );
39
40    atexit(Clock_exit);
41}
42
43void Clock_isr(int vector)
44{
45    Clock_driver_ticks++;
46    rtems_clock_tick();
47}
48
49/*
50 * Called via atexit()
51 * Remove the clock signal
52 */
53
54void Clock_exit(void)
55{
56  _CPU_Stop_clock();
57
58  (void) set_vector( 0, Clock_driver_vector, 1 );
59}
60
61rtems_device_driver Clock_initialize(
62  rtems_device_major_number major,
63  rtems_device_minor_number minor,
64  void *pargp
65)
66{
67    Clock_driver_vector = _CPU_Get_clock_vector();
68
69    Install_clock((rtems_isr_entry) Clock_isr);
70
71    /*
72     * make major/minor avail to others such as shared memory driver
73     */
74    rtems_clock_major = major;
75    rtems_clock_minor = minor;
76
77    return RTEMS_SUCCESSFUL;
78}
Note: See TracBrowser for help on using the repository browser.