source: rtems/c/src/lib/libbsp/m68k/mvme136/clock/ckinit.c @ 9e86dd7d

4.104.114.84.95
Last change on this file since 9e86dd7d was ac7d5ef0, checked in by Joel Sherrill <joel.sherrill@…>, on 05/11/95 at 17:39:37

Initial revision

  • Property mode set to 100644
File size: 3.0 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, 1990, 1991, 1992, 1993, 1994.
11 *  On-Line Applications Research Corporation (OAR).
12 *  All rights assigned to U.S. Government, 1994.
13 *
14 *  This material may be reproduced by or for the U.S. Government pursuant
15 *  to the copyright license under the clause at DFARS 252.227-7013.  This
16 *  notice must appear in all copies of this file and its derivatives.
17 *
18 *  $Id$
19 */
20
21#include <stdlib.h>
22
23#include <rtems.h>
24#include <bsp.h>
25#include <clockdrv.h>
26#include <z8036.h>
27
28#define MICRVAL     0xe2            /* disable lower chain, no vec */
29                                    /*  set right justified addr */
30                                    /*  and master int enable */
31#define MCCRVAL     0xc4            /* enable T1 and port B */
32                                    /*   timers independent */
33#define MS_COUNT    0x07d0          /* T1's countdown constant (1 ms) */
34#define T1MSRVAL    0x80            /* T1 cont. cycle/pulse output */
35#define T1CSRVAL    0xc6            /* enable interrupt, allow and */
36                                    /*   and trigger countdown */
37
38rtems_unsigned32 Clock_isrs;        /* ISRs until next tick */
39volatile rtems_unsigned32 Clock_driver_ticks;
40                                    /* ticks since initialization */
41rtems_isr_entry  Old_ticker;
42
43rtems_device_driver Clock_initialize(
44  rtems_device_major_number major,
45  rtems_device_minor_number minor,
46  void *pargp,
47  rtems_id tid,
48  rtems_unsigned32 *rval
49)
50{
51  Install_clock( Clock_isr );
52}
53
54void ReInstall_clock(
55  rtems_isr_entry clock_isr
56)
57{
58  rtems_unsigned32 isrlevel;
59
60  rtems_interrupt_disable( isrlevel );
61   (void) set_vector( clock_isr, 66, 1 );
62  rtems_interrupt_enable( isrlevel );
63}
64
65void Install_clock(
66  rtems_isr_entry clock_isr
67)
68{
69  volatile struct z8036_map *timer;
70
71  Clock_driver_ticks = 0;
72  Clock_isrs = BSP_Configuration.microseconds_per_tick / 1000;
73
74  if ( BSP_Configuration.ticks_per_timeslice ) {
75    Old_ticker = (rtems_isr_entry) set_vector( clock_isr, 66, 1 );
76    timer = (struct z8036_map *) 0xfffb0000;
77    timer->MASTER_INTR        = MICRVAL;
78    timer->CT1_MODE_SPEC      = T1MSRVAL;
79
80  *((rtems_unsigned16 *)0xfffb0016) = MS_COUNT;  /* write countdown value */
81/*
82    timer->CT1_TIME_CONST_MSB = (MS_COUNT >> 8);
83    timer->CT1_TIME_CONST_LSB = (MS_COUNT &  0xff);
84*/
85    timer->MASTER_CFG         = MCCRVAL;
86    timer->CT1_CMD_STATUS     = T1CSRVAL;
87
88/*
89 * Enable interrupt via VME interrupt mask register
90 */
91    (*(rtems_unsigned8 *)0xfffb0038) &= 0xfd;
92
93
94    atexit( Clock_exit );
95  }
96
97}
98
99void Clock_exit( void )
100{
101  volatile struct z8036_map *timer;
102
103  if ( BSP_Configuration.ticks_per_timeslice ) {
104    timer = (struct z8036_map *) 0xfffb0000;
105    timer->MASTER_INTR        = 0x62;
106    timer->CT1_MODE_SPEC      = 0x00;
107    timer->MASTER_CFG         = 0xf4;
108    timer->CT1_CMD_STATUS     = 0x00;
109    /* do not restore old vector */
110  }
111}
Note: See TracBrowser for help on using the repository browser.