1 | /* set_vector |
---|
2 | * |
---|
3 | * This routine attempts to perform all "generic" interrupt initialization |
---|
4 | * for the specified XINT line. It is specific to the Cyclone CVME961 in |
---|
5 | * that it knows which interrupts are initialized by the monitor, the |
---|
6 | * characteristics of XINT5 (VIC068 clock tick), and that it assumes the |
---|
7 | * i960 is processing interrupts in dedicated mode. It attempts to map |
---|
8 | * XINTs to interrupt vectors in a fairly straght forward way. |
---|
9 | * |
---|
10 | * XINT USE VECTOR INTR TBL INDEX TRIGGERED |
---|
11 | * ==== ============= ====== ============== ========= |
---|
12 | * 0 VMEbus ERROR 0x02 0x03 EDGE |
---|
13 | * 1 DRAM PARITY 0x12 0x13 EDGE |
---|
14 | * 2 Z8530 0x22 0x23 LEVEL |
---|
15 | * 3 SQUALL 0 0x52 0x53 ---- |
---|
16 | * 4 Z8536 (SQSIO4) 0x72 0x73 LEVEL |
---|
17 | * 5 TICK 0x32 0x33 EDGE |
---|
18 | * 6 VIC068 0x62 0x63 LEVEL |
---|
19 | * 7 UNUSED 0x42 0x43 LEVEL |
---|
20 | * |
---|
21 | * The interrupt handler is installed in both the cached and memory |
---|
22 | * resident interrupt tables. The appropriate IMAP register is updated to |
---|
23 | * reflect the vector selected by this routine. Global interrupts are |
---|
24 | * enabled. If XINT5 is being installed, places it in trigger mode. |
---|
25 | * Finally, set_vector_support() is invoked to install the new IMAP and |
---|
26 | * ICON, unmask the XINT in IMASK, and lower the i960's interrupt |
---|
27 | * level to 0. |
---|
28 | * |
---|
29 | * INPUT: |
---|
30 | * func - interrupt handler entry point |
---|
31 | * xint - external interrupt line |
---|
32 | * type - 0 indicates raw hardware connect |
---|
33 | * 1 indicates RTEMS interrupt connect |
---|
34 | * |
---|
35 | * RETURNS: |
---|
36 | * address of previous interrupt handler |
---|
37 | * |
---|
38 | * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994. |
---|
39 | * On-Line Applications Research Corporation (OAR). |
---|
40 | * All rights assigned to U.S. Government, 1994. |
---|
41 | * |
---|
42 | * This material may be reproduced by or for the U.S. Government pursuant |
---|
43 | * to the copyright license under the clause at DFARS 252.227-7013. This |
---|
44 | * notice must appear in all copies of this file and its derivatives. |
---|
45 | * |
---|
46 | * $Id$ |
---|
47 | */ |
---|
48 | |
---|
49 | #include <rtems.h> |
---|
50 | #include <bsp.h> |
---|
51 | |
---|
52 | #include <stdio.h> |
---|
53 | |
---|
54 | void print_prcb(); |
---|
55 | void print_intr_info(); |
---|
56 | void print_ipnd_imsk(); |
---|
57 | |
---|
58 | unsigned int Xint_2_Group_Map[8] = { 0, 1, 2, 5, 7, 3, 6, 4 }; |
---|
59 | |
---|
60 | i960_isr_entry set_vector( /* returns old vector */ |
---|
61 | rtems_isr_entry func, /* isr routine */ |
---|
62 | unsigned int xint, /* XINT number */ |
---|
63 | unsigned int type /* RTEMS or RAW */ |
---|
64 | ) |
---|
65 | { |
---|
66 | i960_isr_entry *intr_tbl, *cached_intr_tbl; |
---|
67 | i960_isr_entry saved_intr; |
---|
68 | unsigned int vector, group, nibble; |
---|
69 | unsigned int *imap; |
---|
70 | |
---|
71 | if ( xint > 7 ) |
---|
72 | exit( 0x80 ); |
---|
73 | |
---|
74 | cached_intr_tbl = (i960_isr_entry *) 0; |
---|
75 | intr_tbl = (i960_isr_entry *) Prcb->intr_tbl; |
---|
76 | group = Xint_2_Group_Map[xint]; /* remap XINT to group */ |
---|
77 | vector = (group << 4) + 2; /* direct vector num */ |
---|
78 | |
---|
79 | if ( type ) |
---|
80 | rtems_interrupt_catch( func, vector, (rtems_isr_entry *) &saved_intr ); |
---|
81 | else { |
---|
82 | saved_intr = (i960_isr_entry) intr_tbl[ vector ]; |
---|
83 | /* return old vector */ |
---|
84 | intr_tbl[ vector + 1 ] = /* normal vector table */ |
---|
85 | cached_intr_tbl[ group ] = (i960_isr_entry) func; /* cached vector */ |
---|
86 | } |
---|
87 | |
---|
88 | if ( xint <= 3 ) imap = &Ctl_tbl->imap0; /* updating IMAP0 */ |
---|
89 | else imap = &Ctl_tbl->imap1; /* updating IMAP1 */ |
---|
90 | nibble = (xint % 4) * 4; |
---|
91 | *imap &= ~(0xf << nibble); |
---|
92 | *imap |= group << nibble; |
---|
93 | |
---|
94 | Ctl_tbl->icon &= ~0x00000400; /* enable global interrupts */ |
---|
95 | Ctl_tbl->icon |= 0x00004000; /* fast sampling mode */ |
---|
96 | switch ( xint ) { |
---|
97 | case 0: Ctl_tbl->icon |= 0x00000004; break; |
---|
98 | case 1: Ctl_tbl->icon |= 0x00000008; break; |
---|
99 | case 2: Ctl_tbl->icon &= ~0x00000010; break; |
---|
100 | case 4: Ctl_tbl->icon &= ~0x00000040; break; |
---|
101 | case 5: Ctl_tbl->icon |= 0x00000080; break; |
---|
102 | case 6: Ctl_tbl->icon &= ~0x00000100; break; |
---|
103 | default: exit( 0x81 ); break; /* unsupported */ |
---|
104 | } |
---|
105 | |
---|
106 | if ( xint == 4 ) { /* reprogram MCON for SQSIO4 */ |
---|
107 | Ctl_tbl->mcon12 = 0x00002012; /* MCON12 - 0xCxxxxxxx */ |
---|
108 | Ctl_tbl->mcon13 = 0x00000000; /* MCON13 - 0xDxxxxxxx */ |
---|
109 | i960_reload_ctl_group( 5 ); /* update MCON12-MCON15 */ |
---|
110 | } |
---|
111 | |
---|
112 | i960_unmask_intr( xint ); /* update IMSK */ |
---|
113 | i960_reload_ctl_group( 1 ); /* update IMAP?/ICON */ |
---|
114 | return( saved_intr ); /* return old vector */ |
---|
115 | } |
---|
116 | |
---|
117 | void print_prcb() |
---|
118 | { |
---|
119 | printf( "fault_table =0x%p\n", Prcb->fault_tbl ); |
---|
120 | printf( "control_tbl =0x%p\n", Prcb->control_tbl ); |
---|
121 | printf( "AC mask ov =0x%x\n", Prcb->initial_ac ); |
---|
122 | printf( "fltconfig =0x%x\n", Prcb->fault_config ); |
---|
123 | printf( "intr tbl =0x%p\n", Prcb->intr_tbl ); |
---|
124 | printf( "systable =0x%p\n", Prcb->sys_proc_tbl ); |
---|
125 | printf( "reserved =0x%x\n", Prcb->reserved ); |
---|
126 | printf( "isr stk =0x%p\n", Prcb->intr_stack ); |
---|
127 | printf( "ins cache =0x%x\n", Prcb->ins_cache_cfg ); |
---|
128 | printf( "reg cache =0x%x\n", Prcb->reg_cache_cfg ); |
---|
129 | } |
---|
130 | |
---|
131 | void print_intr_info() |
---|
132 | { |
---|
133 | printf( "prcb =0x%p\n", Prcb ); |
---|
134 | printf( "ctl_tbl =0x%p\n", Ctl_tbl ); |
---|
135 | printf( "intr_tbl=0x%p\n", Prcb->intr_tbl ); |
---|
136 | printf( "IMAP0 = 0x%x\n", Ctl_tbl->imap0 ); |
---|
137 | printf( "IMAP1 = 0x%x\n", Ctl_tbl->imap1 ); |
---|
138 | print_ipnd_imsk(); |
---|
139 | } |
---|
140 | |
---|
141 | void print_ipnd_imsk() |
---|
142 | { |
---|
143 | printf(" IPEND = 0x%x\n", i960_pend_intrs() ); |
---|
144 | printf(" IMASK = 0x%x\n", i960_mask_intrs() ); |
---|
145 | } |
---|