xref: /openbsd-src/sys/arch/landisk/include/intr.h (revision 864f2f83ec4c08eb41848f403ee4e5dadd8f3951)
1*864f2f83Svisa /*	$OpenBSD: intr.h,v 1.14 2018/08/20 15:02:07 visa Exp $	*/
20d032535Smiod /*	$NetBSD: intr.h,v 1.1 2006/09/01 21:26:18 uwe Exp $	*/
30d032535Smiod 
40d032535Smiod /*-
50d032535Smiod  * Copyright (c) 2002 The NetBSD Foundation, Inc.
60d032535Smiod  * All rights reserved.
70d032535Smiod  *
80d032535Smiod  * Redistribution and use in source and binary forms, with or without
90d032535Smiod  * modification, are permitted provided that the following conditions
100d032535Smiod  * are met:
110d032535Smiod  * 1. Redistributions of source code must retain the above copyright
120d032535Smiod  *    notice, this list of conditions and the following disclaimer.
130d032535Smiod  * 2. Redistributions in binary form must reproduce the above copyright
140d032535Smiod  *    notice, this list of conditions and the following disclaimer in the
150d032535Smiod  *    documentation and/or other materials provided with the distribution.
160d032535Smiod  *
170d032535Smiod  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
180d032535Smiod  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
190d032535Smiod  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
200d032535Smiod  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
210d032535Smiod  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
220d032535Smiod  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
230d032535Smiod  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
240d032535Smiod  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
250d032535Smiod  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
260d032535Smiod  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
270d032535Smiod  * POSSIBILITY OF SUCH DAMAGE.
280d032535Smiod  */
290d032535Smiod 
302fa72412Spirofti #ifndef _MACHINE_INTR_H_
312fa72412Spirofti #define _MACHINE_INTR_H_
320d032535Smiod 
330d032535Smiod #include <sh/intr.h>
340d032535Smiod 
350d032535Smiod /* Number of interrupt source */
360d032535Smiod #define _INTR_N		16
370d032535Smiod 
380d032535Smiod /* Interrupt priority levels */
390d032535Smiod #define	IPL_BIO		10	/* block I/O */
4073bb9e10Smiod #define	IPL_AUDIO	IPL_BIO
410d032535Smiod #define	IPL_NET		11	/* network */
420d032535Smiod #define	IPL_TTY		12	/* terminal */
4373bb9e10Smiod #define	IPL_VM		12
440d032535Smiod #define	IPL_CLOCK	14	/* clock */
4549356bd0Smiod #define	IPL_SCHED	14	/* scheduling */
460d032535Smiod #define	IPL_HIGH	15	/* everything */
470d032535Smiod 
48ee8a2a3cSkettenis #define	IPL_MPSAFE	0	/* no "mpsafe" interrupts */
49bfde8bbeSmpi #define	IPL_MPFLOOR	IPL_NONE	/* no MP on landisk */
50ee8a2a3cSkettenis 
51d083a34cSdlg #define	splraise(_ipl)		_cpu_intr_raise((_ipl) << 4)
52d083a34cSdlg #define	splsoftclock()		splraise(IPL_SOFTCLOCK)
53d083a34cSdlg #define	splsoftnet()		splraise(IPL_SOFTNET)
54d083a34cSdlg #define	splsoftserial()		splraise(IPL_SOFTSERIAL)
55d083a34cSdlg #define	splbio()		splraise(IPL_BIO)
56d083a34cSdlg #define	splnet()		splraise(IPL_NET)
57d083a34cSdlg #define	spltty()		splraise(IPL_TTY)
58d083a34cSdlg #define	splvm()			splraise(IPL_VM)
59d083a34cSdlg #define	splaudio()		splraise(IPL_AUDIO)
60d083a34cSdlg #define	splclock()		splraise(IPL_CLOCK)
610d032535Smiod #define	splstatclock()		splclock()
62d083a34cSdlg #define	splsched()		splraise(IPL_SCHED)
63dd1c16beSmiod #define	splhigh()		_cpu_intr_suspend()
640d032535Smiod 
650d032535Smiod #define	spl0()			_cpu_intr_resume(IPL_NONE << 4)
660d032535Smiod #define	splx(x)			_cpu_intr_resume(x)
670d032535Smiod 
68cd207159Smiod #ifdef DIAGNOSTIC
69cd207159Smiod /*
70cd207159Smiod  * Although this function is implemented in MI code, it must be in this MD
71cd207159Smiod  * header because we don't want this header to include MI includes.
72cd207159Smiod  */
73cd207159Smiod void splassert_fail(int, int, const char *);
74cd207159Smiod extern int splassert_ctl;
75cd207159Smiod void splassert_check(int, const char *);
76cd207159Smiod #define	splassert(__wantipl) \
77cd207159Smiod do {									\
787779a2d7Sthib 	if (splassert_ctl > 0) {					\
79cd207159Smiod 		splassert_check(__wantipl, __func__);			\
80cd207159Smiod 	}								\
81cd207159Smiod } while (0)
82312f6203Smiod #define splsoftassert(__wantipl) splassert(__wantipl)
83cd207159Smiod #else
840d032535Smiod #define	splassert(wantipl)	do { /* nothing yet */ } while (0)
85312f6203Smiod #define	splsoftassert(wantipl)	do { /* nothing yet */ } while (0)
86cd207159Smiod #endif
870d032535Smiod 
880d032535Smiod void intr_init(void);
890d032535Smiod void *extintr_establish(int, int, int (*)(void *), void *, const char *);
900d032535Smiod void extintr_disestablish(void *ih);
910d032535Smiod void extintr_enable(void *ih);
920d032535Smiod void extintr_disable(void *ih);
930d032535Smiod void extintr_disable_by_num(int irq);
940d032535Smiod 
952fa72412Spirofti #endif /* !_MACHINE_INTR_H_ */
96