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

4.104.114.84.9
Last change on this file since 637df35 was 637df35, checked in by Joel Sherrill <joel.sherrill@…>, on Jul 12, 1995 at 7:47:25 PM

Ada95, gnat, go32

  • Property mode set to 100644
File size: 2.4 KB
Line 
1/*  Clock
2 *
3 *  This routine initializes the interval timer on the
4 *  PA-RISC CPU.  The tick frequency is specified by the bsp.
5 *
6 *  COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
7 *  On-Line Applications Research Corporation (OAR).
8 *  All rights assigned to U.S. Government, 1994.
9 *
10 *  This material may be reproduced by or for the U.S. Government pursuant
11 *  to the copyright license under the clause at DFARS 252.227-7013.  This
12 *  notice must appear in all copies of this file and its derivatives.
13 *
14 *  $Id$
15 */
16
17#include <rtems.h>
18
19#include <stdlib.h>
20#include <stdio.h>
21#include <signal.h>
22#include <time.h>
23
24extern rtems_configuration_table Configuration;
25extern sigset_t                  UNIX_SIGNAL_MASK;
26
27/*
28 * Function prototypes
29 */
30
31void Install_clock();
32void Clock_isr();
33void Clock_exit();
34
35/*
36 * CPU_HPPA_CLICKS_PER_TICK is either a #define or an rtems_unsigned32
37 *   allocated and set by bsp_start()
38 */
39
40#ifndef CPU_HPPA_CLICKS_PER_TICK
41extern rtems_unsigned32 CPU_HPPA_CLICKS_PER_TICK;
42#endif
43
44volatile rtems_unsigned32 Clock_driver_ticks;
45
46struct itimerval  new;
47
48rtems_device_driver
49Clock_initialize(
50  rtems_device_major_number major,
51  rtems_device_minor_number minor,
52  void *pargp,
53  rtems_id tid,
54  rtems_unsigned32 *rval
55)
56{
57    Install_clock(Clock_isr);
58}
59
60void
61ReInstall_clock(rtems_isr_entry new_clock_isr)
62{
63    rtems_unsigned32  isrlevel = 0;
64
65    rtems_interrupt_disable(isrlevel);
66    (void)set_vector(new_clock_isr, SIGALRM, 1);
67    rtems_interrupt_enable(isrlevel);
68}
69
70void
71Install_clock(rtems_isr_entry clock_isr)
72{
73    Clock_driver_ticks = 0;
74
75    new.it_value.tv_sec = 0;
76    new.it_value.tv_usec = Configuration.microseconds_per_tick;
77    new.it_interval.tv_sec = 0;
78    new.it_interval.tv_usec = Configuration.microseconds_per_tick;
79
80    (void)set_vector(clock_isr, SIGALRM, 1);
81
82    setitimer(ITIMER_REAL, &new, 0);
83
84    atexit(Clock_exit);
85}
86
87void
88Clock_isr(int vector)
89{
90    Clock_driver_ticks++;
91
92    rtems_clock_tick();
93}
94
95/*
96 * Called via atexit()
97 * Remove the clock signal
98 */
99
100void
101Clock_exit(void)
102{
103     struct sigaction  act;
104
105     /*
106      * Set the SIGALRM signal to ignore any last
107      * signals that might come in while we are
108      * disarming the timer and removing the interrupt
109      * vector.
110      */
111
112     act.sa_handler = SIG_IGN;
113
114     sigaction(SIGALRM, &act, 0);
115
116    new.it_value.tv_sec = 0;
117    new.it_value.tv_usec = 0;
118
119    setitimer(ITIMER_REAL, &new, 0);
120
121    (void)set_vector(0, SIGALRM, 1);
122}
Note: See TracBrowser for help on using the repository browser.