Home | History | Annotate | Line # | Download | only in include
intr.h revision 1.18
      1 /* $NetBSD: intr.h,v 1.18 1998/09/26 00:03:52 thorpej Exp $ */
      2 
      3 /*
      4  * Copyright (c) 1997 Christopher G. Demetriou.  All rights reserved.
      5  * Copyright (c) 1996 Carnegie-Mellon University.
      6  * All rights reserved.
      7  *
      8  * Author: Chris G. Demetriou
      9  *
     10  * Permission to use, copy, modify and distribute this software and
     11  * its documentation is hereby granted, provided that both the copyright
     12  * notice and this permission notice appear in all copies of the
     13  * software, derivative works or modified versions, and any portions
     14  * thereof, and that both notices appear in supporting documentation.
     15  *
     16  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
     17  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
     18  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
     19  *
     20  * Carnegie Mellon requests users of this software to return to
     21  *
     22  *  Software Distribution Coordinator  or  Software.Distribution (at) CS.CMU.EDU
     23  *  School of Computer Science
     24  *  Carnegie Mellon University
     25  *  Pittsburgh PA 15213-3890
     26  *
     27  * any improvements or extensions that they make and grant Carnegie the
     28  * rights to redistribute these changes.
     29  */
     30 
     31 #ifndef _ALPHA_INTR_H_
     32 #define _ALPHA_INTR_H_
     33 
     34 #include <sys/queue.h>
     35 
     36 #define	IPL_NONE	0	/* disable only this interrupt */
     37 #define	IPL_BIO		1	/* disable block I/O interrupts */
     38 #define	IPL_NET		2	/* disable network interrupts */
     39 #define	IPL_TTY		3	/* disable terminal interrupts */
     40 #define	IPL_CLOCK	4	/* disable clock interrupts */
     41 #define	IPL_HIGH	5	/* disable all interrupts */
     42 #define	IPL_SERIAL	6	/* disable serial interrupts */
     43 
     44 #define	IST_UNUSABLE	-1	/* interrupt cannot be used */
     45 #define	IST_NONE	0	/* none (dummy) */
     46 #define	IST_PULSE	1	/* pulsed */
     47 #define	IST_EDGE	2	/* edge-triggered */
     48 #define	IST_LEVEL	3	/* level-triggered */
     49 
     50 #ifdef	_KERNEL
     51 
     52 /* IPL-lowering/restoring macros */
     53 #define splx(s)								\
     54     ((s) == ALPHA_PSL_IPL_0 ? spl0() : alpha_pal_swpipl(s))
     55 #define splsoft()               alpha_pal_swpipl(ALPHA_PSL_IPL_SOFT)
     56 #define splsoftserial()		splsoft()
     57 #define splsoftclock()		splsoft()
     58 #define splsoftnet()		splsoft()
     59 
     60 /* IPL-raising functions/macros */
     61 static __inline int _splraise __P((int)) __attribute__ ((unused));
     62 static __inline int
     63 _splraise(s)
     64 	int s;
     65 {
     66 	int cur = alpha_pal_rdps() & ALPHA_PSL_IPL_MASK;
     67 	return (s > cur ? alpha_pal_swpipl(s) : cur);
     68 }
     69 #define splnet()                _splraise(ALPHA_PSL_IPL_IO)
     70 #define splbio()                _splraise(ALPHA_PSL_IPL_IO)
     71 #define splimp()                _splraise(ALPHA_PSL_IPL_IO)
     72 #define spltty()                _splraise(ALPHA_PSL_IPL_IO)
     73 #define splserial()             _splraise(ALPHA_PSL_IPL_IO)
     74 #define splclock()              _splraise(ALPHA_PSL_IPL_CLOCK)
     75 #define splstatclock()          _splraise(ALPHA_PSL_IPL_CLOCK)
     76 #define splhigh()               _splraise(ALPHA_PSL_IPL_HIGH)
     77 
     78 #define spllpt()		spltty()
     79 
     80 /*
     81  * simulated software interrupt register
     82  */
     83 extern u_int64_t ssir;
     84 
     85 #define	SIR_NET		0x1
     86 #define	SIR_CLOCK	0x2
     87 #define	SIR_SERIAL	0x4
     88 
     89 #define	setsoftnet()	ssir |= SIR_NET
     90 #define	setsoftclock()	ssir |= SIR_CLOCK
     91 #define	setsoftserial()	ssir |= SIR_SERIAL
     92 
     93 /*
     94  * Interprocessor interrupts.
     95  */
     96 #define	ALPHA_IPI_HALT		0UL	/* halt processor */
     97 #define	ALPHA_IPI_IMB		1UL	/* perform an I-stream barrier */
     98 #define	ALPHA_IPI_TBIA		2UL	/* TBI all TB entries */
     99 #define	ALPHA_IPI_TBIAP		3UL	/* TBI all per-process TB entries */
    100 #define	ALPHA_NIPIS		4UL	/* must not exceed 64 */
    101 
    102 typedef void (*ipifunc_t) __P((void));
    103 extern	ipifunc_t ipifuncs[ALPHA_NIPIS];
    104 
    105 void	alpha_send_ipi __P((unsigned long, unsigned long));
    106 
    107 /*
    108  * Alpha shared-interrupt-line common code.
    109  */
    110 
    111 struct alpha_shared_intrhand {
    112 	TAILQ_ENTRY(alpha_shared_intrhand)
    113 		ih_q;
    114 	int	(*ih_fn) __P((void *));
    115 	void	*ih_arg;
    116 	int	ih_level;
    117 	unsigned int ih_num;
    118 };
    119 
    120 struct alpha_shared_intr {
    121 	TAILQ_HEAD(,alpha_shared_intrhand)
    122 		intr_q;
    123 	int	intr_sharetype;
    124 	int	intr_dfltsharetype;
    125 	int	intr_nstrays;
    126 	int	intr_maxstrays;
    127 };
    128 
    129 #define	ALPHA_SHARED_INTR_DISABLE(asi, num)				\
    130 	((asi)[num].intr_maxstrays != 0 &&				\
    131 	 (asi)[num].intr_nstrays == (asi)[num].intr_maxstrays)
    132 
    133 struct alpha_shared_intr *alpha_shared_intr_alloc __P((unsigned int));
    134 int	alpha_shared_intr_dispatch __P((struct alpha_shared_intr *,
    135 	    unsigned int));
    136 void	*alpha_shared_intr_establish __P((struct alpha_shared_intr *,
    137 	    unsigned int, int, int, int (*)(void *), void *, const char *));
    138 void	alpha_shared_intr_disestablish __P((struct alpha_shared_intr *,
    139 	    void *, const char *));
    140 int	alpha_shared_intr_get_sharetype __P((struct alpha_shared_intr *,
    141 	    unsigned int));
    142 int	alpha_shared_intr_isactive __P((struct alpha_shared_intr *,
    143 	    unsigned int));
    144 void	alpha_shared_intr_set_dfltsharetype __P((struct alpha_shared_intr *,
    145 	    unsigned int, int));
    146 void	alpha_shared_intr_set_maxstrays __P((struct alpha_shared_intr *,
    147 	    unsigned int, int));
    148 void	alpha_shared_intr_stray __P((struct alpha_shared_intr *, unsigned int,
    149 	    const char *));
    150 
    151 #endif /* _KERNEL */
    152 #endif /* ! _ALPHA_INTR_H_ */
    153