intr.h revision 1.26
11.26Stsutsui/* $NetBSD: intr.h,v 1.26 2007/03/08 02:24:40 tsutsui 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.6Sscottr * 3. The name of the author may not be used to endorse or promote products 161.2Sscottr * derived from this software without specific prior written permission. 171.2Sscottr * 181.2Sscottr * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 191.2Sscottr * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 201.2Sscottr * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 211.2Sscottr * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 221.2Sscottr * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 231.2Sscottr * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 241.2Sscottr * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 251.2Sscottr * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 261.2Sscottr * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 271.2Sscottr * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 281.2Sscottr */ 291.1Sscottr 301.1Sscottr#ifndef _MAC68K_INTR_H_ 311.1Sscottr#define _MAC68K_INTR_H_ 321.1Sscottr 331.16Sthorpej#include <machine/psl.h> 341.16Sthorpej 351.1Sscottr#ifdef _KERNEL 361.1Sscottr 371.1Sscottr/* spl0 requires checking for software interrupts */ 381.1Sscottr 391.15Sthorpej/* 401.15Sthorpej * This array contains the appropriate PSL_S|PSL_IPL? values 411.15Sthorpej * to raise interrupt priority to the requested level. 421.15Sthorpej */ 431.15Sthorpejextern unsigned short mac68k_ipls[]; 441.15Sthorpej 451.26Stsutsui#define IPL_NONE 0 461.26Stsutsui#define IPL_SOFTCLOCK 1 471.26Stsutsui#define IPL_SOFTNET 2 481.26Stsutsui#define IPL_SOFTSERIAL 3 491.26Stsutsui#define IPL_SOFT 4 501.26Stsutsui#define IPL_BIO 5 511.26Stsutsui#define IPL_NET 6 521.26Stsutsui#define IPL_TTY 7 531.26Stsutsui#define IPL_VM 8 541.26Stsutsui#define IPL_AUDIO 9 551.26Stsutsui#define IPL_ADB 10 561.26Stsutsui#define IPL_STATCLOCK 11 571.26Stsutsui#define IPL_CLOCK 12 581.26Stsutsui#define IPL_SCHED 13 591.26Stsutsui#define IPL_SERIAL 14 601.26Stsutsui#define IPL_HIGH 15 611.26Stsutsui#define IPL_LOCK IPL_HIGH 621.26Stsutsui#define NIPL 16 631.15Sthorpej 641.4Sscottr/* These spl calls are _not_ to be used by machine-independent code. */ 651.26Stsutsui#define splsoft() splraise1() 661.26Stsutsui#define spladb() _splraise(mac68k_ipls[IPL_ADB]) 671.4Sscottr#define splzs() splserial() 681.7Sbriggs 691.7Sbriggs/* 701.1Sscottr * These should be used for: 711.1Sscottr * 1) ensuring mutual exclusion (why use processor level?) 721.1Sscottr * 2) allowing faster devices to take priority 731.1Sscottr */ 741.1Sscottr 751.1Sscottr/* watch out for side effects */ 761.1Sscottr#define splx(s) ((s) & PSL_IPL ? _spl(s) : spl0()) 771.1Sscottr 781.22Syamt 791.24Syamttypedef int ipl_t; 801.24Syamttypedef struct { 811.24Syamt ipl_t _ipl; 821.24Syamt} ipl_cookie_t; 831.24Syamt 841.24Syamtstatic inline ipl_cookie_t 851.24Syamtmakeiplcookie(ipl_t ipl) 861.24Syamt{ 871.24Syamt 881.24Syamt return (ipl_cookie_t){._ipl = ipl}; 891.24Syamt} 901.24Syamt 911.24Syamtstatic inline int 921.24Syamtsplraiseipl(ipl_cookie_t icookie) 931.24Syamt{ 941.24Syamt 951.24Syamt return _splraise(mac68k_ipls[icookie._ipl]); 961.24Syamt} 971.22Syamt 981.22Syamt#include <sys/spl.h> 991.22Syamt 1001.26Stsutsui#include <m68k/softintr.h> 1011.9Sscottr 1021.9Sscottr/* intr.c */ 1031.21Schsvoid intr_init(void); 1041.21Schsvoid intr_establish(int (*)(void *), void *, int); 1051.21Schsvoid intr_disestablish(int); 1061.21Schsvoid intr_dispatch(int); 1071.1Sscottr 1081.1Sscottr/* locore.s */ 1091.21Schsint spl0(void); 1101.1Sscottr#endif /* _KERNEL */ 1111.1Sscottr 1121.1Sscottr#endif /* _MAC68K_INTR_H_ */ 113