1 | /* Clock_initialize |
---|
2 | * |
---|
3 | * This routine initializes the Motorola MFP 68901 on the |
---|
4 | * FORCE CPU386 board. 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 <bsp.h> |
---|
22 | #include <clockdrv.h> |
---|
23 | #include <stdlib.h> |
---|
24 | |
---|
25 | volatile rtems_unsigned32 Clock_driver_ticks; |
---|
26 | rtems_unsigned32 Clock_isrs; /* ISRs until next tick */ |
---|
27 | rtems_isr_entry Old_ticker; |
---|
28 | |
---|
29 | rtems_device_driver Clock_initialize( |
---|
30 | rtems_device_major_number major, |
---|
31 | rtems_device_minor_number minor, |
---|
32 | void *pargp, |
---|
33 | rtems_id tid, |
---|
34 | rtems_unsigned32 *rval |
---|
35 | ) |
---|
36 | { |
---|
37 | Install_clock( Clock_isr ); |
---|
38 | } |
---|
39 | |
---|
40 | void ReInstall_clock( |
---|
41 | rtems_isr_entry clock_isr |
---|
42 | ) |
---|
43 | { |
---|
44 | rtems_unsigned32 isrlevel = 0; |
---|
45 | |
---|
46 | rtems_interrupt_disable( isrlevel ); |
---|
47 | (void) set_vector( clock_isr, 0x38, 1 ); |
---|
48 | rtems_interrupt_enable( isrlevel ); |
---|
49 | } |
---|
50 | |
---|
51 | void Install_clock( |
---|
52 | rtems_isr_entry clock_isr |
---|
53 | ) |
---|
54 | { |
---|
55 | Clock_driver_ticks = 0; |
---|
56 | Clock_isrs = BSP_Configuration.microseconds_per_tick / 1000; |
---|
57 | |
---|
58 | if ( BSP_Configuration.ticks_per_timeslice ) { |
---|
59 | Old_ticker = ( rtems_isr_entry ) set_vector( clock_isr, 0x38, 1 ); |
---|
60 | outport_byte( TBCR, 0x14 ); /* reset it, delay mode, 50X */ |
---|
61 | outport_byte( TBDR, 0x50 ); /* 1 millisecond */ |
---|
62 | outport_byte( IERA, 0x41 ); /* enable interrupt for B */ |
---|
63 | } |
---|
64 | atexit( Clock_exit ); |
---|
65 | } |
---|
66 | |
---|
67 | void Clock_exit( void ) |
---|
68 | { |
---|
69 | if ( BSP_Configuration.ticks_per_timeslice ) { |
---|
70 | outport_byte( TBCR, 0x00 ); /* initial value */ |
---|
71 | outport_byte( IERA, 0x40 ); /* disable interrupt */ |
---|
72 | /* ??? Is "do not restore old vector" causing problems? */ |
---|
73 | } |
---|
74 | } |
---|
75 | |
---|