intr.h revision 1.3
11.3Sscottr/* $NetBSD: intr.h,v 1.3 1997/05/12 07:29:29 scottr Exp $ */ 21.2Sscottr 31.2Sscottr/* 41.2Sscottr * Copyright (C) 1997 Scott Reynolds 51.2Sscottr * All rights reserved. 61.2Sscottr * 71.2Sscottr * Redistribution and use in source and binary forms, with or without 81.2Sscottr * modification, are permitted provided that the following conditions 91.2Sscottr * are met: 101.2Sscottr * 1. Redistributions of source code must retain the above copyright 111.2Sscottr * notice, this list of conditions and the following disclaimer. 121.2Sscottr * 2. Redistributions in binary form must reproduce the above copyright 131.2Sscottr * notice, this list of conditions and the following disclaimer in the 141.2Sscottr * documentation and/or other materials provided with the distribution. 151.2Sscottr * 3. All advertising materials mentioning features or use of this software 161.2Sscottr * must display the following acknowledgement: 171.2Sscottr * This product includes software developed by Scott Reynolds for 181.2Sscottr * the NetBSD Project. 191.2Sscottr * 4. The name of the author may not be used to endorse or promote products 201.2Sscottr * derived from this software without specific prior written permission. 211.2Sscottr * 221.2Sscottr * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 231.2Sscottr * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 241.2Sscottr * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 251.2Sscottr * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 261.2Sscottr * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 271.2Sscottr * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 281.2Sscottr * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 291.2Sscottr * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 301.2Sscottr * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 311.2Sscottr * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 321.2Sscottr */ 331.1Sscottr 341.1Sscottr#ifndef _MAC68K_INTR_H_ 351.1Sscottr#define _MAC68K_INTR_H_ 361.1Sscottr 371.1Sscottr#ifdef _KERNEL 381.1Sscottr/* 391.1Sscottr * spl functions; all but spl0 are done in-line 401.1Sscottr */ 411.1Sscottr 421.1Sscottr#define _spl(s) \ 431.1Sscottr({ \ 441.1Sscottr register int _spl_r; \ 451.1Sscottr \ 461.1Sscottr __asm __volatile ("clrl %0; movew sr,%0; movew %1,sr" : \ 471.1Sscottr "&=d" (_spl_r) : "di" (s)); \ 481.1Sscottr _spl_r; \ 491.1Sscottr}) 501.1Sscottr 511.1Sscottr#define _splraise(s) \ 521.1Sscottr({ \ 531.1Sscottr register int _spl_r; \ 541.1Sscottr \ 551.1Sscottr __asm __volatile ("clrl %0; movew sr,%0;" : "&=d" (_spl_r) : ); \ 561.1Sscottr if ((_spl_r & PSL_IPL) < ((s) & PSL_IPL)) \ 571.1Sscottr __asm __volatile ("movew %0,sr;" : : "di" (s)); \ 581.1Sscottr _spl_r; \ 591.1Sscottr}) 601.1Sscottr 611.1Sscottr/* spl0 requires checking for software interrupts */ 621.1Sscottr#define spl1() _spl(PSL_S|PSL_IPL1) 631.1Sscottr#define spl2() _spl(PSL_S|PSL_IPL2) 641.1Sscottr#define spl3() _spl(PSL_S|PSL_IPL3) 651.1Sscottr#define spl4() _spl(PSL_S|PSL_IPL4) 661.1Sscottr#define spl5() _spl(PSL_S|PSL_IPL5) 671.1Sscottr#define spl6() _spl(PSL_S|PSL_IPL6) 681.1Sscottr#define spl7() _spl(PSL_S|PSL_IPL7) 691.1Sscottr 701.1Sscottr/* 711.1Sscottr * These should be used for: 721.1Sscottr * 1) ensuring mutual exclusion (why use processor level?) 731.1Sscottr * 2) allowing faster devices to take priority 741.1Sscottr * 751.1Sscottr * Note that on the Mac, most things are masked at spl1, almost 761.1Sscottr * everything at spl2, and everything but the panic switch and 771.1Sscottr * power at spl4. 781.1Sscottr */ 791.1Sscottr#define splsoftclock() spl1() /* disallow softclock */ 801.1Sscottr#define splsoftnet() spl1() /* disallow network */ 811.1Sscottr#define spltty() spl1() /* disallow tty (softserial & ADB) */ 821.1Sscottr#define splbio() spl2() /* disallow block I/O */ 831.1Sscottr#define splnet() spl2() /* disallow network */ 841.1Sscottr#define splimp() spl2() /* mutual exclusion for memory allocation */ 851.1Sscottr#define splclock() spl2() /* disallow clock (and other) interrupts */ 861.1Sscottr#define splstatclock() spl2() /* ditto */ 871.1Sscottr#define splzs() spl4() /* disallow serial hw interrupts */ 881.1Sscottr#define spladb() spl7() /* disallow adb interrupts */ 891.1Sscottr#define splhigh() spl7() /* disallow everything */ 901.1Sscottr#define splsched() spl7() /* disallow scheduling */ 911.1Sscottr 921.1Sscottr/* watch out for side effects */ 931.1Sscottr#define splx(s) ((s) & PSL_IPL ? _spl(s) : spl0()) 941.1Sscottr 951.1Sscottr/* 961.1Sscottr * simulated software interrupt register 971.1Sscottr */ 981.1Sscottrextern volatile u_int8_t ssir; 991.1Sscottr 1001.1Sscottr#define SIR_NET 0x01 1011.1Sscottr#define SIR_CLOCK 0x02 1021.1Sscottr#define SIR_SERIAL 0x04 1031.3Sscottr#define SIR_DTMGR 0x08 1041.1Sscottr 1051.1Sscottr#define siron(mask) \ 1061.1Sscottr __asm __volatile ( "orb %0,_ssir" : : "i" (mask)) 1071.1Sscottr#define siroff(mask) \ 1081.1Sscottr __asm __volatile ( "andb %0,_ssir" : : "ir" (~(mask))); 1091.1Sscottr 1101.1Sscottr#define setsoftnet() siron(SIR_NET) 1111.1Sscottr#define setsoftclock() siron(SIR_CLOCK) 1121.1Sscottr#define setsoftserial() siron(SIR_SERIAL) 1131.3Sscottr#define setsoftdtmgr() siron(SIR_DTMGR) 1141.1Sscottr 1151.1Sscottr/* locore.s */ 1161.1Sscottrint spl0 __P((void)); 1171.1Sscottr#endif /* _KERNEL */ 1181.1Sscottr 1191.1Sscottr#endif /* _MAC68K_INTR_H_ */ 120