Home | History | Annotate | Line # | Download | only in include
intr.h revision 1.12
      1  1.12      chs /*	$NetBSD: intr.h,v 1.12 2005/01/19 01:58:21 chs 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.11  mycroft #include <sys/device.h>
     35  1.11  mycroft #include <sys/queue.h>
     36   1.1      dbj #include <machine/psl.h>
     37   1.1      dbj 
     38   1.1      dbj /* Probably want to dealwith IPL's here @@@ */
     39   1.1      dbj 
     40   1.1      dbj #ifdef _KERNEL
     41   1.1      dbj 
     42   1.1      dbj /* spl0 requires checking for software interrupts */
     43   1.1      dbj 
     44   1.1      dbj /* watch out for side effects */
     45   1.1      dbj #define splx(s)         ((s) & PSL_IPL ? _spl(s) : spl0())
     46   1.1      dbj 
     47   1.1      dbj /****************************************************************/
     48   1.1      dbj 
     49   1.4      dbj #define splhigh()       spl7()
     50   1.4      dbj #define splserial()     _splraise(PSL_S|PSL_IPL5)
     51   1.7  thorpej #define splsched()      spl7()
     52   1.8  thorpej #define spllock()	spl7()
     53  1.11  mycroft #define splclock()      _splraise(PSL_S|PSL_IPL3)
     54   1.4      dbj #define splstatclock()  splclock()
     55   1.9  thorpej #define splvm()         _splraise(PSL_S|PSL_IPL6)
     56   1.4      dbj #define spltty()        _splraise(PSL_S|PSL_IPL3)
     57   1.4      dbj #define splbio()        _splraise(PSL_S|PSL_IPL3)
     58   1.4      dbj #define splnet()        _splraise(PSL_S|PSL_IPL3)
     59   1.4      dbj #define splsoftnet()    _splraise(PSL_S|PSL_IPL2)
     60   1.6  thorpej #define	splsoftclock()	splraise1()
     61   1.6  thorpej #define spllowersoftclock() spl1()
     62   1.1      dbj 
     63   1.4      dbj #define spldma()        _splraise(PSL_S|PSL_IPL6)
     64   1.1      dbj 
     65   1.1      dbj /****************************************************************/
     66   1.1      dbj 
     67   1.1      dbj /*
     68   1.1      dbj  * simulated software interrupt register
     69   1.1      dbj  */
     70   1.1      dbj extern volatile u_int8_t ssir;
     71   1.1      dbj 
     72   1.1      dbj #define	SIR_NET		0x01
     73   1.1      dbj #define	SIR_CLOCK	0x02
     74   1.1      dbj #define	SIR_SERIAL	0x04
     75   1.1      dbj #define SIR_DTMGR	0x08
     76   1.1      dbj #define SIR_ADB		0x10
     77   1.1      dbj 
     78   1.1      dbj #define	siron(mask)	\
     79   1.3   kleink 	__asm __volatile ( "orb %1,%0" : "=m" (ssir) : "i" (mask))
     80   1.1      dbj #define	siroff(mask)	\
     81   1.3   kleink 	__asm __volatile ( "andb %1,%0" : "=m" (ssir) : "ir" (~(mask)));
     82   1.1      dbj 
     83   1.1      dbj #define	setsoftnet()	siron(SIR_NET)
     84   1.1      dbj #define	setsoftclock()	siron(SIR_CLOCK)
     85   1.1      dbj #define	setsoftserial()	siron(SIR_SERIAL)
     86   1.1      dbj #define	setsoftdtmgr()	siron(SIR_DTMGR)
     87   1.1      dbj #define	setsoftadb()	siron(SIR_ADB)
     88   1.2      dbj 
     89  1.12      chs extern u_long allocate_sir(void (*)(void *),void *);
     90  1.12      chs extern void init_sir(void);
     91   1.1      dbj 
     92   1.1      dbj /* locore.s */
     93  1.12      chs int	spl0(void);
     94  1.11  mycroft 
     95  1.11  mycroft extern volatile u_long *intrstat;
     96  1.11  mycroft extern volatile u_long *intrmask;
     97  1.11  mycroft #define INTR_SETMASK(x)		(*intrmask = (x))
     98  1.11  mycroft #define INTR_ENABLE(x)		(*intrmask |= NEXT_I_BIT(x))
     99  1.11  mycroft #define INTR_DISABLE(x)		(*intrmask &= (~NEXT_I_BIT(x)))
    100  1.11  mycroft #define INTR_OCCURRED(x)	(*intrstat & NEXT_I_BIT(x))
    101  1.11  mycroft 
    102   1.1      dbj #endif /* _KERNEL */
    103   1.1      dbj 
    104   1.1      dbj #endif /* _NEXT68K_INTR_H_ */
    105