source: rtems/c/src/lib/libbsp/i386/i386ex/clock/ckinit.c @ 752cd8f

4.104.114.84.95
Last change on this file since 752cd8f was 752cd8f, checked in by Joel Sherrill <joel.sherrill@…>, on 10/15/96 at 20:57:04

initial version from Erik

  • Property mode set to 100644
File size: 2.3 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#include <clockdrv.h>
25#include <stdlib.h>
26
27volatile rtems_unsigned32 Clock_driver_ticks;
28rtems_unsigned32 Clock_isrs;              /* ISRs until next tick */
29rtems_isr_entry  Old_ticker;
30
31rtems_device_driver Clock_initialize(
32  rtems_device_major_number major,
33  rtems_device_minor_number minor,
34  void *pargp,
35  rtems_id tid,
36  rtems_unsigned32 *rval
37)
38{
39  Install_clock( Clock_isr );
40}
41
42void ReInstall_clock(
43  rtems_isr_entry clock_isr
44)
45{
46  rtems_unsigned32 isrlevel = 0;
47
48  rtems_interrupt_disable( isrlevel );
49   (void) set_vector( clock_isr, 0x20, 1 ); /* was 0x38 */
50  rtems_interrupt_enable( isrlevel );
51}
52
53void Install_clock(
54  rtems_isr_entry clock_isr
55)
56{
57  Clock_driver_ticks = 0;
58  Clock_isrs = BSP_Configuration.microseconds_per_tick / 1000;
59
60  if ( BSP_Configuration.ticks_per_timeslice ) {
61    Old_ticker = ( rtems_isr_entry ) set_vector( clock_isr, 0x20, 1 );
62                                                     /* was 0x38 */
63
64/*  The following is already set up in interns.s ->
65    ( This is test code only... production code will move the
66      TMRCFG stuff here )
67*/
68#define TMR0      0xF040
69#define TMR1      0xF041
70#define TMR2      0xF042
71#define TMRCON    0xF043
72#define TMRCFG    0xF834
73       
74        outport_byte    ( TMRCFG , 0x80 );
75
76        outport_byte    ( TMRCON , 0x34 );
77        outport_byte    ( TMR0   , 0xA8 );
78        outport_byte    ( TMR0   , 0x04 );
79
80        outport_byte    ( TMRCFG , 0x00 );
81  }
82  atexit( Clock_exit );
83}
84
85void Clock_exit( void )
86{
87  if ( BSP_Configuration.ticks_per_timeslice ) {
88/*     outport_byte( TBCR, 0x00 ); */ /* initial value */
89/*    outport_byte( IERA, 0x40 ); */ /* disable interrupt */
90/* ??? Is "do not restore old vector" causing problems? */
91  }
92}
93
Note: See TracBrowser for help on using the repository browser.