source: rtems/c/src/lib/libbsp/m68k/mvme162/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.8 KB
Line 
1/*  Clock_init()
2 *
3 *  This routine initializes the Tick Timer 2 on the MVME162 board.
4 *  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.rtems.com/license/LICENSE.
16 *
17 *  Modifications of respective RTEMS file: COPYRIGHT (c) 1994.
18 *  EISCAT Scientific Association. M.Savitski
19 *
20 *  This material is a part of the MVME162 Board Support Package
21 *  for the RTEMS executive. Its licensing policies are those of the
22 *  RTEMS above.
23 *
24 *  $Id$
25 */
26
27#include <stdlib.h>
28
29#include <bsp.h>
30#include <rtems/libio.h>
31
32#define MS_COUNT          1000            /* T2's countdown constant (1 ms) */
33#define CLOCK_INT_LEVEL   6               /* T2's interrupt level */
34
35uint32_t         Clock_isrs;                  /* ISRs until next tick */
36volatile uint32_t         Clock_driver_ticks; /* ticks since initialization */
37rtems_isr_entry  Old_ticker;
38
39void Clock_exit( void );
40
41#define CLOCK_VECTOR (VBR0 * 0x10 + 0x9)
42/*
43 * These are set by clock driver during its init
44 */
45
46rtems_device_major_number rtems_clock_major = ~0;
47rtems_device_minor_number rtems_clock_minor;
48
49/*
50 *  ISR Handler
51 */
52
53rtems_isr Clock_isr(rtems_vector_number vector)
54{
55  Clock_driver_ticks += 1;
56  lcsr->timer_cnt_2 = 0;            /* clear counter */
57  lcsr->intr_clear |= 0x02000000;
58
59  if ( Clock_isrs == 1 ) {
60    rtems_clock_tick();
61    Clock_isrs = rtems_configuration_get_microseconds_per_tick() / 1000;
62  }
63  else
64    Clock_isrs -= 1;
65}
66
67void Install_clock(rtems_isr_entry clock_isr )
68{
69
70  Clock_driver_ticks = 0;
71  Clock_isrs = rtems_configuration_get_microseconds_per_tick() / 1000;
72
73  Old_ticker = (rtems_isr_entry) set_vector( clock_isr, CLOCK_VECTOR, 1 );
74  lcsr->vector_base |= MASK_INT;   /* unmask VMEchip2 interrupts */
75  lcsr->to_ctl = 0xE7;             /* prescaler to 1 MHz (see Appendix A1) */
76  lcsr->timer_cmp_2 = MS_COUNT;
77  lcsr->timer_cnt_2 = 0;           /* clear counter */
78  lcsr->board_ctl |= 0x700;        /* increment, reset-on-compare, and */
79                                   /*   clear-overflow-cnt */
80
81  lcsr->intr_level[0] |= CLOCK_INT_LEVEL * 0x10;      /* set int level */
82  lcsr->intr_ena |= 0x02000000;       /* enable tick timer 2 interrupt */
83
84  atexit( Clock_exit );
85}
86
87void Clock_exit( void )
88{
89/* Dummy for now. See other m68k BSP's for code examples */
90}
91
92rtems_device_driver Clock_initialize(
93  rtems_device_major_number major,
94  rtems_device_minor_number minor,
95  void *pargp
96)
97{
98  Install_clock( Clock_isr );
99
100  /*
101   * make major/minor avail to others such as shared memory driver
102   */
103
104  rtems_clock_major = major;
105  rtems_clock_minor = minor;
106
107  return RTEMS_SUCCESSFUL;
108}
Note: See TracBrowser for help on using the repository browser.