1 | /* |
---|
2 | * Motorola MC68020 Dependent Source |
---|
3 | * |
---|
4 | * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994. |
---|
5 | * On-Line Applications Research Corporation (OAR). |
---|
6 | * All rights assigned to U.S. Government, 1994. |
---|
7 | * |
---|
8 | * This material may be reproduced by or for the U.S. Government pursuant |
---|
9 | * to the copyright license under the clause at DFARS 252.227-7013. This |
---|
10 | * notice must appear in all copies of this file and its derivatives. |
---|
11 | * |
---|
12 | * $Id$ |
---|
13 | */ |
---|
14 | |
---|
15 | #include <rtems/system.h> |
---|
16 | #include <rtems/fatal.h> |
---|
17 | #include <rtems/core/isr.h> |
---|
18 | |
---|
19 | /* _CPU_Initialize |
---|
20 | * |
---|
21 | * This routine performs processor dependent initialization. |
---|
22 | * |
---|
23 | * INPUT PARAMETERS: |
---|
24 | * cpu_table - CPU table to initialize |
---|
25 | * thread_dispatch - entry pointer to thread dispatcher |
---|
26 | * |
---|
27 | * OUTPUT PARAMETERS: NONE |
---|
28 | */ |
---|
29 | |
---|
30 | void _CPU_Initialize( |
---|
31 | rtems_cpu_table *cpu_table, |
---|
32 | void (*thread_dispatch) /* ignored on this CPU */ |
---|
33 | ) |
---|
34 | { |
---|
35 | |
---|
36 | _CPU_Table = *cpu_table; |
---|
37 | |
---|
38 | } |
---|
39 | |
---|
40 | /*PAGE |
---|
41 | * |
---|
42 | * _CPU_ISR_Get_level |
---|
43 | */ |
---|
44 | |
---|
45 | unsigned32 _CPU_ISR_Get_level( void ) |
---|
46 | { |
---|
47 | unsigned32 level; |
---|
48 | |
---|
49 | m68k_get_interrupt_level( level ); |
---|
50 | |
---|
51 | return level; |
---|
52 | } |
---|
53 | |
---|
54 | /*PAGE |
---|
55 | * |
---|
56 | * _CPU_ISR_install_raw_handler |
---|
57 | */ |
---|
58 | |
---|
59 | void _CPU_ISR_install_raw_handler( |
---|
60 | unsigned32 vector, |
---|
61 | proc_ptr new_handler, |
---|
62 | proc_ptr *old_handler |
---|
63 | ) |
---|
64 | { |
---|
65 | proc_ptr *interrupt_table = NULL; |
---|
66 | |
---|
67 | m68k_get_vbr( interrupt_table ); |
---|
68 | |
---|
69 | *old_handler = interrupt_table[ vector ]; |
---|
70 | |
---|
71 | interrupt_table[ vector ] = new_handler; |
---|
72 | } |
---|
73 | |
---|
74 | /*PAGE |
---|
75 | * |
---|
76 | * _CPU_ISR_install_vector |
---|
77 | * |
---|
78 | * This kernel routine installs the RTEMS handler for the |
---|
79 | * specified vector. |
---|
80 | * |
---|
81 | * Input parameters: |
---|
82 | * vector - interrupt vector number |
---|
83 | * new_handler - replacement ISR for this vector number |
---|
84 | * old_handler - former ISR for this vector number |
---|
85 | * |
---|
86 | * Output parameters: NONE |
---|
87 | */ |
---|
88 | |
---|
89 | void _CPU_ISR_install_vector( |
---|
90 | unsigned32 vector, |
---|
91 | proc_ptr new_handler, |
---|
92 | proc_ptr *old_handler |
---|
93 | ) |
---|
94 | { |
---|
95 | proc_ptr ignored; |
---|
96 | |
---|
97 | *old_handler = _ISR_Vector_table[ vector ]; |
---|
98 | |
---|
99 | _CPU_ISR_install_raw_handler( vector, _ISR_Handler, &ignored ); |
---|
100 | |
---|
101 | _ISR_Vector_table[ vector ] = new_handler; |
---|
102 | } |
---|
103 | |
---|
104 | |
---|
105 | /*PAGE |
---|
106 | * |
---|
107 | * _CPU_Install_interrupt_stack |
---|
108 | */ |
---|
109 | |
---|
110 | void _CPU_Install_interrupt_stack( void ) |
---|
111 | { |
---|
112 | #if ( M68K_HAS_SEPARATE_STACKS == 1 ) |
---|
113 | void *isp = _CPU_Interrupt_stack_high; |
---|
114 | |
---|
115 | asm volatile ( "movec %0,%%isp" : "=r" (isp) : "0" (isp) ); |
---|
116 | #else |
---|
117 | #warning "FIX ME... HOW DO I INSTALL THE INTERRUPT STACK!!!" |
---|
118 | #endif |
---|
119 | } |
---|
120 | |
---|
121 | #if ( M68K_HAS_BFFFO != 1 ) |
---|
122 | /* |
---|
123 | * Returns log2(x) 0<x<256 |
---|
124 | */ |
---|
125 | const unsigned char __log2table[256] = { |
---|
126 | 0, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, |
---|
127 | 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, |
---|
128 | 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, |
---|
129 | 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, |
---|
130 | 6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, |
---|
131 | 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, |
---|
132 | 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, |
---|
133 | 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, |
---|
134 | 7, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, |
---|
135 | 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, |
---|
136 | 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, |
---|
137 | 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, |
---|
138 | 6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, |
---|
139 | 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, |
---|
140 | 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, |
---|
141 | 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0 |
---|
142 | }; |
---|
143 | #endif |
---|