source: rtems/c/src/lib/libbsp/m68k/mrm332/clock/ckinit.c @ 34ef6c7

4.104.114.95
Last change on this file since 34ef6c7 was 34ef6c7, checked in by Joel Sherrill <joel.sherrill@…>, on Sep 5, 2008 at 10:06:51 PM

2008-09-05 Joel Sherrill <joel.sherrill@…>

  • clock/ckinit.c: The Shared Memory Driver no longer requires the special IOCTL in Clock_control. This was a hack which has existed since before the Classic API Timer Manager was implemented. All implementations of and references to Clock_control were removed.
  • Property mode set to 100644
File size: 2.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-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.rtems.com/license/LICENSE.
16 *
17 *  $Id$
18 */
19
20#include <stdlib.h>
21#include <bsp.h>
22#include <rtems/libio.h>
23#include <mrm332.h>
24
25#define CLOCK_VECTOR   MRM_PIV
26
27uint32_t         Clock_isrs;        /* ISRs until next tick */
28volatile uint32_t         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
41rtems_isr Clock_isr(rtems_vector_number vector)
42{
43  Clock_driver_ticks += 1;
44
45  if ( Clock_isrs == 1 ) {
46    rtems_clock_tick();
47    Clock_isrs = rtems_configuration_get_microseconds_per_tick() / 1000;
48  }
49  else
50    Clock_isrs -= 1;
51}
52
53void Install_clock(
54  rtems_isr_entry clock_isr
55)
56{
57  Clock_driver_ticks = 0;
58  Clock_isrs = rtems_configuration_get_microseconds_per_tick() / 1000;
59
60  Old_ticker = (rtems_isr_entry) set_vector( clock_isr, CLOCK_VECTOR, 1 );
61
62  /* enable 1mS interrupts */
63  *PITR = (unsigned short int)( SAM(0x09,0,PITM) );/* load counter */
64  *PICR = (unsigned short int)                     /* enable interrupt */
65    ( SAM(ISRL_PIT,8,PIRQL) | SAM(CLOCK_VECTOR,0,PIV) );
66
67  atexit( Clock_exit );
68}
69
70void Clock_exit( void )
71{
72  /* shutdown the periodic interrupt */
73  *PICR = (unsigned short int)
74    ( SAM(0,8,PIRQL) | SAM(CLOCK_VECTOR,0,PIV) );
75  /*     ^^ zero disables interrupt */
76
77  /* do not restore old vector */
78}
79
80rtems_device_driver Clock_initialize(
81  rtems_device_major_number major,
82  rtems_device_minor_number minor,
83  void *pargp
84)
85{
86  Install_clock( Clock_isr );
87
88  /*
89   * make major/minor avail to others such as shared memory driver
90   */
91
92  rtems_clock_major = major;
93  rtems_clock_minor = minor;
94
95  return RTEMS_SUCCESSFUL;
96}
Note: See TracBrowser for help on using the repository browser.