1 /* $NetBSD: intr.h,v 1.23 2005/12/24 20:07:15 perry Exp $ */ 2 3 /* 4 * Copyright (C) 1997 Scott Reynolds 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 3. The name of the author may not be used to endorse or promote products 16 * derived from this software without specific prior written permission. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 */ 29 30 #ifndef _MAC68K_INTR_H_ 31 #define _MAC68K_INTR_H_ 32 33 #include <machine/psl.h> 34 35 #ifdef _KERNEL 36 37 /* spl0 requires checking for software interrupts */ 38 39 /* 40 * This array contains the appropriate PSL_S|PSL_IPL? values 41 * to raise interrupt priority to the requested level. 42 */ 43 extern unsigned short mac68k_ipls[]; 44 45 #define MAC68K_IPL_NONE 0 46 #define MAC68K_IPL_SOFT 1 47 #define MAC68K_IPL_BIO 2 48 #define MAC68K_IPL_NET 3 49 #define MAC68K_IPL_TTY 4 50 #define MAC68K_IPL_IMP 5 51 #define MAC68K_IPL_AUDIO 6 52 #define MAC68K_IPL_SERIAL 7 53 #define MAC68K_IPL_ADB 8 54 #define MAC68K_IPL_CLOCK 9 55 #define MAC68K_IPL_STATCLOCK 10 56 #define MAC68K_IPL_SCHED 11 57 #define MAC68K_IPL_HIGH 12 58 #define MAC68K_NIPLS 13 59 60 /* These spl calls are _not_ to be used by machine-independent code. */ 61 #define spladb() _splraise(mac68k_ipls[MAC68K_IPL_ADB]) 62 #define splzs() splserial() 63 64 /* 65 * These should be used for: 66 * 1) ensuring mutual exclusion (why use processor level?) 67 * 2) allowing faster devices to take priority 68 */ 69 #define spllowersoftclock() spl1() 70 71 /* watch out for side effects */ 72 #define splx(s) ((s) & PSL_IPL ? _spl(s) : spl0()) 73 74 #define IPL_NONE MAC68K_IPL_NONE 75 #define IPL_SOFTCLOCK MAC68K_IPL_SOFT 76 #define IPL_SOFTNET MAC68K_IPL_SOFT 77 #define IPL_BIO MAC68K_IPL_BIO 78 #define IPL_NET MAC68K_IPL_NET 79 #define IPL_TTY MAC68K_IPL_TTY 80 #define IPL_VM MAC68K_IPL_IMP 81 #define IPL_AUDIO MAC68K_IPL_AUDIO 82 #define IPL_CLOCK MAC68K_IPL_CLOCK 83 #define IPL_STATCLOCK MAC68K_IPL_STATCLOCK 84 #define IPL_SCHED MAC68K_IPL_SCHED 85 #define IPL_HIGH MAC68K_IPL_HIGH 86 #define IPL_LOCK MAC68K_IPL_HIGH 87 #define IPL_SERIAL MAC68K_IPL_SERIAL 88 89 #define splraiseipl(x) _splraise(mac68k_ipls[x]) 90 91 #include <sys/spl.h> 92 93 /* 94 * simulated software interrupt register 95 */ 96 extern volatile u_int8_t ssir; 97 98 #define SIR_NET 0x01 99 #define SIR_CLOCK 0x02 100 #define SIR_SERIAL 0x04 101 #define SIR_DTMGR 0x08 102 #define SIR_ADB 0x10 103 104 #define siron(mask) \ 105 __asm volatile ( "orb %1,%0" : "=m" (ssir) : "i" (mask)) 106 #define siroff(mask) \ 107 __asm volatile ( "andb %1,%0" : "=m" (ssir) : "ir" (~(mask))); 108 109 #define setsoftnet() siron(SIR_NET) 110 #define setsoftclock() siron(SIR_CLOCK) 111 #define setsoftserial() siron(SIR_SERIAL) 112 #define setsoftdtmgr() siron(SIR_DTMGR) 113 #define setsoftadb() siron(SIR_ADB) 114 115 /* intr.c */ 116 void intr_init(void); 117 void intr_establish(int (*)(void *), void *, int); 118 void intr_disestablish(int); 119 void intr_dispatch(int); 120 121 /* locore.s */ 122 int spl0(void); 123 #endif /* _KERNEL */ 124 125 #endif /* _MAC68K_INTR_H_ */ 126