source: rtems/c/src/lib/libbsp/m68k/mvme136/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: 4.4 KB
RevLine 
[ac7d5ef0]1/*  Clock_init()
2 *
3 *  This routine initializes the Z80386 1 on the MVME136 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 *  $Id$
19 */
20
21#include <stdlib.h>
22
23#include <bsp.h>
[3a4ae6c]24#include <rtems/libio.h>
[ac7d5ef0]25#include <z8036.h>
26
27#define MICRVAL     0xe2            /* disable lower chain, no vec */
28                                    /*  set right justified addr */
29                                    /*  and master int enable */
30#define MCCRVAL     0xc4            /* enable T1 and port B */
31                                    /*   timers independent */
32#define MS_COUNT    0x07d0          /* T1's countdown constant (1 ms) */
33#define T1MSRVAL    0x80            /* T1 cont. cycle/pulse output */
34#define T1CSRVAL    0xc6            /* enable interrupt, allow and */
35                                    /*   and trigger countdown */
36
[3a4ae6c]37#define TIMER        0xfffb0000
38#define RELOAD       0x24            /* clr IP & IUS,allow countdown */
39 
40#define CLOCK_VECTOR 66
41
[ac7d5ef0]42rtems_unsigned32 Clock_isrs;        /* ISRs until next tick */
[3a4ae6c]43
44volatile rtems_unsigned32 Clock_driver_ticks; /* ticks since initialization */
45
[ac7d5ef0]46rtems_isr_entry  Old_ticker;
47
[3a4ae6c]48void Clock_exit( void );
[ac7d5ef0]49
[3a4ae6c]50/*
51 * These are set by clock driver during its init
52 */
53 
54rtems_device_major_number rtems_clock_major = ~0;
55rtems_device_minor_number rtems_clock_minor;
56 
57/*
58 *  ISR Handler
59 */
60 
61rtems_isr Clock_isr(
62  rtems_vector_number vector
[ac7d5ef0]63)
64{
[3a4ae6c]65  Clock_driver_ticks += 1;
66  ((volatile struct z8036_map *) TIMER)->CT1_CMD_STATUS = RELOAD;
[ac7d5ef0]67
[3a4ae6c]68  if ( Clock_isrs == 1 ) {
69    rtems_clock_tick();
70    Clock_isrs = BSP_Configuration.microseconds_per_tick / 1000;
71  }
72  else
73    Clock_isrs -= 1;
[ac7d5ef0]74}
75
76void Install_clock(
77  rtems_isr_entry clock_isr
78)
79{
80  volatile struct z8036_map *timer;
81
82  Clock_driver_ticks = 0;
83  Clock_isrs = BSP_Configuration.microseconds_per_tick / 1000;
84
85  if ( BSP_Configuration.ticks_per_timeslice ) {
[3a4ae6c]86    Old_ticker = (rtems_isr_entry) set_vector( clock_isr, CLOCK_VECTOR, 1 );
[ac7d5ef0]87    timer = (struct z8036_map *) 0xfffb0000;
88    timer->MASTER_INTR        = MICRVAL;
89    timer->CT1_MODE_SPEC      = T1MSRVAL;
90
[3a4ae6c]91    *((rtems_unsigned16 *)0xfffb0016) = MS_COUNT;  /* write countdown value */
92
93    /*
94     *  timer->CT1_TIME_CONST_MSB = (MS_COUNT >> 8);
95     *  timer->CT1_TIME_CONST_LSB = (MS_COUNT &  0xff);
96     */
97
[ac7d5ef0]98    timer->MASTER_CFG         = MCCRVAL;
99    timer->CT1_CMD_STATUS     = T1CSRVAL;
100
[3a4ae6c]101    /*
102     * Enable interrupt via VME interrupt mask register
103     */
[ac7d5ef0]104    (*(rtems_unsigned8 *)0xfffb0038) &= 0xfd;
105
106    atexit( Clock_exit );
107  }
108
109}
110
[3a4ae6c]111void ReInstall_clock(
112  rtems_isr_entry clock_isr
113)
114{
115  rtems_unsigned32 isrlevel;
116
117  rtems_interrupt_disable( isrlevel );
118   (void) set_vector( clock_isr, CLOCK_VECTOR, 1 );
119  rtems_interrupt_enable( isrlevel );
120}
121
[ac7d5ef0]122void Clock_exit( void )
123{
124  volatile struct z8036_map *timer;
125
126  if ( BSP_Configuration.ticks_per_timeslice ) {
127    timer = (struct z8036_map *) 0xfffb0000;
128    timer->MASTER_INTR        = 0x62;
129    timer->CT1_MODE_SPEC      = 0x00;
130    timer->MASTER_CFG         = 0xf4;
131    timer->CT1_CMD_STATUS     = 0x00;
132    /* do not restore old vector */
133  }
134}
[3a4ae6c]135
136rtems_device_driver Clock_initialize(
137  rtems_device_major_number major,
138  rtems_device_minor_number minor,
139  void *pargp
140)
141{
142  Install_clock( Clock_isr );
143
144  /*
145   * make major/minor avail to others such as shared memory driver
146   */
147
148  rtems_clock_major = major;
149  rtems_clock_minor = minor;
150 
151  return RTEMS_SUCCESSFUL;
152}
153
154rtems_device_driver Clock_control(
155  rtems_device_major_number major,
156  rtems_device_minor_number minor,
157  void *pargp
158)
159{
160    rtems_libio_ioctl_args_t *args = pargp;
161 
162    if (args == 0)
163        goto done;
164 
165    /*
166     * This is hokey, but until we get a defined interface
167     * to do this, it will just be this simple...
168     */
169 
170    if (args->command == rtems_build_name('I', 'S', 'R', ' '))
171    {
172        Clock_isr(CLOCK_VECTOR);
173    }
174    else if (args->command == rtems_build_name('N', 'E', 'W', ' '))
175    {
176        ReInstall_clock(args->buffer);
177    }
178 
179done:
180    return RTEMS_SUCCESSFUL;
181}
182
Note: See TracBrowser for help on using the repository browser.