xref: /netbsd-src/sys/arch/sparc/include/intr.h (revision 8b0f9554ff8762542c4defc4f70e1eb76fb508fa)
1 /*	$NetBSD: intr.h,v 1.10 2007/12/03 15:34:21 ad Exp $ */
2 
3 /*-
4  * Copyright (c) 1998 The NetBSD Foundation, Inc.
5  * All rights reserved.
6  *
7  * This code is derived from software contributed to The NetBSD Foundation
8  * by Paul Kranenburg.
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions
12  * are met:
13  * 1. Redistributions of source code must retain the above copyright
14  *    notice, this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright
16  *    notice, this list of conditions and the following disclaimer in the
17  *    documentation and/or other materials provided with the distribution.
18  * 3. All advertising materials mentioning features or use of this software
19  *    must display the following acknowledgement:
20  *        This product includes software developed by the NetBSD
21  *        Foundation, Inc. and its contributors.
22  * 4. Neither the name of The NetBSD Foundation nor the names of its
23  *    contributors may be used to endorse or promote products derived
24  *    from this software without specific prior written permission.
25  *
26  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36  * POSSIBILITY OF SUCH DAMAGE.
37  */
38 
39 /*
40  * Device class interrupt levels
41  * Note: sun4 and sun4c hardware only has software interrupt available
42  *	 on level 1, 4 or 6. This limits the choice of the various
43  * 	 IPL_SOFT* symbols to one of those three values.
44  */
45 #define IPL_NONE	0	/* nothing */
46 #define IPL_SOFTCLOCK	1	/* timeouts */
47 #define IPL_SOFTNET	1	/* protocol stack */
48 #define IPL_SOFTBIO	1	/* block I/O */
49 #define IPL_SOFTAUDIO	4	/* second-level audio */
50 #define IPL_SOFTFDC	4	/* second-level floppy */
51 #define IPL_SOFTSERIAL	6	/* serial */
52 #define IPL_VM		7	/* memory allocation */
53 #define IPL_SCHED	11	/* scheduler */
54 #define IPL_HIGH	15	/* everything */
55 
56 /*
57  * fd hardware, ts102, and tadpole microcontoller interrupts are at level 11
58  */
59 
60 #define	IPL_FD		IPL_SCHED
61 #define	IPL_TS102	IPL_SCHED
62 
63 /*
64  * zs hardware interrupts are at level 12
65  * su (com) hardware interrupts are at level 13
66  * IPL_SERIAL must protect them all.
67  */
68 
69 #define	IPL_ZS		IPL_HIGH
70 
71 #if defined(_KERNEL) && !defined(_LOCORE)
72 void *
73 sparc_softintr_establish(int level, void (*fun)(void *), void *arg);
74 
75 void
76 sparc_softintr_disestablish(void *cookie);
77 
78 /*
79  * NB that sparc_softintr_schedule() casts the cookie to an int *.
80  * This is to get the sic_pilreq member of the softintr_cookie
81  * structure, which is otherwise internal to intr.c.
82  */
83 #if defined(SUN4M) || defined(SUN4D)
84 extern void	raise(int, int);
85 #if !(defined(SUN4) || defined(SUN4C))
86 #define sparc_softintr_schedule(cookie)	raise(0, *((int *) (cookie)))
87 #else /* both defined */
88 #define sparc_softintr_schedule(cookie) do {		\
89 	if (CPU_ISSUN4M || CPU_ISSUN4D)		\
90 		raise(0, *((int *)(cookie)));	\
91 	else					\
92 		ienab_bis(*((int *)(cookie)));	\
93 } while (0)
94 #endif	/* SUN4  || SUN4C */
95 #else	/* SUN4M || SUN4D */
96 #define sparc_softintr_schedule(cookie)	ienab_bis(*((int *) (cookie)))
97 #endif	/* SUN4M || SUN4D */
98 
99 #if 0
100 void sparc_softintr_schedule(void *cookie);
101 #endif
102 #endif /* KERNEL && !_LOCORE */
103