Home | History | Annotate | Line # | Download | only in include
intr.h revision 1.1
      1  1.1  soda /*	$NetBSD: intr.h,v 1.1 2000/01/23 20:24:28 soda Exp $	*/
      2  1.1  soda 
      3  1.1  soda /*
      4  1.1  soda  * Copyright (c) 1996 Charles M. Hannum.  All rights reserved.
      5  1.1  soda  *
      6  1.1  soda  * Redistribution and use in source and binary forms, with or without
      7  1.1  soda  * modification, are permitted provided that the following conditions
      8  1.1  soda  * are met:
      9  1.1  soda  * 1. Redistributions of source code must retain the above copyright
     10  1.1  soda  *    notice, this list of conditions and the following disclaimer.
     11  1.1  soda  * 2. Redistributions in binary form must reproduce the above copyright
     12  1.1  soda  *    notice, this list of conditions and the following disclaimer in the
     13  1.1  soda  *    documentation and/or other materials provided with the distribution.
     14  1.1  soda  * 3. All advertising materials mentioning features or use of this software
     15  1.1  soda  *    must display the following acknowledgement:
     16  1.1  soda  *	This product includes software developed by Charles M. Hannum.
     17  1.1  soda  * 4. The name of the author may not be used to endorse or promote products
     18  1.1  soda  *    derived from this software without specific prior written permission.
     19  1.1  soda  *
     20  1.1  soda  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     21  1.1  soda  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     22  1.1  soda  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     23  1.1  soda  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     24  1.1  soda  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     25  1.1  soda  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     26  1.1  soda  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     27  1.1  soda  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     28  1.1  soda  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     29  1.1  soda  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     30  1.1  soda  */
     31  1.1  soda 
     32  1.1  soda #ifndef _ARC_INTR_H_
     33  1.1  soda #define _ARC_INTR_H_
     34  1.1  soda 
     35  1.1  soda /* Interrupt priority `levels'; not mutually exclusive. */
     36  1.1  soda #define	IPL_BIO		0	/* block I/O */
     37  1.1  soda #define	IPL_NET		1	/* network */
     38  1.1  soda #define	IPL_TTY		2	/* terminal */
     39  1.1  soda #define	IPL_CLOCK	3	/* clock */
     40  1.1  soda #define	IPL_IMP		4	/* memory allocation */
     41  1.1  soda #define	IPL_NONE	5	/* nothing */
     42  1.1  soda #define	IPL_HIGH	6	/* everything */
     43  1.1  soda 
     44  1.1  soda /* Interrupt sharing types. */
     45  1.1  soda #define	IST_NONE	0	/* none */
     46  1.1  soda #define	IST_PULSE	1	/* pulsed */
     47  1.1  soda #define	IST_EDGE	2	/* edge-triggered */
     48  1.1  soda #define	IST_LEVEL	3	/* level-triggered */
     49  1.1  soda 
     50  1.1  soda /* Soft interrupt masks. */
     51  1.1  soda #define	SIR_CLOCK	31
     52  1.1  soda #define	SIR_CLOCKMASK	((1 << SIR_CLOCK))
     53  1.1  soda #define	SIR_NET		30
     54  1.1  soda #define	SIR_NETMASK	((1 << SIR_NET) | SIR_CLOCKMASK)
     55  1.1  soda #define	SIR_TTY		29
     56  1.1  soda #define	SIR_TTYMASK	((1 << SIR_TTY) | SIR_CLOCKMASK)
     57  1.1  soda #define	SIR_ALLMASK	(SIR_CLOCKMASK | SIR_NETMASK | SIR_TTYMASK)
     58  1.1  soda 
     59  1.1  soda #ifndef _LOCORE
     60  1.1  soda 
     61  1.1  soda void setsoftclock __P((void));
     62  1.1  soda void clearsoftclock __P((void));
     63  1.1  soda int  splsoftclock __P((void));
     64  1.1  soda void setsoftnet   __P((void));
     65  1.1  soda void clearsoftnet __P((void));
     66  1.1  soda int  splsoftnet   __P((void));
     67  1.1  soda 
     68  1.1  soda struct clockframe;
     69  1.1  soda void set_intr __P((int, int(*)(u_int, struct clockframe *), int));
     70  1.1  soda 
     71  1.1  soda volatile int cpl, ipending, astpending;
     72  1.1  soda int imask[7];
     73  1.1  soda 
     74  1.1  soda #if 0
     75  1.1  soda extern void Xspllower __P((void));
     76  1.1  soda 
     77  1.1  soda static __inline int splraise __P((int));
     78  1.1  soda static __inline int spllower __P((int));
     79  1.1  soda static __inline void splx __P((int));
     80  1.1  soda static __inline void softintr __P((int));
     81  1.1  soda 
     82  1.1  soda /*
     83  1.1  soda  * Add a mask to cpl, and return the old value of cpl.
     84  1.1  soda  */
     85  1.1  soda static __inline int
     86  1.1  soda splraise(ncpl)
     87  1.1  soda 	register int ncpl;
     88  1.1  soda {
     89  1.1  soda 	register int ocpl = cpl;
     90  1.1  soda 
     91  1.1  soda 	cpl = ocpl | ncpl;
     92  1.1  soda 	return (ocpl);
     93  1.1  soda }
     94  1.1  soda 
     95  1.1  soda /*
     96  1.1  soda  * Restore a value to cpl (unmasking interrupts).  If any unmasked
     97  1.1  soda  * interrupts are pending, call Xspllower() to process them.
     98  1.1  soda  */
     99  1.1  soda static __inline void
    100  1.1  soda splx(ncpl)
    101  1.1  soda 	register int ncpl;
    102  1.1  soda {
    103  1.1  soda 
    104  1.1  soda 	cpl = ncpl;
    105  1.1  soda 	if (ipending & ~ncpl)
    106  1.1  soda 		Xspllower();
    107  1.1  soda }
    108  1.1  soda 
    109  1.1  soda /*
    110  1.1  soda  * Same as splx(), but we return the old value of spl, for the
    111  1.1  soda  * benefit of some splsoftclock() callers.
    112  1.1  soda  */
    113  1.1  soda static __inline int
    114  1.1  soda spllower(ncpl)
    115  1.1  soda 	register int ncpl;
    116  1.1  soda {
    117  1.1  soda 	register int ocpl = cpl;
    118  1.1  soda 
    119  1.1  soda 	cpl = ncpl;
    120  1.1  soda 	if (ipending & ~ncpl)
    121  1.1  soda 		Xspllower();
    122  1.1  soda 	return (ocpl);
    123  1.1  soda }
    124  1.1  soda #endif
    125  1.1  soda 
    126  1.1  soda /*
    127  1.1  soda  * Hardware interrupt masks
    128  1.1  soda  */
    129  1.1  soda #if 0
    130  1.1  soda #define	splbio()	splraise(imask[IPL_BIO])
    131  1.1  soda #define	splnet()	splraise(imask[IPL_NET])
    132  1.1  soda #define	spltty()	splraise(imask[IPL_TTY])
    133  1.1  soda #define	splclock()	splraise(imask[IPL_CLOCK])
    134  1.1  soda #define	splimp()	splraise(imask[IPL_IMP])
    135  1.1  soda #define	splstatclock()	splclock()
    136  1.1  soda 
    137  1.1  soda /*
    138  1.1  soda  * Software interrupt masks
    139  1.1  soda  *
    140  1.1  soda  * NOTE: splsoftclock() is used by hardclock() to lower the priority from
    141  1.1  soda  * clock to softclock before it calls softclock().
    142  1.1  soda  */
    143  1.1  soda #define	splsoftclock()	spllower(SIR_CLOCKMASK)
    144  1.1  soda #define	splsoftnet()	splraise(SIR_NETMASK)
    145  1.1  soda #define	splsofttty()	splraise(SIR_TTYMASK)
    146  1.1  soda 
    147  1.1  soda /*
    148  1.1  soda  * Miscellaneous
    149  1.1  soda  */
    150  1.1  soda #define	splhigh()	splraise(-1)
    151  1.1  soda #define	spl0()		spllower(0)
    152  1.1  soda 
    153  1.1  soda /*
    154  1.1  soda  * Software interrupt registration
    155  1.1  soda  *
    156  1.1  soda  * We hand-code this to ensure that it's atomic.
    157  1.1  soda  */
    158  1.1  soda static __inline void
    159  1.1  soda softintr(mask)
    160  1.1  soda 	register int mask;
    161  1.1  soda {
    162  1.1  soda 
    163  1.1  soda 	__asm __volatile("orl %0,_ipending" : : "ir" (mask));
    164  1.1  soda }
    165  1.1  soda 
    166  1.1  soda #define	setsoftast()	(astpending = 1)
    167  1.1  soda #define	setsoftclock()	softintr(1 << SIR_CLOCK)
    168  1.1  soda #define	setsoftnet()	softintr(1 << SIR_NET)
    169  1.1  soda #define	setsofttty()	softintr(1 << SIR_TTY)
    170  1.1  soda #endif
    171  1.1  soda 
    172  1.1  soda #endif /* _LOCORE */
    173  1.1  soda 
    174  1.1  soda #endif /* _ARC_INTR_H_ */
    175