1 |
27 |
unneback |
#ifndef CYGONCE_HAL_PCMB_INTR_H
|
2 |
|
|
#define CYGONCE_HAL_PCMB_INTR_H
|
3 |
|
|
|
4 |
|
|
//==========================================================================
|
5 |
|
|
//
|
6 |
|
|
// pcmb_intr.h
|
7 |
|
|
//
|
8 |
|
|
// i386/pc Interrupt and clock support
|
9 |
|
|
//
|
10 |
|
|
//==========================================================================
|
11 |
|
|
//####ECOSGPLCOPYRIGHTBEGIN####
|
12 |
|
|
// -------------------------------------------
|
13 |
|
|
// This file is part of eCos, the Embedded Configurable Operating System.
|
14 |
|
|
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
|
15 |
|
|
//
|
16 |
|
|
// eCos is free software; you can redistribute it and/or modify it under
|
17 |
|
|
// the terms of the GNU General Public License as published by the Free
|
18 |
|
|
// Software Foundation; either version 2 or (at your option) any later version.
|
19 |
|
|
//
|
20 |
|
|
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
|
21 |
|
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
22 |
|
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
23 |
|
|
// for more details.
|
24 |
|
|
//
|
25 |
|
|
// You should have received a copy of the GNU General Public License along
|
26 |
|
|
// with eCos; if not, write to the Free Software Foundation, Inc.,
|
27 |
|
|
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
28 |
|
|
//
|
29 |
|
|
// As a special exception, if other files instantiate templates or use macros
|
30 |
|
|
// or inline functions from this file, or you compile this file and link it
|
31 |
|
|
// with other works to produce a work based on this file, this file does not
|
32 |
|
|
// by itself cause the resulting work to be covered by the GNU General Public
|
33 |
|
|
// License. However the source code for this file must still be made available
|
34 |
|
|
// in accordance with section (3) of the GNU General Public License.
|
35 |
|
|
//
|
36 |
|
|
// This exception does not invalidate any other reasons why a work based on
|
37 |
|
|
// this file might be covered by the GNU General Public License.
|
38 |
|
|
//
|
39 |
|
|
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
|
40 |
|
|
// at http://sources.redhat.com/ecos/ecos-license/
|
41 |
|
|
// -------------------------------------------
|
42 |
|
|
//####ECOSGPLCOPYRIGHTEND####
|
43 |
|
|
//==========================================================================
|
44 |
|
|
//#####DESCRIPTIONBEGIN####
|
45 |
|
|
//
|
46 |
|
|
// Author(s): proven
|
47 |
|
|
// Contributors: proven, jskov, pjo
|
48 |
|
|
// Date: 1999-10-15
|
49 |
|
|
// Purpose: Define Interrupt support
|
50 |
|
|
// Description: The macros defined here provide the HAL APIs for handling
|
51 |
|
|
// interrupts and the clock on a standard PC Motherboard.
|
52 |
|
|
// This file contains info about interrupts and
|
53 |
|
|
// peripherals that are common on all PCs; for example,
|
54 |
|
|
// the clock always activates irq 0 and would therefore
|
55 |
|
|
// be listed here.
|
56 |
|
|
//
|
57 |
|
|
// Usage:
|
58 |
|
|
// #include <cyg/hal/pcmb_intr.h>
|
59 |
|
|
// ...
|
60 |
|
|
//
|
61 |
|
|
//####DESCRIPTIONEND####
|
62 |
|
|
//
|
63 |
|
|
//==========================================================================
|
64 |
|
|
|
65 |
|
|
#include <pkgconf/hal.h>
|
66 |
|
|
#include <pkgconf/hal_i386.h>
|
67 |
|
|
#include <pkgconf/hal_i386_pcmb.h>
|
68 |
|
|
|
69 |
|
|
#include <cyg/infra/cyg_type.h>
|
70 |
|
|
|
71 |
|
|
#include <cyg/hal/plf_intr.h>
|
72 |
|
|
#include <cyg/hal/hal_io.h>
|
73 |
|
|
#include <cyg/hal/hal_smp.h>
|
74 |
|
|
|
75 |
|
|
//--------------------------------------------------------------------------
|
76 |
|
|
// Interrupt vectors.
|
77 |
|
|
|
78 |
|
|
#define CYGNUM_HAL_INTERRUPT_IRQ0 32
|
79 |
|
|
#define CYGNUM_HAL_INTERRUPT_IRQ1 33
|
80 |
|
|
#define CYGNUM_HAL_INTERRUPT_IRQ2 34
|
81 |
|
|
#define CYGNUM_HAL_INTERRUPT_IRQ3 35
|
82 |
|
|
#define CYGNUM_HAL_INTERRUPT_IRQ4 36
|
83 |
|
|
#define CYGNUM_HAL_INTERRUPT_IRQ5 37
|
84 |
|
|
#define CYGNUM_HAL_INTERRUPT_IRQ6 38
|
85 |
|
|
#define CYGNUM_HAL_INTERRUPT_IRQ7 39
|
86 |
|
|
#define CYGNUM_HAL_INTERRUPT_IRQ8 40
|
87 |
|
|
#define CYGNUM_HAL_INTERRUPT_IRQ9 41
|
88 |
|
|
#define CYGNUM_HAL_INTERRUPT_IRQ10 42
|
89 |
|
|
#define CYGNUM_HAL_INTERRUPT_IRQ11 43
|
90 |
|
|
#define CYGNUM_HAL_INTERRUPT_IRQ12 44
|
91 |
|
|
#define CYGNUM_HAL_INTERRUPT_IRQ13 45
|
92 |
|
|
#define CYGNUM_HAL_INTERRUPT_IRQ14 46
|
93 |
|
|
#define CYGNUM_HAL_INTERRUPT_IRQ15 47
|
94 |
|
|
|
95 |
|
|
#define CYGNUM_HAL_INTERRUPT_TIMER 32
|
96 |
|
|
#define CYGNUM_HAL_INTERRUPT_KEYBOARD 33
|
97 |
|
|
#define CYGNUM_HAL_INTERRUPT_SLAVE8259 34
|
98 |
|
|
#define CYGNUM_HAL_INTERRUPT_COM2 35
|
99 |
|
|
#define CYGNUM_HAL_INTERRUPT_COM1 36
|
100 |
|
|
#define CYGNUM_HAL_INTERRUPT_LPT2 37
|
101 |
|
|
#define CYGNUM_HAL_INTERRUPT_FDD 38
|
102 |
|
|
#define CYGNUM_HAL_INTERRUPT_LPT1 39
|
103 |
|
|
#define CYGNUM_HAL_INTERRUPT_WALLCLOCK 40
|
104 |
|
|
#define CYGNUM_HAL_INTERRUPT_SLAVE8259REDIR 41
|
105 |
|
|
#define CYGNUM_HAL_INTERRUPT_COPRO 45
|
106 |
|
|
#define CYGNUM_HAL_INTERRUPT_HDD 46
|
107 |
|
|
|
108 |
|
|
#define CYGNUM_HAL_ISR_MIN 32
|
109 |
|
|
#define CYGNUM_HAL_ISR_MAX 255
|
110 |
|
|
#define CYGNUM_HAL_ISR_COUNT (CYGNUM_HAL_ISR_MAX - CYGNUM_HAL_ISR_MIN + 1)
|
111 |
|
|
|
112 |
|
|
#define CYGNUM_HAL_INTERRUPT_RTC CYGNUM_HAL_INTERRUPT_TIMER
|
113 |
|
|
|
114 |
|
|
#ifdef CYGPKG_HAL_SMP_SUPPORT
|
115 |
|
|
|
116 |
|
|
#define CYGNUM_HAL_SMP_CPU_INTERRUPT_VECTOR( _n_ ) (64+(_n_))
|
117 |
|
|
|
118 |
|
|
#endif
|
119 |
|
|
|
120 |
|
|
//--------------------------------------------------------------------------
|
121 |
|
|
// Interrupt vector translation
|
122 |
|
|
|
123 |
|
|
#define HAL_TRANSLATE_VECTOR(_vector_,_index_) \
|
124 |
|
|
((_index_) = ((_vector_)-CYGNUM_HAL_ISR_MIN))
|
125 |
|
|
|
126 |
|
|
|
127 |
|
|
//--------------------------------------------------------------------------
|
128 |
|
|
// PIC interrupt acknowledge
|
129 |
|
|
|
130 |
|
|
#ifndef CYGPKG_HAL_SMP_SUPPORT
|
131 |
|
|
|
132 |
|
|
#define HAL_INTERRUPT_ACKNOWLEDGE( _vector_ ) \
|
133 |
|
|
CYG_MACRO_START \
|
134 |
|
|
int x; \
|
135 |
|
|
HAL_TRANSLATE_VECTOR( _vector_, x ); \
|
136 |
|
|
if ((x >= 8) && (x < 16)) \
|
137 |
|
|
HAL_WRITE_UINT8( 0xa0, 0x20 ); \
|
138 |
|
|
if ((x >= 0) && (x < 16)) \
|
139 |
|
|
HAL_WRITE_UINT8( 0x20, 0x20 ); \
|
140 |
|
|
CYG_MACRO_END
|
141 |
|
|
|
142 |
|
|
#else
|
143 |
|
|
|
144 |
|
|
#define HAL_INTERRUPT_ACKNOWLEDGE( _vector_ ) \
|
145 |
|
|
{ \
|
146 |
|
|
HAL_APIC_WRITE( HAL_APIC_EOI, 0 ); \
|
147 |
|
|
}
|
148 |
|
|
|
149 |
|
|
#endif
|
150 |
|
|
|
151 |
|
|
//--------------------------------------------------------------------------
|
152 |
|
|
// PIC per-interrupt source masking
|
153 |
|
|
|
154 |
|
|
#ifndef CYGPKG_HAL_SMP_SUPPORT
|
155 |
|
|
|
156 |
|
|
#define HAL_INTERRUPT_MASK( _vector_ ) \
|
157 |
|
|
CYG_MACRO_START \
|
158 |
|
|
int x; \
|
159 |
|
|
HAL_TRANSLATE_VECTOR( _vector_, x ); \
|
160 |
|
|
if (x >= 8) \
|
161 |
|
|
{ \
|
162 |
|
|
x = 1 << (x - 8) ; \
|
163 |
|
|
asm( \
|
164 |
|
|
"inb $0xA1, %%al;" \
|
165 |
|
|
"orl %0, %%eax;" \
|
166 |
|
|
"outb %%al, $0xA1;" \
|
167 |
|
|
: /* No outputs. */ \
|
168 |
|
|
: "g" (x) \
|
169 |
|
|
: "eax" \
|
170 |
|
|
); \
|
171 |
|
|
} \
|
172 |
|
|
else \
|
173 |
|
|
{ \
|
174 |
|
|
x = 1 << x ; \
|
175 |
|
|
asm( \
|
176 |
|
|
"inb $0x21, %%al;" \
|
177 |
|
|
"orl %0, %%eax;" \
|
178 |
|
|
"outb %%al, $0x21;" \
|
179 |
|
|
: /* No outputs. */ \
|
180 |
|
|
: "g" (x) \
|
181 |
|
|
: "eax" \
|
182 |
|
|
); \
|
183 |
|
|
} \
|
184 |
|
|
CYG_MACRO_END
|
185 |
|
|
|
186 |
|
|
#define HAL_INTERRUPT_UNMASK( _vector_ ) \
|
187 |
|
|
CYG_MACRO_START \
|
188 |
|
|
int x; \
|
189 |
|
|
HAL_TRANSLATE_VECTOR( _vector_, x ); \
|
190 |
|
|
if (x >= 8) \
|
191 |
|
|
{ \
|
192 |
|
|
x = ~(1 << (x - 8)) ; \
|
193 |
|
|
asm( \
|
194 |
|
|
"inb $0xA1, %%al;" \
|
195 |
|
|
"andl %0, %%eax;" \
|
196 |
|
|
"outb %%al, $0xA1;" \
|
197 |
|
|
: /* No outputs. */ \
|
198 |
|
|
: "g" (x) \
|
199 |
|
|
: "eax" \
|
200 |
|
|
); \
|
201 |
|
|
} \
|
202 |
|
|
else \
|
203 |
|
|
{ \
|
204 |
|
|
x = ~(1 << x) ; \
|
205 |
|
|
asm( \
|
206 |
|
|
"inb $0x21, %%al;" \
|
207 |
|
|
"andl %0, %%eax;" \
|
208 |
|
|
"outb %%al, $0x21;" \
|
209 |
|
|
: /* No outputs. */ \
|
210 |
|
|
: "g" (x) \
|
211 |
|
|
: "eax" \
|
212 |
|
|
); \
|
213 |
|
|
} \
|
214 |
|
|
CYG_MACRO_END
|
215 |
|
|
|
216 |
|
|
#else
|
217 |
|
|
|
218 |
|
|
#define HAL_INTERRUPT_MASK( _vector_ ) \
|
219 |
|
|
{ \
|
220 |
|
|
cyg_uint32 __vec, __val; \
|
221 |
|
|
HAL_TRANSLATE_VECTOR( _vector_, __vec ); \
|
222 |
|
|
HAL_SPINLOCK_SPIN( cyg_hal_ioapic_lock ); \
|
223 |
|
|
__vec = cyg_hal_isa_bus_irq[__vec]; \
|
224 |
|
|
HAL_IOAPIC_READ( HAL_IOAPIC_REG_REDIR_LO(__vec), __val ); \
|
225 |
|
|
__val |= 0x00010000; \
|
226 |
|
|
HAL_IOAPIC_WRITE( HAL_IOAPIC_REG_REDIR_LO(__vec), __val ); \
|
227 |
|
|
HAL_SPINLOCK_CLEAR( cyg_hal_ioapic_lock ); \
|
228 |
|
|
}
|
229 |
|
|
|
230 |
|
|
#define HAL_INTERRUPT_UNMASK( _vector_ ) \
|
231 |
|
|
{ \
|
232 |
|
|
cyg_uint32 __vec, __val; \
|
233 |
|
|
HAL_TRANSLATE_VECTOR( _vector_, __vec ); \
|
234 |
|
|
HAL_SPINLOCK_SPIN( cyg_hal_ioapic_lock ); \
|
235 |
|
|
__vec = cyg_hal_isa_bus_irq[__vec]; \
|
236 |
|
|
HAL_IOAPIC_READ( HAL_IOAPIC_REG_REDIR_LO(__vec), __val ); \
|
237 |
|
|
__val &= ~0x00010000; \
|
238 |
|
|
HAL_IOAPIC_WRITE( HAL_IOAPIC_REG_REDIR_LO(__vec), __val ); \
|
239 |
|
|
HAL_SPINLOCK_CLEAR( cyg_hal_ioapic_lock ); \
|
240 |
|
|
}
|
241 |
|
|
|
242 |
|
|
|
243 |
|
|
#endif
|
244 |
|
|
|
245 |
|
|
//--------------------------------------------------------------------------
|
246 |
|
|
// PIC interrupt configuration
|
247 |
|
|
// Nothing supported here at present
|
248 |
|
|
|
249 |
|
|
#define HAL_INTERRUPT_CONFIGURE( _vector_, _level_, _up_ )
|
250 |
|
|
|
251 |
|
|
#define HAL_INTERRUPT_SET_LEVEL( _vector_, _level_ )
|
252 |
|
|
|
253 |
|
|
#ifdef CYGPKG_HAL_SMP_SUPPORT
|
254 |
|
|
|
255 |
|
|
// Additional SMP interrupt configuration support.
|
256 |
|
|
|
257 |
|
|
__externC void hal_interrupt_set_cpu( CYG_WORD32 vector, HAL_SMP_CPU_TYPE cpu );
|
258 |
|
|
__externC void hal_interrupt_get_cpu( CYG_WORD32 vector, HAL_SMP_CPU_TYPE *cpu );
|
259 |
|
|
|
260 |
|
|
#define HAL_INTERRUPT_SET_CPU( _vector_, _cpu_ ) \
|
261 |
|
|
{ \
|
262 |
|
|
cyg_uint32 __vec, __val; \
|
263 |
|
|
HAL_TRANSLATE_VECTOR( _vector_, __vec ); \
|
264 |
|
|
HAL_SPINLOCK_SPIN( cyg_hal_ioapic_lock ); \
|
265 |
|
|
__vec = cyg_hal_isa_bus_irq[__vec]; \
|
266 |
|
|
HAL_IOAPIC_READ( HAL_IOAPIC_REG_REDIR_HI(__vec), __val ); \
|
267 |
|
|
__val &= 0x00FFFFFF; \
|
268 |
|
|
__val |= (_cpu_)<<24; \
|
269 |
|
|
HAL_IOAPIC_WRITE( HAL_IOAPIC_REG_REDIR_HI(__vec), __val ); \
|
270 |
|
|
HAL_SPINLOCK_CLEAR( cyg_hal_ioapic_lock ); \
|
271 |
|
|
}
|
272 |
|
|
|
273 |
|
|
|
274 |
|
|
#define HAL_INTERRUPT_GET_CPU( _vector_, _cpu_ ) \
|
275 |
|
|
{ \
|
276 |
|
|
cyg_uint32 __vec, __val; \
|
277 |
|
|
HAL_TRANSLATE_VECTOR( _vector_, __vec ); \
|
278 |
|
|
HAL_SPINLOCK_SPIN( cyg_hal_ioapic_lock ); \
|
279 |
|
|
__vec = cyg_hal_isa_bus_irq[__vec]; \
|
280 |
|
|
HAL_IOAPIC_READ( HAL_IOAPIC_REG_REDIR_HI(__vec), __val ); \
|
281 |
|
|
(_cpu_) = (__val>>24) & 0xFF; \
|
282 |
|
|
HAL_SPINLOCK_CLEAR( cyg_hal_ioapic_lock ); \
|
283 |
|
|
}
|
284 |
|
|
|
285 |
|
|
|
286 |
|
|
#endif
|
287 |
|
|
|
288 |
|
|
//---------------------------------------------------------------------------
|
289 |
|
|
// Clock support.
|
290 |
|
|
|
291 |
|
|
externC void hal_pc_clock_initialize(cyg_uint32) ;
|
292 |
|
|
externC void hal_pc_clock_read(cyg_uint32 *) ;
|
293 |
|
|
|
294 |
|
|
#define HAL_CLOCK_INITIALIZE(_period_) hal_pc_clock_initialize(_period_)
|
295 |
|
|
#define HAL_CLOCK_RESET(_vec_, _period_) /* Clock automatically reloads. */
|
296 |
|
|
#define HAL_CLOCK_READ(_pvalue_) hal_pc_clock_read(_pvalue_)
|
297 |
|
|
|
298 |
|
|
// Timer IO ports
|
299 |
|
|
#define PC_PIT_CONTROL (0x43)
|
300 |
|
|
#define PC_PIT_CLOCK_0 (0x40)
|
301 |
|
|
#define PC_PIT_CLOCK_1 (0x41)
|
302 |
|
|
#define PC_PIT_CLOCK_2 (0x42)
|
303 |
|
|
|
304 |
|
|
//---------------------------------------------------------------------------
|
305 |
|
|
#endif // ifndef CYGONCE_HAL_PCMB_INTR_H
|
306 |
|
|
// End of pcmb_intr.h
|