source: rtems/c/src/lib/libbsp/m68k/gen68302/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 09/11/95 at 19:35:39

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.9 KB
Line 
1/*  Clock_init()
2 *
3 *  This routine initializes Timer 1 for an MC68302.
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 *  $Id$
19 */
20
21#include <stdlib.h>                     /* for atexit() */
22
23#include <bsp.h>
24#include <rtems/libio.h>
25
26#include "m68302.h"
27
28#define CLOCK_VECTOR 137
29
30#define TMR1_VAL (  RBIT_TMR_RST        /* software reset the timer */\
31                  | RBIT_TMR_ICLK_MASTER16 /* master clock divided by 16 */\
32                  | RBIT_TMR_FRR        /* restart timer after ref reached */\
33                  | RBIT_TMR_ORI)       /* enable interrupt when ref reached */
34#define TRR1_VAL 1000                   /* 1000 ticks @ 16MHz/16
35                                         *    = 1 millisecond tick.
36                                         */
37
38/*
39 *  Clock_driver_ticks is a monotonically increasing counter of the
40 *  number of clock ticks since the driver was initialized.
41 */
42volatile rtems_unsigned32 Clock_driver_ticks;
43
44/*
45 *  Clock_isrs is the number of clock ISRs until the next invocation of
46 *  the RTEMS clock tick routine.  The clock tick device driver
47 *  gets an interrupt once a millisecond and counts down until the
48 *  length of time between the user configured microseconds per tick
49 *  has passed.
50 */
51rtems_unsigned32 Clock_isrs;
52
53void Clock_exit( void );
54 
55/*
56 * These are set by clock driver during its init
57 */
58 
59rtems_device_major_number rtems_clock_major = ~0;
60rtems_device_minor_number rtems_clock_minor;
61
62/*
63 *  ISR Handler
64 */
65
66rtems_isr Clock_isr(
67  rtems_vector_number vector
68)
69{
70  Clock_driver_ticks += 1;
71
72  m302.reg.isr  = RBIT_ISR_TIMER1;      /* clear in-service bit */
73  m302.reg.ter1 = (RBIT_TER_REF | RBIT_TER_CAP); /* clear timer intr request */
74
75  if ( Clock_isrs == 1 ) {
76    rtems_clock_tick();
77    Clock_isrs = BSP_Configuration.microseconds_per_tick / 1000;
78  }
79  else
80    Clock_isrs -= 1;
81}
82
83void Install_clock(
84  rtems_isr_entry clock_isr
85)
86{
87
88  Clock_driver_ticks = 0;
89  Clock_isrs = BSP_Configuration.microseconds_per_tick / 1000;
90
91  if ( BSP_Configuration.ticks_per_timeslice ) {
92/*  set_vector( clock_isr, CLOCK_VECTOR, 1 );*/
93
94    m302.reg.trr1 = TRR1_VAL;           /* set timer reference register */
95    m302.reg.tmr1 = TMR1_VAL;           /* set timer mode register & enable */
96    /*
97     * Enable TIMER1 interrupts only.
98     */
99    m302.reg.imr  = RBIT_IMR_TIMER1;    /* set 68302 int-mask to allow ints */
100
101    atexit( Clock_exit );
102  }
103}
104
105void ReInstall_clock(
106  rtems_isr_entry clock_isr
107)
108{
109  rtems_unsigned32 isrlevel;
110 
111  rtems_interrupt_disable( isrlevel );
112   /* (void) set_vector( clock_isr, CLOCK_VECTOR, 1 ); */
113  rtems_interrupt_enable( isrlevel );
114}
115
116void Clock_exit( void )
117{
118  if ( BSP_Configuration.ticks_per_timeslice ) {
119    /* TODO: figure out what to do here */
120    /* do not restore old vector */
121  }
122}
123
124rtems_device_driver Clock_initialize(
125  rtems_device_major_number major,
126  rtems_device_minor_number minor,
127  void *pargp
128)
129{
130  Install_clock( Clock_isr );
131 
132  /*
133   * make major/minor avail to others such as shared memory driver
134   */
135 
136  rtems_clock_major = major;
137  rtems_clock_minor = minor;
138 
139  return RTEMS_SUCCESSFUL;
140}
141 
142rtems_device_driver Clock_control(
143  rtems_device_major_number major,
144  rtems_device_minor_number minor,
145  void *pargp
146)
147{
148    rtems_libio_ioctl_args_t *args = pargp;
149 
150    if (args == 0)
151        goto done;
152 
153    /*
154     * This is hokey, but until we get a defined interface
155     * to do this, it will just be this simple...
156     */
157 
158    if (args->command == rtems_build_name('I', 'S', 'R', ' '))
159    {
160        Clock_isr( CLOCK_VECTOR);
161    }
162    else if (args->command == rtems_build_name('N', 'E', 'W', ' '))
163    {
164        ReInstall_clock(args->buffer);
165    }
166 
167done:
168    return RTEMS_SUCCESSFUL;
169}
170
Note: See TracBrowser for help on using the repository browser.