Home | History | Annotate | Line # | Download | only in include
intr.h revision 1.13.16.3
      1  1.13.16.3     yamt /*	$NetBSD: intr.h,v 1.13.16.3 2006/12/10 05:25:44 yamt Exp $	*/
      2        1.2      scw 
      3        1.2      scw /*-
      4        1.2      scw  * Copyright (c) 2000 The NetBSD Foundation, Inc.
      5        1.2      scw  * All rights reserved.
      6        1.2      scw  *
      7        1.2      scw  * This code is derived from software contributed to The NetBSD Foundation
      8        1.2      scw  * by Jason R. Thorpe and Steve C. Woodford.
      9        1.2      scw  *
     10        1.2      scw  * Redistribution and use in source and binary forms, with or without
     11        1.2      scw  * modification, are permitted provided that the following conditions
     12        1.2      scw  * are met:
     13        1.2      scw  * 1. Redistributions of source code must retain the above copyright
     14        1.2      scw  *    notice, this list of conditions and the following disclaimer.
     15        1.2      scw  * 2. Redistributions in binary form must reproduce the above copyright
     16        1.2      scw  *    notice, this list of conditions and the following disclaimer in the
     17        1.2      scw  *    documentation and/or other materials provided with the distribution.
     18        1.2      scw  * 3. All advertising materials mentioning features or use of this software
     19        1.2      scw  *    must display the following acknowledgement:
     20        1.2      scw  *        This product includes software developed by the NetBSD
     21        1.2      scw  *        Foundation, Inc. and its contributors.
     22        1.2      scw  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23        1.2      scw  *    contributors may be used to endorse or promote products derived
     24        1.2      scw  *    from this software without specific prior written permission.
     25        1.2      scw  *
     26        1.2      scw  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27        1.2      scw  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28        1.2      scw  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29        1.2      scw  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30        1.2      scw  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31        1.2      scw  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32        1.2      scw  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33        1.2      scw  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34        1.2      scw  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35        1.2      scw  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36        1.2      scw  * POSSIBILITY OF SUCH DAMAGE.
     37        1.2      scw  */
     38        1.2      scw 
     39        1.2      scw #ifndef _MVME68K_INTR_H
     40        1.2      scw #define _MVME68K_INTR_H
     41        1.2      scw 
     42        1.3      scw #include <sys/device.h>
     43        1.3      scw #include <sys/queue.h>
     44        1.2      scw #include <machine/psl.h>
     45        1.2      scw 
     46        1.2      scw #define	IPL_NONE	0	/* disable only this interrupt */
     47  1.13.16.1     yamt #define	IPL_SOFT	1	/* other software interrupts */
     48        1.3      scw #define	IPL_SOFTCLOCK	2	/* clock software interrupts */
     49  1.13.16.1     yamt #define	IPL_SOFTNET	3	/* network software interrupts */
     50  1.13.16.1     yamt #define	IPL_SOFTSERIAL	4	/* serial software interrupts */
     51  1.13.16.1     yamt #define	IPL_BIO		5	/* disable block I/O interrupts */
     52  1.13.16.1     yamt #define	IPL_NET		6	/* disable network interrupts */
     53  1.13.16.1     yamt #define	IPL_TTY		7	/* disable terminal interrupts */
     54  1.13.16.1     yamt #define	IPL_LPT		IPL_TTY
     55  1.13.16.1     yamt #define	IPL_TTYNOBUF	8	/* IPL_TTY + higher ISR priority */
     56  1.13.16.3     yamt #define	IPL_VM		9
     57  1.13.16.3     yamt #define	IPL_SERIAL	10	/* disable serial interrupts */
     58  1.13.16.3     yamt #define	IPL_CLOCK	11	/* disable clock interrupts */
     59  1.13.16.1     yamt #define	IPL_STATCLOCK	IPL_CLOCK
     60  1.13.16.3     yamt #define	IPL_HIGH	12	/* disable all interrupts */
     61  1.13.16.1     yamt #define	IPL_SCHED	IPL_HIGH
     62  1.13.16.1     yamt #define	IPL_LOCK	IPL_HIGH
     63  1.13.16.1     yamt 
     64  1.13.16.1     yamt #define	SI_SOFTSERIAL	0
     65  1.13.16.1     yamt #define	SI_SOFTNET	1
     66  1.13.16.1     yamt #define	SI_SOFTCLOCK	2
     67  1.13.16.1     yamt #define	SI_SOFT		3
     68  1.13.16.1     yamt 
     69  1.13.16.1     yamt #define	SI_NQUEUES	4
     70        1.3      scw 
     71  1.13.16.1     yamt #define	SI_QUEUENAMES {							\
     72        1.3      scw 	"serial",							\
     73        1.3      scw 	"net",								\
     74        1.3      scw 	"clock",							\
     75        1.3      scw 	"misc",								\
     76        1.3      scw }
     77        1.3      scw 
     78        1.2      scw #ifdef _KERNEL
     79       1.11      scw #define spl0()			_spl0()
     80        1.2      scw #define spllowersoftclock()	spl1()
     81        1.3      scw #define splsoft()		splraise1()
     82        1.3      scw #define splsoftclock()		splsoft()
     83        1.3      scw #define splsoftnet()		splsoft()
     84        1.3      scw #define splsoftserial()		splsoft()
     85        1.2      scw #define splbio()		splraise2()
     86        1.2      scw #define splnet()		splraise3()
     87        1.2      scw #define spltty()		splraise3()
     88        1.7  thorpej #define splvm()			splraise3()
     89        1.2      scw #define splserial()		splraise4()
     90        1.2      scw #define splclock()		splraise5()
     91        1.2      scw #define splstatclock()		splraise5()
     92        1.2      scw #define splhigh()		spl7()
     93        1.2      scw #define splsched()		spl7()
     94        1.4  thorpej #define spllock()		spl7()
     95        1.2      scw 
     96        1.6      scw #ifndef _LOCORE
     97        1.2      scw 
     98  1.13.16.1     yamt typedef int ipl_t;
     99  1.13.16.1     yamt typedef struct {
    100  1.13.16.1     yamt 	int _psl;
    101  1.13.16.1     yamt } ipl_cookie_t;
    102  1.13.16.1     yamt 
    103  1.13.16.1     yamt ipl_cookie_t makeiplcookie(ipl_t);
    104  1.13.16.1     yamt 
    105  1.13.16.1     yamt static inline int
    106  1.13.16.1     yamt splraiseipl(ipl_cookie_t icookie)
    107  1.13.16.1     yamt {
    108  1.13.16.1     yamt 
    109  1.13.16.1     yamt 	return _splraise(icookie._psl);
    110  1.13.16.1     yamt }
    111  1.13.16.1     yamt 
    112       1.13    perry static __inline void
    113        1.6      scw splx(int sr)
    114        1.6      scw {
    115        1.6      scw 
    116       1.12    perry 	__asm volatile("movw %0,%%sr" : : "di" (sr));
    117        1.6      scw }
    118        1.6      scw 
    119        1.3      scw #define setsoft(x)		x = 0
    120        1.3      scw 
    121        1.3      scw struct mvme68k_soft_intrhand {
    122        1.3      scw 	LIST_ENTRY(mvme68k_soft_intrhand) sih_q;
    123        1.3      scw 	struct mvme68k_soft_intr *sih_intrhead;
    124        1.3      scw 	void (*sih_fn)(void *);
    125        1.3      scw 	void *sih_arg;
    126        1.3      scw 	volatile int sih_pending;
    127        1.3      scw };
    128        1.3      scw 
    129        1.3      scw struct mvme68k_soft_intr {
    130        1.3      scw 	LIST_HEAD(, mvme68k_soft_intrhand) msi_q;
    131        1.3      scw 	struct evcnt msi_evcnt;
    132        1.3      scw 	volatile unsigned char msi_ssir;
    133        1.3      scw };
    134        1.3      scw 
    135        1.3      scw void	*softintr_establish(int, void (*)(void *), void *);
    136        1.3      scw void	softintr_disestablish(void *);
    137        1.3      scw void	softintr_init(void);
    138        1.3      scw void	softintr_dispatch(void);
    139       1.11      scw extern void (*_softintr_chipset_assert)(void);
    140        1.3      scw 
    141        1.3      scw #define softintr_schedule(arg)						\
    142        1.3      scw 		do {							\
    143        1.3      scw 			struct mvme68k_soft_intrhand *__sih = (arg);	\
    144        1.3      scw 			__sih->sih_pending = 1;				\
    145        1.3      scw 			setsoft(__sih->sih_intrhead->msi_ssir);		\
    146       1.11      scw 			_softintr_chipset_assert();			\
    147        1.3      scw 		} while (0)
    148        1.3      scw 
    149        1.3      scw /* XXX For legacy software interrupts */
    150        1.3      scw extern struct mvme68k_soft_intrhand *softnet_intrhand;
    151        1.3      scw 
    152        1.3      scw #define setsoftnet()	softintr_schedule(softnet_intrhand)
    153        1.2      scw 
    154        1.2      scw #endif /* !_LOCORE */
    155        1.2      scw #endif /* _KERNEL */
    156        1.2      scw 
    157        1.2      scw #endif /* _MVME68K_INTR_H */
    158