source: rtems/c/src/lib/libbsp/m68k/efi68k/clock/ckinit.c @ 486c329

4.104.114.84.95
Last change on this file since 486c329 was 486c329, checked in by Joel Sherrill <joel.sherrill@…>, on 09/20/95 at 15:05:19

Actually adding efi bsp's from John Gwynne after forgetting to
commit them.

  • Property mode set to 100644
File size: 3.5 KB
Line 
1/*  Clock_init()
2 *
3 *  This routine initializes the DP8570A periodic interrupt on the
4 *  efi68k board. 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#include <bsp.h>
23#include <rtems/libio.h>
24
25#define CLOCK_VECTOR  (TCP_ISR_LEVEL+24)
26
27rtems_unsigned32 Clock_isrs;        /* ISRs until next tick */
28volatile rtems_unsigned32 Clock_driver_ticks;
29                                    /* ticks since initialization */
30rtems_isr_entry  Old_ticker;
31
32void Clock_exit( void );
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
42void per_interrupt(void)
43{
44  Clock_driver_ticks += 1;
45
46  *MSR = PER;
47
48  if ( Clock_isrs == 1 ) {
49    rtems_clock_tick();
50    Clock_isrs = BSP_Configuration.microseconds_per_tick / 1000;
51  }
52  else
53    Clock_isrs -= 1;
54}
55
56rtems_isr Clock_isr(
57  rtems_vector_number vector
58)
59{
60  unsigned char entry_msr, msr;
61
62  entry_msr = *MSR;
63  *MSR = 0;
64  while ( (msr=*MSR) & INT )
65    /* test enabled interrupt bits */
66    if (msr & PER)
67      per_interrupt();
68    else if (msr & T0) {
69      *MSR = T0;                /* reset interrupt */
70      Timer_interrupts++;       /* inc wrap around counter */
71    }
72    else     
73      /* there has been an error if we reach this point */
74      /* default action: reset all the interrupts */
75      *MSR = ( PER | AL | T0 | T1 );
76  *MSR = entry_msr & (RS | PS);
77}
78
79void Install_clock(
80  rtems_isr_entry clock_isr
81)
82{
83  Clock_driver_ticks = 0;
84  Clock_isrs = BSP_Configuration.microseconds_per_tick / 1000;
85
86  if ( BSP_Configuration.ticks_per_timeslice ) {
87    Old_ticker = (rtems_isr_entry) set_vector( clock_isr, CLOCK_VECTOR, 1 );
88
89    *MSR = RS;                  /* enable 1mS interrupts */
90    *ICR0 |= OME;
91
92    atexit( Clock_exit );
93  }
94}
95
96void ReInstall_clock(
97  rtems_isr_entry clock_isr
98)
99{
100  rtems_unsigned32 isrlevel = 0 ;
101
102  rtems_interrupt_disable( isrlevel );
103   (void) set_vector( clock_isr, CLOCK_VECTOR, 1 );
104  rtems_interrupt_enable( isrlevel );
105}
106
107void Clock_exit( void )
108{
109
110  if ( BSP_Configuration.ticks_per_timeslice ) {
111
112    /* shutdown periodic interrupt */
113    *MSR = RS;
114    *ICR0 &= 0xc0;
115    /* do not restore old vector */
116
117  }
118}
119
120rtems_device_driver Clock_initialize(
121  rtems_device_major_number major,
122  rtems_device_minor_number minor,
123  void *pargp
124)
125{
126  Install_clock( Clock_isr );
127 
128  /*
129   * make major/minor avail to others such as shared memory driver
130   */
131 
132  rtems_clock_major = major;
133  rtems_clock_minor = minor;
134 
135  return RTEMS_SUCCESSFUL;
136}
137 
138rtems_device_driver Clock_control(
139  rtems_device_major_number major,
140  rtems_device_minor_number minor,
141  void *pargp
142)
143{
144    rtems_libio_ioctl_args_t *args = pargp;
145 
146    if (args == 0)
147        goto done;
148 
149    /*
150     * This is hokey, but until we get a defined interface
151     * to do this, it will just be this simple...
152     */
153 
154    if (args->command == rtems_build_name('I', 'S', 'R', ' '))
155    {
156        Clock_isr(CLOCK_VECTOR);
157    }
158    else if (args->command == rtems_build_name('N', 'E', 'W', ' '))
159    {
160        ReInstall_clock(args->buffer);
161    }
162 
163done:
164    return RTEMS_SUCCESSFUL;
165}
Note: See TracBrowser for help on using the repository browser.