source: rtems/c/src/lib/libbsp/m68k/efi332/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 Sep 20, 1995 at 3:05:19 PM

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

  • Property mode set to 100644
File size: 3.2 KB
Line 
1/*  Clock_init()
2 *
3 *  This routine initailizes the periodic interrupt timer on
4 *  the Motorola 68332.
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#include <efi332.h>
25
26#define CLOCK_VECTOR   EFI_PIV
27
28rtems_unsigned32 Clock_isrs;        /* ISRs until next tick */
29volatile rtems_unsigned32 Clock_driver_ticks;
30                                    /* ticks since initialization */
31rtems_isr_entry  Old_ticker;
32
33void Clock_exit( void );
34 
35/*
36 * These are set by clock driver during its init
37 */
38 
39rtems_device_major_number rtems_clock_major = ~0;
40rtems_device_minor_number rtems_clock_minor;
41 
42rtems_isr Clock_isr(rtems_vector_number vector)
43{
44  Clock_driver_ticks += 1;
45
46  if ( Clock_isrs == 1 ) {
47    rtems_clock_tick();
48    Clock_isrs = BSP_Configuration.microseconds_per_tick / 1000;
49  }
50  else
51    Clock_isrs -= 1;
52}
53
54void Install_clock(
55  rtems_isr_entry clock_isr
56)
57{
58  Clock_driver_ticks = 0;
59  Clock_isrs = BSP_Configuration.microseconds_per_tick / 1000;
60
61  if ( BSP_Configuration.ticks_per_timeslice ) {
62    Old_ticker = (rtems_isr_entry) set_vector( clock_isr, CLOCK_VECTOR, 1 );
63
64    /* enable 1mS interrupts */
65    *PITR = (unsigned short int)( SAM(0x09,0,PITM) );/* load counter */
66    *PICR = (unsigned short int)                     /* enable interrupt */
67      ( SAM(ISRL_PIT,8,PIRQL) | SAM(CLOCK_VECTOR,0,PIV) );
68   
69    atexit( Clock_exit );
70  }
71}
72
73void ReInstall_clock(
74  rtems_isr_entry clock_isr
75)
76{
77  rtems_unsigned32 isrlevel = 0 ;
78
79  rtems_interrupt_disable( isrlevel );
80   (void) set_vector( clock_isr, CLOCK_VECTOR, 1 );
81  rtems_interrupt_enable( isrlevel );
82}
83
84void Clock_exit( void )
85{
86
87  if ( BSP_Configuration.ticks_per_timeslice ) {
88
89    /* shutdown the periodic interrupt */
90    *PICR = (unsigned short int)
91      ( SAM(0,8,PIRQL) | SAM(CLOCK_VECTOR,0,PIV) );
92    /*     ^^ zero disables interrupt */
93
94    /* do not restore old vector */
95
96  }
97}
98
99rtems_device_driver Clock_initialize(
100  rtems_device_major_number major,
101  rtems_device_minor_number minor,
102  void *pargp
103)
104{
105  Install_clock( Clock_isr );
106 
107  /*
108   * make major/minor avail to others such as shared memory driver
109   */
110 
111  rtems_clock_major = major;
112  rtems_clock_minor = minor;
113 
114  return RTEMS_SUCCESSFUL;
115}
116 
117rtems_device_driver Clock_control(
118  rtems_device_major_number major,
119  rtems_device_minor_number minor,
120  void *pargp
121)
122{
123    rtems_libio_ioctl_args_t *args = pargp;
124 
125    if (args == 0)
126        goto done;
127 
128    /*
129     * This is hokey, but until we get a defined interface
130     * to do this, it will just be this simple...
131     */
132 
133    if (args->command == rtems_build_name('I', 'S', 'R', ' '))
134    {
135        Clock_isr(CLOCK_VECTOR);
136    }
137    else if (args->command == rtems_build_name('N', 'E', 'W', ' '))
138    {
139        ReInstall_clock(args->buffer);
140    }
141 
142done:
143    return RTEMS_SUCCESSFUL;
144}
145 
Note: See TracBrowser for help on using the repository browser.