source: rtems/c/src/lib/libbsp/no_cpu/no_bsp/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: 4.4 KB
Line 
1/*  ckinit.c
2 *
3 *  This file provides a template for the clock device driver initialization.
4 *
5 *  COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
6 *  On-Line Applications Research Corporation (OAR).
7 *  All rights assigned to U.S. Government, 1994.
8 *
9 *  This material may be reproduced by or for the U.S. Government pursuant
10 *  to the copyright license under the clause at DFARS 252.227-7013.  This
11 *  notice must appear in all copies of this file and its derivatives.
12 *
13 *  $Id$
14 */
15
16#include <stdlib.h>
17
18#include <rtems.h>
19#include <rtems/libio.h>
20#include <bsp.h>
21
22void Clock_exit( void );
23rtems_isr Clock_isr( rtems_vector_number vector );
24
25
26/*
27 *  The interrupt vector number associated with the clock tick device
28 *  driver.
29 */
30
31#define CLOCK_VECTOR    4
32
33/*
34 *  Clock_driver_ticks is a monotonically increasing counter of the
35 *  number of clock ticks since the driver was initialized.
36 */
37
38volatile rtems_unsigned32 Clock_driver_ticks;
39
40/*
41 *  Clock_isrs is the number of clock ISRs until the next invocation of
42 *  the RTEMS clock tick routine.  The clock tick device driver
43 *  gets an interrupt once a millisecond and counts down until the
44 *  length of time between the user configured microseconds per tick
45 *  has passed.
46 */
47
48rtems_unsigned32 Clock_isrs;              /* ISRs until next tick */
49
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 *  The previous ISR on this clock tick interrupt vector.
59 */
60
61rtems_isr_entry  Old_ticker;
62
63void Clock_exit( void );
64
65
66/*
67 *  Isr Handler
68 */
69
70rtems_isr Clock_isr(
71  rtems_vector_number vector
72)
73{
74/*
75 * bump the number of clock driver ticks since initialization
76 *
77 * determine if it is time to announce the passing of tick as configured
78 * to RTEMS through the rtems_clock_tick directive
79 *
80 * perform any timer dependent tasks
81 */
82}
83
84/*
85 *  Install_clock
86 *
87 *  Install a clock tick handler and reprograms the chip.  This
88 *  is used to initially establish the clock tick.
89 */
90
91void Install_clock(
92  rtems_isr_entry clock_isr
93)
94{
95  /*
96   *  Initialize the clock tick device driver variables
97   */
98
99  Clock_driver_ticks = 0;
100  Clock_isrs = BSP_Configuration.microseconds_per_tick / 1000;
101
102  /*
103   *  If ticks_per_timeslice is configured as non-zero, then the user
104   *  wants a clock tick.
105   */
106
107  if ( BSP_Configuration.ticks_per_timeslice ) {
108    Old_ticker = ( rtems_isr_entry ) set_vector( clock_isr, CLOCK_VECTOR, 1 );
109    /*
110     *  Hardware specific initialize goes here
111     */
112
113    /* XXX */
114  }
115
116  /*
117   *  Schedule the clock cleanup routine to execute if the application exits.
118   */
119
120  atexit( Clock_exit );
121}
122
123/*
124 *  Reinstall_clock
125 *
126 *  Install a clock tick handler without reprogramming the chip.  This
127 *  is used by the polling shared memory device driver.
128 */
129
130void ReInstall_clock(
131  rtems_isr_entry clock_isr
132)
133{
134  rtems_unsigned32 isrlevel = 0;
135
136  /*
137   *  Disable interrupts and install the clock ISR vector using the
138   *  BSP dependent set_vector routine.  In the below example, the clock
139   *  ISR is on vector 4 and is an RTEMS interrupt.
140   */
141
142  rtems_interrupt_disable( isrlevel );
143   (void) set_vector( clock_isr, CLOCK_VECTOR, 1 );
144  rtems_interrupt_enable( isrlevel );
145}
146
147/*
148 *  Clean up before the application exits
149 */
150
151void Clock_exit( void )
152{
153  if ( BSP_Configuration.ticks_per_timeslice ) {
154
155    /* XXX: turn off the timer interrupts */
156
157    /* XXX: If necessary, restore the old vector */
158  }
159}
160
161/*
162 *  Clock_initialize
163 *
164 *  Device driver entry point for clock tick driver initialization.
165 */
166
167rtems_device_driver Clock_initialize(
168  rtems_device_major_number major,
169  rtems_device_minor_number minor,
170  void *pargp
171)
172{
173  Install_clock( Clock_isr );
174 
175  /*
176   * make major/minor avail to others such as shared memory driver
177   */
178 
179  rtems_clock_major = major;
180  rtems_clock_minor = minor;
181 
182  return RTEMS_SUCCESSFUL;
183}
184
185rtems_device_driver Clock_control(
186  rtems_device_major_number major,
187  rtems_device_minor_number minor,
188  void *pargp
189)
190{
191    rtems_libio_ioctl_args_t *args = pargp;
192 
193    if (args == 0)
194        goto done;
195 
196    /*
197     * This is hokey, but until we get a defined interface
198     * to do this, it will just be this simple...
199     */
200 
201    if (args->command == rtems_build_name('I', 'S', 'R', ' '))
202    {
203        Clock_isr(CLOCK_VECTOR);
204    }
205    else if (args->command == rtems_build_name('N', 'E', 'W', ' '))
206    {
207        ReInstall_clock(args->buffer);
208    }
209 
210done:
211    return RTEMS_SUCCESSFUL;
212}
Note: See TracBrowser for help on using the repository browser.