1 /* $OpenBSD: intr.h,v 1.39 2009/03/15 19:40:40 miod Exp $ */ 2 3 /* 4 * Copyright (c) 1997 Per Fogelstrom, Opsycon AB and RTMX Inc, USA. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 3. All advertising materials mentioning features or use of this software 15 * must display the following acknowledgement: 16 * This product includes software developed under OpenBSD by 17 * Per Fogelstrom, Opsycon AB, Sweden for RTMX Inc, North Carolina USA. 18 * 4. The name of the author may not be used to endorse or promote products 19 * derived from this software without specific prior written permission. 20 * 21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 22 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 23 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 25 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 * 33 */ 34 35 #ifndef _POWERPC_INTR_H_ 36 #define _POWERPC_INTR_H_ 37 38 #define IPL_NONE 0 39 #define IPL_BIO 1 40 #define IPL_AUDIO IPL_BIO /* XXX - was defined this val in audio_if.h */ 41 #define IPL_NET 2 42 #define IPL_TTY 3 43 #define IPL_VM 4 44 #define IPL_CLOCK 5 45 #define IPL_HIGH 6 46 #define IPL_NUM 7 47 48 #define IST_NONE 0 49 #define IST_PULSE 1 50 #define IST_EDGE 2 51 #define IST_LEVEL 3 52 53 #if defined(_KERNEL) && !defined(_LOCORE) 54 55 #include <sys/evcount.h> 56 #include <machine/atomic.h> 57 58 #define PPC_NIRQ 66 59 #define PPC_CLK_IRQ 64 60 #define PPC_STAT_IRQ 65 61 62 void setsoftclock(void); 63 void clearsoftclock(void); 64 int splsoftclock(void); 65 void setsoftnet(void); 66 void clearsoftnet(void); 67 int splsoftnet(void); 68 69 int splraise(int); 70 int spllower(int); 71 void splx(int); 72 73 74 void do_pending_int(void); 75 76 extern int imask[IPL_NUM]; 77 78 /* SPL asserts */ 79 #define splassert(wantipl) /* nothing */ 80 #define splsoftassert(wantipl) /* nothing */ 81 82 #define set_sint(p) atomic_setbits_int(&curcpu()->ci_ipending, p) 83 84 #define SINT_CLOCK 0x10000000 85 #define SINT_NET 0x20000000 86 #define SINT_TTY 0x40000000 87 #define SPL_CLOCK 0x80000000 88 #define SINT_MASK (SINT_CLOCK|SINT_NET|SINT_TTY) 89 90 #define splbio() splraise(imask[IPL_BIO]) 91 #define splnet() splraise(imask[IPL_NET]) 92 #define spltty() splraise(imask[IPL_TTY]) 93 #define splaudio() splraise(imask[IPL_AUDIO]) 94 #define splclock() splraise(imask[IPL_CLOCK]) 95 #define splvm() splraise(imask[IPL_VM]) 96 #define splsched() splhigh() 97 #define spllock() splhigh() 98 #define splstatclock() splhigh() 99 #define splsoftclock() splraise(SINT_CLOCK) 100 #define splsoftnet() splraise(SINT_NET|SINT_CLOCK) 101 #define splsofttty() splraise(SINT_TTY|SINT_NET|SINT_CLOCK) 102 103 #define setsoftclock() set_sint(SINT_CLOCK); 104 #define setsoftnet() set_sint(SINT_NET); 105 #define setsofttty() set_sint(SINT_TTY); 106 107 #define splhigh() splraise(0xffffffff) 108 #define spl0() spllower(0) 109 110 /* 111 * Interrupt control struct used to control the ICU setup. 112 */ 113 114 struct intrhand { 115 struct intrhand *ih_next; 116 int (*ih_fun)(void *); 117 void *ih_arg; 118 struct evcount ih_count; 119 int ih_level; 120 int ih_irq; 121 char *ih_what; 122 }; 123 extern int ppc_configed_intr_cnt; 124 #define MAX_PRECONF_INTR 16 125 extern struct intrhand ppc_configed_intr[MAX_PRECONF_INTR]; 126 void softnet(int isr); 127 128 #define PPC_IPI_NOP 0 129 #define PPC_IPI_DDB 1 130 131 void ppc_send_ipi(struct cpu_info *, int); 132 133 #endif /* _LOCORE */ 134 #endif /* _POWERPC_INTR_H_ */ 135