Home | History | Annotate | Line # | Download | only in include
intr.h revision 1.2.2.2
      1  1.2.2.2  bouyer /*	$NetBSD: intr.h,v 1.2.2.2 2001/01/18 09:23:00 bouyer 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.2.2.1  bouyer 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.2.2.2  bouyer #define	splvm()		splraise(imask[IPL_IMP])
    114      1.1  itojun #define	splhigh()	splraise(imask[IPL_HIGH])
    115  1.2.2.1  bouyer #define	splsched()	splhigh()
    116  1.2.2.1  bouyer #define	spllock()	splhigh()
    117      1.1  itojun #define	spl0()		spllower(0)
    118  1.2.2.1  bouyer #define	splx(x)		spllower(x)
    119      1.1  itojun 
    120      1.1  itojun /*
    121      1.1  itojun  * Software interrupt registration
    122      1.1  itojun  *
    123      1.1  itojun  * We hand-code this to ensure that it's atomic.
    124      1.1  itojun  */
    125      1.1  itojun static __inline void
    126      1.1  itojun softintr(mask)
    127      1.1  itojun 	register int mask;
    128      1.1  itojun {
    129  1.2.2.1  bouyer 	extern void enable_interrupt(void);	/* XXX */
    130  1.2.2.1  bouyer 	extern void disable_interrupt(void);
    131  1.2.2.1  bouyer 
    132  1.2.2.1  bouyer 	disable_interrupt();
    133      1.1  itojun 	ipending |= (1 << mask);
    134  1.2.2.1  bouyer 	enable_interrupt();
    135      1.1  itojun }
    136      1.1  itojun 
    137      1.1  itojun #define	setsoftast()	(astpending = 1)
    138      1.1  itojun #define	setsoftclock()	softintr(SIR_CLOCK)
    139      1.1  itojun #define	setsoftnet()	softintr(SIR_NET)
    140      1.1  itojun #define	setsoftserial()	softintr(SIR_SERIAL)
    141      1.1  itojun 
    142      1.1  itojun #endif /* !_LOCORE */
    143      1.1  itojun 
    144      1.1  itojun #define	INTEVT_SOFT	0xf00	/* This value is stored to INTEVT reg,
    145      1.1  itojun 				   when software interrupt occured */
    146      1.1  itojun #define INTEVT_TMU0 0x400
    147      1.1  itojun #define INTEVT_TMU1 0x420
    148      1.1  itojun #define INTEVT_TMU2 0x440
    149  1.2.2.1  bouyer 
    150  1.2.2.1  bouyer #define INTEVT_SCI0_ERI	0x4e0
    151  1.2.2.1  bouyer #define INTEVT_SCI0_RXI	0x500
    152  1.2.2.1  bouyer #define INTEVT_SCI0_TXI	0x520
    153  1.2.2.1  bouyer #define INTEVT_SCI0_TEI	0x540
    154  1.2.2.1  bouyer 
    155  1.2.2.1  bouyer #define INTEVT_WDT	0x560
    156  1.2.2.1  bouyer 
    157  1.2.2.1  bouyer #define IS_INTEVT_SCI0(x) ((x == INTEVT_SCI0_ERI) || (x == INTEVT_SCI0_RXI) \
    158  1.2.2.1  bouyer 			|| (x == INTEVT_SCI0_TXI) || (x == INTEVT_SCI0_TEI))
    159  1.2.2.1  bouyer 
    160  1.2.2.1  bouyer #define	INTEVT_PRI	0x4a0	/* Periodic interrupt generated by RTC */
    161  1.2.2.1  bouyer 
    162  1.2.2.1  bouyer #if defined(SH4)
    163  1.2.2.1  bouyer #define	INTEVT_SCIF	0x700
    164  1.2.2.1  bouyer #endif
    165      1.1  itojun 
    166      1.1  itojun #endif /* !_SH3_INTR_H_ */
    167