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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [lib/] [libbsp/] [m68k/] [dmv152/] [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 Z80386 1 on the MVME136 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
 *  $Id: ckinit.c,v 1.2 2001-09-27 12:00:00 chris Exp $
18
 */
19
 
20
#include <stdlib.h>
21
 
22
#include <bsp.h>
23
#include <rtems/libio.h>
24
 
25
rtems_unsigned32 Clock_isrs;        /* ISRs until next tick */
26
volatile rtems_unsigned32 Clock_driver_ticks;
27
                                    /* ticks since initialization */
28
rtems_isr_entry  Old_ticker;
29
 
30
void Clock_exit( void );
31
 
32
#define CLOCK_VECTOR  TIMER_VECTOR
33
 
34
/*
35
 * These are set by clock driver during its init
36
 */
37
 
38
rtems_device_major_number rtems_clock_major = ~0;
39
rtems_device_minor_number rtems_clock_minor;
40
 
41
/*
42
 *  ISR Handler
43
 */
44
 
45
rtems_isr Clock_isr(
46
  rtems_vector_number vector
47
)
48
{
49
  Clock_driver_ticks += 1;
50
 
51
  Z8x36_WRITE( TIMER, CT1_CMD_STATUS, 0xE2 );
52
  Z8x36_WRITE( TIMER, CT1_CMD_STATUS, 0x22 );
53
  Z8x36_WRITE( TIMER, CT1_CMD_STATUS, 0xC6 );
54
 
55
  if ( Clock_isrs == 1 ) {
56
    rtems_clock_tick();
57
    Clock_isrs = BSP_Configuration.microseconds_per_tick / 1000;
58
  }
59
  else
60
    Clock_isrs -= 1;
61
}
62
 
63
void Install_clock(
64
  rtems_isr_entry clock_isr
65
)
66
{
67
  rtems_unsigned8 data;
68
 
69
  Clock_driver_ticks = 0;
70
  Clock_isrs = BSP_Configuration.microseconds_per_tick / 1000;
71
 
72
  Old_ticker = (rtems_isr_entry) set_vector( clock_isr, CLOCK_VECTOR, 1 );
73
 
74
  Z8x36_WRITE( TIMER, MASTER_CFG, 0xd4 );
75
  Z8x36_READ ( TIMER, MASTER_INTR, data );
76
  Z8x36_WRITE( TIMER, MASTER_INTR, (data & 0x7E) );
77
  Z8x36_WRITE( TIMER, CT1_TIME_CONST_MSB, 0x04 );
78
  Z8x36_WRITE( TIMER, CT1_TIME_CONST_LSB, 0xCE );
79
  Z8x36_WRITE( TIMER, CT1_MODE_SPEC, 0x83 );
80
  Z8x36_WRITE( TIMER, CNT_TMR_VECTOR, CLOCK_VECTOR );
81
  Z8x36_WRITE( TIMER, CT1_CMD_STATUS, 0x20 );
82
  Z8x36_READ ( TIMER, MASTER_INTR, data );
83
  Z8x36_WRITE( TIMER, MASTER_INTR, (data & 0xDA) | 0x80 );
84
 
85
  /*
86
   * ACC_IC54 - interrupt 5 will be vectored and mapped to level 6
87
   */
88
 
89
  data = (*(rtems_unsigned8 *)0x0D00000B);
90
  (*(rtems_unsigned8 *)0x0D00000B) = (data & 0x7F) | 0x60;
91
 
92
  Z8x36_WRITE( TIMER, CT1_CMD_STATUS, 0xC6 );
93
 
94
  atexit( Clock_exit );
95
}
96
 
97
void Clock_exit( void )
98
{
99
  rtems_unsigned8 data;
100
 
101
  Z8x36_READ ( TIMER, MASTER_INTR, data );
102
  Z8x36_WRITE( TIMER, MASTER_INTR, (data & 0x01) );
103
  /* do not restore old vector */
104
}
105
 
106
rtems_device_driver Clock_initialize(
107
  rtems_device_major_number major,
108
  rtems_device_minor_number minor,
109
  void *pargp
110
)
111
{
112
  Install_clock( Clock_isr );
113
 
114
  /*
115
   * make major/minor avail to others such as shared memory driver
116
   */
117
 
118
  rtems_clock_major = major;
119
  rtems_clock_minor = minor;
120
 
121
  return RTEMS_SUCCESSFUL;
122
}
123
 
124
rtems_device_driver Clock_control(
125
  rtems_device_major_number major,
126
  rtems_device_minor_number minor,
127
  void *pargp
128
)
129
{
130
    rtems_unsigned32 isrlevel;
131
    rtems_libio_ioctl_args_t *args = pargp;
132
 
133
    if (args == 0)
134
        goto done;
135
 
136
    /*
137
     * This is hokey, but until we get a defined interface
138
     * to do this, it will just be this simple...
139
     */
140
 
141
    if (args->command == rtems_build_name('I', 'S', 'R', ' '))
142
    {
143
        Clock_isr(CLOCK_VECTOR);
144
    }
145
    else if (args->command == rtems_build_name('N', 'E', 'W', ' '))
146
    {
147
      rtems_interrupt_disable( isrlevel );
148
       (void) set_vector( args->buffer, CLOCK_VECTOR, 1 );
149
      rtems_interrupt_enable( isrlevel );
150
    }
151
 
152
done:
153
    return RTEMS_SUCCESSFUL;
154
}
155
 

powered by: WebSVN 2.1.0

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