1 | /* Clock_init() |
---|
2 | * |
---|
3 | * This routine initializes the timer on the VIC chip on the CVME961. |
---|
4 | * 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 <stdlib.h> |
---|
22 | |
---|
23 | #include <rtems.h> |
---|
24 | #include <bsp.h> |
---|
25 | #include <clockdrv.h> |
---|
26 | |
---|
27 | rtems_unsigned32 Clock_isrs; /* ISRs until next tick */ |
---|
28 | i960_isr_entry Old_ticker; |
---|
29 | volatile rtems_unsigned32 Clock_driver_ticks; |
---|
30 | /* ticks since initialization */ |
---|
31 | |
---|
32 | rtems_device_driver Clock_initialize( |
---|
33 | rtems_device_major_number major, |
---|
34 | rtems_device_minor_number minor, |
---|
35 | void *pargp, |
---|
36 | rtems_id id, |
---|
37 | rtems_unsigned32 *rval ) |
---|
38 | { |
---|
39 | Install_clock( Clock_isr ); |
---|
40 | atexit( Clock_exit ); |
---|
41 | } |
---|
42 | |
---|
43 | void ReInstall_clock( |
---|
44 | rtems_isr_entry clock_isr |
---|
45 | ) |
---|
46 | { |
---|
47 | (void) set_vector( clock_isr, 5, 1 ); |
---|
48 | } |
---|
49 | |
---|
50 | void Install_clock( |
---|
51 | rtems_isr_entry clock_isr |
---|
52 | ) |
---|
53 | { |
---|
54 | volatile unsigned char *victimer; |
---|
55 | |
---|
56 | Clock_driver_ticks = 0; |
---|
57 | Clock_isrs = BSP_Configuration.microseconds_per_tick / 1000; |
---|
58 | |
---|
59 | if ( BSP_Configuration.ticks_per_timeslice ) { |
---|
60 | Old_ticker = set_vector( clock_isr, 5, 1 ); |
---|
61 | victimer = (volatile unsigned char *) 0xa00000c3; |
---|
62 | *victimer = 0x12; |
---|
63 | *victimer = 0x92; /* 1000 HZ */ |
---|
64 | } |
---|
65 | } |
---|
66 | |
---|
67 | void Clock_exit() |
---|
68 | { |
---|
69 | unsigned char *victimer; |
---|
70 | |
---|
71 | if ( BSP_Configuration.ticks_per_timeslice ) { |
---|
72 | victimer = (unsigned char *) 0xa00000c3; |
---|
73 | *victimer = 0x12; |
---|
74 | i960_mask_intr( 5 ); |
---|
75 | /* do not restore old vector */ |
---|
76 | } |
---|
77 | } |
---|