1 /* $OpenBSD: intr.h,v 1.11 2013/05/17 19:38:52 kettenis 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 50 #define splsoftclock() _cpu_intr_raise(IPL_SOFTCLOCK << 4) 51 #define splsoftnet() _cpu_intr_raise(IPL_SOFTNET << 4) 52 #define splsoftserial() _cpu_intr_raise(IPL_SOFTSERIAL << 4) 53 #define splbio() _cpu_intr_raise(IPL_BIO << 4) 54 #define splnet() _cpu_intr_raise(IPL_NET << 4) 55 #define spltty() _cpu_intr_raise(IPL_TTY << 4) 56 #define splvm() _cpu_intr_raise(IPL_VM << 4) 57 #define splaudio() _cpu_intr_raise(IPL_AUDIO << 4) 58 #define splclock() _cpu_intr_raise(IPL_CLOCK << 4) 59 #define splstatclock() splclock() 60 #define splsched() _cpu_intr_raise(IPL_SCHED << 4) 61 #define splhigh() _cpu_intr_suspend() 62 #define spllock() splhigh() 63 64 #define spl0() _cpu_intr_resume(IPL_NONE << 4) 65 #define splx(x) _cpu_intr_resume(x) 66 67 #ifdef DIAGNOSTIC 68 /* 69 * Although this function is implemented in MI code, it must be in this MD 70 * header because we don't want this header to include MI includes. 71 */ 72 void splassert_fail(int, int, const char *); 73 extern int splassert_ctl; 74 void splassert_check(int, const char *); 75 #define splassert(__wantipl) \ 76 do { \ 77 if (splassert_ctl > 0) { \ 78 splassert_check(__wantipl, __func__); \ 79 } \ 80 } while (0) 81 #define splsoftassert(__wantipl) splassert(__wantipl) 82 #else 83 #define splassert(wantipl) do { /* nothing yet */ } while (0) 84 #define splsoftassert(wantipl) do { /* nothing yet */ } while (0) 85 #endif 86 87 void intr_init(void); 88 void *extintr_establish(int, int, int (*)(void *), void *, const char *); 89 void extintr_disestablish(void *ih); 90 void extintr_enable(void *ih); 91 void extintr_disable(void *ih); 92 void extintr_disable_by_num(int irq); 93 94 #endif /* !_MACHINE_INTR_H_ */ 95