Home | History | Annotate | Line # | Download | only in include
intr.h revision 1.2.2.1
      1  1.2.2.1  thorpej /*	$NetBSD: intr.h,v 1.2.2.1 1997/10/14 08:55:55 thorpej Exp $	*/
      2      1.1  thorpej 
      3      1.1  thorpej /*-
      4      1.1  thorpej  * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
      5      1.1  thorpej  * All rights reserved.
      6      1.1  thorpej  *
      7      1.1  thorpej  * This code is derived from software contributed to The NetBSD Foundation
      8      1.1  thorpej  * by Jason R. Thorpe.
      9      1.1  thorpej  *
     10      1.1  thorpej  * Redistribution and use in source and binary forms, with or without
     11      1.1  thorpej  * modification, are permitted provided that the following conditions
     12      1.1  thorpej  * are met:
     13      1.1  thorpej  * 1. Redistributions of source code must retain the above copyright
     14      1.1  thorpej  *    notice, this list of conditions and the following disclaimer.
     15      1.1  thorpej  * 2. Redistributions in binary form must reproduce the above copyright
     16      1.1  thorpej  *    notice, this list of conditions and the following disclaimer in the
     17      1.1  thorpej  *    documentation and/or other materials provided with the distribution.
     18      1.1  thorpej  * 3. All advertising materials mentioning features or use of this software
     19      1.1  thorpej  *    must display the following acknowledgement:
     20      1.1  thorpej  *        This product includes software developed by the NetBSD
     21      1.1  thorpej  *        Foundation, Inc. and its contributors.
     22      1.1  thorpej  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23      1.1  thorpej  *    contributors may be used to endorse or promote products derived
     24      1.1  thorpej  *    from this software without specific prior written permission.
     25      1.1  thorpej  *
     26      1.1  thorpej  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27      1.1  thorpej  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28      1.1  thorpej  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29  1.2.2.1  thorpej  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30  1.2.2.1  thorpej  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31      1.1  thorpej  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32      1.1  thorpej  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33      1.1  thorpej  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34      1.1  thorpej  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35      1.1  thorpej  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36      1.1  thorpej  * POSSIBILITY OF SUCH DAMAGE.
     37      1.1  thorpej  */
     38      1.1  thorpej 
     39      1.1  thorpej #ifndef _HP300_INTR_H_
     40      1.1  thorpej #define	_HP300_INTR_H_
     41      1.1  thorpej 
     42      1.1  thorpej #include <machine/psl.h>
     43      1.1  thorpej 
     44      1.1  thorpej #ifdef _HP300_INTR_H_PRIVATE
     45      1.1  thorpej #include <sys/queue.h>
     46      1.1  thorpej 
     47      1.1  thorpej /*
     48      1.1  thorpej  * The location and size of the autovectored interrupt portion
     49      1.1  thorpej  * of the vector table.
     50      1.1  thorpej  */
     51      1.1  thorpej #define ISRLOC		0x18
     52      1.1  thorpej #define NISR		8
     53      1.1  thorpej 
     54      1.1  thorpej struct isr {
     55      1.1  thorpej 	LIST_ENTRY(isr) isr_link;
     56      1.1  thorpej 	int		(*isr_func) __P((void *));
     57      1.1  thorpej 	void		*isr_arg;
     58      1.1  thorpej 	int		isr_ipl;
     59      1.1  thorpej 	int		isr_priority;
     60      1.1  thorpej };
     61      1.1  thorpej #endif /* _HP300_INTR_H_PRIVATE */
     62      1.1  thorpej 
     63      1.1  thorpej /*
     64      1.1  thorpej  * Interrupt "levels".  These are a more abstract representation
     65      1.1  thorpej  * of interrupt levels, and do not have the same meaning as m68k
     66      1.1  thorpej  * CPU interrupt levels.  They serve two purposes:
     67      1.1  thorpej  *
     68      1.1  thorpej  *	- properly order ISRs in the list for that CPU ipl
     69      1.1  thorpej  *	- compute CPU PSL values for the spl*() calls.
     70      1.1  thorpej  */
     71      1.1  thorpej #define	IPL_NONE	0	/* disable only this interrupt */
     72      1.1  thorpej #define	IPL_BIO		1	/* disable block I/O interrupts */
     73      1.1  thorpej #define	IPL_NET		2	/* disable network interrupts */
     74      1.1  thorpej #define	IPL_TTY		3	/* disable terminal interrupts */
     75      1.1  thorpej #define	IPL_TTYNOBUF	4	/* IPL_TTY + higher ISR priority */
     76      1.1  thorpej #define	IPL_CLOCK	5	/* disable clock interrupts */
     77      1.1  thorpej #define	IPL_HIGH	6	/* disable all interrupts */
     78      1.1  thorpej 
     79      1.1  thorpej /*
     80      1.1  thorpej  * Convert PSL values to CPU IPLs and vice-versa.
     81      1.1  thorpej  */
     82      1.1  thorpej #define	PSLTOIPL(x)	(((x) >> 8) & 0xf)
     83      1.1  thorpej #define	IPLTOPSL(x)	((((x) & 0xf) << 8) | PSL_S)
     84      1.1  thorpej 
     85      1.1  thorpej #ifdef _KERNEL
     86      1.1  thorpej /*
     87      1.1  thorpej  * spl functions; all but spl0 are done in-line
     88      1.1  thorpej  */
     89      1.1  thorpej 
     90      1.1  thorpej #define	_spl(s)								\
     91      1.1  thorpej ({									\
     92      1.1  thorpej 	register int _spl_r;						\
     93      1.1  thorpej 									\
     94      1.1  thorpej 	__asm __volatile ("clrl %0; movew sr,%0; movew %1,sr" :		\
     95      1.1  thorpej 	    "&=d" (_spl_r) : "di" (s));					\
     96      1.1  thorpej 	_spl_r;								\
     97      1.1  thorpej })
     98      1.1  thorpej 
     99      1.1  thorpej #define	_splraise(s)							\
    100      1.1  thorpej ({									\
    101      1.2   scottr 	int _spl_r;							\
    102      1.1  thorpej 									\
    103      1.2   scottr 	__asm __volatile ("						\
    104      1.2   scottr 		clrl	d0					;	\
    105      1.2   scottr 		movw	sr,d0					;	\
    106      1.2   scottr 		movl	d0,%0					;	\
    107      1.2   scottr 		andw	#0x700,d0				;	\
    108      1.2   scottr 		movw	%1,d1					;	\
    109      1.2   scottr 		andw	#0x700,d1				;	\
    110      1.2   scottr 		cmpw	d0,d1					;	\
    111      1.2   scottr 		jle	1f					;	\
    112      1.2   scottr 		movw	%1,sr					;	\
    113      1.2   scottr 	    1:"							:	\
    114      1.2   scottr 		    "&=d" (_spl_r)				:	\
    115      1.2   scottr 		    "di" (s)					:	\
    116      1.2   scottr 		    "d0", "d1");					\
    117      1.1  thorpej 	_spl_r;								\
    118      1.1  thorpej })
    119      1.1  thorpej 
    120      1.1  thorpej /* spl0 requires checking for software interrupts */
    121      1.1  thorpej #define	spl1()	_spl(PSL_S|PSL_IPL1)
    122      1.1  thorpej #define	spl2()	_spl(PSL_S|PSL_IPL2)
    123      1.1  thorpej #define	spl3()	_spl(PSL_S|PSL_IPL3)
    124      1.1  thorpej #define	spl4()	_spl(PSL_S|PSL_IPL4)
    125      1.1  thorpej #define	spl5()	_spl(PSL_S|PSL_IPL5)
    126      1.1  thorpej #define	spl6()	_spl(PSL_S|PSL_IPL6)
    127      1.1  thorpej #define	spl7()	_spl(PSL_S|PSL_IPL7)
    128      1.1  thorpej 
    129      1.1  thorpej /*
    130      1.1  thorpej  * These four globals contain the appropriate PSL_S|PSL_IPL? values
    131      1.1  thorpej  * to raise interupt priority to the requested level.
    132      1.1  thorpej  */
    133      1.1  thorpej extern	unsigned short hp300_bioipl;
    134      1.1  thorpej extern	unsigned short hp300_netipl;
    135      1.1  thorpej extern	unsigned short hp300_ttyipl;
    136      1.1  thorpej extern	unsigned short hp300_impipl;
    137      1.1  thorpej 
    138      1.1  thorpej /* These spl calls are _not_ to be used by machine-independent code. */
    139      1.1  thorpej #define	splhil()	_splraise(PSL_S|PSL_IPL1)
    140      1.1  thorpej #define	splkbd()	splhil()
    141      1.1  thorpej #define	splsoft()	spl1()
    142      1.1  thorpej 
    143      1.1  thorpej /* These spl calls are used by machine-independent code. */
    144      1.1  thorpej #define	splsoftclock()	splsoft()
    145      1.1  thorpej #define	splsoftnet()	splsoft()
    146      1.1  thorpej #define	splbio()	_splraise(hp300_bioipl)
    147      1.1  thorpej #define	splnet()	_splraise(hp300_netipl)
    148      1.1  thorpej #define	spltty()	_splraise(hp300_ttyipl)
    149      1.1  thorpej #define	splimp()	_splraise(hp300_impipl)
    150      1.1  thorpej #define	splclock()	spl6()
    151      1.1  thorpej #define	splstatclock()	spl6()
    152      1.1  thorpej #define	splvm()		spl6()
    153      1.1  thorpej #define	splhigh()	spl7()
    154      1.1  thorpej #define	splsched()	spl7()
    155      1.1  thorpej 
    156      1.1  thorpej /* watch out for side effects */
    157      1.1  thorpej #define	splx(s)		((s) & PSL_IPL ? _spl((s)) : spl0())
    158      1.1  thorpej 
    159      1.1  thorpej /*
    160      1.1  thorpej  * Simulated software interrupt register.
    161      1.1  thorpej  */
    162      1.1  thorpej extern volatile u_int8_t ssir;
    163      1.1  thorpej 
    164      1.1  thorpej #define	SIR_NET		0x01
    165      1.1  thorpej #define	SIR_CLOCK	0x02
    166      1.1  thorpej 
    167      1.1  thorpej #define	siron(mask)	\
    168      1.1  thorpej 	__asm __volatile ( "orb %0,_ssir" : : "i" ((mask)))
    169      1.1  thorpej #define	siroff(mask)	\
    170      1.1  thorpej 	__asm __volatile ( "andb %0,_ssir" : : "ir" (~(mask)));
    171      1.1  thorpej 
    172      1.1  thorpej #define	setsoftnet()	siron(SIR_NET)
    173      1.1  thorpej #define	setsoftclock()	siron(SIR_CLOCK)
    174      1.1  thorpej 
    175      1.1  thorpej /* locore.s */
    176      1.1  thorpej int	spl0 __P((void));
    177      1.1  thorpej 
    178      1.1  thorpej /* intr.c */
    179      1.1  thorpej void	intr_init __P((void));
    180      1.1  thorpej void	*intr_establish __P((int (*)(void *), void *, int, int));
    181      1.1  thorpej void	intr_disestablish __P((void *));
    182      1.1  thorpej void	intr_dispatch __P((int));
    183      1.1  thorpej void	intr_printlevels __P((void));
    184      1.1  thorpej #endif /* _KERNEL */
    185      1.1  thorpej 
    186      1.1  thorpej #endif /* _HP300_INTR_H_ */
    187