1 |
1633 |
jcastillo |
/*
|
2 |
|
|
** atariints.h -- Atari Linux interrupt handling structs and prototypes
|
3 |
|
|
**
|
4 |
|
|
** Copyright 1994 by Bj”rn Brauel
|
5 |
|
|
**
|
6 |
|
|
** 5/2/94 Roman Hodek:
|
7 |
|
|
** TT interrupt definitions added.
|
8 |
|
|
**
|
9 |
|
|
** 12/02/96: (Roman)
|
10 |
|
|
** Adapted to new int handling scheme (see ataints.c); revised numbering
|
11 |
|
|
**
|
12 |
|
|
** This file is subject to the terms and conditions of the GNU General Public
|
13 |
|
|
** License. See the file COPYING in the main directory of this archive
|
14 |
|
|
** for more details.
|
15 |
|
|
**
|
16 |
|
|
*/
|
17 |
|
|
|
18 |
|
|
#ifndef _LINUX_ATARIINTS_H_
|
19 |
|
|
#define _LINUX_ATARIINTS_H_
|
20 |
|
|
|
21 |
|
|
#include <asm/irq.h>
|
22 |
|
|
#include <asm/atarihw.h>
|
23 |
|
|
|
24 |
|
|
/*
|
25 |
|
|
** Atari Interrupt sources.
|
26 |
|
|
**
|
27 |
|
|
*/
|
28 |
|
|
|
29 |
|
|
#define STMFP_SOURCE_BASE 8
|
30 |
|
|
#define TTMFP_SOURCE_BASE 24
|
31 |
|
|
#define SCC_SOURCE_BASE 40
|
32 |
|
|
#define VME_SOURCE_BASE 56
|
33 |
|
|
#define VME_MAX_SOURCES 16
|
34 |
|
|
|
35 |
|
|
#define NUM_ATARI_SOURCES (VME_SOURCE_BASE+VME_MAX_SOURCES-STMFP_SOURCE_BASE)
|
36 |
|
|
|
37 |
|
|
/* convert vector number to int source number */
|
38 |
|
|
#define IRQ_VECTOR_TO_SOURCE(v) ((v) - ((v) < 0x20 ? 0x18 : (0x40-8)))
|
39 |
|
|
|
40 |
|
|
/* convert irq_handler index to vector number */
|
41 |
|
|
#define IRQ_SOURCE_TO_VECTOR(i) ((i) + ((i) < 8 ? 0x18 : (0x40-8)))
|
42 |
|
|
|
43 |
|
|
/* interrupt service types */
|
44 |
|
|
#define IRQ_TYPE_SLOW 0
|
45 |
|
|
#define IRQ_TYPE_FAST 1
|
46 |
|
|
#define IRQ_TYPE_PRIO 2
|
47 |
|
|
|
48 |
|
|
#define IRQ_SPURIOUS (IRQ_MACHSPEC | 0)
|
49 |
|
|
|
50 |
|
|
/* auto-vector interrupts */
|
51 |
|
|
#define IRQ_AUTO_1 (IRQ_MACHSPEC | 1)
|
52 |
|
|
#define IRQ_AUTO_2 (IRQ_MACHSPEC | 2)
|
53 |
|
|
#define IRQ_AUTO_3 (IRQ_MACHSPEC | 3)
|
54 |
|
|
#define IRQ_AUTO_4 (IRQ_MACHSPEC | 4)
|
55 |
|
|
#define IRQ_AUTO_5 (IRQ_MACHSPEC | 5)
|
56 |
|
|
#define IRQ_AUTO_6 (IRQ_MACHSPEC | 6)
|
57 |
|
|
#define IRQ_AUTO_7 (IRQ_MACHSPEC | 7)
|
58 |
|
|
|
59 |
|
|
/* ST-MFP interrupts */
|
60 |
|
|
#define IRQ_MFP_BUSY (IRQ_MACHSPEC | 8)
|
61 |
|
|
#define IRQ_MFP_DCD (IRQ_MACHSPEC | 9)
|
62 |
|
|
#define IRQ_MFP_CTS (IRQ_MACHSPEC | 10)
|
63 |
|
|
#define IRQ_MFP_GPU (IRQ_MACHSPEC | 11)
|
64 |
|
|
#define IRQ_MFP_TIMD (IRQ_MACHSPEC | 12)
|
65 |
|
|
#define IRQ_MFP_TIMC (IRQ_MACHSPEC | 13)
|
66 |
|
|
#define IRQ_MFP_ACIA (IRQ_MACHSPEC | 14)
|
67 |
|
|
#define IRQ_MFP_FDC (IRQ_MACHSPEC | 15)
|
68 |
|
|
#define IRQ_MFP_ACSI IRQ_MFP_FDC
|
69 |
|
|
#define IRQ_MFP_FSCSI IRQ_MFP_FDC
|
70 |
|
|
#define IRQ_MFP_IDE IRQ_MFP_FDC
|
71 |
|
|
#define IRQ_MFP_TIMB (IRQ_MACHSPEC | 16)
|
72 |
|
|
#define IRQ_MFP_SERERR (IRQ_MACHSPEC | 17)
|
73 |
|
|
#define IRQ_MFP_SEREMPT (IRQ_MACHSPEC | 18)
|
74 |
|
|
#define IRQ_MFP_RECERR (IRQ_MACHSPEC | 19)
|
75 |
|
|
#define IRQ_MFP_RECFULL (IRQ_MACHSPEC | 20)
|
76 |
|
|
#define IRQ_MFP_TIMA (IRQ_MACHSPEC | 21)
|
77 |
|
|
#define IRQ_MFP_RI (IRQ_MACHSPEC | 22)
|
78 |
|
|
#define IRQ_MFP_MMD (IRQ_MACHSPEC | 23)
|
79 |
|
|
|
80 |
|
|
/* TT-MFP interrupts */
|
81 |
|
|
#define IRQ_TT_MFP_IO0 (IRQ_MACHSPEC | 24)
|
82 |
|
|
#define IRQ_TT_MFP_IO1 (IRQ_MACHSPEC | 25)
|
83 |
|
|
#define IRQ_TT_MFP_SCC (IRQ_MACHSPEC | 26)
|
84 |
|
|
#define IRQ_TT_MFP_RI (IRQ_MACHSPEC | 27)
|
85 |
|
|
#define IRQ_TT_MFP_TIMD (IRQ_MACHSPEC | 28)
|
86 |
|
|
#define IRQ_TT_MFP_TIMC (IRQ_MACHSPEC | 29)
|
87 |
|
|
#define IRQ_TT_MFP_DRVRDY (IRQ_MACHSPEC | 30)
|
88 |
|
|
#define IRQ_TT_MFP_SCSIDMA (IRQ_MACHSPEC | 31)
|
89 |
|
|
#define IRQ_TT_MFP_TIMB (IRQ_MACHSPEC | 32)
|
90 |
|
|
#define IRQ_TT_MFP_SERERR (IRQ_MACHSPEC | 33)
|
91 |
|
|
#define IRQ_TT_MFP_SEREMPT (IRQ_MACHSPEC | 34)
|
92 |
|
|
#define IRQ_TT_MFP_RECERR (IRQ_MACHSPEC | 35)
|
93 |
|
|
#define IRQ_TT_MFP_RECFULL (IRQ_MACHSPEC | 36)
|
94 |
|
|
#define IRQ_TT_MFP_TIMA (IRQ_MACHSPEC | 37)
|
95 |
|
|
#define IRQ_TT_MFP_RTC (IRQ_MACHSPEC | 38)
|
96 |
|
|
#define IRQ_TT_MFP_SCSI (IRQ_MACHSPEC | 39)
|
97 |
|
|
|
98 |
|
|
/* SCC interrupts */
|
99 |
|
|
#define IRQ_SCCB_TX (IRQ_MACHSPEC | 40)
|
100 |
|
|
#define IRQ_SCCB_STAT (IRQ_MACHSPEC | 42)
|
101 |
|
|
#define IRQ_SCCB_RX (IRQ_MACHSPEC | 44)
|
102 |
|
|
#define IRQ_SCCB_SPCOND (IRQ_MACHSPEC | 46)
|
103 |
|
|
#define IRQ_SCCA_TX (IRQ_MACHSPEC | 48)
|
104 |
|
|
#define IRQ_SCCA_STAT (IRQ_MACHSPEC | 50)
|
105 |
|
|
#define IRQ_SCCA_RX (IRQ_MACHSPEC | 52)
|
106 |
|
|
#define IRQ_SCCA_SPCOND (IRQ_MACHSPEC | 54)
|
107 |
|
|
|
108 |
|
|
|
109 |
|
|
#define INT_CLK 24576 /* CLK while int_clk =2.456MHz and divide = 100 */
|
110 |
|
|
#define INT_TICKS 246 /* to make sched_time = 99.902... HZ */
|
111 |
|
|
|
112 |
|
|
|
113 |
|
|
#define MFP_ENABLE 0
|
114 |
|
|
#define MFP_PENDING 1
|
115 |
|
|
#define MFP_SERVICE 2
|
116 |
|
|
#define MFP_MASK 3
|
117 |
|
|
|
118 |
|
|
/* Utility functions for setting/clearing bits in the interrupt registers of
|
119 |
|
|
* the MFP. 'type' should be constant, if 'irq' is constant, too, code size is
|
120 |
|
|
* reduced. set_mfp_bit() is nonsense for PENDING and SERVICE registers. */
|
121 |
|
|
|
122 |
|
|
static inline int get_mfp_bit( unsigned irq, int type )
|
123 |
|
|
|
124 |
|
|
{ unsigned char mask, *reg;
|
125 |
|
|
|
126 |
|
|
mask = 1 << (irq & 7);
|
127 |
|
|
reg = (unsigned char *)&mfp.int_en_a + type*4 +
|
128 |
|
|
((irq & 8) >> 2) + (((irq-8) & 16) << 3);
|
129 |
|
|
return( *reg & mask );
|
130 |
|
|
}
|
131 |
|
|
|
132 |
|
|
static inline void set_mfp_bit( unsigned irq, int type )
|
133 |
|
|
|
134 |
|
|
{ unsigned char mask, *reg;
|
135 |
|
|
|
136 |
|
|
mask = 1 << (irq & 7);
|
137 |
|
|
reg = (unsigned char *)&mfp.int_en_a + type*4 +
|
138 |
|
|
((irq & 8) >> 2) + (((irq-8) & 16) << 3);
|
139 |
|
|
__asm__ __volatile__ ( "orb %0,%1"
|
140 |
|
|
: : "di" (mask), "m" (*reg) : "memory" );
|
141 |
|
|
}
|
142 |
|
|
|
143 |
|
|
static inline void clear_mfp_bit( unsigned irq, int type )
|
144 |
|
|
|
145 |
|
|
{ unsigned char mask, *reg;
|
146 |
|
|
|
147 |
|
|
mask = ~(1 << (irq & 7));
|
148 |
|
|
reg = (unsigned char *)&mfp.int_en_a + type*4 +
|
149 |
|
|
((irq & 8) >> 2) + (((irq-8) & 16) << 3);
|
150 |
|
|
if (type == MFP_PENDING || type == MFP_SERVICE)
|
151 |
|
|
__asm__ __volatile__ ( "moveb %0,%1"
|
152 |
|
|
: : "di" (mask), "m" (*reg) : "memory" );
|
153 |
|
|
else
|
154 |
|
|
__asm__ __volatile__ ( "andb %0,%1"
|
155 |
|
|
: : "di" (mask), "m" (*reg) : "memory" );
|
156 |
|
|
}
|
157 |
|
|
|
158 |
|
|
/*
|
159 |
|
|
* {en,dis}able_irq have the usual semantics of temporary blocking the
|
160 |
|
|
* interrupt, but not loosing requests that happen between disabling and
|
161 |
|
|
* enabling. This is done with the MFP mask registers.
|
162 |
|
|
*/
|
163 |
|
|
|
164 |
|
|
static inline void atari_enable_irq( unsigned irq )
|
165 |
|
|
|
166 |
|
|
{
|
167 |
|
|
irq &= ~IRQ_MACHSPEC;
|
168 |
|
|
if (irq < STMFP_SOURCE_BASE || irq >= SCC_SOURCE_BASE) return;
|
169 |
|
|
set_mfp_bit( irq, MFP_MASK );
|
170 |
|
|
}
|
171 |
|
|
|
172 |
|
|
static inline void atari_disable_irq( unsigned irq )
|
173 |
|
|
|
174 |
|
|
{
|
175 |
|
|
irq &= ~IRQ_MACHSPEC;
|
176 |
|
|
if (irq < STMFP_SOURCE_BASE || irq >= SCC_SOURCE_BASE) return;
|
177 |
|
|
clear_mfp_bit( irq, MFP_MASK );
|
178 |
|
|
}
|
179 |
|
|
|
180 |
|
|
/*
|
181 |
|
|
* In opposite to {en,dis}able_irq, requests between turn{off,on}_irq are not
|
182 |
|
|
* "stored"
|
183 |
|
|
*/
|
184 |
|
|
|
185 |
|
|
extern inline void atari_turnon_irq( unsigned irq )
|
186 |
|
|
|
187 |
|
|
{
|
188 |
|
|
irq &= ~IRQ_MACHSPEC;
|
189 |
|
|
if (irq < STMFP_SOURCE_BASE || irq >= SCC_SOURCE_BASE) return;
|
190 |
|
|
set_mfp_bit( irq, MFP_ENABLE );
|
191 |
|
|
}
|
192 |
|
|
|
193 |
|
|
extern inline void atari_turnoff_irq( unsigned irq )
|
194 |
|
|
|
195 |
|
|
{
|
196 |
|
|
irq &= ~IRQ_MACHSPEC;
|
197 |
|
|
if (irq < STMFP_SOURCE_BASE || irq >= SCC_SOURCE_BASE) return;
|
198 |
|
|
clear_mfp_bit( irq, MFP_ENABLE );
|
199 |
|
|
clear_mfp_bit( irq, MFP_PENDING );
|
200 |
|
|
}
|
201 |
|
|
|
202 |
|
|
extern inline void atari_clear_pending_irq( unsigned irq )
|
203 |
|
|
|
204 |
|
|
{
|
205 |
|
|
irq &= ~IRQ_MACHSPEC;
|
206 |
|
|
if (irq < STMFP_SOURCE_BASE || irq >= SCC_SOURCE_BASE) return;
|
207 |
|
|
clear_mfp_bit( irq, MFP_PENDING );
|
208 |
|
|
}
|
209 |
|
|
|
210 |
|
|
extern inline int atari_irq_pending( unsigned irq )
|
211 |
|
|
|
212 |
|
|
{
|
213 |
|
|
irq &= ~IRQ_MACHSPEC;
|
214 |
|
|
if (irq < STMFP_SOURCE_BASE || irq >= SCC_SOURCE_BASE) return( 0 );
|
215 |
|
|
return( get_mfp_bit( irq, MFP_PENDING ) );
|
216 |
|
|
}
|
217 |
|
|
|
218 |
|
|
unsigned long atari_register_vme_int( void );
|
219 |
|
|
|
220 |
|
|
#endif /* linux/atariints.h */
|