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

4.104.114.84.95
Last change on this file since 37f4c2d was 37f4c2d, checked in by Joel Sherrill <joel.sherrill@…>, on 09/27/95 at 20:53:58

Modified UNIX simulator port so all references to native unix
stuff is in the executive source proper in the file cpu.c. This
should help avoid conflicts between RTEMS POSIX files and UNIX files.

  • Property mode set to 100644
File size: 2.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, 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 <bsp.h>
18#include <rtems/libio.h>
19#include <stdlib.h>
20
21void Clock_exit(void);
22
23volatile rtems_unsigned32 Clock_driver_ticks;
24
25rtems_unsigned32 Clock_driver_vector;
26
27/*
28 * These are set by clock driver during its init
29 */
30
31rtems_device_major_number rtems_clock_major = ~0;
32rtems_device_minor_number rtems_clock_minor;
33
34void
35Install_clock(rtems_isr_entry clock_isr)
36{
37    Clock_driver_ticks = 0;
38
39    (void)set_vector(clock_isr, Clock_driver_vector, 1);
40
41    _CPU_Start_clock( BSP_Configuration.microseconds_per_tick );
42
43    atexit(Clock_exit);
44}
45
46void
47ReInstall_clock(rtems_isr_entry new_clock_isr)
48{
49    rtems_unsigned32  isrlevel = 0;
50
51    rtems_interrupt_disable(isrlevel);
52    (void)set_vector(new_clock_isr, Clock_driver_vector, 1);
53    rtems_interrupt_enable(isrlevel);
54}
55
56void
57Clock_isr(int vector)
58{
59    Clock_driver_ticks++;
60    rtems_clock_tick();
61}
62
63/*
64 * Called via atexit()
65 * Remove the clock signal
66 */
67
68void
69Clock_exit(void)
70{
71  _CPU_Stop_clock();
72
73  (void)set_vector(0, Clock_driver_vector, 1);
74}
75
76rtems_device_driver
77Clock_initialize(
78  rtems_device_major_number major,
79  rtems_device_minor_number minor,
80  void *pargp
81)
82{
83    Clock_driver_vector = _CPU_Get_clock_vector();
84
85    Install_clock((rtems_isr_entry) Clock_isr);
86
87    /*
88     * make major/minor avail to others such as shared memory driver
89     */
90    rtems_clock_major = major;
91    rtems_clock_minor = minor;
92
93    return RTEMS_SUCCESSFUL;
94}
95
96rtems_device_driver Clock_control(
97  rtems_device_major_number major,
98  rtems_device_minor_number minor,
99  void *pargp
100)
101{
102    rtems_libio_ioctl_args_t *args = pargp;
103
104    if (args == 0)
105        goto done;
106
107    /*
108     * This is hokey, but until we get a defined interface
109     * to do this, it will just be this simple...
110     */
111
112    if (args->command == rtems_build_name('I', 'S', 'R', ' '))
113    {
114        Clock_isr(Clock_driver_vector);
115    }
116    else if (args->command == rtems_build_name('N', 'E', 'W', ' '))
117    {
118        ReInstall_clock(args->buffer);
119    }
120   
121done:
122    return RTEMS_SUCCESSFUL;
123}
Note: See TracBrowser for help on using the repository browser.