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

4.104.114.84.95
Last change on this file since f7fa7d7 was 98e4ebf5, checked in by Joel Sherrill <joel.sherrill@…>, on 10/08/97 at 15:45:54

Fixed typo in the pointer to the license terms.

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