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