source: rtems/c/src/lib/libbsp/i960/cvme961/clock/ckinit.c @ 08311cc3

4.104.114.84.95
Last change on this file since 08311cc3 was 08311cc3, checked in by Joel Sherrill <joel.sherrill@…>, on 11/17/99 at 17:51:34

Updated copyright notice.

  • Property mode set to 100644
File size: 3.0 KB
Line 
1/*  Clock_init()
2 *
3 *  This routine initializes the timer on the VIC chip on the CVME961.
4 *  The tick frequency is 1 millisecond.
5 *
6 *  Input parameters:  NONE
7 *
8 *  Output parameters:  NONE
9 *
10 *  COPYRIGHT (c) 1989-1999.
11 *  On-Line Applications Research Corporation (OAR).
12 *
13 *  The license and distribution terms for this file may be
14 *  found in the file LICENSE in this distribution or at
15 *  http://www.OARcorp.com/rtems/license.html.
16 *
17 *  $Id$
18 */
19
20#include <stdlib.h>
21
22#include <bsp.h>
23#include <rtems/libio.h>
24
25#define CLOCK_VECTOR 5
26
27rtems_unsigned32 Clock_isrs;              /* ISRs until next tick */
28i960_isr_entry   Old_ticker;
29volatile rtems_unsigned32 Clock_driver_ticks;
30                                          /* ticks since initialization */
31
32void Clock_exit( void );
33 
34/*
35 * These are set by clock driver during its init
36 */
37 
38rtems_device_major_number rtems_clock_major = ~0;
39rtems_device_minor_number rtems_clock_minor;
40
41
42/* this is later in the file to avoid it being inlined */
43rtems_isr Clock_isr( rtems_vector_number vector );
44
45void Install_clock(
46  rtems_isr_entry clock_isr
47)
48{
49  volatile unsigned char *victimer;
50
51  Clock_driver_ticks = 0;
52  Clock_isrs = BSP_Configuration.microseconds_per_tick / 1000;
53
54  if ( BSP_Configuration.ticks_per_timeslice ) {
55    Old_ticker = set_vector( clock_isr, CLOCK_VECTOR, 1 );
56    victimer = (volatile unsigned char *) 0xa00000c3;
57    *victimer = 0x12;
58    *victimer = 0x92;      /* 1000 HZ */
59  }
60}
61
62void Clock_exit()
63{
64  unsigned char *victimer;
65
66  if ( BSP_Configuration.ticks_per_timeslice ) {
67    victimer = (unsigned char *) 0xa00000c3;
68    *victimer = 0x12;
69    i960_mask_intr( 5 );
70    /* do not restore old vector */
71  }
72}
73
74rtems_device_driver Clock_initialize(
75  rtems_device_major_number major,
76  rtems_device_minor_number minor,
77  void *pargp
78)
79{
80  Install_clock( Clock_isr );
81 
82  atexit( Clock_exit );
83
84  /*
85   * make major/minor avail to others such as shared memory driver
86   */
87 
88  rtems_clock_major = major;
89  rtems_clock_minor = minor;
90 
91  return RTEMS_SUCCESSFUL;
92}
93 
94rtems_device_driver Clock_control(
95  rtems_device_major_number major,
96  rtems_device_minor_number minor,
97  void *pargp
98)
99{
100    rtems_unsigned32 isrlevel;
101    rtems_libio_ioctl_args_t *args = pargp;
102 
103    if (args == 0)
104        goto done;
105 
106    /*
107     * This is hokey, but until we get a defined interface
108     * to do this, it will just be this simple...
109     */
110 
111    if (args->command == rtems_build_name('I', 'S', 'R', ' '))
112    {
113        Clock_isr(CLOCK_VECTOR);
114    }
115    else if (args->command == rtems_build_name('N', 'E', 'W', ' '))
116    {
117      rtems_interrupt_disable( isrlevel );
118       (void) set_vector( args->buffer, CLOCK_VECTOR, 1 );
119      rtems_interrupt_enable( isrlevel );
120    }
121 
122done:
123    return RTEMS_SUCCESSFUL;
124}
125
126rtems_isr Clock_isr(
127  rtems_vector_number vector
128)
129{
130  /* enable_tracing(); */
131  Clock_driver_ticks += 1;
132  if ( Clock_isrs == 1 ) {
133    rtems_clock_tick();
134    Clock_isrs = BSP_Configuration.microseconds_per_tick / 1000;
135  }
136  else
137    Clock_isrs -= 1;
138  i960_clear_intr( 5 );
139}
140
Note: See TracBrowser for help on using the repository browser.