xref: /netbsd-src/sys/arch/news68k/include/intr.h (revision 8b0f9554ff8762542c4defc4f70e1eb76fb508fa)
1 /*	$NetBSD: intr.h,v 1.19 2007/12/03 15:34:02 ad Exp $	*/
2 
3 /*
4  *
5  * Copyright (c) 1998 NetBSD Foundation, Inc.
6  * All rights reserved.
7  *
8  * This code is derived from software contributed to The NetBSD Foundation
9  * by Minoura Makoto and Jason R. Thorpe.
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions
13  * are met:
14  * 1. Redistributions of source code must retain the above copyright
15  *    notice, this list of conditions and the following disclaimer.
16  * 2. Redistributions in binary form must reproduce the above copyright
17  *    notice, this list of conditions and the following disclaimer in the
18  *    documentation and/or other materials provided with the distribution.
19  * 3. All advertising materials mentioning features or use of this software
20  *    must display the following acknowledgement:
21  *      This product includes software developed by The NetBSD Foundation
22  *	Inc. and its contributers.
23  * 4. The name of the author may not be used to endorse or promote products
24  *    derived from this software without specific prior written permission.
25  *
26  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
27  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
28  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
29  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
30  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
31  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
35  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36  */
37 
38 #ifndef _NEWS68K_INTR_H_
39 #define	_NEWS68K_INTR_H_
40 
41 #include <sys/device.h>
42 #include <sys/queue.h>
43 #include <machine/psl.h>
44 #include <m68k/asm_single.h>
45 
46 #define	IPL_NONE	0
47 #define	IPL_SOFTCLOCK	1
48 #define	IPL_SOFTBIO	2
49 #define	IPL_SOFTNET	3
50 #define	IPL_SOFTSERIAL	4
51 #define	IPL_VM		5
52 #define	IPL_SCHED	6
53 #define	IPL_HIGH	6
54 #define	NIPL		7
55 
56 typedef int ipl_t;
57 typedef struct {
58 	uint16_t _psl;
59 } ipl_cookie_t;
60 
61 ipl_cookie_t makeiplcookie(ipl_t);
62 
63 static inline int
64 splraiseipl(ipl_cookie_t icookie)
65 {
66 
67 	return _splraise(icookie._psl);
68 }
69 
70 static __inline void
71 splx(int sr)
72 {
73 
74 	__asm volatile("movw %0,%%sr" : : "di" (sr));
75 }
76 
77 /*
78  * news68k can handle software interrupts by its own hardware
79  * so has no need to check for any simulated interrupts, etc.
80  */
81 #define	spl0()		_spl0()
82 
83 #define	splsoftbio()	splraise2()
84 #define	splsoftclock()	splraise2()
85 #define	splsoftnet()	splraise2()
86 #define	splsoftserial()	splraise2()
87 #define	splvm()		splraise5()
88 #define	splhigh()	spl7()
89 #define	splsched()	spl7()
90 
91 #endif /* _NEWS68K_INTR_H_ */
92