1 /* $NetBSD: intr.h,v 1.22 2005/12/11 12:18:06 christos Exp $ */ 2 3 /*- 4 * Copyright (c) 1998 The NetBSD Foundation, Inc. 5 * All rights reserved. 6 * 7 * This code is derived from software contributed to The NetBSD Foundation 8 * by Charles M. Hannum. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 3. All advertising materials mentioning features or use of this software 19 * must display the following acknowledgement: 20 * This product includes software developed by the NetBSD 21 * Foundation, Inc. and its contributors. 22 * 4. Neither the name of The NetBSD Foundation nor the names of its 23 * contributors may be used to endorse or promote products derived 24 * from this software without specific prior written permission. 25 * 26 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 27 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 28 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 29 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 30 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 36 * POSSIBILITY OF SUCH DAMAGE. 37 */ 38 39 #ifndef _MACPPC_INTR_H_ 40 #define _MACPPC_INTR_H_ 41 42 #ifdef _KERNEL_OPT 43 #include "opt_multiprocessor.h" 44 #endif 45 46 /* Interrupt priority `levels'. */ 47 #define IPL_NONE 9 /* nothing */ 48 #define IPL_SOFTCLOCK 8 /* timeouts */ 49 #define IPL_SOFTNET 7 /* protocol stacks */ 50 #define IPL_BIO 6 /* block I/O */ 51 #define IPL_NET 5 /* network */ 52 #define IPL_SOFTSERIAL 4 /* serial */ 53 #define IPL_TTY 3 /* terminal */ 54 #define IPL_VM 3 /* memory allocation */ 55 #define IPL_AUDIO 2 /* audio */ 56 #define IPL_CLOCK 1 /* clock */ 57 #define IPL_HIGH 1 /* everything */ 58 #define IPL_SERIAL 0 /* serial */ 59 #define NIPL 10 60 61 /* Interrupt sharing types. */ 62 #define IST_NONE 0 /* none */ 63 #define IST_PULSE 1 /* pulsed */ 64 #define IST_EDGE 2 /* edge-triggered */ 65 #define IST_LEVEL 3 /* level-triggered */ 66 67 #ifndef _LOCORE 68 #ifdef __HAVE_GENERIC_SOFT_INTERRUPTS 69 #include <powerpc/softintr.h> 70 #endif 71 72 /* 73 * Interrupt handler chains. intr_establish() inserts a handler into 74 * the list. The handler is called with its (single) argument. 75 */ 76 struct intrhand { 77 int (*ih_fun) __P((void *)); 78 void *ih_arg; 79 struct intrhand *ih_next; 80 int ih_level; 81 int ih_irq; 82 }; 83 84 void softnet __P((int)); 85 void softserial __P((void)); 86 87 int splraise __P((int)); 88 int spllower __P((int)); 89 void splx __P((int)); 90 void softintr __P((int)); 91 92 extern volatile int astpending, tickspending; 93 extern int imask[]; 94 95 #define ICU_LEN 64 96 97 /* Soft interrupt masks. */ 98 #define SIR_CLOCK 28 99 #define SIR_NET 29 100 #define SIR_SERIAL 30 101 #define SPL_CLOCK 31 102 103 /* 104 * Hardware interrupt masks 105 */ 106 #define splbio() splraise(imask[IPL_BIO]) 107 #define splnet() splraise(imask[IPL_NET]) 108 #define spltty() splraise(imask[IPL_TTY]) 109 #define splaudio() splraise(imask[IPL_AUDIO]) 110 #define splclock() splraise(imask[IPL_CLOCK]) 111 #define splstatclock() splclock() 112 #define splserial() splraise(imask[IPL_SERIAL]) 113 114 #define spllpt() spltty() 115 116 /* 117 * Software interrupt masks 118 * 119 * NOTE: splsoftclock() is used by hardclock() to lower the priority from 120 * clock to softclock before it calls softclock(). 121 */ 122 #define spllowersoftclock() spllower(imask[IPL_SOFTCLOCK]) 123 #define splsoftclock() splraise(imask[IPL_SOFTCLOCK]) 124 #define splsoftnet() splraise(imask[IPL_SOFTNET]) 125 #define splsoftserial() splraise(imask[IPL_SOFTSERIAL]) 126 127 /* 128 * Miscellaneous 129 */ 130 #define splvm() splraise(imask[IPL_VM]) 131 #define splhigh() splraise(imask[IPL_HIGH]) 132 #define splsched() splhigh() 133 #define spllock() splhigh() 134 #define spl0() spllower(0) 135 136 #define setsoftclock() softintr(SIR_CLOCK) 137 #define setsoftnet() softintr(SIR_NET) 138 #define setsoftserial() softintr(SIR_SERIAL) 139 140 #ifdef MULTIPROCESSOR 141 #define MACPPC_IPI_HALT 0x0001 142 #define MACPPC_IPI_FLUSH_FPU 0x0002 143 #define MACPPC_IPI_FLUSH_VEC 0x0004 144 145 struct cpu_info; 146 void macppc_send_ipi(volatile struct cpu_info *, u_long); 147 #endif 148 149 #define CLKF_BASEPRI(frame) ((frame)->pri == 0) 150 151 #endif /* _LOCORE */ 152 153 #endif /* _MACPPC_INTR_H_ */ 154