xref: /openbsd/sys/arch/landisk/include/intr.h (revision e5dd7070)
1 /*	$OpenBSD: intr.h,v 1.14 2018/08/20 15:02:07 visa Exp $	*/
2 /*	$NetBSD: intr.h,v 1.1 2006/09/01 21:26:18 uwe Exp $	*/
3 
4 /*-
5  * Copyright (c) 2002 The NetBSD Foundation, Inc.
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
18  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
21  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27  * POSSIBILITY OF SUCH DAMAGE.
28  */
29 
30 #ifndef _MACHINE_INTR_H_
31 #define _MACHINE_INTR_H_
32 
33 #include <sh/intr.h>
34 
35 /* Number of interrupt source */
36 #define _INTR_N		16
37 
38 /* Interrupt priority levels */
39 #define	IPL_BIO		10	/* block I/O */
40 #define	IPL_AUDIO	IPL_BIO
41 #define	IPL_NET		11	/* network */
42 #define	IPL_TTY		12	/* terminal */
43 #define	IPL_VM		12
44 #define	IPL_CLOCK	14	/* clock */
45 #define	IPL_SCHED	14	/* scheduling */
46 #define	IPL_HIGH	15	/* everything */
47 
48 #define	IPL_MPSAFE	0	/* no "mpsafe" interrupts */
49 #define	IPL_MPFLOOR	IPL_NONE	/* no MP on landisk */
50 
51 #define	splraise(_ipl)		_cpu_intr_raise((_ipl) << 4)
52 #define	splsoftclock()		splraise(IPL_SOFTCLOCK)
53 #define	splsoftnet()		splraise(IPL_SOFTNET)
54 #define	splsoftserial()		splraise(IPL_SOFTSERIAL)
55 #define	splbio()		splraise(IPL_BIO)
56 #define	splnet()		splraise(IPL_NET)
57 #define	spltty()		splraise(IPL_TTY)
58 #define	splvm()			splraise(IPL_VM)
59 #define	splaudio()		splraise(IPL_AUDIO)
60 #define	splclock()		splraise(IPL_CLOCK)
61 #define	splstatclock()		splclock()
62 #define	splsched()		splraise(IPL_SCHED)
63 #define	splhigh()		_cpu_intr_suspend()
64 
65 #define	spl0()			_cpu_intr_resume(IPL_NONE << 4)
66 #define	splx(x)			_cpu_intr_resume(x)
67 
68 #ifdef DIAGNOSTIC
69 /*
70  * Although this function is implemented in MI code, it must be in this MD
71  * header because we don't want this header to include MI includes.
72  */
73 void splassert_fail(int, int, const char *);
74 extern int splassert_ctl;
75 void splassert_check(int, const char *);
76 #define	splassert(__wantipl) \
77 do {									\
78 	if (splassert_ctl > 0) {					\
79 		splassert_check(__wantipl, __func__);			\
80 	}								\
81 } while (0)
82 #define splsoftassert(__wantipl) splassert(__wantipl)
83 #else
84 #define	splassert(wantipl)	do { /* nothing yet */ } while (0)
85 #define	splsoftassert(wantipl)	do { /* nothing yet */ } while (0)
86 #endif
87 
88 void intr_init(void);
89 void *extintr_establish(int, int, int (*)(void *), void *, const char *);
90 void extintr_disestablish(void *ih);
91 void extintr_enable(void *ih);
92 void extintr_disable(void *ih);
93 void extintr_disable_by_num(int irq);
94 
95 #endif /* !_MACHINE_INTR_H_ */
96