source: rtems/c/src/lib/libbsp/i386/i386ex/clock/ckinit.c @ 39cafa5

4.104.114.84.95
Last change on this file since 39cafa5 was 39cafa5, checked in by Joel Sherrill <joel.sherrill@…>, on 10/15/96 at 21:39:06

updated to format of 3.6.0 clock drivers

  • Property mode set to 100644
File size: 3.2 KB
Line 
1/*  Clock_initialize
2 *
3 *  This routine initializes the Timer/Counter on the Intel
4 *  386ex evaluation board.
5 *
6 *  The tick frequency is 1 millisecond.
7 *
8 *  Input parameters:  NONE
9 *
10 *  Output parameters:  NONE
11 *
12 *  COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
13 *  On-Line Applications Research Corporation (OAR).
14 *  All rights assigned to U.S. Government, 1994.
15 *
16 *  This material may be reproduced by or for the U.S. Government pursuant
17 *  to the copyright license under the clause at DFARS 252.227-7013.  This
18 *  notice must appear in all copies of this file and its derivatives.
19 *
20 *  $Id$
21 */
22
23#include <bsp.h>
24
25#include <rtems/libio.h>
26
27#include <stdlib.h>
28
29#define CLOCK_VECTOR 0x20
30
31rtems_unsigned32 Clock_isrs;              /* ISRs until next tick */
32
33volatile rtems_unsigned32 Clock_driver_ticks;
34
35rtems_isr_entry  Old_ticker;
36
37void Clock_exit( void );
38
39/*
40 * These are set by clock driver during its init
41 */
42 
43rtems_device_major_number rtems_clock_major = ~0;
44rtems_device_major_number rtems_clock_minor = 0;
45
46/*
47 *  This is the ISR handler.
48 */
49
50rtems_isr Clock_isr(
51  rtems_vector_number vector
52)
53{
54  /* enable_tracing(); */
55  Clock_driver_ticks += 1;
56  if ( Clock_isrs == 1 ) {
57    rtems_clock_tick();
58    Clock_isrs = BSP_Configuration.microseconds_per_tick / 1000;
59  }
60  else
61    Clock_isrs -= 1;
62}
63
64void Install_clock(
65  rtems_isr_entry clock_isr
66)
67{
68  Clock_driver_ticks = 0;
69  Clock_isrs = BSP_Configuration.microseconds_per_tick / 1000;
70
71  if ( BSP_Configuration.ticks_per_timeslice ) {
72    Old_ticker = ( rtems_isr_entry ) set_vector( clock_isr, CLOCK_VECTOR, 1 );
73
74/*  The following is already set up in interns.s ->
75    ( This is test code only... production code will move the
76      TMRCFG stuff here )
77*/
78#define TMR0      0xF040
79#define TMR1      0xF041
80#define TMR2      0xF042
81#define TMRCON    0xF043
82#define TMRCFG    0xF834
83       
84        outport_byte    ( TMRCFG , 0x80 );
85
86        outport_byte    ( TMRCON , 0x34 );
87        outport_byte    ( TMR0   , 0xA8 );
88        outport_byte    ( TMR0   , 0x04 );
89
90        outport_byte    ( TMRCFG , 0x00 );
91  }
92  atexit( Clock_exit );
93}
94
95void Clock_exit( void )
96{
97  if ( BSP_Configuration.ticks_per_timeslice ) {
98     /* should do something here */;
99  }
100}
101
102
103rtems_device_driver Clock_initialize(
104  rtems_device_major_number major,
105  rtems_device_minor_number minor,
106  void *pargp
107)
108{
109  Install_clock( Clock_isr );
110
111  /*
112   * make major/minor avail to others such as shared memory driver
113   */
114 
115  rtems_clock_major = major;
116  rtems_clock_minor = minor;
117 
118  return RTEMS_SUCCESSFUL;
119}
120
121rtems_device_driver Clock_control(
122  rtems_device_major_number major,
123  rtems_device_minor_number minor,
124  void *pargp
125)
126{
127    rtems_unsigned32 isrlevel;
128    rtems_libio_ioctl_args_t *args = pargp;
129 
130    if (args == 0)
131        goto done;
132 
133    /*
134     * This is hokey, but until we get a defined interface
135     * to do this, it will just be this simple...
136     */
137 
138    if (args->command == rtems_build_name('I', 'S', 'R', ' '))
139    {
140        Clock_isr(CLOCK_VECTOR);
141    }
142    else if (args->command == rtems_build_name('N', 'E', 'W', ' '))
143    {
144      rtems_interrupt_disable( isrlevel );
145       (void) set_vector( args->buffer, CLOCK_VECTOR, 1 );
146      rtems_interrupt_enable( isrlevel );
147    }
148 
149done:
150    return RTEMS_SUCCESSFUL;
151}
152
Note: See TracBrowser for help on using the repository browser.