Home | History | Annotate | Line # | Download | only in include
intr.h revision 1.1
      1  1.1  dbj /*	$NetBSD: intr.h,v 1.1 1998/06/09 07:53:05 dbj Exp $	*/
      2  1.1  dbj 
      3  1.1  dbj /*
      4  1.1  dbj  * Copyright (C) 1997 Scott Reynolds
      5  1.1  dbj  * Copyright (C) 1998 Darrin Jewell
      6  1.1  dbj  * All rights reserved.
      7  1.1  dbj  *
      8  1.1  dbj  * Redistribution and use in source and binary forms, with or without
      9  1.1  dbj  * modification, are permitted provided that the following conditions
     10  1.1  dbj  * are met:
     11  1.1  dbj  * 1. Redistributions of source code must retain the above copyright
     12  1.1  dbj  *    notice, this list of conditions and the following disclaimer.
     13  1.1  dbj  * 2. Redistributions in binary form must reproduce the above copyright
     14  1.1  dbj  *    notice, this list of conditions and the following disclaimer in the
     15  1.1  dbj  *    documentation and/or other materials provided with the distribution.
     16  1.1  dbj  * 3. The name of the author may not be used to endorse or promote products
     17  1.1  dbj  *    derived from this software without specific prior written permission.
     18  1.1  dbj  *
     19  1.1  dbj  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     20  1.1  dbj  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     21  1.1  dbj  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     22  1.1  dbj  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     23  1.1  dbj  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     24  1.1  dbj  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     25  1.1  dbj  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     26  1.1  dbj  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     27  1.1  dbj  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     28  1.1  dbj  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     29  1.1  dbj  */
     30  1.1  dbj 
     31  1.1  dbj #ifndef _NEXT68K_INTR_H_
     32  1.1  dbj #define _NEXT68K_INTR_H_
     33  1.1  dbj 
     34  1.1  dbj #include <machine/psl.h>
     35  1.1  dbj 
     36  1.1  dbj /* Probably want to dealwith IPL's here @@@ */
     37  1.1  dbj 
     38  1.1  dbj #ifdef _KERNEL
     39  1.1  dbj /*
     40  1.1  dbj  * spl functions; all but spl0 are done in-line
     41  1.1  dbj  */
     42  1.1  dbj 
     43  1.1  dbj #define _spl(s)								\
     44  1.1  dbj ({									\
     45  1.1  dbj         register int _spl_r;						\
     46  1.1  dbj 									\
     47  1.1  dbj         __asm __volatile ("clrl %0; movew sr,%0; movew %1,sr" :		\
     48  1.1  dbj                 "&=d" (_spl_r) : "di" (s));				\
     49  1.1  dbj         _spl_r;								\
     50  1.1  dbj })
     51  1.1  dbj 
     52  1.1  dbj #define _splraise(s)							\
     53  1.1  dbj ({									\
     54  1.1  dbj 	int _spl_r;							\
     55  1.1  dbj 									\
     56  1.1  dbj 	__asm __volatile ("						\
     57  1.1  dbj 		clrl	d0					;	\
     58  1.1  dbj 		movw	sr,d0					;	\
     59  1.1  dbj 		movl	d0,%0					;	\
     60  1.1  dbj 		andw	#0x700,d0				;	\
     61  1.1  dbj 		movw	%1,d1					;	\
     62  1.1  dbj 		andw	#0x700,d1				;	\
     63  1.1  dbj 		cmpw	d0,d1					;	\
     64  1.1  dbj 		jle	1f					;	\
     65  1.1  dbj 		movw	%1,sr					;	\
     66  1.1  dbj 	    1:"							:	\
     67  1.1  dbj 		    "&=d" (_spl_r)				:	\
     68  1.1  dbj 		    "di" (s)					:	\
     69  1.1  dbj 		    "d0", "d1");					\
     70  1.1  dbj 	_spl_r;								\
     71  1.1  dbj })
     72  1.1  dbj 
     73  1.1  dbj /* spl0 requires checking for software interrupts */
     74  1.1  dbj #define spl1()  _spl(PSL_S|PSL_IPL1)
     75  1.1  dbj #define spl2()  _spl(PSL_S|PSL_IPL2)
     76  1.1  dbj #define spl3()  _spl(PSL_S|PSL_IPL3)
     77  1.1  dbj #define spl4()  _spl(PSL_S|PSL_IPL4)
     78  1.1  dbj #define spl5()  _spl(PSL_S|PSL_IPL5)
     79  1.1  dbj #define spl6()  _spl(PSL_S|PSL_IPL6)
     80  1.1  dbj #define spl7()  _spl(PSL_S|PSL_IPL7)
     81  1.1  dbj 
     82  1.1  dbj /* watch out for side effects */
     83  1.1  dbj #define splx(s)         ((s) & PSL_IPL ? _spl(s) : spl0())
     84  1.1  dbj 
     85  1.1  dbj /****************************************************************/
     86  1.1  dbj 
     87  1.1  dbj #define spldma()        spl6()
     88  1.1  dbj 
     89  1.1  dbj #define splscc()        spl5()
     90  1.1  dbj 
     91  1.1  dbj #define splsched()      spl3()
     92  1.1  dbj 
     93  1.1  dbj /* IPL used by soft interrupts: netintr(), softclock() */
     94  1.1  dbj #define splsoftclock()  spl1()
     95  1.1  dbj #define splsoftnet()    spl2()
     96  1.1  dbj 
     97  1.1  dbj 
     98  1.1  dbj /* Highest block device (strategy) IPL. */
     99  1.1  dbj #define splbio()        spl3()
    100  1.1  dbj 
    101  1.1  dbj /* Highest tty device IPL. */
    102  1.1  dbj #define spltty()        spl1()
    103  1.1  dbj 
    104  1.1  dbj /* Highest network interface IPL. */
    105  1.1  dbj #define splnet()        spl2()
    106  1.1  dbj 
    107  1.1  dbj /*
    108  1.1  dbj  * Requirement: imp >= (highest network, tty, or disk IPL)
    109  1.1  dbj  * This is used mostly in the VM code. (Why not splvm?)
    110  1.1  dbj  * Note that the VM code runs at spl7 during kernel
    111  1.1  dbj  * initialization, and later at spl0, so we have to
    112  1.1  dbj  * use splraise to avoid enabling interrupts early.
    113  1.1  dbj  */
    114  1.1  dbj #if 0
    115  1.1  dbj #define splimp()        _splraise(PSL_S|PSL_IPL3)
    116  1.1  dbj #else
    117  1.1  dbj #define splimp()        _splraise(PSL_S|PSL_IPL6)
    118  1.1  dbj #endif
    119  1.1  dbj 
    120  1.1  dbj #define splclock()      spl6()
    121  1.1  dbj #define splstatclock()  splclock()
    122  1.1  dbj 
    123  1.1  dbj /* Block out all interrupts (except NMI of course). */
    124  1.1  dbj #define splhigh()       spl7()
    125  1.1  dbj 
    126  1.1  dbj /****************************************************************/
    127  1.1  dbj 
    128  1.1  dbj /*
    129  1.1  dbj  * simulated software interrupt register
    130  1.1  dbj  */
    131  1.1  dbj extern volatile u_int8_t ssir;
    132  1.1  dbj 
    133  1.1  dbj #define	SIR_NET		0x01
    134  1.1  dbj #define	SIR_CLOCK	0x02
    135  1.1  dbj #define	SIR_SERIAL	0x04
    136  1.1  dbj #define SIR_DTMGR	0x08
    137  1.1  dbj #define SIR_ADB		0x10
    138  1.1  dbj 
    139  1.1  dbj #define	siron(mask)	\
    140  1.1  dbj 	__asm __volatile ( "orb %0,_ssir" : : "i" (mask))
    141  1.1  dbj #define	siroff(mask)	\
    142  1.1  dbj 	__asm __volatile ( "andb %0,_ssir" : : "ir" (~(mask)));
    143  1.1  dbj 
    144  1.1  dbj #define	setsoftnet()	siron(SIR_NET)
    145  1.1  dbj #define	setsoftclock()	siron(SIR_CLOCK)
    146  1.1  dbj #define	setsoftserial()	siron(SIR_SERIAL)
    147  1.1  dbj #define	setsoftdtmgr()	siron(SIR_DTMGR)
    148  1.1  dbj #define	setsoftadb()	siron(SIR_ADB)
    149  1.1  dbj 
    150  1.1  dbj /* locore.s */
    151  1.1  dbj int	spl0 __P((void));
    152  1.1  dbj #endif /* _KERNEL */
    153  1.1  dbj 
    154  1.1  dbj #define INTR_SETMASK(x)  ((*(volatile u_long *)IIOV(NEXT_P_INTRMASK))=(x))
    155  1.1  dbj #define INTR_ENABLE(x)   ((*(volatile u_long *)IIOV(NEXT_P_INTRMASK))|=NEXT_I_BIT(x))
    156  1.1  dbj #define INTR_DISABLE(x)  ((*(volatile u_long *)IIOV(NEXT_P_INTRMASK))&=(~NEXT_I_BIT(x)))
    157  1.1  dbj #define INTR_OCCURRED(x)  ((*(volatile u_long *)IIOV(NEXT_P_INTRSTAT))& NEXT_I_BIT(x))
    158  1.1  dbj 
    159  1.1  dbj #endif /* _NEXT68K_INTR_H_ */
    160