source: rtems/c/src/lib/libbsp/m68k/mvme147/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 01/11/00 at 17:34:20

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: 3.1 KB
Line 
1/*  Clock_init()
2 *
3 *  This routine initializes the Tick Timer 2 on the MVME147 board.
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 *  MVME147 port for TNI - Telecom Bretagne
18 *  by Dominique LE CAMPION (Dominique.LECAMPION@enst-bretagne.fr)
19 *  May 1996
20 *
21 *  $Id$
22 */
23
24#include <stdlib.h>
25
26#include <bsp.h>
27#include <rtems/libio.h>
28
29#define MS_COUNT          65376    /* 1ms */
30/* MS_COUNT = 0x10000 - 1e-3/6.25e-6 */
31#define CLOCK_INT_LEVEL   6               /* T2's interrupt level */
32
33rtems_unsigned32 Clock_isrs;                  /* ISRs until next tick */
34volatile rtems_unsigned32 Clock_driver_ticks; /* ticks since initialization */
35rtems_isr_entry  Old_ticker;
36
37void Clock_exit( void );
38 
39/*
40 * These are set by clock driver during its init
41 */
42 
43rtems_device_major_number rtems_clock_major = ~0;
44rtems_device_minor_number rtems_clock_minor;
45 
46
47/*
48 *  ISR Handler
49 */
50
51rtems_isr Clock_isr(rtems_vector_number vector)
52{
53  Clock_driver_ticks += 1;
54  pcc->timer2_int_control |= 0x80; /* Acknowledge interr. */
55
56  if (Clock_isrs == 1) {
57    rtems_clock_tick();
58    Clock_isrs = BSP_Configuration.microseconds_per_tick / 1000;
59  }
60  else
61    Clock_isrs -= 1;
62}
63
64void Install_clock(rtems_isr_entry clock_isr )
65{
66
67  Clock_driver_ticks = 0;
68  Clock_isrs = BSP_Configuration.microseconds_per_tick / 1000;
69
70  Old_ticker = (rtems_isr_entry) set_vector( clock_isr, TIMER_2_VECTOR, 1 );
71
72  pcc->timer2_int_control = 0x00; /* Disable T2 Interr. */
73  pcc->timer2_preload = MS_COUNT;
74  /* write preload value */
75  pcc->timer2_control = 0x07; /* clear T2 overflow counter, enable counter */
76  pcc->timer2_int_control = CLOCK_INT_LEVEL|0x08;
77  /* Enable Timer 2 and set its int. level */
78   
79  atexit( Clock_exit );
80}
81
82void Clock_exit( void )
83{
84  pcc->timer2_int_control = 0x00; /* Disable T2 Interr. */
85}
86
87rtems_device_driver Clock_initialize(
88  rtems_device_major_number major,
89  rtems_device_minor_number minor,
90  void *pargp
91)
92{
93  Install_clock( Clock_isr );
94 
95  /*
96   * make major/minor avail to others such as shared memory driver
97   */
98 
99  rtems_clock_major = major;
100  rtems_clock_minor = minor;
101 
102  return RTEMS_SUCCESSFUL;
103}
104 
105rtems_device_driver Clock_control(
106  rtems_device_major_number major,
107  rtems_device_minor_number minor,
108  void *pargp
109)
110{
111    rtems_unsigned32 isrlevel;
112    rtems_libio_ioctl_args_t *args = pargp;
113 
114    if (args == 0)
115        goto done;
116 
117    /*
118     * This is hokey, but until we get a defined interface
119     * to do this, it will just be this simple...
120     */
121 
122    if (args->command == rtems_build_name('I', 'S', 'R', ' '))
123    {
124        Clock_isr(TIMER_2_VECTOR);
125    }
126    else if (args->command == rtems_build_name('N', 'E', 'W', ' '))
127    {
128      rtems_interrupt_disable( isrlevel );
129       (void) set_vector( args->buffer, TIMER_2_VECTOR, 1 );
130      rtems_interrupt_enable( isrlevel );
131    }
132 
133done:
134    return RTEMS_SUCCESSFUL;
135}
136
Note: See TracBrowser for help on using the repository browser.