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