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

4.104.114.84.95
Last change on this file since 0dd1d44 was 0dd1d44, checked in by Joel Sherrill <joel.sherrill@…>, on Jan 11, 2000 at 5:34:20 PM

Removed old hack of using Configuration Table entry ticks_per_timeslice
being set to 0 to indicate that there should be no Clock Tick. This
was used by the Timing Tests to avoid clock tick overhead perturbing
execution times. Now the Timing Tests simply leave the Clock Tick
Driver out of the Device Driver Table.

  • Property mode set to 100644
File size: 2.9 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  Old_ticker = set_vector( clock_isr, CLOCK_VECTOR, 1 );
55  victimer = (volatile unsigned char *) 0xa00000c3;
56  *victimer = 0x12;
57  *victimer = 0x92;      /* 1000 HZ */
58}
59
60void Clock_exit()
61{
62  unsigned char *victimer;
63
64  victimer = (unsigned char *) 0xa00000c3;
65  *victimer = 0x12;
66  i960_mask_intr( 5 );
67  /* do not restore old vector */
68}
69
70rtems_device_driver Clock_initialize(
71  rtems_device_major_number major,
72  rtems_device_minor_number minor,
73  void *pargp
74)
75{
76  Install_clock( Clock_isr );
77 
78  atexit( Clock_exit );
79
80  /*
81   * make major/minor avail to others such as shared memory driver
82   */
83 
84  rtems_clock_major = major;
85  rtems_clock_minor = minor;
86 
87  return RTEMS_SUCCESSFUL;
88}
89 
90rtems_device_driver Clock_control(
91  rtems_device_major_number major,
92  rtems_device_minor_number minor,
93  void *pargp
94)
95{
96    rtems_unsigned32 isrlevel;
97    rtems_libio_ioctl_args_t *args = pargp;
98 
99    if (args == 0)
100        goto done;
101 
102    /*
103     * This is hokey, but until we get a defined interface
104     * to do this, it will just be this simple...
105     */
106 
107    if (args->command == rtems_build_name('I', 'S', 'R', ' '))
108    {
109        Clock_isr(CLOCK_VECTOR);
110    }
111    else if (args->command == rtems_build_name('N', 'E', 'W', ' '))
112    {
113      rtems_interrupt_disable( isrlevel );
114       (void) set_vector( args->buffer, CLOCK_VECTOR, 1 );
115      rtems_interrupt_enable( isrlevel );
116    }
117 
118done:
119    return RTEMS_SUCCESSFUL;
120}
121
122rtems_isr Clock_isr(
123  rtems_vector_number vector
124)
125{
126  /* enable_tracing(); */
127  Clock_driver_ticks += 1;
128  if ( Clock_isrs == 1 ) {
129    rtems_clock_tick();
130    Clock_isrs = BSP_Configuration.microseconds_per_tick / 1000;
131  }
132  else
133    Clock_isrs -= 1;
134  i960_clear_intr( 5 );
135}
136
Note: See TracBrowser for help on using the repository browser.