Home | History | Annotate | Line # | Download | only in include
intr.h revision 1.1.2.3
      1  1.1.2.3  bouyer /*	$NetBSD: intr.h,v 1.1.2.3 2001/04/21 17:54:35 bouyer Exp $	*/
      2  1.1.2.2  bouyer 
      3  1.1.2.2  bouyer /*-
      4  1.1.2.2  bouyer  * Copyright (c) 1998 The NetBSD Foundation, Inc.
      5  1.1.2.2  bouyer  * All rights reserved.
      6  1.1.2.2  bouyer  *
      7  1.1.2.2  bouyer  * This code is derived from software contributed to The NetBSD Foundation
      8  1.1.2.2  bouyer  * by Charles M. Hannum.
      9  1.1.2.2  bouyer  *
     10  1.1.2.2  bouyer  * Redistribution and use in source and binary forms, with or without
     11  1.1.2.2  bouyer  * modification, are permitted provided that the following conditions
     12  1.1.2.2  bouyer  * are met:
     13  1.1.2.2  bouyer  * 1. Redistributions of source code must retain the above copyright
     14  1.1.2.2  bouyer  *    notice, this list of conditions and the following disclaimer.
     15  1.1.2.2  bouyer  * 2. Redistributions in binary form must reproduce the above copyright
     16  1.1.2.2  bouyer  *    notice, this list of conditions and the following disclaimer in the
     17  1.1.2.2  bouyer  *    documentation and/or other materials provided with the distribution.
     18  1.1.2.2  bouyer  * 3. All advertising materials mentioning features or use of this software
     19  1.1.2.2  bouyer  *    must display the following acknowledgement:
     20  1.1.2.2  bouyer  *        This product includes software developed by the NetBSD
     21  1.1.2.2  bouyer  *        Foundation, Inc. and its contributors.
     22  1.1.2.2  bouyer  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23  1.1.2.2  bouyer  *    contributors may be used to endorse or promote products derived
     24  1.1.2.2  bouyer  *    from this software without specific prior written permission.
     25  1.1.2.2  bouyer  *
     26  1.1.2.2  bouyer  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27  1.1.2.2  bouyer  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28  1.1.2.2  bouyer  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29  1.1.2.2  bouyer  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30  1.1.2.2  bouyer  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31  1.1.2.2  bouyer  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32  1.1.2.2  bouyer  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33  1.1.2.2  bouyer  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34  1.1.2.2  bouyer  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35  1.1.2.2  bouyer  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36  1.1.2.2  bouyer  * POSSIBILITY OF SUCH DAMAGE.
     37  1.1.2.2  bouyer  */
     38  1.1.2.2  bouyer /*
     39  1.1.2.2  bouyer  * Sandpoint-specific code developed
     40  1.1.2.2  bouyer  * by Allen Briggs for Wasabi Systems, Inc.
     41  1.1.2.2  bouyer  *
     42  1.1.2.2  bouyer  * OpenPIC code derived from code with the following notice.
     43  1.1.2.2  bouyer  */
     44  1.1.2.2  bouyer /*-
     45  1.1.2.2  bouyer  * Copyright (c) 2000 Tsubai Masanari.  All rights reserved.
     46  1.1.2.2  bouyer  *
     47  1.1.2.2  bouyer  * Redistribution and use in source and binary forms, with or without
     48  1.1.2.2  bouyer  * modification, are permitted provided that the following conditions
     49  1.1.2.2  bouyer  * are met:
     50  1.1.2.2  bouyer  * 1. Redistributions of source code must retain the above copyright
     51  1.1.2.2  bouyer  *    notice, this list of conditions and the following disclaimer.
     52  1.1.2.2  bouyer  * 2. Redistributions in binary form must reproduce the above copyright
     53  1.1.2.2  bouyer  *    notice, this list of conditions and the following disclaimer in the
     54  1.1.2.2  bouyer  *    documentation and/or other materials provided with the distribution.
     55  1.1.2.2  bouyer  * 3. The name of the author may not be used to endorse or promote products
     56  1.1.2.2  bouyer  *    derived from this software without specific prior written permission.
     57  1.1.2.2  bouyer  *
     58  1.1.2.2  bouyer  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     59  1.1.2.2  bouyer  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     60  1.1.2.2  bouyer  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     61  1.1.2.2  bouyer  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     62  1.1.2.2  bouyer  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     63  1.1.2.2  bouyer  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     64  1.1.2.2  bouyer  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     65  1.1.2.2  bouyer  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     66  1.1.2.2  bouyer  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     67  1.1.2.2  bouyer  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     68  1.1.2.2  bouyer  */
     69  1.1.2.2  bouyer 
     70  1.1.2.2  bouyer #ifndef _SANDPOINT_INTR_H_
     71  1.1.2.2  bouyer #define _SANDPOINT_INTR_H_
     72  1.1.2.2  bouyer 
     73  1.1.2.2  bouyer /* Interrupt priority `levels'. */
     74  1.1.2.2  bouyer #define	IPL_NONE	9	/* nothing */
     75  1.1.2.2  bouyer #define	IPL_SOFTCLOCK	8	/* software clock interrupt */
     76  1.1.2.2  bouyer #define	IPL_SOFTNET	7	/* software network interrupt */
     77  1.1.2.2  bouyer #define	IPL_BIO		6	/* block I/O */
     78  1.1.2.2  bouyer #define	IPL_NET		5	/* network */
     79  1.1.2.2  bouyer #define	IPL_SOFTSERIAL	4	/* software serial interrupt */
     80  1.1.2.2  bouyer #define	IPL_TTY		3	/* terminal */
     81  1.1.2.2  bouyer #define	IPL_IMP		3	/* memory allocation */
     82  1.1.2.2  bouyer #define	IPL_AUDIO	2	/* audio */
     83  1.1.2.2  bouyer #define	IPL_CLOCK	1	/* clock */
     84  1.1.2.2  bouyer #define	IPL_HIGH	1	/* everything */
     85  1.1.2.2  bouyer #define	IPL_SERIAL	0	/* serial */
     86  1.1.2.2  bouyer #define	NIPL		10
     87  1.1.2.2  bouyer 
     88  1.1.2.2  bouyer /* Interrupt sharing types. */
     89  1.1.2.2  bouyer #define	IST_NONE	0	/* none */
     90  1.1.2.2  bouyer #define	IST_PULSE	1	/* pulsed */
     91  1.1.2.2  bouyer #define	IST_EDGE	2	/* edge-triggered */
     92  1.1.2.2  bouyer #define	IST_LEVEL	3	/* level-triggered */
     93  1.1.2.2  bouyer 
     94  1.1.2.2  bouyer #ifndef _LOCORE
     95  1.1.2.2  bouyer 
     96  1.1.2.2  bouyer /*
     97  1.1.2.2  bouyer  * Interrupt handler chains.  intr_establish() inserts a handler into
     98  1.1.2.2  bouyer  * the list.  The handler is called with its (single) argument.
     99  1.1.2.2  bouyer  */
    100  1.1.2.2  bouyer struct intrhand {
    101  1.1.2.2  bouyer 	int	(*ih_fun)(void *);
    102  1.1.2.2  bouyer 	void	*ih_arg;
    103  1.1.2.2  bouyer 	u_long	ih_count;
    104  1.1.2.2  bouyer 	struct	intrhand *ih_next;
    105  1.1.2.2  bouyer 	int	ih_level;
    106  1.1.2.2  bouyer 	int	ih_irq;
    107  1.1.2.2  bouyer };
    108  1.1.2.2  bouyer 
    109  1.1.2.2  bouyer void	setsoftclock(void);
    110  1.1.2.2  bouyer void	clearsoftclock(void);
    111  1.1.2.2  bouyer int	splsoftclock(void);
    112  1.1.2.2  bouyer void	setsoftnet(void);
    113  1.1.2.2  bouyer void	clearsoftnet(void);
    114  1.1.2.2  bouyer int	splsoftnet(void);
    115  1.1.2.2  bouyer 
    116  1.1.2.2  bouyer void	do_pending_int(void);
    117  1.1.2.2  bouyer void	*intr_establish(int, int, int, int (*)(void *), void *);
    118  1.1.2.2  bouyer void	intr_disestablish(void *);
    119  1.1.2.2  bouyer 
    120  1.1.2.2  bouyer static __inline int splraise(int);
    121  1.1.2.2  bouyer static __inline int spllower(int);
    122  1.1.2.2  bouyer static __inline void splx(int);
    123  1.1.2.2  bouyer static __inline void set_sint(int);
    124  1.1.2.2  bouyer 
    125  1.1.2.2  bouyer void softnet __P((int));	/* Defined in machdep.c, used in extintr.c */
    126  1.1.2.2  bouyer 
    127  1.1.2.2  bouyer extern volatile int cpl, ipending, astpending, tickspending;
    128  1.1.2.2  bouyer extern int imask[];
    129  1.1.2.2  bouyer extern long intrcnt[];
    130  1.1.2.2  bouyer 
    131  1.1.2.2  bouyer /*
    132  1.1.2.2  bouyer  * Reorder protection in the following inline functions is
    133  1.1.2.2  bouyer  * protected with the "eieio" instruction.
    134  1.1.2.2  bouyer  */
    135  1.1.2.2  bouyer static __inline int
    136  1.1.2.2  bouyer splraise(newcpl)
    137  1.1.2.2  bouyer 	int newcpl;
    138  1.1.2.2  bouyer {
    139  1.1.2.2  bouyer 	int oldcpl;
    140  1.1.2.2  bouyer 
    141  1.1.2.2  bouyer 	__asm__ volatile("sync; eieio\n");	/* don't reorder.... */
    142  1.1.2.2  bouyer 	oldcpl = cpl;
    143  1.1.2.2  bouyer 	cpl = oldcpl | newcpl;
    144  1.1.2.2  bouyer 	__asm__ volatile("sync; eieio\n");	/* reorder protect */
    145  1.1.2.2  bouyer 	return(oldcpl);
    146  1.1.2.2  bouyer }
    147  1.1.2.2  bouyer 
    148  1.1.2.2  bouyer static __inline void
    149  1.1.2.2  bouyer splx(newcpl)
    150  1.1.2.2  bouyer 	int newcpl;
    151  1.1.2.2  bouyer {
    152  1.1.2.2  bouyer 	__asm__ volatile("sync; eieio\n");	/* reorder protect */
    153  1.1.2.2  bouyer 	cpl = newcpl;
    154  1.1.2.2  bouyer 	if(ipending & ~newcpl)
    155  1.1.2.2  bouyer 		do_pending_int();
    156  1.1.2.2  bouyer 	__asm__ volatile("sync; eieio\n");	/* reorder protect */
    157  1.1.2.2  bouyer }
    158  1.1.2.2  bouyer 
    159  1.1.2.2  bouyer static __inline int
    160  1.1.2.2  bouyer spllower(newcpl)
    161  1.1.2.2  bouyer 	int newcpl;
    162  1.1.2.2  bouyer {
    163  1.1.2.2  bouyer 	int oldcpl;
    164  1.1.2.2  bouyer 
    165  1.1.2.2  bouyer 	__asm__ volatile("sync; eieio\n");	/* reorder protect */
    166  1.1.2.2  bouyer 	oldcpl = cpl;
    167  1.1.2.2  bouyer 	cpl = newcpl;
    168  1.1.2.2  bouyer 	if(ipending & ~newcpl)
    169  1.1.2.2  bouyer 		do_pending_int();
    170  1.1.2.2  bouyer 	__asm__ volatile("sync; eieio\n");	/* reorder protect */
    171  1.1.2.2  bouyer 	return(oldcpl);
    172  1.1.2.2  bouyer }
    173  1.1.2.2  bouyer 
    174  1.1.2.2  bouyer /* Following code should be implemented with lwarx/stwcx to avoid
    175  1.1.2.2  bouyer  * the disable/enable. i need to read the manual once more.... */
    176  1.1.2.2  bouyer static __inline void
    177  1.1.2.2  bouyer set_sint(pending)
    178  1.1.2.2  bouyer 	int	pending;
    179  1.1.2.2  bouyer {
    180  1.1.2.2  bouyer 	int	msrsave;
    181  1.1.2.2  bouyer 
    182  1.1.2.2  bouyer 	__asm__ ("mfmsr %0" : "=r"(msrsave));
    183  1.1.2.2  bouyer 	__asm__ volatile ("mtmsr %0" :: "r"(msrsave & ~PSL_EE));
    184  1.1.2.2  bouyer 	ipending |= pending;
    185  1.1.2.2  bouyer 	__asm__ volatile ("mtmsr %0" :: "r"(msrsave));
    186  1.1.2.2  bouyer }
    187  1.1.2.2  bouyer 
    188  1.1.2.2  bouyer /*
    189  1.1.2.2  bouyer  * Motorola SandPoint PPC eval board interrupt list
    190  1.1.2.2  bouyer  */
    191  1.1.2.2  bouyer #define	SANDPOINT_INTR_PCI0		0
    192  1.1.2.2  bouyer #define	SANDPOINT_INTR_IDE0		SANDPOINT_INTR_PCI0
    193  1.1.2.2  bouyer #define	SANDPOINT_INTR_PCI1		1
    194  1.1.2.2  bouyer #define	SANDPOINT_INTR_IDE1		SANDPOINT_INTR_PCI1
    195  1.1.2.2  bouyer #define	SANDPOINT_INTR_ISA		SANDPOINT_INTR_PCI1
    196  1.1.2.2  bouyer #define	SANDPOINT_INTR_PCI2		2
    197  1.1.2.2  bouyer #define	SANDPOINT_INTR_PCI3		3
    198  1.1.2.2  bouyer #define	SANDPOINT_INTR_SERCON		4	/* Not used on Unity X4 */
    199  1.1.2.2  bouyer #define	SANDPOINT_INTR_I2C		5
    200  1.1.2.2  bouyer #define	SANDPOINT_INTR_DMA0		6
    201  1.1.2.2  bouyer #define	SANDPOINT_INTR_DMA1		7
    202  1.1.2.2  bouyer #define	SANDPOINT_INTR_I2O		8
    203  1.1.2.2  bouyer #define	SANDPOINT_INTR_TIMER0		9
    204  1.1.2.2  bouyer #define	SANDPOINT_INTR_TIMER1		10
    205  1.1.2.2  bouyer #define	SANDPOINT_INTR_TIMER2		11
    206  1.1.2.2  bouyer #define	SANDPOINT_INTR_TIMER3		12
    207  1.1.2.2  bouyer 
    208  1.1.2.2  bouyer #define	OPENPIC_MAX_EXTERNAL_INT	4
    209  1.1.2.2  bouyer 
    210  1.1.2.2  bouyer #define	ICU_LEN		13
    211  1.1.2.2  bouyer #define	ICU_MASK	0x00001fff
    212  1.1.2.2  bouyer #define	LEGAL_IRQ(x)	((x) >= 0 && (x) < ICU_LEN)
    213  1.1.2.2  bouyer 
    214  1.1.2.2  bouyer #define	SINT_ISA	0x10000000
    215  1.1.2.2  bouyer #define	SINT_NET	0x20000000
    216  1.1.2.2  bouyer #define	SINT_CLOCK	0x40000000
    217  1.1.2.2  bouyer #define	SINT_SERIAL	0x80000000
    218  1.1.2.2  bouyer #define	SPL_CLOCK	0x00000001
    219  1.1.2.2  bouyer #define	SINT_MASK	(SINT_ISA|SINT_CLOCK|SINT_NET|SINT_SERIAL)
    220  1.1.2.2  bouyer 
    221  1.1.2.2  bouyer #define	CNT_SINT_ISA	28
    222  1.1.2.2  bouyer #define	CNT_SINT_NET	29
    223  1.1.2.2  bouyer #define	CNT_SINT_CLOCK	30
    224  1.1.2.2  bouyer #define	CNT_SINT_SERIAL	31
    225  1.1.2.2  bouyer #define	CNT_CLOCK	0
    226  1.1.2.2  bouyer 
    227  1.1.2.2  bouyer #define splbio()	splraise(imask[IPL_BIO])
    228  1.1.2.2  bouyer #define splnet()	splraise(imask[IPL_NET])
    229  1.1.2.2  bouyer #define spltty()	splraise(imask[IPL_TTY])
    230  1.1.2.2  bouyer #define splclock()	splraise(imask[IPL_CLOCK])
    231  1.1.2.2  bouyer #define splvm()		splraise(imask[IPL_IMP])
    232  1.1.2.2  bouyer #define	splserial()	splraise(imask[IPL_SERIAL])
    233  1.1.2.2  bouyer #define splstatclock()	splclock()
    234  1.1.2.2  bouyer #define	spllowersoftclock() spllower(imask[IPL_SOFTCLOCK])
    235  1.1.2.2  bouyer #define	splsoftclock()	splraise(imask[IPL_SOFTCLOCK])
    236  1.1.2.2  bouyer #define	splsoftnet()	splraise(imask[IPL_SOFTNET])
    237  1.1.2.2  bouyer #define	splsoftserial()	splraise(imask[IPL_SOFTSERIAL])
    238  1.1.2.2  bouyer 
    239  1.1.2.2  bouyer #define spllpt()	spltty()
    240  1.1.2.2  bouyer 
    241  1.1.2.2  bouyer #define	setsoftisa()	set_sint(SINT_ISA);
    242  1.1.2.2  bouyer #define	setsoftclock()	set_sint(SINT_CLOCK);
    243  1.1.2.2  bouyer #define	setsoftnet()	set_sint(SINT_NET);
    244  1.1.2.2  bouyer #define	setsoftserial()	set_sint(SINT_SERIAL);
    245  1.1.2.2  bouyer 
    246  1.1.2.2  bouyer #define	splhigh()	splraise(imask[IPL_HIGH])
    247  1.1.2.2  bouyer #define	spl0()		spllower(0)
    248  1.1.2.2  bouyer 
    249  1.1.2.2  bouyer #define splsched()	splhigh()
    250  1.1.2.2  bouyer #define spllock()	splhigh()
    251  1.1.2.2  bouyer 
    252  1.1.2.2  bouyer #endif /* !_LOCORE */
    253  1.1.2.2  bouyer 
    254  1.1.2.2  bouyer #endif /* !_SANDPOINT_INTR_H_ */
    255