intr.h revision 1.24 1 1.24 thorpej /* $NetBSD: intr.h,v 1.24 2000/03/19 01:46:18 thorpej Exp $ */
2 1.1 cgd
3 1.1 cgd /*
4 1.6 cgd * Copyright (c) 1997 Christopher G. Demetriou. All rights reserved.
5 1.1 cgd * Copyright (c) 1996 Carnegie-Mellon University.
6 1.1 cgd * All rights reserved.
7 1.1 cgd *
8 1.1 cgd * Author: Chris G. Demetriou
9 1.1 cgd *
10 1.1 cgd * Permission to use, copy, modify and distribute this software and
11 1.1 cgd * its documentation is hereby granted, provided that both the copyright
12 1.1 cgd * notice and this permission notice appear in all copies of the
13 1.1 cgd * software, derivative works or modified versions, and any portions
14 1.1 cgd * thereof, and that both notices appear in supporting documentation.
15 1.1 cgd *
16 1.1 cgd * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
17 1.1 cgd * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
18 1.1 cgd * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
19 1.1 cgd *
20 1.1 cgd * Carnegie Mellon requests users of this software to return to
21 1.1 cgd *
22 1.1 cgd * Software Distribution Coordinator or Software.Distribution (at) CS.CMU.EDU
23 1.1 cgd * School of Computer Science
24 1.1 cgd * Carnegie Mellon University
25 1.1 cgd * Pittsburgh PA 15213-3890
26 1.1 cgd *
27 1.1 cgd * any improvements or extensions that they make and grant Carnegie the
28 1.1 cgd * rights to redistribute these changes.
29 1.1 cgd */
30 1.1 cgd
31 1.2 cgd #ifndef _ALPHA_INTR_H_
32 1.2 cgd #define _ALPHA_INTR_H_
33 1.2 cgd
34 1.3 cgd #include <sys/queue.h>
35 1.23 thorpej #include <machine/atomic.h>
36 1.3 cgd
37 1.1 cgd #define IPL_NONE 0 /* disable only this interrupt */
38 1.1 cgd #define IPL_BIO 1 /* disable block I/O interrupts */
39 1.1 cgd #define IPL_NET 2 /* disable network interrupts */
40 1.1 cgd #define IPL_TTY 3 /* disable terminal interrupts */
41 1.1 cgd #define IPL_CLOCK 4 /* disable clock interrupts */
42 1.1 cgd #define IPL_HIGH 5 /* disable all interrupts */
43 1.16 matt #define IPL_SERIAL 6 /* disable serial interrupts */
44 1.1 cgd
45 1.3 cgd #define IST_UNUSABLE -1 /* interrupt cannot be used */
46 1.1 cgd #define IST_NONE 0 /* none (dummy) */
47 1.1 cgd #define IST_PULSE 1 /* pulsed */
48 1.1 cgd #define IST_EDGE 2 /* edge-triggered */
49 1.1 cgd #define IST_LEVEL 3 /* level-triggered */
50 1.17 thorpej
51 1.11 mjacob #ifdef _KERNEL
52 1.2 cgd
53 1.6 cgd /* IPL-lowering/restoring macros */
54 1.2 cgd #define splx(s) \
55 1.7 cgd ((s) == ALPHA_PSL_IPL_0 ? spl0() : alpha_pal_swpipl(s))
56 1.20 thorpej #define spllowersoftclock() alpha_pal_swpipl(ALPHA_PSL_IPL_SOFT)
57 1.6 cgd
58 1.8 cgd /* IPL-raising functions/macros */
59 1.10 cgd static __inline int _splraise __P((int)) __attribute__ ((unused));
60 1.8 cgd static __inline int
61 1.8 cgd _splraise(s)
62 1.8 cgd int s;
63 1.8 cgd {
64 1.8 cgd int cur = alpha_pal_rdps() & ALPHA_PSL_IPL_MASK;
65 1.9 cgd return (s > cur ? alpha_pal_swpipl(s) : cur);
66 1.8 cgd }
67 1.20 thorpej #define splsoft() _splraise(ALPHA_PSL_IPL_SOFT)
68 1.20 thorpej #define splsoftserial() splsoft()
69 1.20 thorpej #define splsoftclock() splsoft()
70 1.20 thorpej #define splsoftnet() splsoft()
71 1.6 cgd #define splnet() _splraise(ALPHA_PSL_IPL_IO)
72 1.6 cgd #define splbio() _splraise(ALPHA_PSL_IPL_IO)
73 1.6 cgd #define splimp() _splraise(ALPHA_PSL_IPL_IO)
74 1.6 cgd #define spltty() _splraise(ALPHA_PSL_IPL_IO)
75 1.16 matt #define splserial() _splraise(ALPHA_PSL_IPL_IO)
76 1.6 cgd #define splclock() _splraise(ALPHA_PSL_IPL_CLOCK)
77 1.6 cgd #define splstatclock() _splraise(ALPHA_PSL_IPL_CLOCK)
78 1.6 cgd #define splhigh() _splraise(ALPHA_PSL_IPL_HIGH)
79 1.14 is
80 1.14 is #define spllpt() spltty()
81 1.2 cgd
82 1.2 cgd /*
83 1.2 cgd * simulated software interrupt register
84 1.2 cgd */
85 1.2 cgd extern u_int64_t ssir;
86 1.2 cgd
87 1.2 cgd #define SIR_NET 0x1
88 1.2 cgd #define SIR_CLOCK 0x2
89 1.16 matt #define SIR_SERIAL 0x4
90 1.2 cgd
91 1.21 thorpej #define setsoft(x) alpha_atomic_setbits_q(&ssir, (x))
92 1.21 thorpej
93 1.21 thorpej #define setsoftnet() setsoft(SIR_NET)
94 1.21 thorpej #define setsoftclock() setsoft(SIR_CLOCK)
95 1.21 thorpej #define setsoftserial() setsoft(SIR_SERIAL)
96 1.18 thorpej
97 1.18 thorpej /*
98 1.19 thorpej * Interprocessor interrupts. In order how we want them processed.
99 1.18 thorpej */
100 1.22 thorpej #define ALPHA_IPI_HALT 0x0000000000000001UL
101 1.22 thorpej #define ALPHA_IPI_TBIA 0x0000000000000002UL
102 1.22 thorpej #define ALPHA_IPI_TBIAP 0x0000000000000004UL
103 1.22 thorpej #define ALPHA_IPI_SHOOTDOWN 0x0000000000000008UL
104 1.22 thorpej #define ALPHA_IPI_IMB 0x0000000000000010UL
105 1.22 thorpej #define ALPHA_IPI_AST 0x0000000000000020UL
106 1.19 thorpej
107 1.22 thorpej #define ALPHA_NIPIS 6 /* must not exceed 64 */
108 1.18 thorpej
109 1.18 thorpej typedef void (*ipifunc_t) __P((void));
110 1.18 thorpej extern ipifunc_t ipifuncs[ALPHA_NIPIS];
111 1.18 thorpej
112 1.18 thorpej void alpha_send_ipi __P((unsigned long, unsigned long));
113 1.19 thorpej void alpha_broadcast_ipi __P((unsigned long));
114 1.3 cgd
115 1.3 cgd /*
116 1.3 cgd * Alpha shared-interrupt-line common code.
117 1.3 cgd */
118 1.3 cgd
119 1.3 cgd struct alpha_shared_intrhand {
120 1.3 cgd TAILQ_ENTRY(alpha_shared_intrhand)
121 1.3 cgd ih_q;
122 1.24 thorpej struct alpha_shared_intr *ih_intrhead;
123 1.3 cgd int (*ih_fn) __P((void *));
124 1.3 cgd void *ih_arg;
125 1.3 cgd int ih_level;
126 1.15 thorpej unsigned int ih_num;
127 1.3 cgd };
128 1.3 cgd
129 1.3 cgd struct alpha_shared_intr {
130 1.3 cgd TAILQ_HEAD(,alpha_shared_intrhand)
131 1.3 cgd intr_q;
132 1.22 thorpej void *intr_private;
133 1.3 cgd int intr_sharetype;
134 1.3 cgd int intr_dfltsharetype;
135 1.3 cgd int intr_nstrays;
136 1.3 cgd int intr_maxstrays;
137 1.3 cgd };
138 1.12 thorpej
139 1.13 thorpej #define ALPHA_SHARED_INTR_DISABLE(asi, num) \
140 1.13 thorpej ((asi)[num].intr_maxstrays != 0 && \
141 1.13 thorpej (asi)[num].intr_nstrays == (asi)[num].intr_maxstrays)
142 1.3 cgd
143 1.3 cgd struct alpha_shared_intr *alpha_shared_intr_alloc __P((unsigned int));
144 1.3 cgd int alpha_shared_intr_dispatch __P((struct alpha_shared_intr *,
145 1.3 cgd unsigned int));
146 1.3 cgd void *alpha_shared_intr_establish __P((struct alpha_shared_intr *,
147 1.3 cgd unsigned int, int, int, int (*)(void *), void *, const char *));
148 1.15 thorpej void alpha_shared_intr_disestablish __P((struct alpha_shared_intr *,
149 1.15 thorpej void *, const char *));
150 1.3 cgd int alpha_shared_intr_get_sharetype __P((struct alpha_shared_intr *,
151 1.3 cgd unsigned int));
152 1.3 cgd int alpha_shared_intr_isactive __P((struct alpha_shared_intr *,
153 1.3 cgd unsigned int));
154 1.3 cgd void alpha_shared_intr_set_dfltsharetype __P((struct alpha_shared_intr *,
155 1.3 cgd unsigned int, int));
156 1.3 cgd void alpha_shared_intr_set_maxstrays __P((struct alpha_shared_intr *,
157 1.3 cgd unsigned int, int));
158 1.3 cgd void alpha_shared_intr_stray __P((struct alpha_shared_intr *, unsigned int,
159 1.3 cgd const char *));
160 1.22 thorpej void alpha_shared_intr_set_private __P((struct alpha_shared_intr *,
161 1.22 thorpej unsigned int, void *));
162 1.22 thorpej void *alpha_shared_intr_get_private __P((struct alpha_shared_intr *,
163 1.22 thorpej unsigned int));
164 1.2 cgd
165 1.17 thorpej #endif /* _KERNEL */
166 1.17 thorpej #endif /* ! _ALPHA_INTR_H_ */
167