source: rtems/c/src/lib/libbsp/m68k/mvme162/clock/ckinit.c @ 3a4ae6c

4.104.114.84.95
Last change on this file since 3a4ae6c was 3a4ae6c, checked in by Joel Sherrill <joel.sherrill@…>, on Sep 11, 1995 at 7:35:39 PM

The word "RTEMS" almost completely removed from the core.

Configuration Table Template file added and all tests
modified to use this. All gvar.h and conftbl.h files
removed from test directories.

Configuration parameter maximum_devices added.

Core semaphore and mutex handlers added and RTEMS API Semaphore
Manager updated to reflect this.

Initialization sequence changed to invoke API specific initialization
routines. Initialization tasks table now owned by RTEMS Tasks Manager.

Added user extension for post-switch.

Utilized user extensions to implement API specific functionality
like signal dispatching.

Added extensions to the System Initialization Thread so that an
API can register a function to be invoked while the system
is being initialized. These are largely equivalent to the
pre-driver and post-driver hooks.

Added the Modules file oar-go32_p5, modified oar-go32, and modified
the file make/custom/go32.cfg to look at an environment varable which
determines what CPU model is being used.

All BSPs updated to reflect named devices and clock driver's IOCTL
used by the Shared Memory Driver. Also merged clock isr into
main file and removed ckisr.c where possible.

Updated spsize to reflect new and moved variables.

Makefiles for the executive source and include files updated to show
break down of files into Core, RTEMS API, and Neither.

Header and inline files installed into subdirectory based on whether
logically in the Core or a part of the RTEMS API.

  • Property mode set to 100644
File size: 3.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, 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 *  Modifications of respective RTEMS file: COPYRIGHT (c) 1994.
19 *  EISCAT Scientific Association. M.Savitski
20 *
21 *  This material is a part of the MVME162 Board Support Package
22 *  for the RTEMS executive. Its licensing policies are those of the
23 *  RTEMS above.
24 *
25 *  $Id$
26 */
27
28#include <stdlib.h>
29
30#include <bsp.h>
31#include <rtems/libio.h>
32
33#define MS_COUNT          1000            /* T2's countdown constant (1 ms) */
34#define CLOCK_INT_LEVEL   6               /* T2's interrupt level */
35
36rtems_unsigned32 Clock_isrs;                  /* ISRs until next tick */
37volatile rtems_unsigned32 Clock_driver_ticks; /* ticks since initialization */
38rtems_isr_entry  Old_ticker;
39
40void Clock_exit( void );
41 
42#define CLOCK_VECTOR (VBR0 * 0x10 + 0x9)
43/*
44 * These are set by clock driver during its init
45 */
46 
47rtems_device_major_number rtems_clock_major = ~0;
48rtems_device_minor_number rtems_clock_minor;
49 
50
51/*
52 *  ISR Handler
53 */
54
55rtems_isr Clock_isr(rtems_vector_number vector)
56{
57  Clock_driver_ticks += 1;
58  lcsr->timer_cnt_2 = 0;            /* clear counter */
59  lcsr->intr_clear |= 0x02000000;
60
61  if ( Clock_isrs == 1 ) {
62    rtems_clock_tick();
63    Clock_isrs = BSP_Configuration.microseconds_per_tick / 1000;
64  }
65  else 
66    Clock_isrs -= 1;
67}
68
69void Install_clock(rtems_isr_entry clock_isr )
70{
71
72  Clock_driver_ticks = 0;
73  Clock_isrs = BSP_Configuration.microseconds_per_tick / 1000;
74
75  if ( BSP_Configuration.ticks_per_timeslice ) {
76    Old_ticker = 
77      (rtems_isr_entry) set_vector( clock_isr, CLOCK_VECTOR, 1 );
78    lcsr->vector_base |= MASK_INT;   /* unmask VMEchip2 interrupts */
79    lcsr->to_ctl = 0xE7;             /* prescaler to 1 MHz (see Appendix A1) */
80    lcsr->timer_cmp_2 = MS_COUNT;
81    lcsr->timer_cnt_2 = 0;           /* clear counter */
82    lcsr->board_ctl |= 0x700;        /* increment, reset-on-compare, and */
83                                     /*   clear-overflow-cnt */
84
85    lcsr->intr_level[0] |= CLOCK_INT_LEVEL * 0x10;      /* set int level */
86    lcsr->intr_ena |= 0x02000000;       /* enable tick timer 2 interrupt */
87
88    atexit( Clock_exit );
89  } 
90}
91
92void ReInstall_clock(rtems_isr_entry clock_isr)
93{
94  rtems_unsigned32 isrlevel;
95
96  rtems_interrupt_disable( isrlevel );
97  (void) set_vector( clock_isr, CLOCK_VECTOR, 1 );
98  rtems_interrupt_enable( isrlevel );
99}
100
101void Clock_exit( void )
102{
103/* Dummy for now. See other m68k BSP's for code examples */
104}
105
106rtems_device_driver Clock_initialize(
107  rtems_device_major_number major,
108  rtems_device_minor_number minor,
109  void *pargp
110)
111{
112  Install_clock( Clock_isr );
113 
114  /*
115   * make major/minor avail to others such as shared memory driver
116   */
117 
118  rtems_clock_major = major;
119  rtems_clock_minor = minor;
120 
121  return RTEMS_SUCCESSFUL;
122}
123 
124rtems_device_driver Clock_control(
125  rtems_device_major_number major,
126  rtems_device_minor_number minor,
127  void *pargp
128)
129{
130    rtems_libio_ioctl_args_t *args = pargp;
131 
132    if (args == 0)
133        goto done;
134 
135    /*
136     * This is hokey, but until we get a defined interface
137     * to do this, it will just be this simple...
138     */
139 
140    if (args->command == rtems_build_name('I', 'S', 'R', ' '))
141    {
142        Clock_isr(CLOCK_VECTOR);
143    }
144    else if (args->command == rtems_build_name('N', 'E', 'W', ' '))
145    {
146        ReInstall_clock(args->buffer);
147    }
148 
149done:
150    return RTEMS_SUCCESSFUL;
151}
152
Note: See TracBrowser for help on using the repository browser.