Home | History | Annotate | Line # | Download | only in include
intr.h revision 1.19
      1 /*	$NetBSD: intr.h,v 1.19 2007/03/11 05:22:25 thorpej Exp $	*/
      2 
      3 /*
      4  * Copyright (C) 1997 Scott Reynolds
      5  * Copyright (C) 1998 Darrin Jewell
      6  * All rights reserved.
      7  *
      8  * Redistribution and use in source and binary forms, with or without
      9  * modification, are permitted provided that the following conditions
     10  * are met:
     11  * 1. Redistributions of source code must retain the above copyright
     12  *    notice, this list of conditions and the following disclaimer.
     13  * 2. Redistributions in binary form must reproduce the above copyright
     14  *    notice, this list of conditions and the following disclaimer in the
     15  *    documentation and/or other materials provided with the distribution.
     16  * 3. The name of the author may not be used to endorse or promote products
     17  *    derived from this software without specific prior written permission.
     18  *
     19  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     20  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     21  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     22  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     23  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     24  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     25  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     26  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     28  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     29  */
     30 
     31 #ifndef _NEXT68K_INTR_H_
     32 #define _NEXT68K_INTR_H_
     33 
     34 #include <machine/psl.h>
     35 
     36 /* Probably want to dealwith IPL's here @@@ */
     37 
     38 #ifdef _KERNEL
     39 
     40 /* spl0 requires checking for software interrupts */
     41 
     42 /* watch out for side effects */
     43 #define splx(s)         ((s) & PSL_IPL ? _spl(s) : spl0())
     44 
     45 #define splsoft()	splraise1()
     46 #define splsoftnet()    splsoft()
     47 #define splsoftclock()	splsoft()
     48 #define splsoftserial()	splsoft()
     49 #define splbio()        splraise3()
     50 #define splnet()        splraise3()
     51 #define spltty()        splraise3()
     52 #define splserial()     splraise5()
     53 #define splvm()         splraise6()
     54 #define splclock()      splraise3()	/* ??? */
     55 #define splstatclock()  splclock()
     56 #define splhigh()       spl7()
     57 #define splsched()      spl7()
     58 #define spllock()       spl7()
     59 
     60 #define spldma()        splraise6()
     61 
     62 /****************************************************************/
     63 
     64 #define	IPL_NONE	0
     65 #define	IPL_SOFTCLOCK	1
     66 #define	IPL_SOFTNET	2
     67 #define	IPL_SOFTSERIAL	3
     68 #define	IPL_SOFT	4
     69 #define	IPL_BIO		5
     70 #define	IPL_NET		6
     71 #define	IPL_TTY		7
     72 #define	IPL_SERIAL	8
     73 #define	IPL_VM		9
     74 #define	IPL_CLOCK	10
     75 #define	IPL_STATCLOCK	IPL_CLOCK
     76 #define	IPL_HIGH	11
     77 #define	IPL_LOCK	IPL_HIGH
     78 #define	IPL_SCHED	IPL_HIGH
     79 #define	NIPL		12
     80 
     81 typedef int ipl_t;
     82 typedef struct {
     83 	uint16_t _psl;
     84 } ipl_cookie_t;
     85 
     86 extern const int ipl2psl_table[NIPL];
     87 
     88 ipl_cookie_t makeiplcookie(ipl_t);
     89 
     90 static inline int
     91 splraiseipl(ipl_cookie_t icookie)
     92 {
     93 
     94 	return _splraise(icookie._psl);
     95 }
     96 
     97 /****************************************************************/
     98 
     99 /* locore.s */
    100 int	spl0(void);
    101 
    102 extern volatile u_long *intrstat;
    103 extern volatile u_long *intrmask;
    104 #define INTR_SETMASK(x)		(*intrmask = (x))
    105 #define INTR_ENABLE(x)		(*intrmask |= NEXT_I_BIT(x))
    106 #define INTR_DISABLE(x)		(*intrmask &= (~NEXT_I_BIT(x)))
    107 #define INTR_OCCURRED(x)	(*intrstat & NEXT_I_BIT(x))
    108 
    109 #include <m68k/softintr.h>
    110 
    111 #endif /* _KERNEL */
    112 
    113 #endif /* _NEXT68K_INTR_H_ */
    114