source: rtems/c/src/lib/libbsp/no_cpu/no_bsp/clock/ckinit.c @ 5072b07

4.104.114.84.95
Last change on this file since 5072b07 was 7f6a24ab, checked in by Joel Sherrill <joel.sherrill@…>, on 08/28/95 at 15:30:29

Added unused priority ceiling parameter to rtems_semaphore_create.

Rearranged code to created thread handler routines to initialize,
start, restart, and "close/delete" a thread.

Made internal threads their own object class. This now uses the
thread support routines for starting and initializing a thread.

Insured deleted tasks are freed to the Inactive pool associated with the
correct Information block.

Added an RTEMS API specific data area to the thread control block.

Beginnings of removing the word "rtems" from the core.

  • Property mode set to 100644
File size: 4.1 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
63/*
64 *  Reinstall_clock
65 *
66 *  Install a clock tick handler without reprogramming the chip.  This
67 *  is used by the polling shared memory device driver.
68 */
69
70void ReInstall_clock(
71  rtems_isr_entry clock_isr
72)
73{
74  rtems_unsigned32 isrlevel = 0;
75
76  /*
77   *  Disable interrupts and install the clock ISR vector using the
78   *  BSP dependent set_vector routine.  In the below example, the clock
79   *  ISR is on vector 4 and is an RTEMS interrupt.
80   */
81
82  rtems_interrupt_disable( isrlevel );
83   (void) set_vector( clock_isr, CLOCK_VECTOR, 1 );
84  rtems_interrupt_enable( isrlevel );
85}
86
87/*
88 *  Install_clock
89 *
90 *  Install a clock tick handler and reprograms the chip.  This
91 *  is used to initially establish the clock tick.
92 */
93
94void Install_clock(
95  rtems_isr_entry clock_isr
96)
97{
98  /*
99   *  Initialize the clock tick device driver variables
100   */
101
102  Clock_driver_ticks = 0;
103  Clock_isrs = BSP_Configuration.microseconds_per_tick / 1000;
104
105  /*
106   *  If ticks_per_timeslice is configured as non-zero, then the user
107   *  wants a clock tick.
108   */
109
110  if ( BSP_Configuration.ticks_per_timeslice ) {
111    Old_ticker = ( rtems_isr_entry ) set_vector( clock_isr, CLOCK_VECTOR, 1 );
112    /*
113     *  Hardware specific initialize goes here
114     */
115
116    /* XXX */
117  }
118
119  /*
120   *  Schedule the clock cleanup routine to execute if the application exits.
121   */
122
123  atexit( Clock_exit );
124}
125
126/*
127 *  Clean up before the application exits
128 */
129
130void Clock_exit( void )
131{
132  if ( BSP_Configuration.ticks_per_timeslice ) {
133
134    /* XXX: turn off the timer interrupts */
135
136    /* XXX: If necessary, restore the old vector */
137  }
138}
139
140/*
141 *  Clock_initialize
142 *
143 *  Device driver entry point for clock tick driver initialization.
144 */
145
146rtems_device_driver Clock_initialize(
147  rtems_device_major_number major,
148  rtems_device_minor_number minor,
149  void *pargp
150)
151{
152  Install_clock((rtems_isr_entry) Clock_isr);
153
154  /*
155   * make major/minor avail to others such as shared memory driver
156   */
157  rtems_clock_major = major;
158    rtems_clock_minor = minor;
159
160  return RTEMS_SUCCESSFUL;
161}
162
163rtems_device_driver Clock_control(
164  rtems_device_major_number major,
165  rtems_device_minor_number minor,
166  void *pargp
167)
168{
169    rtems_libio_ioctl_args_t *args = pargp;
170 
171    if (args == 0)
172        goto done;
173 
174    /*
175     * This is hokey, but until we get a defined interface
176     * to do this, it will just be this simple...
177     */
178 
179    if (args->command == rtems_build_name('I', 'S', 'R', ' '))
180    {
181        Clock_isr(CLOCK_VECTOR);
182    }
183    else if (args->command == rtems_build_name('N', 'E', 'W', ' '))
184    {
185        ReInstall_clock(args->buffer);
186    }
187 
188done:
189    return RTEMS_SUCCESSFUL;
190}
Note: See TracBrowser for help on using the repository browser.