source: rtems/c/src/lib/libbsp/m68k/dmv152/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: 3.5 KB
Line 
1/*  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$
18 */
19
20#include <stdlib.h>
21 
22#include <bsp.h>
23#include <rtems/libio.h>
24
25rtems_unsigned32 Clock_isrs;        /* ISRs until next tick */
26volatile rtems_unsigned32 Clock_driver_ticks;
27                                    /* ticks since initialization */
28rtems_isr_entry  Old_ticker;
29
30void Clock_exit( void );
31
32#define CLOCK_VECTOR  TIMER_VECTOR
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 *  ISR Handler
43 */
44
45rtems_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
63void 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
97void 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
106rtems_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 
124rtems_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 
152done:
153    return RTEMS_SUCCESSFUL;
154}
155
Note: See TracBrowser for help on using the repository browser.