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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [lib/] [libbsp/] [m68k/] [mvme147/] [clock/] [ckinit.c] - Blame information for rev 173

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*  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: ckinit.c,v 1.2 2001-09-27 12:00:16 chris Exp $
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
 
33
rtems_unsigned32 Clock_isrs;                  /* ISRs until next tick */
34
volatile rtems_unsigned32 Clock_driver_ticks; /* ticks since initialization */
35
rtems_isr_entry  Old_ticker;
36
 
37
void Clock_exit( void );
38
 
39
/*
40
 * These are set by clock driver during its init
41
 */
42
 
43
rtems_device_major_number rtems_clock_major = ~0;
44
rtems_device_minor_number rtems_clock_minor;
45
 
46
 
47
/*
48
 *  ISR Handler
49
 */
50
 
51
rtems_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
 
64
void 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
 
82
void Clock_exit( void )
83
{
84
  pcc->timer2_int_control = 0x00; /* Disable T2 Interr. */
85
}
86
 
87
rtems_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
 
105
rtems_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
 
133
done:
134
    return RTEMS_SUCCESSFUL;
135
}
136
 

powered by: WebSVN 2.1.0

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