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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [lib/] [libbsp/] [unix/] [posix/] [clock/] [clock.c] - Blame information for rev 846

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*  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.OARcorp.com/rtems/license.html.
12
 *
13
 *  $Id: clock.c,v 1.2 2001-09-27 12:01:14 chris Exp $
14
 */
15
 
16
#include <bsp.h>
17
#include <rtems/libio.h>
18
#include <stdlib.h>
19
 
20
void Clock_exit(void);
21
 
22
volatile rtems_unsigned32 Clock_driver_ticks;
23
 
24
rtems_unsigned32 Clock_driver_vector;
25
 
26
/*
27
 * These are set by clock driver during its init
28
 */
29
 
30
rtems_device_major_number rtems_clock_major = ~0;
31
rtems_device_minor_number rtems_clock_minor;
32
 
33
void 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( BSP_Configuration.microseconds_per_tick );
40
 
41
    atexit(Clock_exit);
42
}
43
 
44
void 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
 
55
void Clock_exit(void)
56
{
57
  _CPU_Stop_clock();
58
 
59
  (void) set_vector( 0, Clock_driver_vector, 1 );
60
}
61
 
62
rtems_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
}
80
 
81
rtems_device_driver Clock_control(
82
  rtems_device_major_number major,
83
  rtems_device_minor_number minor,
84
  void *pargp
85
)
86
{
87
    rtems_unsigned32 isrlevel;
88
    rtems_libio_ioctl_args_t *args = pargp;
89
 
90
    if (args == 0)
91
        goto done;
92
 
93
    /*
94
     * This is hokey, but until we get a defined interface
95
     * to do this, it will just be this simple...
96
     */
97
 
98
    if (args->command == rtems_build_name('I', 'S', 'R', ' '))
99
    {
100
        Clock_isr(Clock_driver_vector);
101
    }
102
    else if (args->command == rtems_build_name('N', 'E', 'W', ' '))
103
    {
104
      rtems_interrupt_disable( isrlevel );
105
       (void) set_vector( args->buffer, Clock_driver_vector, 1 );
106
      rtems_interrupt_enable( isrlevel );
107
    }
108
 
109
done:
110
    return RTEMS_SUCCESSFUL;
111
}

powered by: WebSVN 2.1.0

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