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

Subversion Repositories openrisc

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

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*  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-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:02 chris Exp $
18
 */
19
 
20
#include <stdlib.h>
21
#include <bsp.h>
22
#include <rtems/libio.h>
23
 
24
#define CLOCK_VECTOR  (TCP_ISR_LEVEL+24)
25
 
26
rtems_unsigned32 Clock_isrs;        /* ISRs until next tick */
27
volatile rtems_unsigned32 Clock_driver_ticks;
28
                                    /* ticks since initialization */
29
rtems_isr_entry  Old_ticker;
30
 
31
void Clock_exit( void );
32
 
33
/*
34
 * These are set by clock driver during its init
35
 */
36
 
37
rtems_device_major_number rtems_clock_major = ~0;
38
rtems_device_minor_number rtems_clock_minor;
39
 
40
 
41
void per_interrupt(void)
42
{
43
  Clock_driver_ticks += 1;
44
 
45
  *MSR = PER;
46
 
47
  if ( Clock_isrs == 1 ) {
48
    rtems_clock_tick();
49
    Clock_isrs = BSP_Configuration.microseconds_per_tick / 1000;
50
  }
51
  else
52
    Clock_isrs -= 1;
53
}
54
 
55
rtems_isr Clock_isr(
56
  rtems_vector_number vector
57
)
58
{
59
  unsigned char entry_msr, msr;
60
 
61
  entry_msr = *MSR;
62
  *MSR = 0;
63
  while ( (msr=*MSR) & INT )
64
    /* test enabled interrupt bits */
65
    if (msr & PER)
66
      per_interrupt();
67
    else if (msr & T0) {
68
      *MSR = T0;                /* reset interrupt */
69
      Timer_interrupts++;       /* inc wrap around counter */
70
    }
71
    else
72
      /* there has been an error if we reach this point */
73
      /* default action: reset all the interrupts */
74
      *MSR = ( PER | AL | T0 | T1 );
75
  *MSR = entry_msr & (RS | PS);
76
}
77
 
78
void Install_clock(
79
  rtems_isr_entry clock_isr
80
)
81
{
82
  Clock_driver_ticks = 0;
83
  Clock_isrs = BSP_Configuration.microseconds_per_tick / 1000;
84
 
85
  Old_ticker = (rtems_isr_entry) set_vector( clock_isr, CLOCK_VECTOR, 1 );
86
 
87
  *MSR = RS;                    /* enable 1mS interrupts */
88
  *ICR0 |= OME;
89
 
90
  atexit( Clock_exit );
91
}
92
 
93
void Clock_exit( void )
94
{
95
  /* shutdown periodic interrupt */
96
  *MSR = RS;
97
  *ICR0 &= 0xc0;
98
  /* do not restore old vector */
99
}
100
 
101
rtems_device_driver Clock_initialize(
102
  rtems_device_major_number major,
103
  rtems_device_minor_number minor,
104
  void *pargp
105
)
106
{
107
  Install_clock( Clock_isr );
108
 
109
  /*
110
   * make major/minor avail to others such as shared memory driver
111
   */
112
 
113
  rtems_clock_major = major;
114
  rtems_clock_minor = minor;
115
 
116
  return RTEMS_SUCCESSFUL;
117
}
118
 
119
rtems_device_driver Clock_control(
120
  rtems_device_major_number major,
121
  rtems_device_minor_number minor,
122
  void *pargp
123
)
124
{
125
    rtems_unsigned32 isrlevel;
126
    rtems_libio_ioctl_args_t *args = pargp;
127
 
128
    if (args == 0)
129
        goto done;
130
 
131
    /*
132
     * This is hokey, but until we get a defined interface
133
     * to do this, it will just be this simple...
134
     */
135
 
136
    if (args->command == rtems_build_name('I', 'S', 'R', ' '))
137
    {
138
        Clock_isr(CLOCK_VECTOR);
139
    }
140
    else if (args->command == rtems_build_name('N', 'E', 'W', ' '))
141
    {
142
      rtems_interrupt_disable( isrlevel );
143
       (void) set_vector( args->buffer, CLOCK_VECTOR, 1 );
144
      rtems_interrupt_enable( isrlevel );
145
    }
146
 
147
done:
148
    return RTEMS_SUCCESSFUL;
149
}

powered by: WebSVN 2.1.0

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