Home | History | Annotate | Line # | Download | only in include
intr.h revision 1.7
      1  1.7  msaitoh /*	$NetBSD: intr.h,v 1.7 2000/08/17 00:01:53 msaitoh Exp $	*/
      2  1.1   itojun 
      3  1.1   itojun /*
      4  1.1   itojun  * Copyright (c) 1996, 1997 Charles M. Hannum.  All rights reserved.
      5  1.1   itojun  *
      6  1.1   itojun  * Redistribution and use in source and binary forms, with or without
      7  1.1   itojun  * modification, are permitted provided that the following conditions
      8  1.1   itojun  * are met:
      9  1.1   itojun  * 1. Redistributions of source code must retain the above copyright
     10  1.1   itojun  *    notice, this list of conditions and the following disclaimer.
     11  1.1   itojun  * 2. Redistributions in binary form must reproduce the above copyright
     12  1.1   itojun  *    notice, this list of conditions and the following disclaimer in the
     13  1.1   itojun  *    documentation and/or other materials provided with the distribution.
     14  1.1   itojun  * 3. All advertising materials mentioning features or use of this software
     15  1.1   itojun  *    must display the following acknowledgement:
     16  1.1   itojun  *	This product includes software developed by Charles M. Hannum.
     17  1.1   itojun  * 4. The name of the author may not be used to endorse or promote products
     18  1.1   itojun  *    derived from this software without specific prior written permission.
     19  1.1   itojun  *
     20  1.1   itojun  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     21  1.1   itojun  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     22  1.1   itojun  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     23  1.1   itojun  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     24  1.1   itojun  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     25  1.1   itojun  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     26  1.1   itojun  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     27  1.1   itojun  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     28  1.1   itojun  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     29  1.1   itojun  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     30  1.1   itojun  */
     31  1.1   itojun 
     32  1.1   itojun /*
     33  1.1   itojun  * SH3 Version
     34  1.1   itojun  *
     35  1.1   itojun  * T.Horiuchi Brains Corp.  5/22/98
     36  1.1   itojun  */
     37  1.1   itojun 
     38  1.1   itojun #ifndef _SH3_INTR_H_
     39  1.1   itojun #define _SH3_INTR_H_
     40  1.1   itojun 
     41  1.1   itojun /* Interrupt sharing types. */
     42  1.1   itojun #define	IST_NONE	0	/* none */
     43  1.1   itojun #define	IST_PULSE	1	/* pulsed */
     44  1.1   itojun #define	IST_EDGE	2	/* edge-triggered */
     45  1.1   itojun #define	IST_LEVEL	3	/* level-triggered */
     46  1.1   itojun 
     47  1.1   itojun #ifndef _LOCORE
     48  1.1   itojun 
     49  1.1   itojun volatile int cpl, ipending, astpending;
     50  1.1   itojun int imask[NIPL];
     51  1.1   itojun 
     52  1.1   itojun extern void Xspllower __P((void));
     53  1.1   itojun 
     54  1.1   itojun static __inline int splraise __P((int));
     55  1.6  msaitoh static __inline void spllower __P((int));
     56  1.1   itojun static __inline void softintr __P((int));
     57  1.1   itojun 
     58  1.1   itojun /*
     59  1.1   itojun  * Add a mask to cpl, and return the old value of cpl.
     60  1.1   itojun  */
     61  1.1   itojun static __inline int
     62  1.1   itojun splraise(ncpl)
     63  1.1   itojun 	register int ncpl;
     64  1.1   itojun {
     65  1.1   itojun 	int ocpl ;
     66  1.1   itojun 
     67  1.1   itojun 	ocpl = cpl;
     68  1.1   itojun 
     69  1.1   itojun 	cpl = ocpl | ncpl;
     70  1.1   itojun 	return (ocpl);
     71  1.1   itojun }
     72  1.1   itojun 
     73  1.1   itojun /*
     74  1.1   itojun  * Restore a value to cpl (unmasking interrupts).  If any unmasked
     75  1.1   itojun  * interrupts are pending, call Xspllower() to process them.
     76  1.1   itojun  */
     77  1.1   itojun static __inline void
     78  1.1   itojun spllower(ncpl)
     79  1.1   itojun 	register int ncpl;
     80  1.1   itojun {
     81  1.1   itojun 
     82  1.1   itojun 	cpl = ncpl;
     83  1.1   itojun 	if (ipending & ~ncpl)
     84  1.1   itojun 		Xspllower();
     85  1.1   itojun }
     86  1.1   itojun 
     87  1.1   itojun /*
     88  1.1   itojun  * Hardware interrupt masks
     89  1.1   itojun  */
     90  1.1   itojun #define	splbio()	splraise(imask[IPL_BIO])
     91  1.1   itojun #define	splnet()	splraise(imask[IPL_NET])
     92  1.1   itojun #define	spltty()	splraise(imask[IPL_TTY])
     93  1.1   itojun #define	splaudio()	splraise(imask[IPL_AUDIO])
     94  1.1   itojun #define	splclock()	splraise(imask[IPL_CLOCK])
     95  1.1   itojun #define	splstatclock()	splclock()
     96  1.1   itojun #define	splserial()	splraise(imask[IPL_SERIAL])
     97  1.1   itojun 
     98  1.1   itojun /*
     99  1.1   itojun  * Software interrupt masks
    100  1.1   itojun  *
    101  1.1   itojun  * NOTE: splsoftclock() is used by hardclock() to lower the priority from
    102  1.1   itojun  * clock to softclock before it calls softclock().
    103  1.1   itojun  */
    104  1.2   tsubai #define	spllowersoftclock() spllower(imask[IPL_SOFTCLOCK])
    105  1.2   tsubai #define	splsoftclock()	splraise(imask[IPL_SOFTCLOCK])
    106  1.1   itojun #define	splsoftnet()	splraise(imask[IPL_SOFTNET])
    107  1.1   itojun #define	splsoftserial()	splraise(imask[IPL_SOFTSERIAL])
    108  1.1   itojun 
    109  1.1   itojun /*
    110  1.1   itojun  * Miscellaneous
    111  1.1   itojun  */
    112  1.1   itojun #define	splimp()	splraise(imask[IPL_IMP])
    113  1.1   itojun #define	splhigh()	splraise(imask[IPL_HIGH])
    114  1.1   itojun #define	spl0()		spllower(0)
    115  1.6  msaitoh #define	splx(x)		spllower(x)
    116  1.1   itojun 
    117  1.1   itojun /*
    118  1.1   itojun  * Software interrupt registration
    119  1.1   itojun  *
    120  1.1   itojun  * We hand-code this to ensure that it's atomic.
    121  1.1   itojun  */
    122  1.1   itojun static __inline void
    123  1.1   itojun softintr(mask)
    124  1.1   itojun 	register int mask;
    125  1.1   itojun {
    126  1.4  msaitoh 	extern void enable_interrupt(void);	/* XXX */
    127  1.4  msaitoh 	extern void disable_interrupt(void);
    128  1.4  msaitoh 
    129  1.4  msaitoh 	disable_interrupt();
    130  1.1   itojun 	ipending |= (1 << mask);
    131  1.4  msaitoh 	enable_interrupt();
    132  1.1   itojun }
    133  1.1   itojun 
    134  1.1   itojun #define	setsoftast()	(astpending = 1)
    135  1.1   itojun #define	setsoftclock()	softintr(SIR_CLOCK)
    136  1.1   itojun #define	setsoftnet()	softintr(SIR_NET)
    137  1.1   itojun #define	setsoftserial()	softintr(SIR_SERIAL)
    138  1.1   itojun 
    139  1.1   itojun #endif /* !_LOCORE */
    140  1.1   itojun 
    141  1.1   itojun #define	INTEVT_SOFT	0xf00	/* This value is stored to INTEVT reg,
    142  1.1   itojun 				   when software interrupt occured */
    143  1.1   itojun #define INTEVT_TMU0 0x400
    144  1.1   itojun #define INTEVT_TMU1 0x420
    145  1.1   itojun #define INTEVT_TMU2 0x440
    146  1.3  msaitoh 
    147  1.3  msaitoh #define INTEVT_SCI0_ERI	0x4e0
    148  1.3  msaitoh #define INTEVT_SCI0_RXI	0x500
    149  1.3  msaitoh #define INTEVT_SCI0_TXI	0x520
    150  1.3  msaitoh #define INTEVT_SCI0_TEI	0x540
    151  1.7  msaitoh 
    152  1.7  msaitoh #define INTEVT_WDT	0x560
    153  1.3  msaitoh 
    154  1.3  msaitoh #define IS_INTEVT_SCI0(x) ((x == INTEVT_SCI0_ERI) || (x == INTEVT_SCI0_RXI) \
    155  1.3  msaitoh 			|| (x == INTEVT_SCI0_TXI) || (x == INTEVT_SCI0_TEI))
    156  1.3  msaitoh 
    157  1.3  msaitoh #define	INTEVT_PRI	0x4a0	/* Periodic interrupt generated by RTC */
    158  1.3  msaitoh 
    159  1.3  msaitoh #if defined(SH4)
    160  1.3  msaitoh #define	INTEVT_SCIF	0x700
    161  1.3  msaitoh #endif
    162  1.1   itojun 
    163  1.1   itojun #endif /* !_SH3_INTR_H_ */
    164